public void CreateDeploymentWithILBAndRemoveILB() { try { string ilbName = Utilities.GetUniqueShortName("ILB"); string vmName = Utilities.GetUniqueShortName(vmNamePrefix); var ilbConfig = vmPowershellCmdlets.NewAzureInternalLoadBalancerConfig(ilbName); Utilities.ExecuteAndLog(() => { var vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password, false); vmPowershellCmdlets.NewAzureVMWithInternalLoadBalancer(serviceName, new[] { vm }, ilbConfig, location: locationName); }, string.Format("Create a Vm with Internal load balancer {0}", ilbName)); VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig); VerifyDeployment("Verify internal load balancer name of the deployment", ilbName); Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureInternalLoadBalancer(serviceName), "Remove Azure Internal Load Balancer"); VerifyDeployment("Get azure deployment and verify that the deployment doesnt have ILB"); pass = true; } catch (Exception ex) { pass = false; Console.WriteLine(ex.InnerException.ToString()); throw ex; } }
private PersistentVM CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(string vmName, OS os) { string disk1 = "Disk1"; int diskSize = 30; string availabilitySetName = Utilities.GetUniqueShortName("AvailSet"); string img = string.Empty; bool isWindowsOs = false; if (os == OS.Windows) { img = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); isWindowsOs = true; } else { img = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Linux" }, false); isWindowsOs = false; } PersistentVM vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, img, isWindowsOs, username, password); AddAzureDataDiskConfig azureDataDiskConfigInfo1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, diskSize, disk1, 0, HostCaching.ReadWrite.ToString()); azureDataDiskConfigInfo1.Vm = vm; vm = vmPowershellCmdlets.SetAzureSubnet(vm, new string[] { subnet }); vm = vmPowershellCmdlets.SetAzureAvailabilitySet(availabilitySetName, vm); return(vm); }
public PersistentVM CreateIaaSVMObjectWithDisk(string vmName, InstanceSize size, string imageName, bool isWindows, string username, string password) { PersistentVM vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, isWindows, username, password); AddAzureDataDiskConfig azureDataDiskConfigInfo1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, diskSize1, diskLabel1, lunSlot1, cahcing.ToString()); azureDataDiskConfigInfo1.Vm = vm; return(vmPowershellCmdlets.AddAzureDataDisk(azureDataDiskConfigInfo1)); }
private static PersistentVM CreateVMWithEndpointDataDiskAndPublicIP(string vmName, string endpointName, string disklabel1, string publicIpName, string serviceName, int localPort, int publicport) { var vm1 = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password); var endpointConfiginput = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, TCP_PROTOCAL, localPort, publicport, endpointName, serviceName: serviceName); endpointConfiginput.Vm = vm1; vm1 = vmPowershellCmdlets.AddAzureEndPoint(endpointConfiginput); var dataDiskConfig1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 128, disklabel1, 0); dataDiskConfig1.Vm = vm1; vm1 = vmPowershellCmdlets.AddAzureDataDisk(dataDiskConfig1); vm1 = (PersistentVM)vmPowershellCmdlets.SetAzurePublicIp(publicIpName, vm1); return(vm1); }
public void CreateDeploymentWithILBIPaddressAndSetILBEndpoint() { try { string ilbName = Utilities.GetUniqueShortName("ILB"); string vmName = Utilities.GetUniqueShortName(vmNamePrefix); string endpointName = Utilities.GetUniqueShortName("endpoint"); IPAddress ipAddress = IPAddress.Parse(GetAvailableIpAddressinVnet()); string lbsetName = Utilities.GetUniqueShortName("LbSet"); var ilbConfig = vmPowershellCmdlets.NewAzureInternalLoadBalancerConfig(ilbName, subNet, ipAddress); Utilities.ExecuteAndLog(() => { var vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password, false); var endpointConfiginput = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe, TCP_PROTOCAL, LOCAL_PORT_NUMBER1, PUBLIC_PORT_NUMBER1, endpointName, lbsetName, null, false, ilbName); endpointConfiginput.Vm = vm; vm = vmPowershellCmdlets.AddAzureEndPoint(endpointConfiginput); vmPowershellCmdlets.NewAzureVMWithInternalLoadBalancer(serviceName, new[] { vm }, ilbConfig, vnetName, locationName); }, string.Format("Create a Vm with Internal load balancer {0}", ilbName)); ilbConfig.SubnetName = subNet; ilbConfig.IPAddress = ipAddress.ToString(); VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig); var loadBalancerEndpointConfig = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe, UDP_PROTOCAL, LOCAL_PORT_NUMBER2, PUBLIC_PORT_NUMBER2, endpointName, lbsetName, internalLoadBalancer: ilbName, serviceName: serviceName); vmPowershellCmdlets.SetAzureLoadBalancedEndPoint(loadBalancerEndpointConfig, AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe); VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig); VerifyEndpoint("Verify Azure endpoint", vmName, loadBalancerEndpointConfig); VerifyDeployment("Verify internal load balancer name and vnet name of the deployment", ilbName, vnetName); ilbConfig.IPAddress = ipAddress.ToString(); VerifyInternalLoadBalancer("Verify ILB name, subnet, ip address of the ILB", ilbConfig); pass = true; } catch (Exception ex) { pass = false; Console.WriteLine(ex.InnerException.ToString()); throw ex; } }
public void CreateDeploymentWithILBSubnetAndAddILBEndpoint() { try { string ilbName = Utilities.GetUniqueShortName("ILB"); string vmName = Utilities.GetUniqueShortName(vmNamePrefix); string endpointName = Utilities.GetUniqueShortName("endpoint"); var ilbConfig = vmPowershellCmdlets.NewAzureInternalLoadBalancerConfig(ilbName, subNet); Utilities.ExecuteAndLog(() => { var vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password, false); vm = vmPowershellCmdlets.SetAzureSubnet(vm, new string[] { subNet }); vmPowershellCmdlets.NewAzureVMWithInternalLoadBalancer(serviceName, new[] { vm }, ilbConfig, vnetName, locationName); }, string.Format("Create a Vm with Internal load balancer {0}", ilbName)); ilbConfig.SubnetName = subNet; VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig); var endpointConfig = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, TCP_PROTOCAL, LOCAL_PORT_NUMBER1, PUBLIC_PORT_NUMBER1, endpointName, internalLoadBalancer: ilbName); Utilities.ExecuteAndLog(() => { var vmRoleContext = vmPowershellCmdlets.GetAzureVM(vmName, serviceName); endpointConfig.Vm = vmRoleContext.VM; var vm = vmPowershellCmdlets.AddAzureEndPoint(endpointConfig); vmPowershellCmdlets.UpdateAzureVM(vmName, serviceName, vm); }, "Add Azure endpoint to the vm"); VerifyEndpoint("Verify Azure endpoint", vmName, endpointConfig); VerifyDeployment("Verify internal load balancer name and vnet name of the deployment", ilbName, vnetName); ilbConfig.IPAddress = ipAddress; VerifyInternalLoadBalancer("Verify ILB name, subnet, ip address of the ILB", ilbConfig); pass = true; } catch (Exception ex) { pass = false; Console.WriteLine(ex.InnerException.ToString()); throw ex; } }
public void CaptureSpecializedVMAndDeploy() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string serviceName1 = Utilities.GetUniqueShortName(serviceNamePrefix); try { // a. Deploy a new IaaS VM string vmName = Utilities.GetUniqueShortName(vmNamePrefix); Console.WriteLine("--------------------------------Deploying a new IaaS VM :{0}--------------------------------", vmName); var vm = CreateIaaSVMObjectWithDisk(vmName, InstanceSize.Small, imageName, true, username, password); vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, locationName); Console.WriteLine("--------------------------------Deploying a new IaaS VM :{0} completed.---------------------", vmName); //b. Stop the VM Console.WriteLine("--------------------------------Stopping vm :{0}--------------------------------", vmName); vmPowershellCmdlets.StopAzureVM(vmName, serviceName, force: true); Console.WriteLine("--------------------------------Stopped vm :{0}--------------------------------", vmName); //c. Save the VM image Console.WriteLine("--------------------------------Save the VM image--------------------------------"); vmImageName = vmName + "Image"; vmPowershellCmdlets.SaveAzureVMImage(serviceName, vmName, vmImageName, CONSTANT_SPECIALIZED, vmImageName); Console.WriteLine("--------------------------------Saved VM image with name {0}----------------------"); //d. Verify the VM image by Get-AzureVMImage Console.WriteLine("--------------------------------Verify the VM image--------------------------------"); VerifyVMImage(vmImageName, OS.Windows, vmImageName, CONSTANT_SPECIALIZED, cahcing, lunSlot1, diskSize1, 1); Console.WriteLine("--------------------------------Verified that the VM image is saved successfully--------------------------------"); //e. Deploy a new IaaS VM with the save VM image Console.WriteLine("--------------------------------Deploy a new IaaS VM with the saved VM image {0}--------------------------------", vmImageName); string vmName1 = Utilities.GetUniqueShortName(vmNamePrefix); vm = Utilities.CreateIaaSVMObject(vmName1, InstanceSize.Small, vmImageName); vmPowershellCmdlets.NewAzureVM(serviceName1, new[] { vm }, locationName); Console.WriteLine("--------------------------------Deployed a IaaS VM {0} with the saved VM image {1}--------------------------------", vmName1, vmImageName); //f. Verify the VM by Get-AzureVM Console.WriteLine("--------------------------------Verify the VM by Get-AzureVM--------------------------------", vmName1, vmImageName); var vmRoleContext = vmPowershellCmdlets.GetAzureVM(vmName1, serviceName1); Utilities.PrintContext(vmRoleContext); VerifyVM(vmRoleContext.VM, OS.Windows, HostCaching.ReadWrite, diskSize1, 1); Console.WriteLine("--------------------------------Verified the VM {0} successfully--------------------------------", vmName1); //g. Add another IaaS VM with the save VM image to the existing service string vmName2 = Utilities.GetUniqueShortName(vmNamePrefix); Console.WriteLine("--------------------------------Deploy a new IaaS VM with the saved VM image {0}--------------------------------", vmImageName); vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, vmName2, serviceName1, vmImageName); Console.WriteLine("--------------------------------Deployed a IaaS VM {0} with the saved VM image {1}--------------------------------", vmName2, vmImageName); //h. Verify the VM by Get-AzureVM Console.WriteLine("--------------------------------Verify the VM by Get-AzureVM--------------------------------", vmName2, vmImageName); vmRoleContext = vmPowershellCmdlets.GetAzureVM(vmName2, serviceName1); VerifyVM(vmRoleContext.VM, OS.Windows, HostCaching.ReadWrite, diskSize1, 1); Utilities.PrintContext(vmRoleContext); Console.WriteLine("--------------------------------Verified the VM {0} successfully--------------------------------", vmName2); pass = true; } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw; } finally { CleanupService(serviceName1); // Delete the VM image Console.WriteLine("------------------------------Delete the VM image---------------------------------"); DeleteVMImageIfExists(vmImageName); Console.WriteLine("------------------------------Deleted the VM image---------------------------------"); } }
public void CaptureGeneralizedLinuxVMAndDeploy() { string serviceName1 = Utilities.GetUniqueShortName(serviceNamePrefix); string linuxImageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Linux" }, false); try { // a. Deploy a new IaaS VM string vmName = Utilities.GetUniqueShortName(vmNamePrefix); Console.WriteLine("--------------------------------Deploying a new IaaS VM :{0} completed.---------------------", vmName); PersistentVM vm = CreateIaaSVMObjectWithDisk(vmName, InstanceSize.Small, linuxImageName, false, username, password); vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, locationName); Console.WriteLine("--------------------------------Deploying a new IaaS VM :{0} completed.---------------------", vmName); //b. Stop the VM Console.WriteLine("--------------------------------Stopping vm :{0}--------------------------------", vmName); vmPowershellCmdlets.StopAzureVM(vmName, serviceName, force: true); Console.WriteLine("--------------------------------Stopped vm :{0}--------------------------------", vmName); //c. Save the VM image Console.WriteLine("--------------------------------Save the VM image--------------------------------"); vmImageName = vmName + "Image"; vmPowershellCmdlets.SaveAzureVMImage(serviceName, vmName, vmImageName, CONSTANT_GENERALIZED, vmImageName); Console.WriteLine("--------------------------------Saved VM image with name {0}----------------------"); //d. Verify the VM image by Get-AzureVMImage Console.WriteLine("--------------------------------Verify the VM image--------------------------------"); VerifyVMImage(vmImageName, OS.Linux, vmImageName, CONSTANT_GENERALIZED, cahcing, lunSlot1, diskSize1, 1); Console.WriteLine("--------------------------------Verified that the VM image is saved successfully--------------------------------"); //e. Deploy a new IaaS VM with the save VM image Console.WriteLine("--------------------------------Deploy a new IaaS VM with the saved VM image {0}--------------------------------", vmImageName); string vmName1 = Utilities.GetUniqueShortName(vmNamePrefix); vm = Utilities.CreateIaaSVMObject(vmName1, InstanceSize.Small, vmImageName, false, username, password); vmPowershellCmdlets.NewAzureVM(serviceName1, new[] { vm }, locationName); Console.WriteLine("--------------------------------Deployed a IaaS VM {0} with the saved VM image {1}--------------------------------", vmName1, vmImageName); //f. Verify the VM by Get-AzureVM Console.WriteLine("--------------------------------Verify the VM by Get-AzureVM--------------------------------", vmName1, vmImageName); var vmRoleContext = vmPowershellCmdlets.GetAzureVM(vmName1, serviceName1); Utilities.PrintContext(vmRoleContext); Console.WriteLine("--------------------------------Verified the VM {0} successfully--------------------------------", vmName1); //g. Add another IaaS VM with the save VM image to the existing service string vmName2 = Utilities.GetUniqueShortName(vmNamePrefix); Console.WriteLine("--------------------------------Deploy a new IaaS VM with the saved VM image {0}--------------------------------", vmImageName); vmPowershellCmdlets.NewAzureQuickVM(OS.Linux, vmName2, serviceName1, vmImageName, username, password); Console.WriteLine("--------------------------------Deployed a IaaS VM {0} with the saved VM image {1}--------------------------------", vmName2, vmImageName); //h. Verify the VM by Get-AzureVM Console.WriteLine("--------------------------------Verify the VM by Get-AzureVM--------------------------------", vmName2, vmImageName); vmRoleContext = vmPowershellCmdlets.GetAzureVM(vmName2, serviceName1); Utilities.PrintContext(vmRoleContext); Console.WriteLine("--------------------------------Verified the VM {0} successfully--------------------------------", vmName2); pass = true; } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw; } finally { CleanupService(serviceName1); //Delete the VM image Console.WriteLine("------------------------------Delete the VM image---------------------------------"); vmPowershellCmdlets.RemoveAzureVMImage(vmImageName, true); Console.WriteLine("------------------------------Deleted the VM image---------------------------------"); } }