本文整理汇总了C#中CloudServersProvider.DeleteServer方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServersProvider.DeleteServer方法的具体用法?C# CloudServersProvider.DeleteServer怎么用?C# CloudServersProvider.DeleteServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CloudServersProvider
的用法示例。
在下文中一共展示了CloudServersProvider.DeleteServer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClassCleanup
public static void ClassCleanup()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
Stopwatch timer = Stopwatch.StartNew();
Console.Write(" Deleting...");
bool deleted = provider.DeleteServer(_server.Id);
Assert.IsTrue(deleted);
provider.WaitForServerDeleted(_server.Id);
Console.Write("done. {0} seconds", timer.Elapsed.TotalSeconds);
}
示例2: 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();
}
示例3: CleanupServers
public void CleanupServers()
{
var provider = new CloudServersProvider(_testIdentity);
var srvs = provider.ListServers();
foreach (var svr in srvs.Where(s => s.Name == "net-sdk-test-server"))
provider.DeleteServer(svr.Id);
var networkProvider = new CloudNetworksProvider(_testIdentity);
var networks = networkProvider.ListNetworks();
foreach (var network in networks.Where(n => n.Label == "net-sdk-test-network" || n.Label == "net-sdk-test-network-for-server"))
networkProvider.DeleteNetwork(network.Id);
}
示例4: Should_Delete_Server_To_Free_Up_Network
public void Should_Delete_Server_To_Free_Up_Network()
{
var provider = new CloudServersProvider(_testIdentity);
provider.DeleteServer(_created_server_id);
provider.WaitForServerDeleted(_created_server_id);
}
示例5: CleanupTestServers
public void CleanupTestServers()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
IEnumerable<SimpleServer> servers = ListAllServers(provider);
foreach (SimpleServer server in servers)
{
if (string.IsNullOrEmpty(server.Name))
continue;
if (!server.Name.StartsWith(UnitTestServerPrefix))
continue;
Console.WriteLine("Deleting unit test server... {0} ({1})", server.Name, server.Id);
bool deleted = provider.DeleteServer(server.Id);
Assert.IsTrue(deleted);
provider.WaitForServerDeleted(server.Id);
}
}
示例6: Should_Mark_The_Server_For_Deletion_For_Server2
public void Should_Mark_The_Server_For_Deletion_For_Server2()
{
var provider = new CloudServersProvider(_testIdentity);
var result = provider.DeleteServer(_testServer2.Id);
Assert.IsTrue(result);
}
示例7: Main
public static void Main(string[] args)
{
// step-1
var username = "your_auth_username";
var password = "your_auth_password";
var project_name = "your_project_name";
var project_id = "your_project_id";
var auth_url = "http://controller:5000/v2.0";
var region = "your_region_name";
var networkid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
var identity = new CloudIdentityWithProject () {
Username = username,
Password = password,
ProjectId = new ProjectId(project_id),
ProjectName = project_name
};
var identityProvider = new OpenStackIdentityProvider (
new Uri (auth_url));
var conn = new CloudServersProvider (identity, identityProvider);
// step-2
var images = conn.ListImages (region: region);
foreach (var image in images) {
Console.WriteLine (string.Format(
"Image Id: {0} - Image Name: {1}",
image.Id,
image.Name));
}
// step-3
var flavors = conn.ListFlavors (region: region);
foreach (var flavor in flavors) {
Console.WriteLine (string.Format(
"Flavor Id: {0} - Flavor Name: {1}",
flavor.Id,
flavor.Name));
}
// step-4
var image_id = "97f55846-6ea5-4e9d-b437-bda97586bd0c";
var _image = conn.GetImage(image_id, region:region);
Console.WriteLine (string.Format(
"Image Id: {0} - Image Name: {1}",
_image.Id,
_image.Name));
// step-5
var flavor_id = "42";
var _flavor = conn.GetFlavor (flavor_id, region: region);
Console.WriteLine (string.Format(
"Flavor Id: {0} - Flavor Name: {1}",
_flavor.Id,
_flavor.Name));
// step-6
var instance_name = "testing";
var testing_instance = conn.CreateServer (instance_name,
_image.Id,
_flavor.Id,
region: region,
networks: new List<String> () { networkid });
Console.WriteLine (string.Format(
"Instance Id: {0} at {1}",
testing_instance.Id,
testing_instance.Links
));
// step-7
var instances = conn.ListServers(region:region);
foreach (var instance in instances) {
Console.WriteLine (string.Format(
"Instance Id: {0} at {1}",
testing_instance.Id,
testing_instance.Links));
}
// step-8
conn.DeleteServer(testing_instance.Id, region:region);
// step-9
// step-10
// step-11
// step-12
// step-13
// step-14
// step-15
Console.Read ();
}