public void Invoke() { this._Logger.Information("Creating and Configuring the replica vm."); this._Context.SetHighAndLowLevelState("PROVISIONING", "ConfiguringVm"); this._CheckVolumesSpecified(); this._ESXHost = this._GetHelperESXHost(); this._HelperVm = this._GetHelperVm(); this._HelperSCSIControllers = this._GetScsiControllersInfo(this._HelperVm); this._Datastores = this._GetDatastores(); this._ValidateHelperForJob(); this._CheckStopping(); this._CheckVmDoesntExist(); this._ReportVmInfo(); this._CheckStopping(); VmCreationInfo vmCreationInfo = this._BuildCreationInfo(); IVimVm vmWithNoDisks = this._CreateVmWithNoDisks(vmCreationInfo); this._Logger.Verbose("Setting up replica vm information for " + this._Context.JobInfoWrapper.VmName); vmCreationInfo.Disks[0].SizeMB = Math.Max(vmCreationInfo.Disks[0].SizeMB, 2060L); this._Logger.Verbose("Finished creating replica vm:" + this._Context.JobInfoWrapper.VmName); this._CheckStopping(); this._Context.JobInfoWrapper.VmUuid = new Guid(vmWithNoDisks.Uuid); this._Logger.Verbose("Saving the VM's GUID: " + vmWithNoDisks.Uuid); if (this._Context.ESXHost.VC_Vim != null && !this._Context.ESXHost.VC_Vim.IsVirtualCenter && this._VirtualNicType() == VirtualNicType.Vmxnet3) { this._PowerOnAndOff(); } this._CreateAnyAdditionalSCSIControllers(vmWithNoDisks, vmCreationInfo.Disks); this._AddDisksTo(vmWithNoDisks, vmCreationInfo.Disks); this._VerifyDisksAllAdded(vmWithNoDisks, vmCreationInfo.Disks); this._Logger.Information("Creation and configuration of the replica vm complete."); }
protected virtual IVimVm _CreateVm(VmCreationInfo vmCreationInfo, IVimHost esxHost) { CreateVmOp createVmOp = new CreateVmOp(this._Context.ESXHost.VC_Vim, esxHost, vmCreationInfo, this._Context.Logger, 120); createVmOp.Run(); return(createVmOp.NewVm); }
private IVimVm _CreateVmWithNoDisks(VmCreationInfo vmCreationInfo) { this._CheckStopping(); this._Context.SetLowLevelState("CreatingVm"); VmDiskInfo[] disks = vmCreationInfo.Disks; vmCreationInfo.Disks = (VmDiskInfo[])null; IVimVm vm = this._CreateVm(vmCreationInfo, this._ESXHost); vmCreationInfo.Disks = disks; return(vm); }