Exemplo n.º 1
0
 def test_image_meta_key_get(self):
     # Get api sample of an image metadata key request.
     image_id = fake.get_valid_image_id()
     key = "kernel_id"
     response = self._do_get('images/%s/metadata/%s' % (image_id, key))
     subs = self._get_regexes()
     self._verify_response('image-meta-key-get', subs, response, 200)
Exemplo n.º 2
0
 def test_image_get(self):
     # Get api sample of one single image details request.
     image_id = fake.get_valid_image_id()
     response = self._do_get('images/%s' % image_id)
     subs = self._get_regexes()
     subs['image_id'] = image_id
     self._verify_response('image-get-resp', subs, response, 200)
Exemplo n.º 3
0
 def test_image_metadata_get(self):
     # Get api sample of an image metadata request.
     image_id = fake.get_valid_image_id()
     response = self._do_get('images/%s/metadata' % image_id)
     subs = self._get_regexes()
     subs['image_id'] = image_id
     self._verify_response('image-metadata-get-resp', subs, response, 200)
Exemplo n.º 4
0
 def test_image_metadata_get(self):
     # Get api sample of an image metadata request.
     image_id = fake.get_valid_image_id()
     response = self._do_get('images/%s/metadata' % image_id)
     subs = self._get_regexes()
     subs['image_id'] = image_id
     self._verify_response('image-metadata-get-resp', subs, response, 200)
    def _test_server_rebuild_preserve_ephemeral(self, value):
        uuid = self._post_server()
        image = fake.get_valid_image_id()
        subs = {
            'host': self._get_host(),
            'uuid': image,
            'name': 'foobar',
            'pass': '******',
            'hostid': '[a-f0-9]+',
            'preserve_ephemeral': str(value).lower(),
            'action': 'rebuild',
            'glance_host': self._get_glance_host(),
        }

        def fake_rebuild(self_,
                         context,
                         instance,
                         image_href,
                         admin_password,
                         files_to_inject=None,
                         **kwargs):
            self.assertEqual(kwargs['preserve_ephemeral'], value)

        self.stubs.Set(compute_api.API, 'rebuild', fake_rebuild)

        response = self._do_post('servers/%s/action' % uuid,
                                 'server-action-rebuild-preserve-ephemeral',
                                 subs)
        self.assertEqual(response.status_code, 202)
Exemplo n.º 6
0
 def test_image_metadata_post(self):
     # Get api sample to update metadata of an image metadata request.
     image_id = fake.get_valid_image_id()
     response = self._do_post('images/%s/metadata' % image_id,
                              'image-metadata-post-req', {})
     subs = self._get_regexes()
     self._verify_response('image-metadata-post-resp', subs, response, 200)
Exemplo n.º 7
0
 def test_image_meta_key_get(self):
     # Get api sample of an image metadata key request.
     image_id = fake.get_valid_image_id()
     key = "kernel_id"
     response = self._do_get('images/%s/metadata/%s' % (image_id, key))
     subs = self._get_regexes()
     self._verify_response('image-meta-key-get', subs, response, 200)
Exemplo n.º 8
0
 def test_image_get(self):
     # Get api sample of one single image details request.
     image_id = fake.get_valid_image_id()
     response = self._do_get('images/%s' % image_id)
     subs = self._get_regexes()
     subs['image_id'] = image_id
     self._verify_response('image-get-resp', subs, response, 200)
Exemplo n.º 9
0
 def test_image_meta_key_put(self):
     # Get api sample of image metadata key put request.
     image_id = fake.get_valid_image_id()
     key = "auto_disk_config"
     response = self._do_put('images/%s/metadata/%s' % (image_id, key),
                             'image-meta-key-put-req', {})
     subs = self._get_regexes()
     self._verify_response('image-meta-key-put-resp', subs, response, 200)
Exemplo n.º 10
0
 def test_image_metadata_put(self):
     # Get api sample of image metadata put request.
     image_id = fake.get_valid_image_id()
     response = self._do_put('%s/images/%s/metadata' %
                             (self.api.project_id, image_id),
                             'image-metadata-put-req', {})
     subs = self._get_regexes()
     self._verify_response('image-metadata-put-resp', subs, response, 200)
