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


Python data_utils.parse_image_id函数代码示例

本文整理汇总了Python中tempest.common.utils.data_utils.parse_image_id函数的典型用法代码示例。如果您正苦于以下问题:Python parse_image_id函数的具体用法?Python parse_image_id怎么用?Python parse_image_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: setUpClass

    def setUpClass(cls):
        super(ListImageFiltersTest, cls).setUpClass()
        cls.client = cls.images_client

        name = rand_name("server")
        resp, cls.server1 = cls.servers_client.create_server(name, cls.image_ref, cls.flavor_ref)
        name = rand_name("server")
        resp, cls.server2 = cls.servers_client.create_server(name, cls.image_ref, cls.flavor_ref)
        cls.servers_client.wait_for_server_status(cls.server1["id"], "ACTIVE")
        cls.servers_client.wait_for_server_status(cls.server2["id"], "ACTIVE")

        # Create images to be used in the filter tests
        image1_name = rand_name("image")
        resp, body = cls.client.create_image(cls.server1["id"], image1_name)
        cls.image1_id = parse_image_id(resp["location"])
        cls.client.wait_for_image_resp_code(cls.image1_id, 200)
        cls.client.wait_for_image_status(cls.image1_id, "ACTIVE")
        resp, cls.image1 = cls.client.get_image(cls.image1_id)

        # Servers have a hidden property for when they are being imaged
        # Performing back-to-back create image calls on a single
        # server will sometimes cause failures
        image3_name = rand_name("image")
        resp, body = cls.client.create_image(cls.server2["id"], image3_name)
        cls.image3_id = parse_image_id(resp["location"])
        cls.client.wait_for_image_resp_code(cls.image3_id, 200)
        cls.client.wait_for_image_status(cls.image3_id, "ACTIVE")
        resp, cls.image3 = cls.client.get_image(cls.image3_id)

        image2_name = rand_name("image")
        resp, body = cls.client.create_image(cls.server1["id"], image2_name)
        cls.image2_id = parse_image_id(resp["location"])
        cls.client.wait_for_image_resp_code(cls.image2_id, 200)
        cls.client.wait_for_image_status(cls.image2_id, "ACTIVE")
        resp, cls.image2 = cls.client.get_image(cls.image2_id)
开发者ID:eslng,项目名称:tempest,代码行数:35,代码来源:test_list_image_filters.py

示例2: setUpClass

    def setUpClass(cls):
        super(ListImageFiltersTestJSON, cls).setUpClass()
        cls.client = cls.images_client

        resp, cls.server1 = cls.create_server()
        resp, cls.server2 = cls.create_server(wait_until='ACTIVE')
        # NOTE(sdague) this is faster than doing the sync wait_util on both
        cls.servers_client.wait_for_server_status(cls.server1['id'], 'ACTIVE')

        # Create images to be used in the filter tests
        image1_name = rand_name('image')
        resp, body = cls.client.create_image(cls.server1['id'], image1_name)
        cls.image1_id = parse_image_id(resp['location'])
        cls.client.wait_for_image_resp_code(cls.image1_id, 200)
        cls.client.wait_for_image_status(cls.image1_id, 'ACTIVE')
        resp, cls.image1 = cls.client.get_image(cls.image1_id)

        # Servers have a hidden property for when they are being imaged
        # Performing back-to-back create image calls on a single
        # server will sometimes cause failures
        image3_name = rand_name('image')
        resp, body = cls.client.create_image(cls.server2['id'], image3_name)
        cls.image3_id = parse_image_id(resp['location'])
        cls.client.wait_for_image_resp_code(cls.image3_id, 200)
        cls.client.wait_for_image_status(cls.image3_id, 'ACTIVE')
        resp, cls.image3 = cls.client.get_image(cls.image3_id)

        image2_name = rand_name('image')
        resp, body = cls.client.create_image(cls.server1['id'], image2_name)
        cls.image2_id = parse_image_id(resp['location'])
        cls.client.wait_for_image_resp_code(cls.image2_id, 200)
        cls.client.wait_for_image_status(cls.image2_id, 'ACTIVE')
        resp, cls.image2 = cls.client.get_image(cls.image2_id)
开发者ID:rushiagr,项目名称:tempest,代码行数:33,代码来源:test_list_image_filters.py

