public void CommandOperator_DefaultValues_SetsNothing() { var expected = new GetAzureVmCommand(); Command actual = expected; Assert.That(actual.Parameters, Is.Empty); }
public void CommandOperator_ServiceNameIsEmpty_SetsNothing() { var expected = new GetAzureVmCommand { ServiceName = String.Empty }; Command command = expected; var actual = command.Parameters.FirstOrDefault(x => x.Name == GetAzureVmCommand.ServiceNameParameter); Assert.That(actual, Is.Null); }
public void CommandOperator_ServiceNameIsSomething_SetsServiceName() { var expected = new GetAzureVmCommand { ServiceName = "SomeName" }; Command command = expected; var actual = command.Parameters.FirstOrDefault(x => x.Name == GetAzureVmCommand.ServiceNameParameter); Assert.That(actual, Is.Not.Null); Assert.That(actual.Value, Is.EqualTo(expected.ServiceName)); }
private static bool AzureVirtualMachineExists(IPowershellExecutor executor, VirtualMachine virtualMachine, string serviceName) { var getAzureVmCommand = new GetAzureVmCommand { ServiceName = serviceName, Name = virtualMachine.Name }; var results = executor.Execute(getAzureVmCommand); var result = results.Any(); return result; }
private static void AttachAzureDrive(IPowershellExecutor executor, VirtualMachine virtualMachine, string serviceName, string dataDiskName) { var getAzureVm = new GetAzureVmCommand { Name = virtualMachine.Name, ServiceName = serviceName }; var addAzureDataDisk = new AddAzureDataDiskCommand { Import = true, DiskName = dataDiskName, LogicalUnitNumber = 0 }; var updateAzureVm = new UpdateAzureVmCommand(); var result = executor.Execute(getAzureVm, addAzureDataDisk, updateAzureVm); }
private static string GetAttachedOsDisks(IPowershellExecutor executor, VirtualMachine virtualMachine, string serviceName) { var getAzureVmCommand = new GetAzureVmCommand { ServiceName = serviceName, Name = virtualMachine.Name }; var getAzureOsDiskCommand = new GetAzureOsDiskCommand(); var osDisk = executor.Execute(getAzureVmCommand, getAzureOsDiskCommand) .Select(x => x.Properties["DiskName"].Value) .Cast<string>() .FirstOrDefault(); return osDisk; }
private static IEnumerable<KeyValuePair<string, int>> GetAttachedDataDisks(IPowershellExecutor executor, VirtualMachine virtualMachine, string serviceName) { var getAzureVmCommand = new GetAzureVmCommand { ServiceName = serviceName, Name = virtualMachine.Name }; var getAzureDataDiskCommand = new GetAzureDataDiskCommand(); var dataDisks = executor.Execute(getAzureVmCommand, getAzureDataDiskCommand) .ToDictionary(x => (string) x.Properties["DiskName"].Value, y => (int) y.Properties["LUN"].Value); //.Select(x => x.Properties["DiskName"].Value) //.Cast<string>(); return dataDisks; }
private static void DetachDiskFromVirtualMachine(IPowershellExecutor executor, VirtualMachine virtualMachine, string serviceName, int logicalUnitNumber) { var getAzureVmCommand = new GetAzureVmCommand { ServiceName = serviceName, Name = virtualMachine.Name }; var removeAzureDataDiskCommand = new RemoveAzureDataDiskCommand { LogicalUnitNumber = logicalUnitNumber }; var updateAzureVmCommand = new UpdateAzureVmCommand(); executor.Execute(getAzureVmCommand, removeAzureDataDiskCommand, updateAzureVmCommand); }