Exemplo n.º 11
0
 def test_image_metadata_post(self):
     # Get api sample to update metadata of an image metadata request.
     image_id = fake.get_valid_image_id()
     response = self._do_post(
             'images/%s/metadata' % image_id,
             'image-metadata-post-req', {})
     subs = self._get_regexes()
     self._verify_response('image-metadata-post-resp', subs, response, 200)
Exemplo n.º 12
0
 def test_servers_post(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
         'access_ip_v4': '1.2.3.4',
         'access_ip_v6': 'fe80::'
     }
     self._servers_post(subs)
Exemplo n.º 13
0
 def test_servers_post(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
         'access_ip_v4': '1.2.3.4',
         'access_ip_v6': 'fe80::'
     }
     self._servers_post(subs)
Exemplo n.º 14
0
 def test_scheduler_hints_post(self):
     # Get api sample of scheduler hint post request.
     subs = self._get_regexes()
     subs.update({'image_id': fake.get_valid_image_id(),
                  'image_near': str(uuid.uuid4())})
     response = self._do_post('servers', 'scheduler-hints-post-req',
                              subs)
     self._verify_response('scheduler-hints-post-resp', subs, response, 202)
Exemplo n.º 15
0
 def test_image_metadata_put(self):
     # Get api sample of image metadata put request.
     image_id = fake.get_valid_image_id()
     response = self._do_put(
         '%s/images/%s/metadata' % (self.api.project_id, image_id),
         'image-metadata-put-req', {})
     subs = self._get_regexes()
     self._verify_response('image-metadata-put-resp', subs, response, 200)
Exemplo n.º 16
0
 def test_image_meta_key_put(self):
     # Get api sample of image metadata key put request.
     image_id = fake.get_valid_image_id()
     key = "auto_disk_config"
     response = self._do_put('images/%s/metadata/%s' % (image_id, key),
                             'image-meta-key-put-req', {})
     subs = self._get_regexes()
     self._verify_response('image-meta-key-put-resp', subs, response, 200)
Exemplo n.º 17
0
 def test_scheduler_hints_post(self):
     # Get api sample of scheduler hint post request.
     subs = self._get_regexes()
     subs.update({
         'image_id': fake.get_valid_image_id(),
         'image_near': str(uuid.uuid4())
     })
     response = self._do_post('servers', 'scheduler-hints-post-req', subs)
     self._verify_response('scheduler-hints-post-resp', subs, response, 202)
Exemplo n.º 18
0
 def test_multiple_create(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
         'min_count': "2",
         'max_count': "3"
     }
     response = self._do_post('servers', 'multiple-create-post-req', subs)
     subs.update(self._get_regexes())
     self._verify_response('multiple-create-post-resp', subs, response, 202)
Exemplo n.º 19
0
 def test_multiple_create(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
         'min_count': "2",
         'max_count': "3"
     }
     response = self._do_post('servers', 'multiple-create-post-req', subs)
     subs.update(self._get_regexes())
     self._verify_response('multiple-create-post-resp', subs, response, 202)
Exemplo n.º 20
0
 def test_cloud_pipe_create(self):
     # Get api samples of cloud pipe extension creation.
     self.flags(vpn_image_id=fake.get_valid_image_id())
     project = {'project_id': str(uuid_lib.uuid4().hex)}
     response = self._do_post('os-cloudpipe', 'cloud-pipe-create-req',
                              project)
     subs = self._get_regexes()
     subs.update(project)
     subs['image_id'] = CONF.vpn_image_id
     self._verify_response('cloud-pipe-create-resp', subs, response, 200)
     return project
Exemplo n.º 21
0
 def test_cloud_pipe_create(self):
     # Get api samples of cloud pipe extension creation.
     self.flags(vpn_image_id=fake.get_valid_image_id())
     project = {'project_id': str(uuid_lib.uuid4().hex)}
     response = self._do_post('os-cloudpipe', 'cloud-pipe-create-req',
                              project)
     subs = self._get_regexes()
     subs.update(project)
     subs['image_id'] = CONF.vpn_image_id
     self._verify_response('cloud-pipe-create-resp', subs, response, 200)
     return project
Exemplo n.º 22
0
 def test_servers_rebuild(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host()
     }
     uuid = self._servers_post(subs)
     response = self._do_post('servers/%s/action' % uuid,
                              'server-action-rebuild-req', subs)
     subs['hostid'] = '[a-f0-9]+'
     subs['id'] = uuid
     self._verify_response('server-action-rebuild-resp',
                           subs, response, 202)