示例3: test_create_backup

    def test_create_backup(self):
        # Positive test:create backup successfully and rotate backups correctly
        # create the first and the second backup
        backup1 = data_utils.rand_name("backup-1")
        resp, _ = self.servers_client.create_backup(self.server_id, "daily", 2, backup1)
        oldest_backup_exist = True

        # the oldest one should be deleted automatically in this test
        def _clean_oldest_backup(oldest_backup):
            if oldest_backup_exist:
                self.images_client.delete_image(oldest_backup)

        image1_id = data_utils.parse_image_id(resp["location"])
        self.addCleanup(_clean_oldest_backup, image1_id)
        self.assertEqual(202, resp.status)
        self.images_client.wait_for_image_status(image1_id, "active")

        backup2 = data_utils.rand_name("backup-2")
        self.servers_client.wait_for_server_status(self.server_id, "ACTIVE")
        resp, _ = self.servers_client.create_backup(self.server_id, "daily", 2, backup2)
        image2_id = data_utils.parse_image_id(resp["location"])
        self.addCleanup(self.images_client.delete_image, image2_id)
        self.assertEqual(202, resp.status)
        self.images_client.wait_for_image_status(image2_id, "active")

        # verify they have been created
        properties = {"image_type": "backup", "backup_type": "daily", "instance_uuid": self.server_id}
        resp, image_list = self.images_client.image_list_detail(properties, sort_key="created_at", sort_dir="asc")
        self.assertEqual(200, resp.status)
        self.assertEqual(2, len(image_list))
        self.assertEqual((backup1, backup2), (image_list[0]["name"], image_list[1]["name"]))

        # create the third one, due to the rotation is 2,
        # the first one will be deleted
        backup3 = data_utils.rand_name("backup-3")
        self.servers_client.wait_for_server_status(self.server_id, "ACTIVE")
        resp, _ = self.servers_client.create_backup(self.server_id, "daily", 2, backup3)
        image3_id = data_utils.parse_image_id(resp["location"])
        self.addCleanup(self.images_client.delete_image, image3_id)
        self.assertEqual(202, resp.status)
        # the first back up should be deleted
        self.images_client.wait_for_resource_deletion(image1_id)
        oldest_backup_exist = False
        resp, image_list = self.images_client.image_list_detail(properties, sort_key="created_at", sort_dir="asc")
        self.assertEqual(200, resp.status)
        self.assertEqual(
            2,
            len(image_list),
            "Unexpected number of images for "
            "v3:test_create_backup; was the oldest backup not "
            "yet deleted? Image list: %s" % [image["name"] for image in image_list],
        )
        self.assertEqual((backup2, backup3), (image_list[0]["name"], image_list[1]["name"]))
开发者ID:ntt-sic,项目名称:tempest,代码行数:53,代码来源:test_server_actions.py

示例4: test_create_delete_image

    def test_create_delete_image(self):

        # Create a new image
        name = data_utils.rand_name('image')
        meta = {'image_type': 'test'}
        body = self.client.create_image(self.server_id, name=name,
                                        metadata=meta)
        image_id = data_utils.parse_image_id(body.response['location'])
        waiters.wait_for_image_status(self.client, image_id, 'ACTIVE')

        # Verify the image was created correctly
        image = self.client.show_image(image_id)['image']
        self.assertEqual(name, image['name'])
        self.assertEqual('test', image['metadata']['image_type'])

        original_image = self.client.show_image(self.image_ref)['image']

        # Verify minRAM is the same as the original image
        self.assertEqual(image['minRam'], original_image['minRam'])

        # Verify minDisk is the same as the original image or the flavor size
        flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)
        self.assertIn(str(image['minDisk']),
                      (str(original_image['minDisk']), str(flavor_disk_size)))

        # Verify the image was deleted correctly
        self.client.delete_image(image_id)
        self.client.wait_for_resource_deletion(image_id)
开发者ID:flyingfish007,项目名称:tempest,代码行数:28,代码来源:test_images_oneserver.py

示例5: __create_image__

 def __create_image__(self, server_id, name, meta=None):
     resp, body = self.client.create_image(server_id, name, meta)
     image_id = parse_image_id(resp['location'])
     self.client.wait_for_image_resp_code(image_id, 200)
     self.client.wait_for_image_status(image_id, 'ACTIVE')
     self.image_ids.append(image_id)
     return resp, body
开发者ID:davidtao1983,项目名称:tempest,代码行数:7,代码来源:test_images.py

