Esempio n. 1
0
    def test_set_image_metadata_item(self):
        """
        The value provided for the given meta item should be set for the image
        """
        meta = {'nova': 'server'}
        name = rand_name('server')
        resp, server = self.servers_client.create_server(
            name, self.image_ref, self.flavor_ref)
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

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

        meta = {'nova': 'alt'}
        resp, body = self.client.set_image_metadata_item(
            image['id'], 'nova', meta)
        resp, metadata = self.client.list_image_metadata(image['id'])
        self.assertEqual('alt', metadata['nova'])

        self.servers_client.delete_server(server['id'])
        self.client.delete_image(image['id'])
Esempio n. 2
0
    def setUpClass(cls):
        cls.os = openstack.Manager()
        cls.servers_client = cls.os.servers_client
        cls.client = cls.os.images_client
        cls.config = storm.config.StormConfig()
        cls.image_ref = cls.config.env.image_ref
        cls.flavor_ref = cls.config.env.flavor_ref
        cls.ssh_timeout = cls.config.nova.ssh_timeout

        name = rand_name("server")
        resp, cls.server = cls.servers_client.create_server(name, cls.image_ref, cls.flavor_ref)
        # Wait for the server to become active
        cls.servers_client.wait_for_server_status(cls.server["id"], "ACTIVE")

        # Create an image from the server
        name = rand_name("image")
        cls.meta = {"key1": "value1", "key2": "value2"}
        resp, body = cls.client.create_image(cls.server["id"], name, cls.meta)
        image_ref = resp["location"]
        temp = image_ref.rsplit("/")
        image_id = temp[len(temp) - 1]

        cls.client.wait_for_image_resp_code(image_id, 200)
        cls.client.wait_for_image_status(image_id, "ACTIVE")
        resp, cls.image = cls.client.get_image(image_id)
Esempio n. 3
0
    def test_set_image_metadata(self):
        """The metadata for the image should match the new values"""
        meta = {'meta1': 'data1'}
        name = rand_name('server')
        resp, server = self.servers_client.create_server(
            name, self.image_ref, self.flavor_ref)
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

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

        meta = {'meta2': 'data2', 'meta3': 'data3'}
        resp, body = self.client.set_image_metadata(image['id'], meta)

        resp, metadata = self.client.list_image_metadata(image['id'])
        self.assertEqual('data2', metadata['meta2'])
        self.assertEqual('data3', metadata['meta3'])
        self.assertTrue('meta1' not in metadata)

        self.servers_client.delete_server(server['id'])
        self.client.delete_image(image['id'])
Esempio n. 4
0
    def setUpClass(cls):
        cls.os = openstack.Manager()
        cls.servers_client = cls.os.servers_client
        cls.client = cls.os.images_client
        cls.config = storm.config.StormConfig()
        cls.image_ref = cls.config.env.image_ref
        cls.flavor_ref = cls.config.env.flavor_ref
        cls.ssh_timeout = cls.config.nova.ssh_timeout

        name = rand_name('server')
        resp, cls.server = cls.servers_client.create_server(
            name, cls.image_ref, cls.flavor_ref)
        #Wait for the server to become active
        cls.servers_client.wait_for_server_status(cls.server['id'], 'ACTIVE')

        #Create an image from the server
        name = rand_name('image')
        cls.meta = {'key1': 'value1', 'key2': 'value2'}
        resp, body = cls.client.create_image(cls.server['id'], name, cls.meta)
        image_ref = resp['location']
        temp = image_ref.rsplit('/')
        image_id = temp[len(temp) - 1]

        cls.client.wait_for_image_resp_code(image_id, 200)
        cls.client.wait_for_image_status(image_id, 'ACTIVE')
        resp, cls.image = cls.client.get_image(image_id)