Exemplo n.º 23
0
 def test_rebuild_server(self):
     uuid = self._post_server(use_common_server_api_samples=False)
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
     }
     response = self._do_post('servers/%s/action' % uuid,
                              'server-action-rebuild-req', subs)
     subs = self._get_regexes()
     subs['hostid'] = '[a-f0-9]+'
     self._verify_response('server-action-rebuild-resp',
                           subs, response, 202)
Exemplo n.º 24
0
 def test_server_rebuild(self):
     uuid = self._post_server()
     image = fake.get_valid_image_id()
     subs = {
         'host': self._get_host(),
         'uuid': image,
         'name': 'foobar',
         'pass': '******',
         'hostid': '[a-f0-9]+',
     }
     self._test_server_action(uuid, 'rebuild', 'server-action-rebuild',
                              subs, 'server-action-rebuild-resp')
Exemplo n.º 25
0
    def test_user_data_post(self):
        user_data_contents = '#!/bin/bash\n/bin/su\necho "I am in you!"\n'
        user_data = base64.b64encode(user_data_contents)
        subs = {
            'image_id': fake.get_valid_image_id(),
            'host': self._get_host(),
            'user_data': user_data
            }
        response = self._do_post('servers', 'userdata-post-req', subs)

        subs.update(self._get_regexes())
        self._verify_response('userdata-post-resp', subs, response, 202)
Exemplo n.º 26
0
    def test_user_data_post(self):
        user_data_contents = '#!/bin/bash\n/bin/su\necho "I am in you!"\n'
        user_data = base64.b64encode(user_data_contents)
        subs = {
            'image_id': fake.get_valid_image_id(),
            'host': self._get_host(),
            'user_data': user_data
        }
        response = self._do_post('servers', 'userdata-post-req', subs)

        subs.update(self._get_regexes())
        self._verify_response('userdata-post-resp', subs, response, 202)
Exemplo n.º 27
0
 def test_servers_details(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
         'access_ip_v4': '1.2.3.4',
         'access_ip_v6': 'fe80::'
     }
     uuid = self._servers_post(subs)
     response = self._do_get('servers/detail')
     subs['hostid'] = '[a-f0-9]+'
     subs['id'] = uuid
     self._verify_response('servers-details-resp', subs, response, 200)
Exemplo n.º 28
0
 def test_servers_details(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
         'access_ip_v4': '1.2.3.4',
         'access_ip_v6': 'fe80::'
     }
     uuid = self._servers_post(subs)
     response = self._do_get('servers/detail')
     subs['hostid'] = '[a-f0-9]+'
     subs['id'] = uuid
     self._verify_response('servers-details-resp', subs, response, 200)
Exemplo n.º 29
0
 def test_server_rebuild(self):
     uuid = self._post_server()
     image = fake.get_valid_image_id()
     subs = {'host': self._get_host(),
             'uuid': image,
             'name': 'foobar',
             'pass': '******',
             'hostid': '[a-f0-9]+',
             }
     self._test_server_action(uuid, 'rebuild',
                              'server-action-rebuild',
                               subs,
                              'server-action-rebuild-resp')
Exemplo n.º 30
0
 def test_servers_update(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
         'access_ip_v4': '1.2.3.4',
         'access_ip_v6': 'fe80::'
     }
     uuid = self._servers_post(subs)
     subs['access_ip_v4'] = "4.3.2.1"
     subs['access_ip_v6'] = '80fe::'
     response = self._do_put('servers/%s' % uuid, 'server-put-req', subs)
     subs['hostid'] = '[a-f0-9]+'
     subs['id'] = uuid
     self._verify_response('server-put-resp', subs, response, 200)
Exemplo n.º 31
0
 def test_servers_update(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host(),
         'access_ip_v4': '1.2.3.4',
         'access_ip_v6': 'fe80::'
     }
     uuid = self._servers_post(subs)
     subs['access_ip_v4'] = "4.3.2.1"
     subs['access_ip_v6'] = '80fe::'
     response = self._do_put('servers/%s' % uuid, 'server-put-req', subs)
     subs['hostid'] = '[a-f0-9]+'
     subs['id'] = uuid
     self._verify_response('server-put-resp', subs, response, 200)