示例6: test_create_delete_image

    def test_create_delete_image(self):
        """An image for the provided server should be created"""
        server_name = rand_name('server')
        resp, server = self.servers_client.create_server(server_name,
                                                         self.image_ref,
                                                         self.flavor_ref)
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

        # Create a new image
        name = rand_name('image')
        meta = {'image_type': 'test'}
        resp, body = self.client.create_image(server['id'], name, meta)
        image_id = parse_image_id(resp['location'])
        self.client.wait_for_image_resp_code(image_id, 200)
        self.client.wait_for_image_status(image_id, 'ACTIVE')

        # Verify the image was created correctly
        resp, image = self.client.get_image(image_id)
        self.assertEqual(name, image['name'])
        self.assertEqual('test', image['metadata']['image_type'])

        # Verify minRAM and minDisk values are the same as the original image
        resp, original_image = self.client.get_image(self.image_ref)
        self.assertEqual(original_image['minRam'], image['minRam'])
        self.assertEqual(original_image['minDisk'], image['minDisk'])

        # Teardown
        self.client.delete_image(image['id'])
        self.servers_client.delete_server(server['id'])
开发者ID:aristanetworks,项目名称:arista-ovs-testing,代码行数:29,代码来源:test_images.py

示例7: test_create_image_from_deleted_server

    def test_create_image_from_deleted_server(self):
        # An image should not be created if the server instance is removed
        server_name = rand_name('server')
        resp, server = self.servers_client.create_server(server_name,
                                                         self.image_ref,
                                                         self.flavor_ref)
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

        # Delete server before trying to create server
        self.servers_client.delete_server(server['id'])

        try:
            # Create a new image after server is deleted
            name = rand_name('image')
            meta = {'image_type': 'test'}
            resp, body = self.client.create_image(server['id'], name, meta)

        except Exception:
            pass

        else:
            image_id = parse_image_id(resp['location'])
            self.client.wait_for_image_resp_code(image_id, 200)
            self.client.wait_for_image_status(image_id, 'ACTIVE')
            self.client.delete_image(image_id)
            self.fail("Should not create snapshot from deleted instance!")
开发者ID:dani4571,项目名称:tempest,代码行数:26,代码来源:test_images.py

示例8: test_create_delete_image

    def test_create_delete_image(self):

        # Create a new image
        name = rand_name('image')
        meta = {'image_type': 'test'}
        resp, body = self.client.create_image(self.server['id'], name, meta)
        self.assertEqual(202, resp.status)
        image_id = parse_image_id(resp['location'])
        self.client.wait_for_image_status(image_id, 'ACTIVE')

        # Verify the image was created correctly
        resp, image = self.client.get_image(image_id)
        self.assertEqual(name, image['name'])
        self.assertEqual('test', image['metadata']['image_type'])

        resp, original_image = self.client.get_image(self.image_ref)

        # Verify minRAM is the same as the original image
        self.assertEqual(image['minRam'], original_image['minRam'])

        # Verify minDisk is the same as the original image or the flavor size
        flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)
        self.assertIn(str(image['minDisk']),
                      (str(original_image['minDisk']), str(flavor_disk_size)))

        # Verify the image was deleted correctly
        resp, body = self.client.delete_image(image_id)
        self.assertEqual('204', resp['status'])
        self.client.wait_for_resource_deletion(image_id)
开发者ID:notmyname,项目名称:tempest,代码行数:29,代码来源:test_images_oneserver.py

示例9: create_image_from_server

    def create_image_from_server(cls, server_id, **kwargs):
        """Wrapper utility that returns an image created from the server."""
        name = data_utils.rand_name(cls.__name__ + "-image")
        if 'name' in kwargs:
            name = kwargs.pop('name')

        if cls._api_version == 2:
            resp, image = cls.images_client.create_image(server_id, name)
        elif cls._api_version == 3:
            resp, image = cls.servers_client.create_image(server_id, name)
        image_id = data_utils.parse_image_id(resp['location'])
        cls.images.append(image_id)

        if 'wait_until' in kwargs:
            cls.images_client.wait_for_image_status(image_id,
                                                    kwargs['wait_until'])
            if cls._api_version == 2:
                resp, image = cls.images_client.get_image(image_id)
            elif cls._api_version == 3:
                resp, image = cls.images_client.get_image_meta(image_id)

            if kwargs['wait_until'] == 'ACTIVE':
                if kwargs.get('wait_for_server', True):
                    cls.servers_client.wait_for_server_status(server_id,
                                                              'ACTIVE')
        return resp, image