Esempio n. 5
0
    def setUpClass(cls):
        cls.os = openstack.Manager()
        cls.client = cls.os.servers_client
        cls.config = storm.config.StormConfig()
        cls.image_ref = cls.config.env.image_ref
        cls.flavor_ref = cls.config.env.flavor_ref
        cls.image_ref_alt = cls.config.env.image_ref_alt
        cls.flavor_ref_alt = cls.config.env.flavor_ref_alt

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

        cls.s2_name = rand_name('server')
        resp, server = cls.client.create_server(cls.s2_name, cls.image_ref_alt,
                                                cls.flavor_ref)
        cls.client.wait_for_server_status(server['id'], 'ACTIVE')
        resp, cls.s2 = cls.client.get_server(server['id'])

        cls.s3_name = rand_name('server')
        resp, server = cls.client.create_server(cls.s3_name, cls.image_ref,
                                                cls.flavor_ref_alt)
        cls.client.wait_for_server_status(server['id'], 'ACTIVE')
        resp, cls.s3 = cls.client.get_server(server['id'])
Esempio n. 6
0
    def setUpClass(cls):
        cls.os = openstack.Manager()
        cls.client = cls.os.servers_client
        cls.config = storm.config.StormConfig()
        cls.image_ref = cls.config.env.image_ref
        cls.flavor_ref = cls.config.env.flavor_ref
        cls.image_ref_alt = cls.config.env.image_ref_alt
        cls.flavor_ref_alt = cls.config.env.flavor_ref_alt

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

        cls.s2_name = rand_name('server')
        resp, server = cls.client.create_server(cls.s2_name, cls.image_ref_alt,
                                                cls.flavor_ref)
        cls.client.wait_for_server_status(server['id'], 'ACTIVE')
        resp, cls.s2 = cls.client.get_server(server['id'])

        cls.s3_name = rand_name('server')
        resp, server = cls.client.create_server(cls.s3_name, cls.image_ref,
                                                cls.flavor_ref_alt)
        cls.client.wait_for_server_status(server['id'], 'ACTIVE')
        resp, cls.s3 = cls.client.get_server(server['id'])
Esempio n. 7
0
    def test_create_delete_server(self):
        meta = {'hello': 'world'}
        accessIPv4 = '1.1.1.1'
        accessIPv6 = '::babe:220.12.22.2'
        name = rand_name('server')
        file_contents = 'This is a test file.'
        personality = [{'path': '/etc/test.txt',
                       'contents': base64.b64encode(file_contents)}]
        resp, server = self.client.create_server(name,
                                                 self.image_ref,
                                                 self.flavor_ref,
                                                 meta=meta,
                                                 accessIPv4=accessIPv4,
                                                 accessIPv6=accessIPv6,
                                                 personality=personality)

        #Wait for the server to become active
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Verify the specified attributes are set correctly
        resp, server = self.client.get_server(server['id'])
        self.assertEqual('1.1.1.1', server['accessIPv4'])
        self.assertEqual('::babe:220.12.22.2', server['accessIPv6'])
        self.assertEqual(name, server['name'])
        self.assertEqual(self.image_ref, server['image']['id'])
        self.assertEqual(str(self.flavor_ref), server['flavor']['id'])

        #Teardown
        self.client.delete_server(self.id)
Esempio n. 8
0
    def test_create_delete_server(self):
        meta = {'hello': 'world'}
        accessIPv4 = '1.1.1.1'
        accessIPv6 = '::babe:220.12.22.2'
        name = rand_name('server')
        file_contents = 'This is a test file.'
        personality = [{
            'path': '/etc/test.txt',
            'contents': base64.b64encode(file_contents)
        }]
        resp, server = self.client.create_server(name,
                                                 self.image_ref,
                                                 self.flavor_ref,
                                                 meta=meta,
                                                 accessIPv4=accessIPv4,
                                                 accessIPv6=accessIPv6,
                                                 personality=personality)

        #Wait for the server to become active
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Verify the specified attributes are set correctly
        resp, server = self.client.get_server(server['id'])
        self.assertEqual('1.1.1.1', server['accessIPv4'])
        self.assertEqual('::babe:220.12.22.2', server['accessIPv6'])
        self.assertEqual(name, server['name'])
        self.assertEqual(self.image_ref, server['image']['id'])
        self.assertEqual(str(self.flavor_ref), server['flavor']['id'])

        #Teardown
        self.client.delete_server(self.id)