Exemplo n.º 32
0
    def setUp(self):

        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()
        self._context = context.RequestContext('fake_user', 'fake_project')

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._image_id = image_fake.get_valid_image_id()
        self._instance_values = {
            'name': 'fake_name',
            'uuid': 'fake_uuid',
            'vcpus': 1,
            'memory_mb': 512,
            'image_ref': self._image_id,
            'root_gb': 10,
            'node': 'respool-1001(MyResPoolName)',
            'expected_attrs': ['system_metadata'],
        }
        self._instance = fake_instance.fake_instance_obj(
            self._context, **self._instance_values)
    def _test_server_rebuild_preserve_ephemeral(self, value):
        uuid = self._post_server()
        image = fake.get_valid_image_id()
        subs = {'host': self._get_host(),
                'uuid': image,
                'name': 'foobar',
                'pass': '******',
                'hostid': '[a-f0-9]+',
                'preserve_ephemeral': str(value).lower(),
                'action': 'rebuild',
                'glance_host': self._get_glance_host(),
                }

        def fake_rebuild(self_, context, instance, image_href, admin_password,
                         files_to_inject=None, **kwargs):
            self.assertEqual(kwargs['preserve_ephemeral'], value)
        self.stubs.Set(compute_api.API, 'rebuild', fake_rebuild)

        response = self._do_post('servers/%s/action' % uuid,
                                 'server-action-rebuild-preserve-ephemeral',
                                 subs)
        self.assertEqual(response.status_code, 202)
Exemplo n.º 34
0
    def setUp(self):

        super(VMwareVolumeOpsTestCase, self).setUp()
        vmwareapi_fake.reset()
        stubs.set_stubs(self.stubs)
        self._session = driver.VMwareAPISession()
        self._context = context.RequestContext('fake_user', 'fake_project')

        self._volumeops = volumeops.VMwareVolumeOps(self._session)
        self._image_id = image_fake.get_valid_image_id()
        self._instance_values = {
            'name': 'fake_name',
            'uuid': 'fake_uuid',
            'vcpus': 1,
            'memory_mb': 512,
            'image_ref': self._image_id,
            'root_gb': 10,
            'node': 'respool-1001(MyResPoolName)',
            'expected_attrs': ['system_metadata'],
        }
        self._instance = fake_instance.fake_instance_obj(self._context,
            **self._instance_values)
Exemplo n.º 35
0
    def _post_server(self, use_common_server_api_samples=True):
        # param use_common_server_api_samples: Boolean to set whether tests use
        # common sample files for server post request and response.
        # Default is True which means _get_sample_path method will fetch the
        # common server sample files from 'servers' directory.
        # Set False if tests need to use extension specific sample files

        subs = {
            'image_id': fake.get_valid_image_id(),
            'host': self._get_host(),
            'glance_host': self._get_glance_host()
        }
        orig_value = self.__class__._use_common_server_api_samples
        try:
            self.__class__._use_common_server_api_samples = (
                                        use_common_server_api_samples)
            response = self._do_post('servers', 'server-post-req', subs)
            subs = self._get_regexes()
            status = self._verify_response('server-post-resp', subs,
                                           response, 202)
            return status
        finally:
            self.__class__._use_common_server_api_samples = orig_value
Exemplo n.º 36
0
    def _post_server(self, use_common_server_api_samples=True):
        # param use_common_server_api_samples: Boolean to set whether tests use
        # common sample files for server post request and response.
        # Default is True which means _get_sample_path method will fetch the
        # common server sample files from 'servers' directory.
        # Set False if tests need to use extension specific sample files

        subs = {
            'image_id': fake.get_valid_image_id(),
            'host': self._get_host(),
            'glance_host': self._get_glance_host()
        }
        orig_value = self.__class__._use_common_server_api_samples
        try:
            self.__class__._use_common_server_api_samples = (
                use_common_server_api_samples)
            response = self._do_post('servers', 'server-post-req', subs)
            subs = self._get_regexes()
            status = self._verify_response('server-post-resp', subs, response,
                                           202)
            return status
        finally:
            self.__class__._use_common_server_api_samples = orig_value
Exemplo n.º 37
0
 def test_get_image(self):
     image_id = fake.get_valid_image_id()
     response = self._do_get('images/%s' % image_id)
     subs = self._get_regexes()
     subs['image_id'] = image_id
     self._verify_response('image-get-resp', subs, response, 200)
Exemplo n.º 38
0
 def test_servers_post(self):
     subs = {
         'image_id': fake.get_valid_image_id(),
         'host': self._get_host()
     }
     self._servers_post(subs)