开发者ID:armando-migliaccio,项目名称:tempest-1,代码行数:26,代码来源:base.py

示例10: test_create_delete_image

    def test_create_delete_image(self):

        # Create a new image
        name = data_utils.rand_name("image")
        meta = {"image_type": "test"}
        body = self.client.create_image(self.server_id, name, meta)
        image_id = data_utils.parse_image_id(body.response["location"])
        waiters.wait_for_image_status(self.client, image_id, "ACTIVE")

        # Verify the image was created correctly
        image = self.client.show_image(image_id)
        self.assertEqual(name, image["name"])
        self.assertEqual("test", image["metadata"]["image_type"])

        original_image = self.client.show_image(self.image_ref)

        # Verify minRAM is the same as the original image
        self.assertEqual(image["minRam"], original_image["minRam"])

        # Verify minDisk is the same as the original image or the flavor size
        flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)
        self.assertIn(str(image["minDisk"]), (str(original_image["minDisk"]), str(flavor_disk_size)))

        # Verify the image was deleted correctly
        self.client.delete_image(image_id)
        self.client.wait_for_resource_deletion(image_id)
开发者ID:SivagnanamCiena,项目名称:tempest,代码行数:26,代码来源:test_images_oneserver.py

示例11: test_create_delete_image

    def test_create_delete_image(self):

        # Create a new image
        name = rand_name('image')
        meta = {'image_type': 'test'}
        resp, body = self.client.create_image(self.server['id'], name, meta)
        self.assertEqual(202, resp.status)
        image_id = parse_image_id(resp['location'])
        self.client.wait_for_image_resp_code(image_id, 200)
        self.client.wait_for_image_status(image_id, 'ACTIVE')

        # Verify the image was created correctly
        resp, image = self.client.get_image(image_id)
        self.assertEqual(name, image['name'])
        self.assertEqual('test', image['metadata']['image_type'])

        # Verify minRAM and minDisk values are the same as the original image
        resp, original_image = self.client.get_image(self.image_ref)
        self.assertEqual(original_image['minRam'], image['minRam'])
        self.assertEqual(original_image['minDisk'], image['minDisk'])

        # Verify the image was deleted correctly
        resp, body = self.client.delete_image(image_id)
        self.assertEqual('204', resp['status'])
        self.client.wait_for_resource_deletion(image_id)
开发者ID:SinSiXX,项目名称:tempest,代码行数:25,代码来源:test_images_oneserver.py

示例12: setUpClass

    def setUpClass(cls):
        if not compute.MULTI_USER:
            msg = "Need >1 user"
            raise cls.skipException(msg)

        super(AuthorizationTest, cls).setUpClass()

        cls.client = cls.os.servers_client
        cls.images_client = cls.os.images_client
        cls.keypairs_client = cls.os.keypairs_client
        cls.security_client = cls.os.security_groups_client

        if cls.config.compute.allow_tenant_isolation:
            creds = cls._get_isolated_creds()
            username, tenant_name, password = creds
            cls.alt_manager = clients.Manager(username=username,
                                              password=password,
                                              tenant_name=tenant_name)
        else:
            # Use the alt_XXX credentials in the config file
            cls.alt_manager = clients.AltManager()

        cls.alt_client = cls.alt_manager.servers_client
        cls.alt_images_client = cls.alt_manager.images_client
        cls.alt_keypairs_client = cls.alt_manager.keypairs_client
        cls.alt_security_client = cls.alt_manager.security_groups_client

        cls.alt_security_client._set_auth()
        name = rand_name('server')
        resp, server = cls.client.create_server(name, cls.image_ref,
                                                cls.flavor_ref)
        cls.client.wait_for_server_status(server['id'], 'ACTIVE')
        resp, cls.server = cls.client.get_server(server['id'])

        name = rand_name('image')
        resp, body = cls.client.create_image(server['id'], name)
        image_id = parse_image_id(resp['location'])
        cls.images_client.wait_for_image_resp_code(image_id, 200)
        cls.images_client.wait_for_image_status(image_id, 'ACTIVE')
        resp, cls.image = cls.images_client.get_image(image_id)

        cls.keypairname = rand_name('keypair')
        resp, keypair = \
            cls.keypairs_client.create_keypair(cls.keypairname)

        name = rand_name('security')
        description = rand_name('description')
        resp, cls.security_group = \
        cls.security_client.create_security_group(name, description)

        parent_group_id = cls.security_group['id']
        ip_protocol = 'tcp'
        from_port = 22
        to_port = 22
        resp, cls.rule =\
        cls.security_client.create_security_group_rule(
                                        parent_group_id,
                                        ip_protocol, from_port,
                                        to_port)
