Exemplo n.º 1
0
 public bool Invoke(OculiVolumePersistedState volumeInfo)
 {
     this._Logger.Verbose("Locking down job for disk removal for job " + this._Context.JobInfoWrapper.Name);
     try
     {
         lock (Win32Utils.HelperOSLock)
         {
             VmdkProperties local_2 = this._FindDriveVmdkProperties(volumeInfo);
             if (local_2 != null)
             {
                 string local_3 = volumeInfo.PNPDeviceID;
                 if (local_3 != null)
                 {
                     this._RemoveSCSIDevice(local_3);
                 }
                 this._RemoveVirtualDisk(volumeInfo, local_2);
                 this._Logger.Verbose("Removed Drive for " + local_3);
             }
             else
             {
                 this._Logger.Warning("Could not find hard disk: " + volumeInfo.VirtualDiskFilename);
             }
             return(true);
         }
     }
     finally
     {
         this._Logger.Verbose("Releasing lock for disk removal for job " + this._Context.JobInfoWrapper.Name);
     }
 }
Exemplo n.º 2
0
        public TaskContext(PrepareVmInformation bootInfo, ILogger logger, IServiceResolver serviceResolver)
        {
            Invariant.ArgumentNotNull((object)bootInfo, "bootInfo");
            this.ServiceResolver  = serviceResolver;
            this._JobInfo         = new JobInfo();
            this._JobInfo.Options = new JobOptions();
            this._JobInfo.Options.OculiOptions   = new OculiOptions();
            this._JobInfo.Options.ClusterOptions = new ClusterOptions();
            this._JobInfo.JobPersistedState      = new JobPersistedState();
            this._JobInfo.JobPersistedState.OculiPersistedState = new OculiPersistedState();
            this._JobInfo.JobPersistedState.OculiPersistedState.SourceMachineInfo            = new MachineInfo();
            this._JobInfo.JobPersistedState.OculiPersistedState.SourceMachineInfo.ServerInfo = new ServerInfo();
            this._JobInfo.JobPersistedState.OculiPersistedState.SourceMachineInfo.ServerInfo.OperatingSystem = new OperatingSystemInfo();
            this._JobInfo.JobPersistedState.OculiPersistedState.SourceMachineInfo.ProductInfo = new ProductInfo();
            this._JobInfo.JobPersistedState.OculiPersistedState.State = new JobState()
            {
                HasError  = false,
                HighLevel = "CREATED",
                IsInSync  = false,
                LowLevel  = "Created"
            };
            this._Logger             = (ILogger) new LoggerWrapper(logger);
            this._JobInfoWrapper     = (ITaskInfoWrapper) new Oculi.Jobs.Context.TaskInfoWrapper(this._JobInfo, (IOculiCredentialHelper)null);
            this._StateContext       = new JobStateContext(this);
            this.Factory             = (ICommandFactory) new CommandFactory(this);
            this.Invoker             = (ICommandInvoker) new CommandInvoker(this.Factory);
            this.LocalDiskManagement = new LocalDiskManagement(this);
            this._JobInfo.JobPersistedState.OculiPersistedState.SourceMachineInfo.ServerInfo.OperatingSystem.Version      = bootInfo.OSVersion;
            this._JobInfo.JobPersistedState.OculiPersistedState.SourceMachineInfo.ServerInfo.OperatingSystem.Architecture = bootInfo.CPUArchitecture;
            this._JobInfo.Options.OculiOptions.Hypervisor = bootInfo.Hypervisor;
            this._JobInfo.JobType = "Oculi";
            this._JobInfo.Options.ClusterOptions.TargetIsCluster          = false;
            this._JobInfo.Options.OculiOptions.IsSourceHostCluster        = false;
            this._JobInfo.JobPersistedState.OculiPersistedState.Nics      = ((IEnumerable <VirtualNetworkInterfaceInfo>)bootInfo.NetworkInterfaceInfo).Select <VirtualNetworkInterfaceInfo, OculiInternalVirtualNetworkInterfaceInfo>((Func <VirtualNetworkInterfaceInfo, OculiInternalVirtualNetworkInterfaceInfo>)(nic => OculiInternalVirtualNetworkInterfaceInfo.Create(nic))).ToArray <OculiInternalVirtualNetworkInterfaceInfo>();
            this._JobInfo.JobPersistedState.OculiPersistedState.VmVersion = bootInfo.VmVersion;
            OculiPersistedState vraPersistedState = this._JobInfo.JobPersistedState.OculiPersistedState;

            OculiVolumePersistedState[] volumePersistedStateArray = new OculiVolumePersistedState[1];
            int index = 0;
            OculiVolumePersistedState volumePersistedState = new OculiVolumePersistedState();

            volumePersistedState.MountPoint = bootInfo.SystemVolumeMountPath;
            int num = 1;

            volumePersistedState.IsSystemDrive = num != 0;
            string str = bootInfo.WindowsDir.Substring(0, 1);

            volumePersistedState.Name              = str;
            volumePersistedStateArray[index]       = volumePersistedState;
            vraPersistedState.VolumePersistedState = volumePersistedStateArray;
            this.LocalDiskManagement.FillVolumeInfoFromMountPath(this.JobInfoWrapper.VolumePersistedState[0]);
            this._JobInfo.JobPersistedState.OculiPersistedState.SourceMachineInfo.ServerInfo.SystemRoot      = bootInfo.WindowsDir;
            this._JobInfo.JobPersistedState.OculiPersistedState.SourceMachineInfo.ServerInfo.SystemVolume    = bootInfo.WindowsDir.Substring(0, 2);
            this._JobInfo.JobPersistedState.OculiPersistedState.OculiVirtualizationConnectionInfo            = new VirtualizationConnectionInfo();
            this._JobInfo.JobPersistedState.OculiPersistedState.OculiVirtualizationConnectionInfo.RepsetName = "";
            this._JobInfo.Options.OculiOptions.VMInfo = new VMInfo();
            this._JobInfoWrapper.TargetOSVersion      = OculiService.TargetHostOperatingSystemInfo.Version;
        }
