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


C# CloudServersProvider.GetFlavor方法代码示例

本文整理汇总了C#中CloudServersProvider.GetFlavor方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServersProvider.GetFlavor方法的具体用法?C# CloudServersProvider.GetFlavor怎么用?C# CloudServersProvider.GetFlavor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CloudServersProvider的用法示例。


在下文中一共展示了CloudServersProvider.GetFlavor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateServerNodeAsync

        private async Task<CloudServersServerNode> CreateServerNodeAsync(CloudServersProvider provider, Server server, FlavorDetails[] flavors, ServerImage[] images)
        {
            FlavorDetails flavor = flavors.FirstOrDefault(i => server.Flavor != null && string.Equals(server.Flavor.Id, i.Id, StringComparison.OrdinalIgnoreCase));
            try
            {
                if (flavor == null && server.Flavor != null)
                    flavor = await Task.Run(() => provider.GetFlavor(server.Flavor.Id));
            }
            catch (ResponseException)
            {
                // ignore
                flavor = null;
            }

            ServerImage image = images.FirstOrDefault(i => server.Image != null && string.Equals(server.Image.Id, i.Id, StringComparison.OrdinalIgnoreCase));
            try
            {
                if (image == null && server.Image != null)
                    image = await Task.Run(() => provider.GetImage(server.Image.Id));
            }
            catch (ResponseException)
            {
                // ignore
                image = null;
            }

            return new CloudServersServerNode(provider, server, flavor, image);
        }
开发者ID:rackerlabs,项目名称:rax-vsix,代码行数:28,代码来源:CloudServersEndpointNode.cs

示例2: TestGetFlavor

        public void TestGetFlavor()
        {
            IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
            IEnumerable<FlavorDetails> flavors = ListAllFlavorsWithDetails(provider);
            Assert.IsNotNull(flavors);
            if (!flavors.Any())
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any configured flavors.");

            foreach (FlavorDetails flavor in flavors)
            {
                Assert.IsNotNull(flavor);
                FlavorDetails details = provider.GetFlavor(flavor.Id);
                Assert.AreEqual(flavor.Disabled, details.Disabled);
                Assert.AreEqual(flavor.DiskSizeInGB, details.DiskSizeInGB);
                Assert.AreEqual(flavor.Id, details.Id);
                //Assert.AreEqual(flavor.Links, details.Links);
                Assert.AreEqual(flavor.Name, details.Name);
                Assert.AreEqual(flavor.RAMInMB, details.RAMInMB);
                Assert.AreEqual(flavor.VirtualCPUCount, details.VirtualCPUCount);
            }
        }
开发者ID:nick-o,项目名称:openstack.net,代码行数:21,代码来源:UserComputeTests.cs

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