当前位置: 首页>>代码示例>>C#>>正文


C# CloudServersProvider.DeleteServer方法代码示例

本文整理汇总了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);
        }
开发者ID:nick-o,项目名称:openstack.net,代码行数:12,代码来源:UserServerTests.cs

示例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();
    }
开发者ID:rackspace,项目名称:rackspace-net-sdk,代码行数:46,代码来源:AssignPublicIPSamples.cs

示例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);
        }
开发者ID:jasonmitschke,项目名称:openstack.net,代码行数:13,代码来源:CloudNetworksTests.cs

示例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);
 }
开发者ID:jasonmitschke,项目名称:openstack.net,代码行数:6,代码来源:CloudNetworksTests.cs

示例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);
            }
        }
开发者ID:nick-o,项目名称:openstack.net,代码行数:18,代码来源:UserComputeTests.cs

示例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);
        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:7,代码来源:CloudServersTests.cs

示例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 ();
        }
开发者ID:DonSchenck,项目名称:api-site,代码行数:98,代码来源:getting_started.cs


注:本文中的CloudServersProvider.DeleteServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。