本文整理汇总了C#中AzureProvisioningConfigInfo类的典型用法代码示例。如果您正苦于以下问题:C# AzureProvisioningConfigInfo类的具体用法?C# AzureProvisioningConfigInfo怎么用?C# AzureProvisioningConfigInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AzureProvisioningConfigInfo类属于命名空间,在下文中一共展示了AzureProvisioningConfigInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PersistentVMConfigInfo
public PersistentVMConfigInfo(AzureVMConfigInfo vmConfig, AzureProvisioningConfigInfo provConfig, AddAzureDataDiskConfig diskConfig, AzureEndPointConfigInfo endPointConfig)
{
this.VmConfig = vmConfig;
this.ProvConfig = provConfig;
this.DiskConfig = diskConfig;
this.EndPointConfig = endPointConfig;
}
示例2: AddAzureProvisioningConfigCmdletInfo
public AddAzureProvisioningConfigCmdletInfo(AzureProvisioningConfigInfo provConfig)
{
this.cmdletName = Utilities.AddAzureProvisioningConfigCmdletName;
this.cmdletParams.Add(new CmdletParam("VM", provConfig.Vm));
this.cmdletParams.Add(new CmdletParam(provConfig.OS.ToString()));
this.cmdletParams.Add(new CmdletParam("Password", provConfig.Password));
if (provConfig.LinuxUser != null)
{
this.cmdletParams.Add(new CmdletParam("LinuxUser", provConfig.LinuxUser));
}
if (provConfig.AdminUsername != null)
{
this.cmdletParams.Add(new CmdletParam("AdminUsername", provConfig.AdminUsername));
}
if (provConfig.Option != null && provConfig.Option == "WindowsDomain")
{
this.cmdletParams.Add(new CmdletParam("WindowsDomain"));
}
if (provConfig.Domain != null)
{
this.cmdletParams.Add(new CmdletParam("Domain", provConfig.Domain));
}
if (provConfig.JoinDomain != null)
{
this.cmdletParams.Add(new CmdletParam("JoinDomain", provConfig.JoinDomain));
}
if (provConfig.DomainUserName != null)
{
this.cmdletParams.Add(new CmdletParam("DomainUserName", provConfig.DomainUserName));
}
if (provConfig.DomainPassword != null)
{
this.cmdletParams.Add(new CmdletParam("DomainPassword", provConfig.DomainPassword));
}
if (provConfig.Reset)
{
this.cmdletParams.Add(new CmdletParam("ResetPasswordInFirstLogon"));
}
if (provConfig.Certs != null && provConfig.Certs.Count != 0)
{
this.cmdletParams.Add(new CmdletParam("Certificates", provConfig.Certs));
}
}
示例3: CreateDeploymentWithReservedIPNegativeTest
public void CreateDeploymentWithReservedIPNegativeTest()
{
try
{
string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
if (string.IsNullOrEmpty(imageName))
{
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
}
var azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall.ToString(), imageName);
var azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.Small.ToString(), imageName);
var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
var azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
var azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);
var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, null);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);
PersistentVM[] VMs = { persistentVM1, persistentVM2 };
// AG1 on location 1
vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null);
// AG2 on location 2
var anotherLocation = GetLocation("PersistentVMRole", locationName);
vmPowershellCmdlets.NewAzureAffinityGroup(affName2, anotherLocation.Name, null, null);
// Reserve an ip on AG1
vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName2);
var rsvIPreturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
Verify.AzureReservedIPNotInUse(rsvIPreturned, rsvIpName1, null, affName2);
// Try to create a new deployment with AG2 and the reserved IP
Utilities.VerifyFailure(
() => vmPowershellCmdlets.NewAzureVMWithReservedIP(svcNameAG, VMs, rsvIpName1, affName1),
BadRequestException);
// Create a new deployment with location 2, and then reserved the IP of it
vmPowershellCmdlets.NewAzureVM(svcNameLoc, VMs, locationName);
Utilities.VerifyFailure(
() => vmPowershellCmdlets.NewAzureReservedIP(rsvIpName2, affName2, svcNameLoc, svcNameLoc),
BadRequestException);
// Remove the reserved IP and verify
vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1);
Utilities.VerifyFailure(
() => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException);
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
示例4: RemoveAzureReservedIPWithDeploymentTest
public void RemoveAzureReservedIPWithDeploymentTest()
{
try
{
vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null);
string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
if (string.IsNullOrEmpty(imageName))
{
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
}
var azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall.ToString(), imageName);
var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
var azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
var azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);
var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
//PersistentVM[] VMs = { persistentVM1, persistentVM2 };
PersistentVM[] VMs = { persistentVM1 };
// Create a new deployment
vmPowershellCmdlets.NewAzureVMWithAG(svcNameAG, VMs, affName1);
// Reserve the ip of the deployment
vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName1, svcNameAG, svcNameAG, rsvIPLabel);
// Get the deployment and verify
var deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameAG);
// Verify the reserved ip
var reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
deploymentReturned.ServiceName);
// Stop-deallocate the first VM and verify reserved ip
Utilities.VerifyFailure(() => vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1), BadRequestException);
vmPowershellCmdlets.StopAzureVM(newAzureVM1Name, svcNameAG, false, true);
// Verify the reserved ip
reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
deploymentReturned.ServiceName);
// Stop-deallocate the second VM and verify reserved ip
Utilities.VerifyFailure(() => vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1), BadRequestException);
// Remove all VMs and service and verify reserved ip
vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, svcNameAG, true);
// Verify the reserved ip
reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1);
// Remove the reserved IP and verify
vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1);
Utilities.VerifyFailure(
() => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException);
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
示例5: StopAzureVMDeprovisionedTest
public void StopAzureVMDeprovisionedTest()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
try
{
// starting the test.
AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall, imageName);
AzureProvisioningConfigInfo azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(vmName2, InstanceSize.Small, imageName);
AzureProvisioningConfigInfo azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);
PersistentVM[] VMs = { persistentVM1, persistentVM2 };
vmPowershellCmdlets.NewAzureVM(svcName, VMs);
Console.WriteLine("The VM is successfully created: {0}", vmName1);
Console.WriteLine("The VM is successfully created: {0}", vmName2);
// Stop and deallocate VM1
vmPowershellCmdlets.StopAzureVM(vmName1, svcName);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
WaitForStartedState(svcName, vmName2);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState, provisioningState }));
try
{
// Try to Stop and deallocate VM2 without Force. Should fail and give a warning message.
vmPowershellCmdlets.RunPSScript(string.Format("{0} -ServiceName {1} -Name {2} | {3}",
Utilities.GetAzureVMCmdletName, svcName, vmName2, Utilities.StopAzureVMCmdletName));
Assert.Fail();
}
catch (Exception e)
{
if (e is AssertFailedException)
{
throw;
}
else
{
Console.WriteLine(e.ToString());
}
}
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState, provisioningState }));
// Stop and deallocate VM2
vmPowershellCmdlets.StopAzureVM(vmName2, svcName, false, true);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw;
}
finally
{
if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
{
vmPowershellCmdlets.RemoveAzureService(svcName);
}
}
}
示例6: AzureSubnetTest
public void AzureSubnetTest()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
try
{
//vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
var azureVMConfigInfo = new AzureVMConfigInfo(vmName, InstanceSize.Small.ToString(), imageName);
var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);
string [] subs = {"subnet1", "subnet2", "subnet3"};
PersistentVM vm = vmPowershellCmdlets.SetAzureSubnet(vmPowershellCmdlets.AddAzureProvisioningConfig(azureProvisioningConfig), subs);
SubnetNamesCollection subnets = vmPowershellCmdlets.GetAzureSubnet(vm);
foreach (string subnet in subnets)
{
Console.WriteLine("Subnet: {0}", subnet);
}
CollectionAssert.AreEqual(subnets, subs);
pass = true;
}
catch (Exception e)
{
Console.WriteLine("Exception occurred: {0}", e);
throw;
}
}
示例7: RestartAzureVMTest
public void RestartAzureVMTest()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
try
{
DateTime prevTime = DateTime.Now;
// starting the test.
var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.Small.ToString(), imageName);
var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
PersistentVM[] VMs = { persistentVM1 };
Utilities.RecordTimeTaken(ref prevTime);
vmPowershellCmdlets.NewAzureVM(svcName, VMs);
Utilities.RecordTimeTaken(ref prevTime);
Console.WriteLine("The VM is successfully created: {0}", vmName1);
WaitForReadyState(svcName, vmName1);
Console.WriteLine(vmPowershellCmdlets.GetAzureVM(vmName1, svcName).InstanceStatus);
Utilities.RecordTimeTaken(ref prevTime);
vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true);
Utilities.RecordTimeTaken(ref prevTime);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));
Utilities.RecordTimeTaken(ref prevTime);
vmPowershellCmdlets.StartAzureVM(vmName1, svcName);
Utilities.RecordTimeTaken(ref prevTime);
WaitForReadyState(svcName, vmName1);
Utilities.RecordTimeTaken(ref prevTime);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState }));
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw;
}
finally
{
if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
{
vmPowershellCmdlets.RemoveAzureService(svcName);
}
}
}
示例8: RestartAzureVMAfterDeallocateTest
public void RestartAzureVMAfterDeallocateTest()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
try
{
DateTime prevTime = DateTime.Now;
// starting the test.
var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.Small.ToString(), imageName);
var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
PersistentVM[] VMs = { persistentVM1 };
Utilities.RecordTimeTaken(ref prevTime);
vmPowershellCmdlets.NewAzureVM(svcName, VMs);
Utilities.RecordTimeTaken(ref prevTime);
Console.WriteLine("The VM is successfully created: {0}", vmName1);
WaitForReadyState(svcName, vmName1);
Console.WriteLine(vmPowershellCmdlets.GetAzureVM(vmName1, svcName).InstanceStatus);
Utilities.RecordTimeTaken(ref prevTime);
vmPowershellCmdlets.StopAzureVM(vmName1, svcName, false, true);
Utilities.RecordTimeTaken(ref prevTime);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
for (int i = 0 ; i < 10 ; i++)
{
try
{
Utilities.RecordTimeTaken(ref prevTime);
vmPowershellCmdlets.StartAzureVM(vmName1, svcName);
Utilities.RecordTimeTaken(ref prevTime);
break;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Thread.Sleep(60 * 1000);
}
}
WaitForReadyState(svcName, vmName1);
Utilities.RecordTimeTaken(ref prevTime);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new [] { readyState }));
var vm = vmPowershellCmdlets.GetAzureVM(vmName1, svcName).VM;
var vmSizeConfig = new SetAzureVMSizeConfig(InstanceSize.Medium.ToString());
vmSizeConfig.Vm = vm;
vm = vmPowershellCmdlets.SetAzureVMSize(vmSizeConfig);
vmPowershellCmdlets.UpdateAzureVM(vmName1, svcName, vm);
vm = vmPowershellCmdlets.GetAzureVM(vmName1, svcName).VM;
Console.WriteLine("RoleSize: {0}", vm.RoleSize);
Assert.AreEqual(InstanceSize.Medium.ToString(), vm.RoleSize);
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw;
}
finally
{
if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
{
vmPowershellCmdlets.RemoveAzureService(svcName);
}
}
}
示例9: AdvancedProvisioning
public void AdvancedProvisioning()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
if (string.IsNullOrEmpty(imageName))
{
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
}
vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName);
AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);
PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);
PersistentVM[] VMs = { persistentVM1, persistentVM2 };
vmPowershellCmdlets.NewAzureVM(serviceName, VMs);
// Cleanup
vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName);
vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName);
Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName));
Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName));
pass = true;
}
示例10: StopAzureVMsDeprovisionedTest
public void StopAzureVMsDeprovisionedTest()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
try
{
// starting the test.
var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall.ToString(), imageName);
var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
var azureVMConfigInfo2 = new AzureVMConfigInfo(vmName2, InstanceSize.Small.ToString(), imageName);
var azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);
PersistentVM[] VMs = { persistentVM1, persistentVM2 };
vmPowershellCmdlets.NewAzureVM(svcName, VMs);
Console.WriteLine("The VM is successfully created: {0}", vmName1);
Console.WriteLine("The VM is successfully created: {0}", vmName2);
WaitForReadyState(svcName, vmName1);
WaitForReadyState(svcName, vmName2);
var vm1 = vmPowershellCmdlets.GetAzureVM(vmName1, svcName);
var vm2 = vmPowershellCmdlets.GetAzureVM(vmName2, svcName);
Assert.AreEqual(vm1.HostName, vmName1);
Assert.AreEqual(vm2.HostName, vmName2);
// Stop and deallocate the VMs
vmPowershellCmdlets.StopAzureVM("*", svcName, false, true);
WaitForStoppedState(svcName, vmName1);
WaitForStoppedState(svcName, vmName2);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));
// Start the VMs
Utilities.RetryActionUntilSuccess(() => vmPowershellCmdlets.StartAzureVM("*", svcName), "HTTP Status Code: 409", 10, 60);
//StartAzureVMs("*", svcName);
WaitForStartedState(svcName, vmName1);
WaitForStartedState(svcName, vmName2);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState, provisioningState }));
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState, provisioningState }));
try
{
// Try to Stop and deallocate VM2 without Force. Should fail and give a warning message.
vmPowershellCmdlets.StopAzureVM("*", svcName);
Assert.Fail();
}
catch (Exception e)
{
if (e is AssertFailedException)
{
throw;
}
else
{
Console.WriteLine(e.ToString());
}
}
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState, provisioningState }));
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState, provisioningState }));
// Stop and deallocate VMs
vmPowershellCmdlets.StopAzureVM("*", svcName, false, true);
WaitForStoppedState(svcName, vmName1);
WaitForStoppedState(svcName, vmName2);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw;
}
finally
{
if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
{
vmPowershellCmdlets.RemoveAzureService(svcName);
}
}
}
示例11: AzureDnsTest2
public void AzureDnsTest2()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
const string dnsName = "OpenDns1";
const string ipAddress = "208.67.222.222";
const string ipAddress2 = "127.0.0.1";
try
{
vmPowershellCmdlets.NewAzureService(serviceName, locationName);
// Create a VM
var azureVMConfigInfo = new AzureVMConfigInfo(vmName, InstanceSize.ExtraSmall.ToString(), imageName);
var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm });
// Add a DNS server
vmPowershellCmdlets.AddAzureDns(dnsName, ipAddress, serviceName);
var dnsServer = vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings.DnsServers[0];
Assert.AreEqual(dnsName, dnsServer.Name);
Assert.AreEqual(ipAddress, dnsServer.Address);
// Edit the DNS server
vmPowershellCmdlets.SetAzureDns(dnsName, ipAddress2, serviceName);
dnsServer = vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings.DnsServers[0];
Assert.AreEqual(dnsName, dnsServer.Name);
Assert.AreEqual(ipAddress2, dnsServer.Address);
// Remove the DNS server
vmPowershellCmdlets.RemoveAzureDns(dnsName, serviceName, force:true);
Assert.IsNull(vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings);
pass = true;
}
catch (Exception e)
{
pass = false;
Console.WriteLine("Exception occurred: {0}", e.ToString());
throw;
}
}
示例12: AddEndPointACLsWithNewDeployment
public void AddEndPointACLsWithNewDeployment()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
if (string.IsNullOrEmpty(imageName))
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
NetworkAclObject aclObj = vmPowershellCmdlets.NewAzureAclConfig();
vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 100, ACLAction.Permit, "172.0.0.0/8", "notes1");
vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 200, ACLAction.Deny, "10.0.0.0/8", "notes2");
AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName);
AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.DefaultProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", aclObj, true);
PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);
PersistentVM[] VMs = { persistentVM1, persistentVM2 };
vmPowershellCmdlets.NewAzureVM(serviceName, VMs);
// Cleanup
vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName);
vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName);
Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName));
Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName));
pass = true;
}
示例13: CaptureImagingExportingImportingVMConfig
public void CaptureImagingExportingImportingVMConfig()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
// Create a unique VM name
string newAzureVMName = Utilities.GetUniqueShortName("PSTestVM");
Console.WriteLine("VM Name: {0}", newAzureVMName);
// Create a unique Service Name
vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
Console.WriteLine("Service Name: {0}", serviceName);
if (string.IsNullOrEmpty(imageName))
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
// starting the test.
var azureVMConfigInfo = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small.ToString(), imageName); // parameters for New-AzureVMConfig (-Name -InstanceSize -ImageName)
var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); // parameters for Add-AzureProvisioningConfig (-Windows -Password)
var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
PersistentVM persistentVM = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo); // New-AzureVMConfig & Add-AzureProvisioningConfig
PersistentVM[] VMs = { persistentVM };
vmPowershellCmdlets.NewAzureVM(serviceName, VMs); // New-AzureVM
Console.WriteLine("The VM is successfully created: {0}", persistentVM.RoleName);
PersistentVMRoleContext vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName);
Assert.AreEqual(vmRoleCtxt.Name, persistentVM.RoleName, true);
vmPowershellCmdlets.StopAzureVM(newAzureVMName, serviceName, true); // Stop-AzureVM
for (int i = 0; i < 3; i++)
{
vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName);
if (vmRoleCtxt.InstanceStatus == "StoppedVM")
{
break;
}
Console.WriteLine("The status of the VM {0} : {1}", persistentVM.RoleName, vmRoleCtxt.InstanceStatus);
Thread.Sleep(120000);
}
Assert.AreEqual(vmRoleCtxt.InstanceStatus, "StoppedVM", true);
// Save-AzureVMImage
vmPowershellCmdlets.SaveAzureVMImage(serviceName, newAzureVMName, newAzureVMName);
// Verify VM image.
var image = vmPowershellCmdlets.GetAzureVMImage(newAzureVMName)[0];
Assert.AreEqual("Windows", image.OS, "OS is not matching!");
Assert.AreEqual(newAzureVMName, image.ImageName, "Names are not matching!");
// Verify that the VM is removed
Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName));
// Cleanup the registered image
vmPowershellCmdlets.RemoveAzureVMImage(newAzureVMName, true);
pass = true;
}
示例14: AddAzureProvisioningConfig
public PersistentVM AddAzureProvisioningConfig(AzureProvisioningConfigInfo provConfig)
{
AddAzureProvisioningConfigCmdletInfo addAzureProvisioningConfigCmdletInfog = new AddAzureProvisioningConfigCmdletInfo(provConfig);
WindowsAzurePowershellCmdlet addAzureProvisioningConfigCmdlet = new WindowsAzurePowershellCmdlet(addAzureProvisioningConfigCmdletInfog);
Collection<PSObject> result = addAzureProvisioningConfigCmdlet.Run();
if (result.Count == 1)
{
return (PersistentVM)result[0].BaseObject;
}
return null;
}
示例15: RemoveAndCreateDeploymentWithReservedIP
public void RemoveAndCreateDeploymentWithReservedIP()
{
try
{
vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null);
string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
if (string.IsNullOrEmpty(imageName))
{
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
}
AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.Small, imageName);
AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
AzureEndPointConfigInfo azureEndPointConfigInfo =
new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80,
80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);
PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);
// Create a new deployment
vmPowershellCmdlets.NewAzureVM(svcNameLoc, new [] {persistentVM1}, locationName);
// Reserve the ip of the deployment
vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName1, svcNameLoc, svcNameLoc, rsvIPLabel);
// Get the deployment and verify
var deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameLoc);
Utilities.PrintContext(deploymentReturned);
// Verify the reserved ip
var reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
deploymentReturned.ServiceName);
// Remove the VMs and verify
Console.WriteLine("\nRemoving VMs...\n");
vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, svcNameLoc);
// Verify the reserved ip
reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1);
// Remove the service
Console.WriteLine("\nRemoving the service...\n");
vmPowershellCmdlets.RemoveAzureService(svcNameLoc);
// Verify the reserved ip
reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1);
// Re-deploy the VM and verify
vmPowershellCmdlets.NewAzureVMWithReservedIP(svcNameAG, new[] { persistentVM2 },rsvIpName1, affName1);
// Get the deployment and verify
deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameAG);
Utilities.PrintContext(deploymentReturned);
// Verify the reserved ip
reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
deploymentReturned.ServiceName);
// Remove the VM
vmPowershellCmdlets.RemoveAzureService(svcNameAG);
// Remove the reserved IP and verify
vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1);
Utilities.VerifyFailure(
() => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException);
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}