Beispiel #1
0
        public Interface(Mapping.Interface iface, DataCenter[] dataCenters = null, IpAddress[] ips = null)
        {
            this.Id = iface.Id;
            this.DataCenterId = iface.DataCenterId;
            if (dataCenters != null)
                this.DataCenter = dataCenters.SingleOrDefault(d => d.Id == iface.DataCenterId);
            this.Created = iface.Created;
            this.LastUpdated = iface.LastUpdated;
            if (iface.Num != null)
                this.Index = Convert.ToInt32(iface.Num);
            this.Status = Converter.ToInterfaceStatus(iface.State);
            this.Bandwidth = iface.Bandwidth;
            this.Type = Converter.ToInterfaceType(iface.Type);
            if (iface.VirtualMachineId != null)
                this.VirtualMachineId = Convert.ToInt32(iface.VirtualMachineId);
            this.VirtualMachine = null;
            this.IpAddressIds = iface.IpAddressIds;
            if (ips != null)
            {
                List<IpAddress> ipList = new List<IpAddress>();
                foreach (int ipId in iface.IpAddressIds)
                {
                    IpAddress ipAddress = ips.SingleOrDefault(i => i.Id == ipId);

                    if (ipAddress.Interface == null)
                        ipAddress.Interface = this;

                    ipList.Add(ipAddress);
                }
                this.IpAddresses = ipList.ToArray();
            }
        }
Beispiel #2
0
 public Image(Mapping.Image image, DataCenter[] dataCenters = null, Disk[] disks = null)
 {
     this.Id = image.Id;
     this.Label = image.Label;
     this.DataCenterId = image.DataCenterId;
     if (dataCenters != null)
         this.DataCenter = dataCenters.SingleOrDefault(d => d.Id == image.DataCenterId);
     this.DiskId = image.DiskId;
     if (disks != null)
         this.Disk = disks.SingleOrDefault(d => d.Id == image.DiskId);
     this.Visibility = Converter.ToImageVisibility(image.Visibility);
     this.Architecture = Converter.ToImageArchitecture(image.OsArchitecture);
     this.AuthorId = image.AuthorId;
 }
Beispiel #3
0
 public IpAddress(Mapping.IpAddress ipAddress, DataCenter[] dataCenters = null)
 {
     this.Id = ipAddress.Id;
     this.DataCenterId = ipAddress.DataCenterId;
     if (dataCenters != null)
         this.DataCenter = dataCenters.SingleOrDefault(d => d.Id == ipAddress.DataCenterId);
     if (ipAddress.InterfaceId != null)
         this.InterfaceId = Convert.ToInt32(ipAddress.InterfaceId);
     this.Interface = null;
     this.Created = ipAddress.Created;
     this.LastUpdated = ipAddress.LastUpdated;
     this.Ip = IPAddress.Parse(ipAddress.Ip);
     this.Reverse = ipAddress.Reverse;
     this.Status = Converter.ToIpAddressStatus(ipAddress.State);
     this.Version = Converter.ToIpVersion(ipAddress.Version);
 }
Beispiel #4
0
 public Disk(Mapping.Disk disk, DataCenter[] dataCenters = null)
 {
     this.Id = disk.Id;
     this.Name = disk.Name;
     this.Created = disk.Created;
     this.LastUpdated = disk.LastUpdated;
     this.Size = disk.Size;
     this.State = disk.State;
     if (disk.Source != null)
         this.Source = Convert.ToInt32(disk.Source);
     this.Visibility = disk.Visibility;
     this.Type = Converter.ToDiskType(disk.Type);
     this.IsBootDisk = disk.IsBootDisk;
     this.VirtualMachineIds = disk.VirtualMachineIds;
     this.VirtualMachines = null;
     this.KernelVersion = disk.KernelVersion;
     this.Label = disk.Label;
     this.DataCenterId = disk.DataCenterId;
     if (dataCenters != null)
         this.DataCenter = dataCenters.SingleOrDefault(d => d.Id == disk.DataCenterId);
 }