开发者ID:dani4571,项目名称:tempest,代码行数:59,代码来源:test_authorization.py

示例13: test_create_image_specify_multibyte_character_image_name

 def test_create_image_specify_multibyte_character_image_name(self):
     # prefix character is:
     # http://www.fileformat.info/info/unicode/char/1F4A9/index.htm
     utf8_name = data_utils.rand_name(u'\xF0\x9F\x92\xA9')
     resp, body = self.client.create_image(self.server_id, utf8_name)
     image_id = data_utils.parse_image_id(resp['location'])
     self.addCleanup(self.client.delete_image, image_id)
     self.assertEqual('202', resp['status'])
开发者ID:LIS,项目名称:LIS-Tempest,代码行数:8,代码来源:test_images_oneserver.py

示例14: setUpClass

    def setUpClass(cls):
        if not compute.MULTI_USER:
            msg = "Need >1 user"
            raise SkipTest(msg)

        super(AuthorizationTest, cls).setUpClass()

        cls.client = cls.os.servers_client
        cls.images_client = cls.os.images_client
        cls.keypairs_client = cls.os.keypairs_client
        cls.security_client = cls.os.security_groups_client
        cls.console_outputs_client = cls.os.console_outputs_client

        if cls.config.compute.allow_tenant_isolation:
            creds = cls._get_isolated_creds()
            username, tenant_name, password = creds
            cls.alt_manager = openstack.Manager(username=username, password=password, tenant_name=tenant_name)
        else:
            # Use the alt_XXX credentials in the config file
            cls.alt_manager = openstack.AltManager()

        cls.alt_client = cls.alt_manager.servers_client
        cls.alt_images_client = cls.alt_manager.images_client
        cls.alt_keypairs_client = cls.alt_manager.keypairs_client
        cls.alt_security_client = cls.alt_manager.security_groups_client
        cls.alt_console_outputs_client = cls.alt_manager.console_outputs_client

        cls.alt_security_client._set_auth()
        name = rand_name("server")
        resp, server = cls.client.create_server(name, cls.image_ref, cls.flavor_ref)
        cls.client.wait_for_server_status(server["id"], "ACTIVE")
        resp, cls.server = cls.client.get_server(server["id"])

        name = rand_name("image")
        resp, body = cls.client.create_image(server["id"], name)
        image_id = parse_image_id(resp["location"])
        cls.images_client.wait_for_image_resp_code(image_id, 200)
        cls.images_client.wait_for_image_status(image_id, "ACTIVE")
        resp, cls.image = cls.images_client.get_image(image_id)

        cls.keypairname = rand_name("keypair")
        resp, keypair = cls.keypairs_client.create_keypair(cls.keypairname)

        name = rand_name("security")
        description = rand_name("description")
        resp, cls.security_group = cls.security_client.create_security_group(name, description)

        parent_group_id = cls.security_group["id"]
        ip_protocol = "tcp"
        from_port = 22
        to_port = 22
        resp, cls.rule = cls.security_client.create_security_group_rule(
            parent_group_id, ip_protocol, from_port, to_port
        )
开发者ID:eghobo,项目名称:tempest,代码行数:54,代码来源:test_authorization.py

示例15: test_create_image_specify_multibyte_character_image_name

    def test_create_image_specify_multibyte_character_image_name(self):
        # prefix character is:
        # http://www.fileformat.info/info/unicode/char/1F4A9/index.htm

        # We use a string with 3 byte utf-8 character due to bug
        # #1370954 in glance which will 500 if mysql is used as the
        # backend and it attempts to store a 4 byte utf-8 character
        utf8_name = data_utils.rand_name('\xe2\x82\xa1')
        body = self.client.create_image(self.server_id, name=utf8_name)
        image_id = data_utils.parse_image_id(body.response['location'])
        self.addCleanup(self.client.delete_image, image_id)
开发者ID:flyingfish007,项目名称:tempest,代码行数:11,代码来源:test_images_oneserver.py


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