Exemplo n.º 3
0
 private void _RemoveVirtualDisk(OculiVolumePersistedState volumeInfo, VmdkProperties driveProperties)
 {
     VmdkProperties[] vmdkProps = new VmdkProperties[1] {
         driveProperties
     };
     try
     {
         CUtils.Retry(this._RemoveVirtualDisk_Retry, this._RemoveVirtualDisk_Delay, (CUtils.Workload)(() =>
         {
             this._HelperVm_RemoveVirtualDisk(vmdkProps);
             if (!this._CheckDriveGone(volumeInfo))
             {
                 throw new OculiServiceException(0, string.Format("Failed to detach a volume from the Helper VM ({0:d})", (object)volumeInfo.DriveName));
             }
         }));
     }
     catch (Exception ex)
     {
         this._Logger.FormatWarningWithException(ex, "Failed to detach volume {0} from helper VM due to exception:  ", (object)volumeInfo.VolumeName);
         throw;
     }
 }
 public bool Invoke(OculiVolumePersistedState volumeInfo)
 {
     volumeInfo.IsGpt = volumeInfo.DesiredSize > 2199023255552L;
     return(this._RunDiskPart("select disk " + (object)volumeInfo.DriveIndex + "\nattributes disk clear readonly noerr\nonline disk noerr\nclean\nconvert dynamic\nconvert basic\n" + (volumeInfo.IsGpt ? "convert gpt\n" : "convert mbr\n") + "create partition primary align=64\nselect partition 1\n" + (volumeInfo.IsSystemDrive ? "active\n" : string.Empty)));
 }
Exemplo n.º 5
0
 private bool _CheckDriveGone(OculiVolumePersistedState volumeInfo)
 {
     return(this._FindDriveVmdkProperties(volumeInfo) == null);
 }
Exemplo n.º 6
0
 private VmdkProperties _FindDriveVmdkProperties(OculiVolumePersistedState volumeInfo)
 {
     return(((IEnumerable <VmdkProperties>) this._HelperVm_GetVMDKInfo()).FirstOrDefault <VmdkProperties>((Func <VmdkProperties, bool>)(v => v.FileName == volumeInfo.VirtualDiskFilename)));
 }