public override void Validate(IValdiator v)
 {
     if (string.IsNullOrEmpty(file_path))
     {
         v.AddError("Device_Source_File.file_path", "Path cannot be empty!");
     }
 }
示例#2
0
 public void Validate(IValdiator v)
 {
     if (string.IsNullOrWhiteSpace(address))
     {
         v.AddError("address", "Address cannot be empty or null");
     }
 }
 public void Validate(IValdiator v)
 {
     if (string.IsNullOrWhiteSpace(address))
     {
         v.AddError("address", "Address cannot be empty or null");
     }
 }
 public override void Validate(IValdiator v)
 {
     if (string.IsNullOrEmpty(block_path))
     {
         v.AddError("Device_Source_Block.block_path", "Path cannot be empty!");
     }
 }
示例#5
0
 public void Validate(IValdiator v, Models.Concrete.CPU_Layout obj, CS_Objects.Host obj2)
 {
     Libvirt._virNodeInfo info;
     obj2.virNodeGetInfo(out info);
     if (obj.vCpu_Count > info.cpus)
     {
         v.AddError("vCpu_Count", "Cannot exceed the Maximum Available!");
     }
 }
 public void Validate(IValdiator v, Models.Concrete.Storage_Pool obj, CS_Objects.Host obj2)
 {
     using (var s = obj2.virConnectListAllStoragePools(virConnectListAllStoragePoolsFlags.VIR_CONNECT_LIST_STORAGE_POOLS_DEFAULT))
     {
         if (s.Any(a => a.virStoragePoolGetName().ToLower() == obj.name.ToLower()))
         {
             v.AddError("name", "A pool with that name already exists, try another!");
         }
     }
 }
 public void Validate(IValdiator v, Models.Concrete.General_Metadata obj, CS_Objects.Host obj2)
 {
     using (var d = obj2.virConnectListAllDomains(Libvirt.virConnectListAllDomainsFlags.VIR_DEFAULT))
     {
         if (d.Any(a => a.virDomainGetName() == obj.name))
         {
             v.AddError("General_Metadata.name", "A VM with that name already exists, try another!");
         }
     }
 }
示例#8
0
 public void Validate(IValdiator v)
 {
     if (Disk_Device_Type == Disk_Device_Types.cdrom)
     {
         ReadOnly = true;// force this here
     }
     if (Source != null)
     {
         Source.Validate(v);
     }
 }
 public override void Validate(IValdiator v)
 {
     if (string.IsNullOrEmpty(pool))
     {
         v.AddError("Device_Source_Volume.pool", "Pool cannot be empty!");
     }
     if (string.IsNullOrEmpty(volume))
     {
         v.AddError("Device_Source_Volume.volume", "Volume cannot be empty!");
     }
 }
 public void Validate(IValdiator v)
 {
     if (memory_unit != currentMemory_unit)
     {
         //for now, both should equal one another...
         v.AddError("currentMemory_unit", "Must equal memory_unit");
         v.AddError("memory_unit", "Must equal currentMemory_unit");
     }
     else if (currentMemory < memory)
     {
         v.AddError("currentMemory", "currentMemory Cannot be less than memory!");
     }
 }
示例#11
0
        public void Validate(IValdiator v, Libvirt.Models.Concrete.Drive_Collection obj, CS_Objects.Host obj2)
        {
            var d = new Device_Validator();

            foreach (var item in obj.Disks)
            {
                if (!v.IsValid())
                {
                    break;
                }
                d.Validate(v, item, obj2);
            }
        }