Esempio n. 9
0
    def test_update_server_metadata(self):
        """
        The server's metadata values should be updated to the
        provided values
        """
        meta = {'key1': 'value1', 'key2': 'value2'}
        name = rand_name('server')
        resp, server = self.client.create_server(name,
                                                 self.image_ref,
                                                 self.flavor_ref,
                                                 meta=meta)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Update all metadata items for the server
        meta = {'key1': 'alt1', 'key2': 'alt2'}
        resp, metadata = self.client.update_server_metadata(server['id'], meta)
        self.assertEqual(200, resp.status)

        #Verify the values have been updated to the proper values
        resp, body = self.client.list_server_metadata(server['id'])
        self.assertEqual('alt1', metadata['key1'])
        self.assertEqual('alt2', metadata['key2'])

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 10
0
    def test_create_server_with_admin_password(self):
        """
        If an admin password is provided on server creation, the server's root
        password should be set to that password.
        """

        name = rand_name('server')
        resp, server = self.client.create_server(name,
                                                 self.image_ref,
                                                 self.flavor_ref,
                                                 adminPass='******')

        #Verify the password is set correctly in the response
        self.assertEqual('testpassword', server['adminPass'])

        #SSH into the server using the set password
        self.client.wait_for_server_status(server['id'], 'ACTIVE')
        resp, addresses = self.client.list_addresses(server['id'])
        ip = addresses['public'][0]['addr']

        client = ssh.Client(ip, 'root', 'testpassword', self.ssh_timeout)
        self.assertTrue(client.test_connection_auth())

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 11
0
    def test_delete_image_metadata_item(self):
        """The metadata value/key pair should be deleted from the image"""
        meta = {"delkey": "delvalue"}
        name = rand_name("server")
        resp, server = self.servers_client.create_server(name, self.image_ref, self.flavor_ref)
        self.servers_client.wait_for_server_status(server["id"], "ACTIVE")

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

        resp, body = self.client.delete_image_metadata_item(image["id"], "delkey")
        resp, metadata = self.client.list_image_metadata(image["id"])
        self.assertTrue("delkey" not in metadata)

        self.servers_client.delete_server(server["id"])
        self.client.delete_image(image["id"])
Esempio n. 12
0
    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')
        resp, body = self.client.create_image(server['id'], name)
        image_id = self._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'])

        #Teardown
        self.client.delete_image(image['id'])
        self.servers_client.delete_server(server['id'])
Esempio n. 13
0
    def test_delete_image_metadata_item(self):
        """The metadata value/key pair should be deleted from the image"""
        meta = {'delkey': 'delvalue'}
        name = rand_name('server')
        resp, server = self.servers_client.create_server(
            name, self.image_ref, self.flavor_ref)
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

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

        resp, body = self.client.delete_image_metadata_item(
            image['id'], 'delkey')
        resp, metadata = self.client.list_image_metadata(image['id'])
        self.assertTrue('delkey' not in metadata)

        self.servers_client.delete_server(server['id'])
        self.client.delete_image(image['id'])
Esempio n. 14
0
    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')
        resp, body = self.client.create_image(server['id'], name)
        image_id = self._parse_image_id(resp['location'])
        self.client.wait_for_image_exists(image_id)
        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'])

        #Teardown
        self.client.delete_image(image['id'])
        self.servers_client.delete_server(server['id'])
Esempio n. 15
0
 def test_invalid_ip_v6_address(self):
     """An access IPv6 address must match a valid address pattern"""
     #Currently failing due to bug
     accessIPv6 = 'notvalid'
     name = rand_name('server')
     try:
         resp, server = self.client.create_server(name,
                                                  self.image_ref,
                                                  self.flavor_ref,
                                                  accessIPv6=accessIPv6)
     except exceptions.BadRequest:
         pass
     else:
         self.fail('Access IPv6 address must match the correct format')
