本文整理汇总了C#中CloudServersProvider.WaitForServerActive方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServersProvider.WaitForServerActive方法的具体用法?C# CloudServersProvider.WaitForServerActive怎么用?C# CloudServersProvider.WaitForServerActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CloudServersProvider
的用法示例。
在下文中一共展示了CloudServersProvider.WaitForServerActive方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClassInitialize
public static void ClassInitialize(TestContext testContext)
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
string serverName = UserComputeTests.UnitTestServerPrefix + Path.GetRandomFileName();
Flavor flavor = UserComputeTests.ListAllFlavorsWithDetails(provider).OrderBy(i => i.RAMInMB).ThenBy(i => i.DiskSizeInGB).FirstOrDefault();
if (flavor == null)
Assert.Inconclusive("Couldn't find a flavor to use for the test server.");
SimpleServerImage[] images = UserComputeTests.ListAllImages(provider).ToArray();
SimpleServerImage image = images.FirstOrDefault(i => i.Name.IndexOf("CentOS 6.0", StringComparison.OrdinalIgnoreCase) >= 0);
if (image == null)
Assert.Inconclusive("Couldn't find the CentOS 6.0 image to use for the test server.");
Stopwatch timer = Stopwatch.StartNew();
Console.Write("Creating server for image {0}...", image.Name);
NewServer server = provider.CreateServer(serverName, image.Id, flavor.Id);
Assert.IsNotNull(server);
Assert.IsFalse(string.IsNullOrEmpty(server.Id));
_password = server.AdminPassword;
_server = provider.WaitForServerActive(server.Id);
Assert.IsNotNull(_server);
Assert.AreEqual(server.Id, _server.Id);
Assert.AreEqual(ServerState.Active, _server.Status);
Console.WriteLine("done. {0} seconds", timer.Elapsed.TotalSeconds);
}
示例2: Should_Wait_Until_Server_Becomes_Active_Or_A_Maximum_Of_10_Minutes
public void Should_Wait_Until_Server_Becomes_Active_Or_A_Maximum_Of_10_Minutes()
{
var provider = new CloudServersProvider(_testIdentity);
var serverDetails = provider.WaitForServerActive(_testServer.Id);
Assert.IsNotNull(serverDetails);
Assert.AreEqual("ACTIVE", serverDetails.Status);
}
示例3: Run
public async Task Run(string username, string apiKey, string region)
{
// Configure authentication
var identity = new CloudIdentity
{
Username = username,
APIKey = apiKey
};
var identityService = new CloudIdentityProvider(identity);
var result = identityService.Authenticate();
var serverService = new CloudServersProvider(identity, region, null, null);
var rackConnectService = new RackConnectService(identityService, region);
// Create a cloud server on your hybrid network
Console.WriteLine($"Looking up your RackConnect network in {region}...");
var networks = await rackConnectService.ListNetworksAsync();
var network = networks.FirstOrDefault();
if (network == null)
throw new Exception($"You do not have a Hybrid Cloud / RackConnect network configured in the {region} which is required to run this sample.");
Console.WriteLine("Creating sample cloud server... ");
// Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
const string ubuntuImageId = "09de0a66-3156-48b4-90a5-1cf25a905207";
// 512MB Standard Instance
const string standardFlavorId = "2";
var requestedServer = serverService.CreateServer("sample", ubuntuImageId, standardFlavorId,
networks: new string[] {network.Id});
serverService.WaitForServerActive(requestedServer.Id);
Console.WriteLine("Allocating a public IP address...");
var ip = await rackConnectService.CreatePublicIPAsync(
new PublicIPCreateDefinition {ShouldRetain = true});
await ip.WaitUntilActiveAsync();
Console.WriteLine($"Acquired {ip.PublicIPv4Address}!");
Console.WriteLine("Assigning the public IP to the sample cloud server...");
await ip.AssignAsync(requestedServer.Id);
await ip.WaitUntilActiveAsync();
Console.WriteLine("Deleting sample cloud server...");
serverService.DeleteServer(requestedServer.Id);
Console.WriteLine("Deallocating the public IP address...");
await ip.DeleteAsync();
}
示例4: Should_Create_A_Server_With_New_Network_And_Wait_For_Active
public void Should_Create_A_Server_With_New_Network_And_Wait_For_Active()
{
var provider = new CloudServersProvider(_testIdentity);
var networks = new List<Guid>() { new Guid(_created_network_id2) };
var testServer = provider.CreateServer("net-sdk-test-server", "d531a2dd-7ae9-4407-bb5a-e5ea03303d98", "2", networks: networks);
Assert.IsNotNull(testServer.Id);
_created_server_id = testServer.Id;
var serverDetails = provider.WaitForServerActive(_created_server_id);
Assert.AreEqual("ACTIVE", serverDetails.Status);
}
示例5: Should_Wait_For_Server_To_Go_Into_Active_Status_After_UnRescue
public void Should_Wait_For_Server_To_Go_Into_Active_Status_After_UnRescue()
{
Assert.IsTrue(_unRescueSuccess);
var provider = new CloudServersProvider(_testIdentity);
var details = provider.WaitForServerActive(_testServer.Id);
Assert.IsNotNull(details);
}
示例6: Should_Wait_For_Server_To_Be_In_Active_State_After_Reverting_Resize
public void Should_Wait_For_Server_To_Be_In_Active_State_After_Reverting_Resize()
{
Assert.IsTrue(_revertResizeSuccess);
var provider = new CloudServersProvider(_testIdentity);
var details = provider.WaitForServerActive(_testServer.Id);
Assert.IsNotNull(details);
}
示例7: Should_Wait_For_Server_To_Go_Into_Active_Status_After_Rebuild
public void Should_Wait_For_Server_To_Go_Into_Active_Status_After_Rebuild()
{
Assert.IsNotNull(_rebuildServer);
var provider = new CloudServersProvider(_testIdentity);
var details = provider.WaitForServerActive(_testServer.Id);
Assert.IsNotNull(details);
}
示例8: TestRevertServerResize
public void TestRevertServerResize()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
string serverName = UserComputeTests.UnitTestServerPrefix + Path.GetRandomFileName();
Flavor flavor = UserComputeTests.ListAllFlavorsWithDetails(provider).OrderBy(i => i.RAMInMB).ThenBy(i => i.DiskSizeInGB).FirstOrDefault(i => !i.Id.Equals(_server.Flavor.Id, StringComparison.OrdinalIgnoreCase));
if (flavor == null)
Assert.Inconclusive("Couldn't find a flavor to use for the test server.");
bool resized = provider.ResizeServer(_server.Id, serverName, flavor.Id);
Assert.IsTrue(resized);
Server resizedServer = provider.WaitForServerState(_server.Id, ServerState.VerifyResize, new[] { ServerState.Error, ServerState.Unknown, ServerState.Suspended });
Assert.AreEqual(ServerState.VerifyResize, resizedServer.Status);
_server = resizedServer;
bool reverted = provider.RevertServerResize(resizedServer.Id);
Assert.IsTrue(reverted);
Server revertedServer = provider.WaitForServerActive(_server.Id);
Assert.AreEqual(ServerState.Active, revertedServer.Status);
_server = revertedServer;
}
示例9: TestRebuildServer
public void TestRebuildServer()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
Flavor flavor = UserComputeTests.ListAllFlavorsWithDetails(provider).OrderBy(i => i.RAMInMB).ThenBy(i => i.DiskSizeInGB).FirstOrDefault();
if (flavor == null)
Assert.Inconclusive("Couldn't find a flavor to use for the test server.");
SimpleServerImage[] images = UserComputeTests.ListAllImages(provider).ToArray();
SimpleServerImage image = images.FirstOrDefault(i => i.Name.IndexOf("CentOS 6.0", StringComparison.OrdinalIgnoreCase) >= 0);
if (image == null)
Assert.Inconclusive("Couldn't find the CentOS 6.0 image to use for the test server.");
Server rebuilt = provider.RebuildServer(_server.Id, null, image.Id, flavor.Id, _password);
Assert.IsNotNull(rebuilt);
Server rebuiltServer = provider.WaitForServerActive(rebuilt.Id);
Assert.AreEqual(ServerState.Active, rebuiltServer.Status);
_server = rebuiltServer;
}
示例10: TestRescueServer
public void TestRescueServer()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
string rescueResult = provider.RescueServer(_server.Id);
Assert.IsFalse(string.IsNullOrEmpty(rescueResult));
Server rescueServer = provider.WaitForServerState(_server.Id, ServerState.Rescue, new[] { ServerState.Error });
Assert.AreEqual(ServerState.Rescue, rescueServer.Status);
bool unrescueResult = provider.UnRescueServer(_server.Id);
Assert.IsTrue(unrescueResult);
Server unrescueServer = provider.WaitForServerActive(_server.Id);
Assert.AreEqual(ServerState.Active, unrescueServer.Status);
}
示例11: TestSoftRebootServer
public void TestSoftRebootServer()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
bool rebootResult = provider.RebootServer(_server.Id, RebootType.Soft);
Assert.IsTrue(rebootResult);
Server rebootServer = provider.WaitForServerActive(_server.Id);
Assert.AreEqual(ServerState.Active, rebootServer.Status);
}
示例12: TestChangeAdministratorPassword
public void TestChangeAdministratorPassword()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
string password = Path.GetTempPath();
bool changePasswordResult = provider.ChangeAdministratorPassword(_server.Id, password);
Assert.IsTrue(changePasswordResult);
_password = password;
Server changePasswordServer = provider.WaitForServerActive(_server.Id);
Assert.AreEqual(ServerState.Active, changePasswordServer.Status);
}