示例#12
0
        public void Validate(IValdiator v)
        {
            if (string.IsNullOrWhiteSpace(default_gateway_address))
            {
                v.AddError("default_gateway_address", "cannot be empty!");
            }
            else if (!CheckIPValid(default_gateway_address))
            {
                v.AddError("default_gateway_address", "Not a valid IP address!");
            }
            if (string.IsNullOrWhiteSpace(netmask))
            {
                v.AddError("netmask", "cannot be empty!");
            }
            else if (!CheckIPValid(netmask))
            {
                v.AddError("netmask", "Not a valid IP address!");
            }
            bool dhcp_range_good = false;

            if (string.IsNullOrWhiteSpace(dhcp_range_start))
            {
                v.AddError("dhcp_range_start", "cannot be empty!");
            }
            else if (!CheckIPValid(dhcp_range_start))
            {
                v.AddError("dhcp_range_start", "Not a valid IP address!");
            }
            else
            {
                dhcp_range_good = true;
            }
            if (string.IsNullOrWhiteSpace(dhcp_range_end))
            {
                v.AddError("dhcp_range_end", "cannot be empty!");
            }
            else if (!CheckIPValid(dhcp_range_end))
            {
                v.AddError("dhcp_range_end", "Not a valid IP address!");
            }
            else if (dhcp_range_good)
            {//all checks have passed except the dhcp end range
                int begin = BitConverter.ToInt32(System.Net.IPAddress.Parse(dhcp_range_start).GetAddressBytes(), 0);
                int end   = BitConverter.ToInt32(System.Net.IPAddress.Parse(dhcp_range_end).GetAddressBytes(), 0);
                if (begin >= end)
                {
                    v.AddError("dhcp_range_start", "the start must be less than the end range!");
                    v.AddError("dhcp_range_end", "the end must be greater than the start range!");
                }
            }
        }
 public void Validate(IValdiator v)
 {
     if (string.IsNullOrWhiteSpace(name)) v.AddError("General_Metadata.name", "Name cannot be empty!");
     else
     {
         foreach (var item in name)
         {
             if (!Char.IsLetter(item) && item != '_')
             {
                 v.AddError("General_Metadata.name", "Name can only contain letters or underscores!");
                 break;
             }
         }
     }
 }
 public void Validate(IValdiator v, Models.Concrete.Storage_Volume obj, CS_Objects.Storage_Pool obj2)
 {
     CS_Objects.Storage_Volume[] vols;
     if (obj2.virStoragePoolListAllVolumes(out vols) > -1)
     {
         if (vols.Any(a => a.virStorageVolGetName().ToLower() == obj.name.ToLower()))
         {
             v.AddError("name", "A volume with that name already exists, try another!");
         }
     }
     foreach (var item in vols)
     {
         item.Dispose();
     }
 }
        public void Validate(IValdiator v, Models.Concrete.Memory_Allocation obj, CS_Objects.Host obj2)
        {
            Libvirt._virNodeInfo info;
            obj2.virNodeGetInfo(out info);
            var maxmemory = (info.memory / 1024);

            //check ignored until i can convert memory units correctly
            //if (obj.memory > maxmemory)
            //{
            //    v.AddError("Memory_Allocation.maxMemory", "Cannot exceed the Maximum Memory Available on the host!");
            //}
            //if (obj.currentMemory > obj.memory)
            //{
            //    v.AddError("Memory_Allocation.memory", "Cannot exceed the Maximum Memory Available on the host!");
            //}
        }
示例#16
0
 public void Validate(IValdiator v)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         v.AddError("General_Metadata.name", "Name cannot be empty!");
     }
     else
     {
         foreach (var item in name)
         {
             if (!Char.IsLetter(item) && item != '_')
             {
                 v.AddError("General_Metadata.name", "Name can only contain letters or underscores!");
                 break;
             }
         }
     }
 }
示例#17
0
 public void Validate(IValdiator v, Models.Concrete.Disk obj, CS_Objects.Host obj2)
 {
     if (obj.Source.GetType() == typeof(Libvirt.Models.Concrete.Device_Source_Volume))
     {
         var src = obj.Source as Libvirt.Models.Concrete.Device_Source_Volume;
         using (var pool = obj2.virStoragePoolLookupByName(src.pool))
         {
             if (!pool.IsValid)
             {
                 v.AddError("Device.Source.pool", "Pool is invalid!");
             }
             using (var volume = pool.virStorageVolLookupByName(src.volume))
             {
                 if (!volume.IsValid)
                 {
                     v.AddError("Device.Source.volume", "Volume is invalid!");
                 }
             }
         }
     }
 }
示例#18
0
 public void Validate(IValdiator v)
 {
     if (Graphic_Type == Graphic_Types.NONE)
     {
         return;
     }
     if (_autoport && _port != -1)
     {
         v.AddError("autoport", "If autoport is true, port must also be -1");
     }
     if (websocket.HasValue && Graphic_Type == Graphic_Types.spice)
     {
         v.AddError("websocket", "websocket must be null if the graphics type is spice.");
     }
     if (passwdValidTo.HasValue)
     {
         if (string.IsNullOrWhiteSpace(passwd))
         {
             v.AddError("passwdValidTo", "You must specify a password when using passwdValidTo!");
         }
     }
 }
示例#19
0
 public void Validate(IValdiator v)
 {
     if (Device_Device_Type == Disk_Device_Types.cdrom)
     {
         ReadOnly = true;// force this here
     }
     if (Device_Type == Disk_Types.file && Device_Device_Type == Disk_Device_Types.cdrom)
     {
         var src = Source as Device_Source_File;
         if (!string.IsNullOrWhiteSpace(src.file_path))
         {
             if (!src.file_path.EndsWith(".iso"))
             {
                 v.AddError("Source.file_path", "You must select an ISO!");
             }
         }
         else
         {
             v.AddError("Source.file_path", "You must select an ISO!");
         }
     }
 }
 public abstract void Validate(IValdiator v);
