本文整理汇总了C#中PersistentVMConfigInfo类的典型用法代码示例。如果您正苦于以下问题:C# PersistentVMConfigInfo类的具体用法?C# PersistentVMConfigInfo怎么用?C# PersistentVMConfigInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersistentVMConfigInfo类属于命名空间,在下文中一共展示了PersistentVMConfigInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DevTestProvisioning
public void DevTestProvisioning()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
//Find a Windows VM Image
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
//vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
//Specify a small Windows image, with username and pw
AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 80, 80, "Http");
PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, null, azureEndPointConfigInfo);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
//Add all the endpoints that are added by the Dev Test feature in Azure Tools
azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 443, 443, "Https");
azureEndPointConfigInfo.Vm = persistentVM1;
persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo);
azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 1433, 1433, "MSSQL");
azureEndPointConfigInfo.Vm = persistentVM1;
persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo);
azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 8172, 8172, "WebDeploy");
azureEndPointConfigInfo.Vm = persistentVM1;
persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo);
// Make a storage account named "devtestNNNNN"
string storageAcctName = "devtest" + new Random().Next(10000, 99999);
vmPowershellCmdlets.NewAzureStorageAccount(storageAcctName, locationName);
vmPowershellCmdlets.SetAzureSubscription(defaultAzureSubscription.SubscriptionName, storageAcctName);
// When making a new azure VM, you can't specify a location if you want to use the existing service
PersistentVM[] VMs = { persistentVM1 };
vmPowershellCmdlets.NewAzureVM(serviceName, VMs, locationName);
var svcDeployment = vmPowershellCmdlets.GetAzureDeployment(serviceName);
Assert.AreEqual(svcDeployment.ServiceName, serviceName);
var vmDeployment = vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName);
Assert.AreEqual(vmDeployment.InstanceName, newAzureVM1Name);
// Cleanup
vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName);
Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName));
//TODO: Is failing for me because of active containers
//Utilities.RetryActionUntilSuccess(() => vmPowershellCmdlets.RemoveAzureStorageAccount(storageAcctName), "in use", 10, 30);
ServiceManagementTest.SetDefaultStorage();
pass = true;
}
开发者ID:rmattsampson,项目名称:azure-sdk-tools,代码行数:51,代码来源:ScenarioTest.cs
示例2: 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;
}
}
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:75,代码来源:ReservedIPTest.cs
示例3: NewAzureVMDomainJoinTest
public void NewAzureVMDomainJoinTest()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
var newAzureVMName = Utilities.GetUniqueShortName(vmNamePrefix);
const string joinDomainStr = "www.microsoft.com";
const string domainStr = "microsoft.com";
const string domainUser = "pstestdomainuser";
const string domainPassword = "[email protected]";
try
{
if (string.IsNullOrEmpty(imageName))
{
imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] {"Windows"}, false);
}
vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
var azureVMConfigInfo = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small, imageName);
var azureProvisioningConfig = new AzureProvisioningConfigInfo("WindowsDomain", username, password,
joinDomainStr, domainStr, domainUser,
domainPassword);
var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null,
null);
PersistentVM persistentVM = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);
PersistentVM[] VMs = {persistentVM};
vmPowershellCmdlets.NewAzureVM(serviceName, VMs);
// Todo: Check the domain of the VM
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw;
}
}
开发者ID:rmattsampson,项目名称:azure-sdk-tools,代码行数:40,代码来源:ScenarioTest.cs
示例4: 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);
}
}
}
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:77,代码来源:StopAzureVMTest.cs
示例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);
}
}
}
开发者ID:nakidsworks,项目名称:azure-sdk-tools,代码行数:71,代码来源:StopAzureVMTest.cs
示例6: StopAzureVMsStayProvisionedTest
public void StopAzureVMsStayProvisionedTest()
{
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);
WaitForStartingState(svcName, vmName1);
WaitForStartingState(svcName, vmName2);
vmPowershellCmdlets.StopAzureVM("*", svcName, true, true);
WaitForStoppedState(svcName, vmName1);
WaitForStoppedState(svcName, vmName2);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedProvisionedState }));
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw;
}
finally
{
if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
{
vmPowershellCmdlets.RemoveAzureService(svcName);
}
}
}
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:48,代码来源:StopAzureVMTest.cs
示例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);
}
}
}
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:55,代码来源:StopAzureVMTest.cs
示例8: 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;
}
}
开发者ID:kenazk,项目名称:azure-sdk-tools,代码行数:48,代码来源:FunctionalTest.cs
示例9: 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;
}
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:38,代码来源:LBandEndPointACLsTest.cs
示例10: GetPersistentVM
internal PersistentVM GetPersistentVM(PersistentVMConfigInfo configInfo)
{
PersistentVM vm = null;
if (null != configInfo)
{
if (configInfo.VmConfig != null)
{
vm = NewAzureVMConfig(configInfo.VmConfig);
}
if (configInfo.ProvConfig != null)
{
configInfo.ProvConfig.Vm = vm;
vm = AddAzureProvisioningConfig(configInfo.ProvConfig);
}
if (configInfo.DiskConfig != null)
{
configInfo.DiskConfig.Vm = vm;
vm = AddAzureDataDisk(configInfo.DiskConfig);
}
if (configInfo.EndPointConfig != null)
{
configInfo.EndPointConfig.Vm = vm;
vm = AddAzureEndPoint(configInfo.EndPointConfig);
}
}
return vm;
}
开发者ID:huangpf,项目名称:azure-sdk-tools,代码行数:32,代码来源:ServiceManagementCmdletTestHelper.cs
示例11: 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;
}
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:57,代码来源:ScenarioTest.cs
示例12: 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;
}
}
开发者ID:nakidsworks,项目名称:azure-sdk-tools,代码行数:90,代码来源:ReservedIPTest.cs
示例13: 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);
}
}
}
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:95,代码来源:StopAzureVMTest.cs
示例14: StopAzureVMOnStoppedVMTest
public void StopAzureVMOnStoppedVMTest()
{
StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
try
{
// starting the test.
AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.Small, imageName);
AzureProvisioningConfigInfo azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
PersistentVM[] VMs = { persistentVM1 };
vmPowershellCmdlets.NewAzureVM(svcName, VMs);
Console.WriteLine("The VM is successfully created: {0}", vmName1);
WaitForStartingState(svcName, vmName1);
// Stop the VM with StayProvisioned
vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));
// Try to stop it again. Should not change the state.
vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));
try
{
// Try to stop without any option. Should fail with a warning message.
vmPowershellCmdlets.StopAzureVM(vmName1, svcName);
Assert.Fail();
}
catch (Exception e)
{
if (e is AssertFailedException)
{
throw;
}
else
{
Console.WriteLine(e.ToString());
}
}
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));
// Stop the VM with Force option. Should deallocate the VM.
vmPowershellCmdlets.StopAzureVM(vmName1, svcName, false, true);
Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
pass = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw;
}
finally
{
if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
{
vmPowershellCmdlets.RemoveAzureService(svcName);
}
}
}
开发者ID:nakidsworks,项目名称:azure-sdk-tools,代码行数:64,代码来源:StopAzureVMTest.cs
示例15: AdvancedProvisioning
|
请发表评论