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


C# CloudServersProvider.ListImages方法代码示例

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


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

示例1: Init

        public static void Init(TestContext context)
        {
            _testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);
            
            var provider = new CloudServersProvider(_testIdentity);

            _initImage = provider.ListImages(imageName: "CentOS 6.3").First();
            _initFlavor = provider.ListFlavors().OrderBy(f => f.Id).First();
        }
开发者ID:amitgandhinz,项目名称:openstack.net,代码行数:9,代码来源:CloudServersTests.cs

示例2: Init

        public static void Init(TestContext context)
        {
            _testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);
            
            var provider = new CloudServersProvider(_testIdentity);

            _initImage = provider.ListImages(imageName: "CentOS 6.3").First();
            _initFlavor = provider.ListFlavors().OrderBy(f => f.Id).First();

            var netProvider = new CloudNetworksProvider(_testIdentity);
            var networks = netProvider.ListNetworks();
            _testNetwork = networks.FirstOrDefault(n => !n.Label.Equals("public") && !n.Label.Equals("private"));
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:13,代码来源:CloudServersTests.cs

示例3: Should_Rebuild_Server

        public void Should_Rebuild_Server()
        {
            _preBuildDetails = _testServer.GetDetails();
            var provider = new CloudServersProvider(_testIdentity);
            var image = provider.ListImages().First(i => i.Name.Contains("CentOS") && i.Id != _preBuildDetails.Image.Id);
            var flavor = int.Parse(_preBuildDetails.Flavor.Id) + 1;

            _rebuildServerSuccess = _testServer.Rebuild(string.Format("{0}_REBUILD", _preBuildDetails.Name), image.Id, flavor.ToString(), _newTestServer.AdminPassword);

            Assert.IsTrue(_rebuildServerSuccess);
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:11,代码来源:CloudServersTests.cs

示例4: Should_Return_All_Images_When_Using_A_Limit_Greater_Than_What_Actually_Exists

        public void Should_Return_All_Images_When_Using_A_Limit_Greater_Than_What_Actually_Exists()
        {
            var provider = new CloudServersProvider(_testIdentity);
            var images = provider.ListImages(limit: _allImages.Count() * 2);

            Assert.IsTrue(images.Count() == _allImages.Count());
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:7,代码来源:CloudServersTests.cs

示例5: Should_Return_Exactly_Two_Images

        public void Should_Return_Exactly_Two_Images()
        {
            var provider = new CloudServersProvider(_testIdentity);
            var images = provider.ListImages(limit: 2);

            Assert.IsTrue(images.Count() == 2);
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:7,代码来源:CloudServersTests.cs

示例6: Should_Return_At_Least_One_Image_When_Searching_By_Valid_Change_Since_Date

        public void Should_Return_At_Least_One_Image_When_Searching_By_Valid_Change_Since_Date()
        {
            var validImage = _allImages.First();
            var provider = new CloudServersProvider(_testIdentity);
            var images = provider.ListImages(changesSince: validImage.Updated.AddSeconds(-1));

            Assert.IsTrue(images.Any());
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs

示例7: Should_Return_At_Least_One_Image_When_Searching_By_Valid_Status

        public void Should_Return_At_Least_One_Image_When_Searching_By_Valid_Status()
        {
            var validImage = _allImages.First();
            var provider = new CloudServersProvider(_testIdentity);
            var images = provider.ListImages(imageStatus: validImage.Status);

            Assert.IsTrue(images.Any());
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs

示例8: Should_Return_One_Image_When_Searching_By_Valid_Id

        public void Should_Return_One_Image_When_Searching_By_Valid_Id()
        {
            var validImage = _allImages.First(i => i.Server != null);
            var provider = new CloudServersProvider(_testIdentity);
            var images = provider.ListImages(server: validImage.Server.Id);

            Assert.IsTrue(images.Any());
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs

示例9: Should_Get_List_All_Images_Which_should_Equal_Base_And_Snapshot_Combined

        public void Should_Get_List_All_Images_Which_should_Equal_Base_And_Snapshot_Combined()
        {
            var provider = new CloudServersProvider(_testIdentity);
            var allImages = provider.ListImages(identity: _testIdentity);
            var baseImages = provider.ListImages(imageType: ImageType.Base);
            var snapImages = provider.ListImages(imageType: ImageType.Snapshot);

            Assert.IsTrue(allImages.Any());
            Assert.IsTrue(allImages.Count() == (baseImages.Count() + snapImages.Count()));
            foreach (var image in allImages)
            {
                Assert.IsTrue(baseImages.Any(i => i.Id.Equals(image.Id, StringComparison.OrdinalIgnoreCase)) ^ snapImages.Any(i => i.Id.Equals(image.Id, StringComparison.OrdinalIgnoreCase)));
            }
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:14,代码来源:CloudServersTests.cs

示例10: Should_Get_List_Of_Snapshot_Images

        public void Should_Get_List_Of_Snapshot_Images()
        {
            var provider = new CloudServersProvider(_testIdentity);
            var images = provider.ListImages(imageType: ImageType.Snapshot);

            Assert.IsTrue(images.Any());
        }
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:7,代码来源:CloudServersTests.cs

示例11: 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

示例12: Main

        static void Main(string[] args)
        {
            /* Login
             * List servers
             * select server to clone
             * create image of server
             * create server using image
             * delete image
             */

            Console.WriteLine();
            if (ParseArguments(args))
            {
                Console.WriteLine("Logging in...");

                if (Login())
                {
                    var cloudServers = new CloudServersProvider(auth);

                    Console.WriteLine("Listing servers...");

                    try
                    {
                        var servers = cloudServers.ListServers(status: ServerState.ACTIVE, limit: 9, region: ServerRegion).ToList();

                        if (servers.Count == 0)
                            throw new Exception("No active servers on account");

                        Console.WriteLine();

                        for (int i = 0; i < servers.Count(); i++)
                        {
                            Console.WriteLine(String.Format("{0,2} {1}", i+1, servers[i].Name));
                        }

                        Console.WriteLine();

                        var validSelection = false;
                        int index = -1;
                        do
                        {
                            Console.Write(String.Format("Select server to clone [1-{0}]:", Math.Min(9, servers.Count)));
                            var selection = Console.ReadLine();
                            if (Int32.TryParse(selection, out index))
                            {
                                index--;
                                validSelection = (index >= 0 && index < servers.Count);
                            }
                        } while (!validSelection);

                        var imageName = String.Format("clone{0}", DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss"));
                        Console.Write("Enter new server name:");
                        var serverName = Console.ReadLine();

                        // get detailed information of the selected server, this allows us to access the server's flavor ID
                        var server = cloudServers.GetDetails(servers[index].Id, ServerRegion);

                        Console.WriteLine("Creating image...");
                        if (cloudServers.CreateImage(servers[index].Id, imageName, region: ServerRegion))
                        {
                            SimpleServerImage image = null;
                            // find the image we just created so we can monitor the progress.
                            image = cloudServers.ListImages(server: servers[index].Id, region: ServerRegion).Where(result => result.Name == imageName).Single();
                            if (image != null)
                            {
                                try
                                {
                                    image.WaitForActive(progressUpdatedCallback: delegate(int p)
                                    {
                                        Console.SetCursorPosition(0, Console.CursorTop - 1);
                                        Console.WriteLine(String.Format("{0} {1}%", "Creating image...", p));
                                    });

                                    Console.WriteLine("Creating Server...");
                                    var newServer = cloudServers.CreateServer(serverName, image.Id, server.Flavor.Id, region: ServerRegion);

                                    Console.WriteLine(String.Format(" {0,-2} {1,-10} {2,-14} {3,-15} {4,-10} {5,-21}", "%", "Name", "Password", "IPv4", "Status", "Task"));
                                    Console.WriteLine();

                                    newServer.WaitForActive(progressUpdatedCallback: delegate(int p)
                                    {
                                        server = newServer.GetDetails();

                                        Console.SetCursorPosition(0, Console.CursorTop - 1);
                                        Console.WriteLine(String.Format("{0,-3} {1,-10} {2,-14} {3,-15} {4,-10} {5,-21}", p, server.Name, newServer.AdminPassword, server.AccessIPv4, server.VMState, server.TaskState));
                                    });

                                    // output the server details one last time so we capture the IPv4 address.
                                    server = newServer.GetDetails();
                                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                                    Console.WriteLine(String.Format("100 {0,-10} {1,-14} {2,-15} {3,-10} {4,-21}", server.Name, newServer.AdminPassword, server.AccessIPv4, server.VMState, server.TaskState));
                                }
                                finally
                                {
                                    Console.WriteLine("Cleaning up temporary image...");
                                    Console.WriteLine();
                                    if (image.Delete())
                                    {
                                        image.WaitForDelete(progressUpdatedCallback: delegate(int p)
                                        {
//.........这里部分代码省略.........
开发者ID:jonwalton,项目名称:cloud_code_samples,代码行数:101,代码来源:Program.cs


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