Esempio n. 16
0
    def test_set_image_metadata_item(self):
        """
        The value provided for the given meta item should be set for the image
        """
        meta = {"nova": "server"}
        name = rand_name("server")
        resp, server = self.servers_client.create_server(name, self.image_ref, self.flavor_ref)
        self.servers_client.wait_for_server_status(server["id"], "ACTIVE")

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

        meta = {"nova": "alt"}
        resp, body = self.client.set_image_metadata_item(image["id"], "nova", meta)
        resp, metadata = self.client.list_image_metadata(image["id"])
        self.assertEqual("alt", metadata["nova"])

        self.servers_client.delete_server(server["id"])
        self.client.delete_image(image["id"])
Esempio n. 17
0
    def test_update_image_metadata(self):
        """The metadata for the image should match the updated values"""
        meta = {"key1": "value1", "key2": "value2"}
        name = rand_name("server")
        resp, server = self.servers_client.create_server(name, self.image_ref, self.flavor_ref)
        self.servers_client.wait_for_server_status(server["id"], "ACTIVE")

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

        meta = {"key1": "alt1", "key2": "alt2"}
        resp, metadata = self.client.update_image_metadata(image["id"], meta)

        resp, metadata = self.client.list_image_metadata(image["id"])
        self.assertEqual("alt1", metadata["key1"])
        self.assertEqual("alt2", metadata["key2"])

        self.servers_client.delete_server(server["id"])
        self.client.delete_image(image["id"])
Esempio n. 18
0
 def test_invalid_ip_v6_address(self):
     """An access IPv6 address must match a valid address pattern"""
     #Currently failing due to bug
     accessIPv6 = 'notvalid'
     name = rand_name('server')
     try:
         resp, server = self.client.create_server(name,
                                                  self.image_ref,
                                                  self.flavor_ref,
                                                  accessIPv6=accessIPv6)
     except exceptions.BadRequest:
         pass
     else:
         self.fail('Access IPv6 address must match the correct format')
Esempio n. 19
0
    def test_set_image_metadata(self):
        """The metadata for the image should match the new values"""
        meta = {"meta1": "data1"}
        name = rand_name("server")
        resp, server = self.servers_client.create_server(name, self.image_ref, self.flavor_ref)
        self.servers_client.wait_for_server_status(server["id"], "ACTIVE")

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

        meta = {"meta2": "data2", "meta3": "data3"}
        resp, body = self.client.set_image_metadata(image["id"], meta)

        resp, metadata = self.client.list_image_metadata(image["id"])
        self.assertEqual("data2", metadata["meta2"])
        self.assertEqual("data3", metadata["meta3"])
        self.assertTrue("meta1" not in metadata)

        self.servers_client.delete_server(server["id"])
        self.client.delete_image(image["id"])
Esempio n. 20
0
    def setUpClass(cls):
        cls.os = openstack.Manager()
        cls.client = cls.os.servers_client
        cls.config = storm.config.StormConfig()
        cls.image_ref = cls.config.env.image_ref
        cls.flavor_ref = cls.config.env.flavor_ref

        #Create a server to be used for all read only tests
        cls.meta = {'test1': 'value1', 'test2': 'value2'}
        name = rand_name('server')
        resp, cls.server = cls.client.create_server(name, cls.image_ref,
                                                cls.flavor_ref, meta=cls.meta)

        #Wait for the server to become active
        cls.client.wait_for_server_status(cls.server['id'], 'ACTIVE')
Esempio n. 21
0
    def test_update_image_metadata(self):
        """The metadata for the image should match the updated values"""
        meta = {'key1': 'value1', 'key2': 'value2'}
        name = rand_name('server')
        resp, server = self.servers_client.create_server(
            name, self.image_ref, self.flavor_ref)
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

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

        meta = {'key1': 'alt1', 'key2': 'alt2'}
        resp, metadata = self.client.update_image_metadata(image['id'], meta)

        resp, metadata = self.client.list_image_metadata(image['id'])
        self.assertEqual('alt1', metadata['key1'])
        self.assertEqual('alt2', metadata['key2'])

        self.servers_client.delete_server(server['id'])
        self.client.delete_image(image['id'])