示例#21
0
 public void Validate(IValdiator v)
 {
     Configuration.Validate(v);
 }
示例#22
0
 public void Validate(IValdiator v, Models.Concrete.BIOS_Bootloader obj, CS_Objects.Host obj2)
 {
 }
 public override void Validate(IValdiator v)
 {
 }
示例#24
0
 public new void Validate(IValdiator v)
 {
 }
 public void Validate(IValdiator v)
 {
     if (memory_unit != currentMemory_unit)
     {
         //for now, both should equal one another...
         v.AddError("currentMemory_unit", "Must equal memory_unit");
         v.AddError("memory_unit", "Must equal currentMemory_unit");
     }
     else if (currentMemory < memory)
         {
             v.AddError("currentMemory", "currentMemory Cannot be less than memory!");
         }
 }
 public override void Validate(IValdiator v)
 {
     if (string.IsNullOrEmpty(pool))
     {
         v.AddError("Device_Source_Volume.pool", "Pool cannot be empty!");
     }
     if (string.IsNullOrEmpty(volume))
     {
         v.AddError("Device_Source_Volume.volume", "Volume cannot be empty!");
     }
 }
 public void Validate(IValdiator v, Models.Concrete.Features obj, CS_Objects.Host obj2)
 {
 }
 public abstract void Validate(IValdiator v);
示例#29
0
 public void Validate(IValdiator v)
 {
     if (Device_Device_Type == Disk_Device_Types.cdrom)
     {
         ReadOnly = true;// force this here
     }
     if (Device_Type == Disk_Types.file && Device_Device_Type == Disk_Device_Types.cdrom)
     {
         var src = Source as Device_Source_File;
         if (!string.IsNullOrWhiteSpace(src.file_path))
         {
             if (!src.file_path.EndsWith(".iso"))
             {
                 v.AddError("Source.file_path", "You must select an ISO!");
             }
         }
         else
         {
             v.AddError("Source.file_path", "You must select an ISO!");
         }
     }
 }
示例#30
0
 public void Validate(IValdiator v)
 {
     if (Disk_Device_Type == Disk_Device_Types.cdrom)
     {
         ReadOnly = true;// force this here
     }
     if (Source != null) Source.Validate(v);
 }
示例#31
0
 public void Validate(IValdiator v)
 {
     if (Graphic_Type == Graphic_Types.NONE) return;
     if (_autoport && _port != -1)
     {
         v.AddError("autoport", "If autoport is true, port must also be -1");
     }
     if (websocket.HasValue && Graphic_Type == Graphic_Types.spice)
     {
         v.AddError("websocket", "websocket must be null if the graphics type is spice.");
     }
     if (passwdValidTo.HasValue)
     {
         if (string.IsNullOrWhiteSpace(passwd))
         {
             v.AddError("passwdValidTo", "You must specify a password when using passwdValidTo!");
         }
     }
 }
 public void Validate(IValdiator v)
 {
 }
示例#33
0
 public void Validate(IValdiator v)
 {
     if (string.IsNullOrWhiteSpace(default_gateway_address)) v.AddError("default_gateway_address", "cannot be empty!");
     else if (!CheckIPValid(default_gateway_address)) v.AddError("default_gateway_address", "Not a valid IP address!");
     if (string.IsNullOrWhiteSpace(netmask)) v.AddError("netmask", "cannot be empty!");
     else if (!CheckIPValid(netmask)) v.AddError("netmask", "Not a valid IP address!");
     bool dhcp_range_good = false;
     if (string.IsNullOrWhiteSpace(dhcp_range_start)) v.AddError("dhcp_range_start", "cannot be empty!");
     else if (!CheckIPValid(dhcp_range_start)) v.AddError("dhcp_range_start", "Not a valid IP address!");
     else dhcp_range_good = true;
     if (string.IsNullOrWhiteSpace(dhcp_range_end)) v.AddError("dhcp_range_end", "cannot be empty!");
     else if (!CheckIPValid(dhcp_range_end)) v.AddError("dhcp_range_end", "Not a valid IP address!");
     else if (dhcp_range_good)
     {//all checks have passed except the dhcp end range
         int begin = BitConverter.ToInt32(System.Net.IPAddress.Parse(dhcp_range_start).GetAddressBytes(), 0);
         int end = BitConverter.ToInt32(System.Net.IPAddress.Parse(dhcp_range_end).GetAddressBytes(), 0);
         if (begin >= end)
         {
             v.AddError("dhcp_range_start", "the start must be less than the end range!");
             v.AddError("dhcp_range_end", "the end must be greater than the start range!");
         }
     }
 }
 public override void Validate(IValdiator v)
 {
 }
示例#35
0
 public void Validate(IValdiator v)
 {
     Configuration.Validate(v);
 }