コード例 #1
0
ファイル: DriverTask.cs プロジェクト: blinds52/remoteinstall
 public DriverTask(
     RemoteInstallConfig config,
     string logpath,
     bool simulationOnly,
     VirtualMachineConfig vmConfig,
     InstallersConfig installersConfig)
 {
     _config = config;
     _simulationOnly = simulationOnly;
     _logpath = logpath;
     _vmConfig = vmConfig;
     _installersConfig = installersConfig;
 }
コード例 #2
0
 public DriverTask(
     RemoteInstallConfig config,
     string logpath,
     bool simulationOnly,
     VirtualMachineConfig vmConfig,
     InstallersConfig installersConfig)
 {
     _config           = config;
     _simulationOnly   = simulationOnly;
     _logpath          = logpath;
     _vmConfig         = vmConfig;
     _installersConfig = installersConfig;
 }
コード例 #3
0
ファイル: DriverTask.cs プロジェクト: blinds52/remoteinstall
 public DriverTaskInstance(
     RemoteInstallConfig config,
     string logpath,
     bool simulationOnly,
     VirtualMachineConfig vmConfig,
     InstallersConfig installersConfig,
     SnapshotConfig snapshotConfig)
 {
     _config = config;
     _vmConfig = vmConfig;
     _simulationOnly = simulationOnly;
     _logpath = logpath;
     _vmPowerDriver = new VirtualMachinePowerDriver(vmConfig, snapshotConfig, simulationOnly);
     _installersConfig = installersConfig;
 }
コード例 #4
0
 public DriverTaskInstance(
     RemoteInstallConfig config,
     string logpath,
     bool simulationOnly,
     VirtualMachineConfig vmConfig,
     InstallersConfig installersConfig,
     SnapshotConfig snapshotConfig)
 {
     _config           = config;
     _vmConfig         = vmConfig;
     _simulationOnly   = simulationOnly;
     _logpath          = logpath;
     _vmPowerDriver    = new VirtualMachinePowerDriver(vmConfig, snapshotConfig, simulationOnly);
     _installersConfig = installersConfig;
 }
コード例 #5
0
        public void OneOverlapTest()
        {
            VirtualMachineConfig config1 = new VirtualMachineConfig();

            config1.File = Guid.NewGuid().ToString();
            config1.Host = Guid.NewGuid().ToString();

            VirtualMachineConfig config2 = new VirtualMachineConfig();

            config2.File = config1.File;
            config2.Host = config2.File;

            Assert.IsFalse(config1.Overlaps(config2));
            Assert.IsFalse(config2.Overlaps(config1));
        }
コード例 #6
0
        public void NoOverlapHostTest()
        {
            VirtualMachineConfig config1 = new VirtualMachineConfig();

            config1.File = Guid.NewGuid().ToString();
            config1.Host = Guid.NewGuid().ToString();

            VirtualMachineConfig config2 = new VirtualMachineConfig();

            config2.File = Guid.NewGuid().ToString();
            config2.Host = config1.Host;

            // overlap self
            Assert.IsTrue(config1.Overlaps(config1));
            Assert.IsTrue(config2.Overlaps(config2));
            // overlap other
            Assert.IsFalse(config1.Overlaps(config2));
            Assert.IsFalse(config2.Overlaps(config1));
        }
コード例 #7
0
        public void OneChildNoOverlapTest()
        {
            VirtualMachineConfig config1 = new VirtualMachineConfig();

            config1.File = Guid.NewGuid().ToString();
            config1.Host = Guid.NewGuid().ToString();

            VirtualMachineConfig config2 = new VirtualMachineConfig();

            config2.File = Guid.NewGuid().ToString();
            config2.Host = Guid.NewGuid().ToString();

            SnapshotConfig snapshot1 = new SnapshotConfig();

            config2.Snapshots.Add(snapshot1);
            SnapshotsConfig snapshots1 = new SnapshotsConfig();

            snapshots1.Add(snapshot1);

            Assert.IsFalse(config1.Overlaps(config2));
            Assert.IsFalse(config2.Overlaps(config1));
        }
コード例 #8
0
        public void TwoChildrenOverlapTest()
        {
            VirtualMachineConfig config1 = new VirtualMachineConfig();

            config1.File = Guid.NewGuid().ToString();
            config1.Host = Guid.NewGuid().ToString();

            VirtualMachineConfig config2 = new VirtualMachineConfig();

            config2.File = Guid.NewGuid().ToString();
            config2.Host = Guid.NewGuid().ToString();

            // a snapshot child with a virtual machine
            SnapshotConfig  snapshot0  = new SnapshotConfig();
            SnapshotsConfig snapshots0 = new SnapshotsConfig();

            snapshots0.Add(snapshot0);
            VirtualMachineConfig config3 = new VirtualMachineConfig();

            config3.File = Guid.NewGuid().ToString();
            config3.Host = Guid.NewGuid().ToString();
            snapshot0.VirtualMachines.Add(config3);
            config2.Snapshots.Add(snapshot0);

            SnapshotConfig  snapshot1  = new SnapshotConfig();
            SnapshotsConfig snapshots1 = new SnapshotsConfig();

            snapshots1.Add(snapshot1);
            config3.Snapshots.Add(snapshot1);

            Assert.IsFalse(config1.Overlaps(config2));
            Assert.IsFalse(config2.Overlaps(config1));

            snapshot1.VirtualMachines.Add(config1);
            Assert.IsTrue(config1.Overlaps(config2));
            Assert.IsTrue(config2.Overlaps(config1));
        }