Esempio n. 22
0
    def setUpClass(cls):
        cls.os = openstack.Manager()
        cls.client = cls.os.servers_client
        cls.config = storm.config.StormConfig()
        cls.image_ref = cls.config.env.image_ref
        cls.flavor_ref = cls.config.env.flavor_ref

        #Create a server to be used for all read only tests
        cls.meta = {'test1': 'value1', 'test2': 'value2'}
        name = rand_name('server')
        resp, cls.server = cls.client.create_server(name,
                                                    cls.image_ref,
                                                    cls.flavor_ref,
                                                    meta=cls.meta)

        #Wait for the server to become active
        cls.client.wait_for_server_status(cls.server['id'], 'ACTIVE')
Esempio n. 23
0
    def test_update_server_name(self):
        """The server name should be changed to the the provided value"""
        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                 self.flavor_ref)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Update the server with a new name
        self.client.update_server(server['id'], name='newname')
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Verify the name of the server has changed
        resp, server = self.client.get_server(server['id'])
        self.assertEqual('newname', server['name'])

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 24
0
    def test_update_server_name(self):
        """The server name should be changed to the the provided value"""
        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                 self.flavor_ref)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Update the server with a new name
        self.client.update_server(server['id'], name='newname')
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Verify the name of the server has changed
        resp, server = self.client.get_server(server['id'])
        self.assertEqual('newname', server['name'])

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 25
0
    def test_delete_server_metadata_item(self):
        """The metadata value/key pair should be deleted from the server"""
        meta = {'delkey': 'delvalue'}
        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                self.flavor_ref, meta=meta)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Delete the metadata item
        resp, metadata = self.client.delete_server_metadata_item(server['id'],
                                                                 'delkey')
        self.assertEqual(204, resp.status)

        #Verify the metadata item has been removed
        resp, metadata = self.client.list_server_metadata(server['id'])
        self.assertTrue('delkey' not in metadata)

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 26
0
    def test_set_server_metadata_item(self):
        """The item's value should be updated to the provided value"""
        meta = {'nova': 'server'}
        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                self.flavor_ref, meta=meta)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Update the metadata value
        meta = {'nova': 'alt'}
        resp, body = self.client.set_server_metadata_item(server['id'],
                                                          'nova', meta)
        self.assertEqual(200, resp.status)

        #Verify the meta item's value has been updated
        resp, body = self.client.list_server_metadata(server['id'])
        self.assertEqual('alt', metadata['nova'])

        #Teardown
        self.client.delete_server(server.id)
Esempio n. 27
0
    def test_update_access_server_address(self):
        """
        The server's access addresses should reflect the provided values
        """
        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                 self.flavor_ref)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Update the IPv4 and IPv6 access addresses
        self.client.update_server(server['id'], accessIPv4='1.1.1.1',
                                  accessIPv6='::babe:2.2.2.2')
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Verify the access addresses have been updated
        resp, server = self.client.get_server(server['id'])
        self.assertEqual('1.1.1.1', server['accessIPv4'])
        self.assertEqual('::babe:2.2.2.2', server['accessIPv6'])

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 28
0
    def test_delete_server_metadata_item(self):
        """The metadata value/key pair should be deleted from the server"""
        meta = {'delkey': 'delvalue'}
        name = rand_name('server')
        resp, server = self.client.create_server(name,
                                                 self.image_ref,
                                                 self.flavor_ref,
                                                 meta=meta)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Delete the metadata item
        resp, metadata = self.client.delete_server_metadata_item(
            server['id'], 'delkey')
        self.assertEqual(204, resp.status)

        #Verify the metadata item has been removed
        resp, metadata = self.client.list_server_metadata(server['id'])
        self.assertTrue('delkey' not in metadata)

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 29
0
    def test_set_server_metadata_item(self):
        """The item's value should be updated to the provided value"""
        meta = {'nova': 'server'}
        name = rand_name('server')
        resp, server = self.client.create_server(name,
                                                 self.image_ref,
                                                 self.flavor_ref,
                                                 meta=meta)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Update the metadata value
        meta = {'nova': 'alt'}
        resp, body = self.client.set_server_metadata_item(
            server['id'], 'nova', meta)
        self.assertEqual(200, resp.status)

        #Verify the meta item's value has been updated
        resp, body = self.client.list_server_metadata(server['id'])
        self.assertEqual('alt', metadata['nova'])

        #Teardown
        self.client.delete_server(server.id)
Esempio n. 30
0
    def test_set_server_metadata(self):
        """The server's metadata should be replaced with the provided values"""
        meta = {'meta1': 'data1'}
        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                self.flavor_ref, meta=meta)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Create a new set of metadata for the server
        meta = {'meta2': 'data2', 'meta3': 'data3'}
        resp, metadata = self.client.set_server_metadata(server['id'], meta)
        self.assertEqual(200, resp.status)

        #Verify the expected values are correct, and that the
        #previous values have been removed
        resp, body = self.client.list_server_metadata(server['id'])
        self.assertEqual('data2', metadata['meta2'])
        self.assertEqual('data3', metadata['meta3'])
        self.assertTrue('meta1' not in metadata)

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 31
0
    def test_update_access_server_address(self):
        """
        The server's access addresses should reflect the provided values
        """
        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                 self.flavor_ref)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Update the IPv4 and IPv6 access addresses
        self.client.update_server(server['id'],
                                  accessIPv4='1.1.1.1',
                                  accessIPv6='::babe:2.2.2.2')
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Verify the access addresses have been updated
        resp, server = self.client.get_server(server['id'])
        self.assertEqual('1.1.1.1', server['accessIPv4'])
        self.assertEqual('::babe:2.2.2.2', server['accessIPv6'])

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 32
0
    def test_update_server_metadata(self):
        """
        The server's metadata values should be updated to the
        provided values
        """
        meta = {'key1': 'value1', 'key2': 'value2'}
        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                self.flavor_ref, meta=meta)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Update all metadata items for the server
        meta = {'key1': 'alt1', 'key2': 'alt2'}
        resp, metadata = self.client.update_server_metadata(server['id'], meta)
        self.assertEqual(200, resp.status)

        #Verify the values have been updated to the proper values
        resp, body = self.client.list_server_metadata(server['id'])
        self.assertEqual('alt1', metadata['key1'])
        self.assertEqual('alt2', metadata['key2'])

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 33
0
    def test_set_server_metadata(self):
        """The server's metadata should be replaced with the provided values"""
        meta = {'meta1': 'data1'}
        name = rand_name('server')
        resp, server = self.client.create_server(name,
                                                 self.image_ref,
                                                 self.flavor_ref,
                                                 meta=meta)
        self.client.wait_for_server_status(server['id'], 'ACTIVE')

        #Create a new set of metadata for the server
        meta = {'meta2': 'data2', 'meta3': 'data3'}
        resp, metadata = self.client.set_server_metadata(server['id'], meta)
        self.assertEqual(200, resp.status)

        #Verify the expected values are correct, and that the
        #previous values have been removed
        resp, body = self.client.list_server_metadata(server['id'])
        self.assertEqual('data2', metadata['meta2'])
        self.assertEqual('data3', metadata['meta3'])
        self.assertTrue('meta1' not in metadata)

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 34
0
    def test_create_server_with_admin_password(self):
        """
        If an admin password is provided on server creation, the server's root
        password should be set to that password.
        """

        name = rand_name('server')
        resp, server = self.client.create_server(name, self.image_ref,
                                                 self.flavor_ref,
                                                 adminPass='******')

        #Verify the password is set correctly in the response
        self.assertEqual('testpassword', server['adminPass'])

        #SSH into the server using the set password
        self.client.wait_for_server_status(server['id'], 'ACTIVE')
        resp, addresses = self.client.list_addresses(server['id'])
        ip = addresses['public'][0]['addr']

        client = ssh.Client(ip, 'root', 'testpassword', self.ssh_timeout)
        self.assertTrue(client.test_connection_auth())

        #Teardown
        self.client.delete_server(server['id'])
Esempio n. 35
0
 def setUp(self):
     self.name = rand_name('server')
     resp, server = self.client.create_server(self.name, self.image_ref,
                                              self.flavor_ref)
     self.id = server['id']
     self.client.wait_for_server_status(self.id, 'ACTIVE')