コード例 #9
0
 public DriverTask_Alternate(RemoteInstallConfig config, string logpath, bool simulationOnly, VirtualMachineConfig vmConfig, InstallersConfig installersConfig, bool install, bool uninstall)
     : base(config, logpath, simulationOnly, vmConfig, installersConfig)
 {
     _install = install;
     _uninstall = uninstall;
 }
コード例 #10
0
 public DriverTask_Lifo(RemoteInstallConfig config, string logpath, bool simulationOnly, VirtualMachineConfig vmConfig, InstallersConfig installersConfig)
     : base(config, logpath, simulationOnly, vmConfig, installersConfig)
 {
 }
コード例 #11
0
 public DriverTask_Fifo(RemoteInstallConfig config, string logpath, bool simulationOnly, VirtualMachineConfig vmConfig, InstallersConfig installersConfig)
     : base(config, logpath, simulationOnly, vmConfig, installersConfig)
 {
 }
コード例 #12
0
 public DriverTask_Alternate(RemoteInstallConfig config, string logpath, bool simulationOnly, VirtualMachineConfig vmConfig, InstallersConfig installersConfig, bool install, bool uninstall)
     : base(config, logpath, simulationOnly, vmConfig, installersConfig)
 {
     _install   = install;
     _uninstall = uninstall;
 }
コード例 #13
0
        public async Task <CreateVirtualMachineResponse> CreateVirtualMachineAsync(
            EnviormentConfig enviormentConfig,
            SimpleVirtualMachineConfig simpleVirtualMachineConfig,
            CancellationToken cancellationToken = default)
        {
            var folder = await this.GetFolderAsync(cancellationToken);

            if (folder == null)
            {
                return(null);
            }

            var esxDatastore = await this.GetDatastoreAsync(enviormentConfig.DatastoreName, cancellationToken);

            var esxHost = await this.GetHostAsync(enviormentConfig.HostName, cancellationToken);

            var esxNetwork = await this.GetNetworkAsync(enviormentConfig.NetworkName, cancellationToken);

            var virtualMachineConfig = new VirtualMachineConfig
            {
                Spec = new Spec
                {
                    Name    = simpleVirtualMachineConfig.Name,
                    GuestOs = simpleVirtualMachineConfig.GuestOs,
                    Cpu     = new Cpu
                    {
                        Count          = simpleVirtualMachineConfig.Cpus,
                        CoresPerSocket = 1,
                        HotAddEnabled  = true
                    },
                    Disks = new Disk[]
                    {
                        new Disk
                        {
                            Scsi = new Scsi
                            {
                                Bus  = 0,
                                Unit = 0,
                            },
                            Type    = "SCSI",
                            NewVmdk = new NewVmdk
                            {
                                Capacity = simpleVirtualMachineConfig.DiskSizeGB * 1024L * 1024L * 1024L
                            }
                        }
                    },
                    Cdroms = new Cdrom[]
                    {
                        new Cdrom
                        {
                            StartConnected    = true,
                            AllowGuestControl = true,
                            Type = "SATA",
                            Sata = new Sata
                            {
                                Bus  = 0,
                                Unit = 0
                            },
                            Backing = new CdromBacking
                            {
                                Type    = "ISO_FILE",
                                IsoFile = simpleVirtualMachineConfig.IsoFile
                            }
                        }
                    },
                    Memory = new Memory
                    {
                        SizeMiB = simpleVirtualMachineConfig.MemorySizeGB * 1024
                    },
                    Nics = new Nic[]
                    {
                        new Nic
                        {
                            Type              = EthernetAdapterEmulationType.VMXNET3,
                            MacType           = MacAddressType.GENERATED,
                            StartConnected    = true,
                            AllowGuestControl = true,
                            Backing           = new NicBacking
                            {
                                Network = esxNetwork.Network,
                                Type    = esxNetwork.Type
                            }
                        }
                    },
                    Placement = new Placement
                    {
                        Datastore = esxDatastore,
                        Folder    = folder,
                        Host      = esxHost
                    }
                }
            };

            var json = JsonConvert.SerializeObject(virtualMachineConfig, this._jsonSerializerSettings);

            var responseMessage = await this._httpClient.PostAsync($"vcenter/vm", new StringContent(json, Encoding.UTF8, "application/json"), cancellationToken);

            json = await responseMessage.Content.ReadAsStringAsync();

            if (!responseMessage.IsSuccessStatusCode)
            {
                Console.WriteLine(json);
                return(null);
            }

            var item = JsonConvert.DeserializeObject <CreateVirtualMachineResponse>(json, this._jsonSerializerSettings);

            return(item);
        }