Пример #1
0
    def test_rebuild_server(self):
        # The server should be rebuilt using the provided image and data
        meta = {"rebuild": "server"}
        new_name = data_utils.rand_name("server")
        file_contents = "Test server rebuild."
        personality = [{"path": "rebuild.txt", "contents": base64.b64encode(file_contents)}]
        password = "******"
        resp, rebuilt_server = self.client.rebuild(
            self.server_id,
            self.image_ref_alt,
            name=new_name,
            metadata=meta,
            personality=personality,
            adminPass=password,
        )
        self.addCleanup(self.client.rebuild, self.server_id, self.image_ref)

        # Verify the properties in the initial response are correct
        self.assertEqual(self.server_id, rebuilt_server["id"])
        rebuilt_image_id = rebuilt_server["image"]["id"]
        self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
        self.assertEqual(self.flavor_ref, rebuilt_server["flavor"]["id"])

        # Verify the server properties after the rebuild completes
        self.client.wait_for_server_status(rebuilt_server["id"], "ACTIVE")
        resp, server = self.client.get_server(rebuilt_server["id"])
        rebuilt_image_id = server["image"]["id"]
        self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
        self.assertEqual(new_name, server["name"])

        if self.run_ssh:
            # Verify that the user can authenticate with the provided password
            linux_client = RemoteClient(server, self.ssh_user, password)
            linux_client.validate_authentication()
    def test_attach_detach_volume(self):
        # Stop and Start a server with an attached volume, ensuring that
        # the volume remains attached.
        self._create_and_attach()
        server = self.server
        volume = self.volume

        self.servers_client.stop(server['id'])
        self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

        self.servers_client.start(server['id'])
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

        linux_client = RemoteClient(server,
                                    self.image_ssh_user, server['adminPass'])
        partitions = linux_client.get_partitions()
        self.assertIn(self.device, partitions)

        self._detach(server['id'], volume['id'])
        self.attached = False

        self.servers_client.stop(server['id'])
        self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

        self.servers_client.start(server['id'])
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

        linux_client = RemoteClient(server,
                                    self.image_ssh_user, server['adminPass'])
        partitions = linux_client.get_partitions()
        self.assertNotIn(self.device, partitions)
Пример #3
0
    def test_rebuild_server(self):
        # The server should be rebuilt using the provided image and data
        meta = {'rebuild': 'server'}
        new_name = data_utils.rand_name('server')
        file_contents = 'Test server rebuild.'
        personality = [{'path': 'rebuild.txt',
                       'contents': base64.b64encode(file_contents)}]
        password = '******'
        resp, rebuilt_server = self.client.rebuild(self.server_id,
                                                   self.image_ref_alt,
                                                   name=new_name,
                                                   metadata=meta,
                                                   personality=personality,
                                                   admin_password=password)

        # Verify the properties in the initial response are correct
        self.assertEqual(self.server_id, rebuilt_server['id'])
        rebuilt_image_id = rebuilt_server['image']['id']
        self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
        self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])

        # Verify the server properties after the rebuild completes
        self.client.wait_for_server_status(rebuilt_server['id'], 'ACTIVE')
        resp, server = self.client.get_server(rebuilt_server['id'])
        rebuilt_image_id = rebuilt_server['image']['id']
        self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
        self.assertEqual(new_name, rebuilt_server['name'])

        if self.run_ssh:
            # Verify that the user can authenticate with the provided password
            linux_client = RemoteClient(server, self.ssh_user, password)
            linux_client.validate_authentication()
Пример #4
0
    def test_rebuild_server(self):
        # The server should be rebuilt using the provided image and data
        meta = {'rebuild': 'server'}
        new_name = rand_name('server')
        file_contents = 'Test server rebuild.'
        personality = [{
            'path': 'rebuild.txt',
            'contents': base64.b64encode(file_contents)
        }]
        password = '******'
        resp, rebuilt_server = self.client.rebuild(self.server_id,
                                                   self.image_ref_alt,
                                                   name=new_name,
                                                   meta=meta,
                                                   personality=personality,
                                                   adminPass=password)

        # Verify the properties in the initial response are correct
        self.assertEqual(self.server_id, rebuilt_server['id'])
        rebuilt_image_id = rebuilt_server['image']['id']
        self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
        self.assertEqual(self.flavor_ref, int(rebuilt_server['flavor']['id']))

        # Verify the server properties after the rebuild completes
        self.client.wait_for_server_status(rebuilt_server['id'], 'ACTIVE')
        resp, server = self.client.get_server(rebuilt_server['id'])
        rebuilt_image_id = rebuilt_server['image']['id']
        self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
        self.assertEqual(new_name, rebuilt_server['name'])

        if self.run_ssh:
            # Verify that the user can authenticate with the provided password
            linux_client = RemoteClient(server, self.ssh_user, password)
            self.assertTrue(linux_client.can_authenticate())
Пример #5
0
    def test_rebuild_server(self):
        # The server should be rebuilt using the provided image and data
        meta = {'rebuild': 'server'}
        new_name = data_utils.rand_name('server')
        password = '******'
        resp, rebuilt_server = self.client.rebuild(self.server_id,
                                                   self.image_ref_alt,
                                                   name=new_name,
                                                   metadata=meta,
                                                   admin_password=password)
        self.addCleanup(self.client.rebuild, self.server_id, self.image_ref)

        # Verify the properties in the initial response are correct
        self.assertEqual(self.server_id, rebuilt_server['id'])
        rebuilt_image_id = rebuilt_server['image']['id']
        self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
        self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])

        # Verify the server properties after the rebuild completes
        self.client.wait_for_server_status(rebuilt_server['id'], 'ACTIVE')
        resp, server = self.client.get_server(rebuilt_server['id'])
        rebuilt_image_id = server['image']['id']
        self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
        self.assertEqual(new_name, server['name'])

        if self.run_ssh:
            # Verify that the user can authenticate with the provided password
            linux_client = RemoteClient(server, self.ssh_user, password)
            linux_client.validate_authentication()
    def test_metadata_agent_on_concurrent_deployment(self):
        """Verifies created neutron resources."""
        neutron_basic_template = self.load_template(
            'concurrent_deployment_of_vms_with_fip')
        keypair = self.create_keypair(manager=self.admin_manager)
        stack_name = data_utils.rand_name('heat')
        user_data = '#!/bin/sh\necho "pass" > /tmp/userdata.out'
        template = self.read_template('concurrent_deployment_of_vms_with_fip')
        network_name = data_utils.rand_name('priv_net')
        parameters = {
            'public_net': CONF.network.public_network_id,
            'private_net_name': network_name,
            'private_net_cidr': '97.0.0.0/24',
            'private_net_gateway': '97.0.0.1',
            'private_net_pool_start': '97.0.0.5',
            'private_net_pool_end': '97.0.0.100',
            'image': CONF.compute.image_ref,
            'flavor': CONF.compute.flavor_ref,
            'key_name': keypair['name'],
            'user_data': user_data
        }
        # create the stack
        stack_identifier = self.create_stack(stack_name, template, parameters)
        stack_id = stack_identifier.split('/')[1]

        self.client.wait_for_stack_status(stack_id, 'CREATE_COMPLETE')
        resources = (self.client.list_resources(stack_identifier)['resources'])

        test_resources = {}
        for resource in resources:
            test_resources[resource['logical_resource_id']] = resource

        resources = [
            ('vm1', neutron_basic_template['resources']['vm1']['type']),
            ('vm2', neutron_basic_template['resources']['vm2']['type']),
            ('vm3', neutron_basic_template['resources']['vm3']['type']),
            ('vm4', neutron_basic_template['resources']['vm4']['type']),
            ('vm5', neutron_basic_template['resources']['vm5']['type']),
            ('vm6', neutron_basic_template['resources']['vm6']['type']),
            ('vm7', neutron_basic_template['resources']['vm7']['type'])
        ]

        for resource_name, resource_type in resources:
            resource = test_resources.get(resource_name, None)
            server = NuageBaseTest.get_server(
                self,
                server_id=resource['physical_resource_id'],
                manager=self.admin_manager)
            fip = None
            for net in server['addresses'][network_name]:
                if net['OS-EXT-IPS:type'] == 'floating':
                    fip = net['addr']
            self.fip_acs = RemoteClient(
                ip_address=fip,
                username=CONF.validation.image_ssh_user,
                pkey=keypair['private_key'])
            self.assertTrue(
                test_utils.call_until_true(self.is_userdata_ready, 300, 30))
        self._clear_stacks()
Пример #7
0
 def test_verify_created_server_vcpus(self):
     """
     Verify that the number of vcpus reported by the instance matches
     the amount stated by the flavor
     """
     resp, flavor = self.flavors_client.get_flavor_details(self.flavor_ref)
     linux_client = RemoteClient(self.server, self.ssh_user, self.password)
     self.assertEqual(flavor['vcpus'], linux_client.get_number_of_vcpus())
Пример #8
0
    def test_change_server_password(self):
        # The server's password should be set to the provided password
        new_password = '******'
        resp, body = self.client.change_password(self.server_id, new_password)
        self.assertEqual(202, resp.status)
        self.client.wait_for_server_status(self.server_id, 'ACTIVE')

        if self.run_ssh:
            # Verify that the user can authenticate with the new password
            resp, server = self.client.get_server(self.server_id)
            linux_client = RemoteClient(server, self.ssh_user, new_password)
            linux_client.validate_authentication()
Пример #9
0
    def test_change_server_password(self):
        # The server's password should be set to the provided password
        new_password = '******'
        resp, body = self.client.change_password(self.server_id, new_password)
        self.assertEqual(202, resp.status)
        self.client.wait_for_server_status(self.server_id, 'ACTIVE')

        if self.run_ssh:
            # Verify that the user can authenticate with the new password
            resp, server = self.client.get_server(self.server_id)
            linux_client = RemoteClient(server, self.ssh_user, new_password)
            self.assertTrue(linux_client.can_authenticate())
Пример #10
0
    def test_reboot_server_hard(self):
        # The server should be power cycled
        if self.run_ssh:
            # Get the time the server was last rebooted,
            resp, server = self.client.get_server(self.server_id)
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            boot_time = linux_client.get_boot_time()

        resp, body = self.client.reboot(self.server_id, "HARD")
        self.assertEqual(202, resp.status)
        self.client.wait_for_server_status(self.server_id, "ACTIVE")

        if self.run_ssh:
            # Log in and verify the boot time has changed
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            new_boot_time = linux_client.get_boot_time()
            self.assertGreater(new_boot_time, boot_time)
Пример #11
0
    def test_reboot_server_soft(self):
        # The server should be signaled to reboot gracefully
        if self.run_ssh:
            # Get the time the server was last rebooted,
            resp, server = self.client.get_server(self.server_id)
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            boot_time = linux_client.get_boot_time()

        resp, body = self.client.reboot(self.server_id, 'SOFT')
        self.assertEqual(202, resp.status)
        self.client.wait_for_server_status(self.server_id, 'ACTIVE')

        if self.run_ssh:
            # Log in and verify the boot time has changed
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            new_boot_time = linux_client.get_boot_time()
            self.assertGreater(new_boot_time, boot_time)
Пример #12
0
    def _ssh_to_server(self, server):
        username = self.config.scenario.ssh_user
        ip = server.networks[self.config.compute.network_for_ssh][0]
        linux_client = RemoteClient(ip,
                                    username,
                                    pkey=self.keypair.private_key)

        return linux_client.ssh_client
Пример #13
0
    def test_reboot_server_soft(self):
        """The server should be signaled to reboot gracefully"""
        if self.run_ssh:
            # Get the time the server was last rebooted,
            # waiting for one minute as who doesn't have seconds precision
            resp, server = self.client.get_server(self.server_id)
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            boot_time = linux_client.get_boot_time()
            time.sleep(60)

        resp, body = self.client.reboot(self.server_id, 'SOFT')
        self.assertEqual(202, resp.status)
        self.client.wait_for_server_status(self.server_id, 'ACTIVE')

        if self.run_ssh:
            # Log in and verify the boot time has changed
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            new_boot_time = linux_client.get_boot_time()
            self.assertGreater(new_boot_time, boot_time)
Пример #14
0
    def test_can_log_into_created_server(self):

        sid = self.stack_identifier
        rid = 'SmokeServer'

        # wait for server resource create to complete.
        self.client.wait_for_resource_status(sid, rid, 'CREATE_COMPLETE')

        resp, body = self.client.get_resource(sid, rid)
        self.assertEqual('CREATE_COMPLETE', body['resource_status'])

        # fetch the IP address from servers client, since we can't get it
        # from the stack until stack create is complete
        resp, server = self.servers_client.get_server(
            body['physical_resource_id'])

        # Check that the user can authenticate with the generated password
        linux_client = RemoteClient(server, 'ec2-user',
                                    pkey=self.keypair['private_key'])
        linux_client.validate_authentication()
Пример #15
0
    def test_can_log_into_created_server(self):

        sid = self.stack_identifier
        rid = 'SmokeServer'

        # wait for server resource create to complete.
        self.client.wait_for_resource_status(sid, rid, 'CREATE_COMPLETE')

        resp, body = self.client.get_resource(sid, rid)
        self.assertEqual('CREATE_COMPLETE', body['resource_status'])

        # fetch the IP address from servers client, since we can't get it
        # from the stack until stack create is complete
        resp, server = self.servers_client.get_server(
            body['physical_resource_id'])

        # Check that the user can authenticate with the generated password
        linux_client = RemoteClient(
            server, 'ec2-user', pkey=self.keypair['private_key'])
        self.assertTrue(linux_client.can_authenticate())
Пример #16
0
 def _remote_client_to_server(self, server_or_ip):
     if isinstance(server_or_ip, basestring):
         ip = server_or_ip
     else:
         network_name_for_ssh = self.config.compute.network_for_ssh
         ip = server_or_ip.networks[network_name_for_ssh][0]
     username = self.config.scenario.ssh_user
     linux_client = RemoteClient(ip,
                                 username,
                                 pkey=self.keypair.private_key)
     return linux_client
Пример #17
0
 def get_remote_client(self, server_or_ip, username=None, private_key=None):
     if isinstance(server_or_ip, basestring):
         ip = server_or_ip
     else:
         network_name_for_ssh = self.config.compute.network_for_ssh
         ip = server_or_ip.networks[network_name_for_ssh][0]
     if username is None:
         username = self.config.scenario.ssh_user
     if private_key is None:
         private_key = self.keypair.private_key
     return RemoteClient(ip, username, pkey=private_key)
Пример #18
0
    def test_attach_detach_volume(self):
        # Stop and Start a server with an attached volume, ensuring that
        # the volume remains attached.
        self._create_and_attach()
        server = self.server
        volume = self.volume

        self.servers_client.stop(server['id'])
        self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

        self.servers_client.start(server['id'])
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

        linux_client = RemoteClient(server, self.image_ssh_user,
                                    server['admin_password'])
        partitions = linux_client.get_partitions()
        self.assertIn(self.device, partitions)

        self._detach(server['id'], volume['id'])
        self.attached = False

        self.servers_client.stop(server['id'])
        self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

        self.servers_client.start(server['id'])
        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

        linux_client = RemoteClient(server, self.image_ssh_user,
                                    server['admin_password'])
        partitions = linux_client.get_partitions()
        self.assertNotIn(self.device, partitions)
Пример #19
0
    def test_attach_detach_volume(self):
        # Stop and Start a server with an attached volume, ensuring that
        # the volume remains attached.
        try:
            self._create_and_attach()
            server = self.server
            volume = self.volume

            self.servers_client.stop(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

            self.servers_client.start(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

            linux_client = RemoteClient(server,
                                        self.ssh_user, server['adminPass'])
            partitions = linux_client.get_partitions()
            self.assertTrue(self.device in partitions)

            self._detach(server['id'], volume['id'])
            self.attached = False

            self.servers_client.stop(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

            self.servers_client.start(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

            linux_client = RemoteClient(server,
                                        self.ssh_user, server['adminPass'])
            partitions = linux_client.get_partitions()
            self.assertFalse(self.device in partitions)
        except Exception:
            self.fail("The test_attach_detach_volume is faild!")
        finally:
            if self.attached:
                self._detach(server['id'], volume['id'])
            # NOTE(maurosr): here we do the cleanup for volume, servers are
            # dealt on BaseComputeTest.tearDownClass
            self._delete(self.volume)
Пример #20
0
    def test_attach_detach_volume(self):
        """
        Stop and Start a server with an attached volume, ensuring that
        the volume remains attached.
        """
        server, volume = self._create_and_attach()

        attached = True

        try:
            self.servers_client.stop(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

            self.servers_client.start(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

            linux_client = RemoteClient(server,
                                        self.ssh_user, server['adminPass'])
            partitions = linux_client.get_partitions()
            self.assertTrue(self.device in partitions)

            self._detach(server['id'], volume['id'])
            attached = False

            self.servers_client.stop(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

            self.servers_client.start(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

            linux_client = RemoteClient(server,
                                        self.ssh_user, server['adminPass'])
            partitions = linux_client.get_partitions()
            self.assertFalse(self.device in partitions)
        finally:
            if attached:
                self._detach(server['id'], volume['id'])
            self._delete(server['id'], volume['id'])
Пример #21
0
    def test_reboot_server_soft(self):
        # The server should be signaled to reboot gracefully
        if self.run_ssh:
            # Get the time the server was last rebooted,
            resp, server = self.client.get_server(self.server_id)
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            boot_time = linux_client.get_boot_time()

        resp, body = self.client.reboot(self.server_id, 'SOFT')
        self.assertEqual(202, resp.status)
        self.client.wait_for_server_status(self.server_id, 'ACTIVE')

        if self.run_ssh:
            # Log in and verify the boot time has changed
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            new_boot_time = linux_client.get_boot_time()
            self.assertGreater(new_boot_time, boot_time)
Пример #22
0
    def test_reboot_server_soft(self):
        """The server should be signaled to reboot gracefully"""
        if self.run_ssh:
            # Get the time the server was last rebooted,
            # waiting for one minute as who doesn't have seconds precision
            resp, server = self.client.get_server(self.server_id)
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            boot_time = linux_client.get_boot_time()
            time.sleep(60)

        resp, body = self.client.reboot(self.server_id, 'SOFT')
        self.assertEqual(202, resp.status)
        self.client.wait_for_server_status(self.server_id, 'ACTIVE')

        if self.run_ssh:
            # Log in and verify the boot time has changed
            linux_client = RemoteClient(server, self.ssh_user, self.password)
            new_boot_time = linux_client.get_boot_time()
            self.assertGreater(new_boot_time, boot_time)
Пример #23
0
    def test_attach_detach_volume(self):
        # Stop and Start a server with an attached volume, ensuring that
        # the volume remains attached.
        try:
            self._create_and_attach()
            server = self.server
            volume = self.volume

            self.servers_client.stop(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

            self.servers_client.start(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

            linux_client = RemoteClient(server, self.ssh_user,
                                        server['adminPass'])
            partitions = linux_client.get_partitions()
            self.assertTrue(self.device in partitions)

            self._detach(server['id'], volume['id'])
            self.attached = False

            self.servers_client.stop(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

            self.servers_client.start(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

            linux_client = RemoteClient(server, self.ssh_user,
                                        server['adminPass'])
            partitions = linux_client.get_partitions()
            self.assertFalse(self.device in partitions)
        except Exception:
            self.fail("The test_attach_detach_volume is faild!")
        finally:
            if self.attached:
                self._detach(server['id'], volume['id'])
            # NOTE(maurosr): here we do the cleanup for volume, servers are
            # dealt on BaseComputeTest.tearDownClass
            self._delete(self.volume)
Пример #24
0
    def test_attach_detach_volume(self):
        """
        Stop and Start a server with an attached volume, ensuring that
        the volume remains attached.
        """
        server, volume = self._create_and_attach()

        attached = True

        try:
            self.servers_client.stop(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

            self.servers_client.start(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

            linux_client = RemoteClient(server, self.ssh_user,
                                        server['adminPass'])
            partitions = linux_client.get_partitions()
            self.assertTrue(self.device in partitions)

            self._detach(server['id'], volume['id'])
            attached = False

            self.servers_client.stop(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')

            self.servers_client.start(server['id'])
            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')

            linux_client = RemoteClient(server, self.ssh_user,
                                        server['adminPass'])
            partitions = linux_client.get_partitions()
            self.assertFalse(self.device in partitions)
        finally:
            if attached:
                self._detach(server['id'], volume['id'])
            self._delete(server['id'], volume['id'])
Пример #25
0
 def test_host_name_is_same_as_server_name(self):
     # Verify the instance host name is the same as the server name
     linux_client = RemoteClient(self.server, self.ssh_user, self.password)
     self.assertTrue(linux_client.hostname_equals_servername(self.name))
Пример #26
0
 def ssh_to_server(self):
     username = self.config.scenario.ssh_user
     self.linux_client = RemoteClient(self.floating_ip.ip,
                                      username,
                                      pkey=self.keypair.private_key)
Пример #27
0
class TestMinimumBasicScenario(manager.OfficialClientTest):

    """
    This is a basic minimum scenario test.

    This test below:
    * across the multiple components
    * as a regular user
    * with and without optional parameters
    * check command outputs

    """

    def _wait_for_server_status(self, status):
        server_id = self.server.id
        self.status_timeout(
            self.compute_client.servers, server_id, status)

    def _wait_for_volume_status(self, status):
        volume_id = self.volume.id
        self.status_timeout(
            self.volume_client.volumes, volume_id, status)

    def _image_create(self, name, fmt, path, properties={}):
        name = rand_name('%s-' % name)
        image_file = open(path, 'rb')
        self.addCleanup(image_file.close)
        params = {
            'name': name,
            'container_format': fmt,
            'disk_format': fmt,
            'is_public': 'True',
        }
        params.update(properties)
        image = self.image_client.images.create(**params)
        self.addCleanup(self.image_client.images.delete, image)
        self.assertEqual("queued", image.status)
        image.update(data=image_file)
        return image.id

    def glance_image_create(self):
        aki_img_path = self.config.scenario.img_dir + "/" + \
            self.config.scenario.aki_img_file
        ari_img_path = self.config.scenario.img_dir + "/" + \
            self.config.scenario.ari_img_file
        ami_img_path = self.config.scenario.img_dir + "/" + \
            self.config.scenario.ami_img_file
        LOG.debug("paths: ami: %s, ari: %s, aki: %s"
                  % (ami_img_path, ari_img_path, aki_img_path))
        kernel_id = self._image_create('scenario-aki', 'aki', aki_img_path)
        ramdisk_id = self._image_create('scenario-ari', 'ari', ari_img_path)
        properties = {
            'properties': {'kernel_id': kernel_id, 'ramdisk_id': ramdisk_id}
        }
        self.image = self._image_create('scenario-ami', 'ami',
                                        path=ami_img_path,
                                        properties=properties)

    def nova_keypair_add(self):
        name = rand_name('scenario-keypair-')

        self.keypair = self.compute_client.keypairs.create(name=name)
        self.addCleanup(self.compute_client.keypairs.delete, self.keypair)
        self.assertEqual(name, self.keypair.name)

    def nova_boot(self):
        name = rand_name('scenario-server-')
        client = self.compute_client
        flavor_id = self.config.compute.flavor_ref
        self.server = client.servers.create(name=name, image=self.image,
                                            flavor=flavor_id,
                                            key_name=self.keypair.name)
        self.addCleanup(self.compute_client.servers.delete, self.server)
        self.assertEqual(name, self.server.name)
        self._wait_for_server_status('ACTIVE')

    def nova_list(self):
        servers = self.compute_client.servers.list()
        LOG.debug("server_list:%s" % servers)
        self.assertIn(self.server, servers)

    def nova_show(self):
        got_server = self.compute_client.servers.get(self.server)
        LOG.debug("got server:%s" % got_server)
        self.assertEqual(self.server, got_server)

    def cinder_create(self):
        name = rand_name('scenario-volume-')
        LOG.debug("volume display-name:%s" % name)
        self.volume = self.volume_client.volumes.create(size=1,
                                                        display_name=name)
        LOG.debug("volume created:%s" % self.volume.display_name)
        self._wait_for_volume_status('available')

        self.addCleanup(self.volume_client.volumes.delete, self.volume)
        self.assertEqual(name, self.volume.display_name)

    def cinder_list(self):
        volumes = self.volume_client.volumes.list()
        self.assertIn(self.volume, volumes)

    def cinder_show(self):
        volume = self.volume_client.volumes.get(self.volume.id)
        self.assertEqual(self.volume, volume)

    def nova_volume_attach(self):
        attach_volume_client = self.compute_client.volumes.create_server_volume
        volume = attach_volume_client(self.server.id,
                                      self.volume.id,
                                      '/dev/vdb')
        self.assertEqual(self.volume.id, volume.id)
        self._wait_for_volume_status('in-use')

    def nova_reboot(self):
        self.server.reboot()
        self._wait_for_server_status('ACTIVE')

    def nova_floating_ip_create(self):
        self.floating_ip = self.compute_client.floating_ips.create()
        self.addCleanup(self.floating_ip.delete)

    def nova_floating_ip_add(self):
        self.server.add_floating_ip(self.floating_ip)

    def nova_security_group_rule_create(self):
        sgs = self.compute_client.security_groups.list()
        for sg in sgs:
            if sg.name == 'default':
                secgroup = sg

        ruleset = {
            # ssh
            'ip_protocol': 'tcp',
            'from_port': 22,
            'to_port': 22,
            'cidr': '0.0.0.0/0',
            'group_id': None
        }
        sg_rule = self.compute_client.security_group_rules.create(secgroup.id,
                                                                  **ruleset)
        self.addCleanup(self.compute_client.security_group_rules.delete,
                        sg_rule.id)

    def ssh_to_server(self):
        username = self.config.scenario.ssh_user
        self.linux_client = RemoteClient(self.floating_ip.ip,
                                         username,
                                         pkey=self.keypair.private_key)

    def check_partitions(self):
        partitions = self.linux_client.get_partitions()
        self.assertEqual(1, partitions.count('vdb'))

    def nova_volume_detach(self):
        detach_volume_client = self.compute_client.volumes.delete_server_volume
        detach_volume_client(self.server.id, self.volume.id)
        self._wait_for_volume_status('available')

        volume = self.volume_client.volumes.get(self.volume.id)
        self.assertEqual('available', volume.status)

    def test_minimum_basic_scenario(self):
        self.glance_image_create()
        self.nova_keypair_add()
        self.nova_boot()
        self.nova_list()
        self.nova_show()
        self.cinder_create()
        self.cinder_list()
        self.cinder_show()
        self.nova_volume_attach()
        self.cinder_show()
        self.nova_reboot()

        self.nova_floating_ip_create()
        self.nova_floating_ip_add()
        self.nova_security_group_rule_create()
        self.ssh_to_server()
        self.check_partitions()

        self.nova_volume_detach()
Пример #28
0
class TestMinimumBasicScenario(manager.OfficialClientTest):

    """
    This is a basic minimum scenario test.

    This test below:
    * across the multiple components
    * as a regular user
    * with and without optional parameters
    * check command outputs

    """

    def _wait_for_server_status(self, status):
        server_id = self.server.id
        self.status_timeout(
            self.compute_client.servers, server_id, status)

    def _wait_for_volume_status(self, status):
        volume_id = self.volume.id
        self.status_timeout(
            self.volume_client.volumes, volume_id, status)

    def _image_create(self, name, fmt, path, properties={}):
        name = rand_name('%s-' % name)
        image_file = open(path, 'rb')
        self.addCleanup(image_file.close)
        params = {
            'name': name,
            'container_format': fmt,
            'disk_format': fmt,
            'is_public': 'True',
        }
        params.update(properties)
        image = self.image_client.images.create(**params)
        self.addCleanup(self.image_client.images.delete, image)
        self.assertEqual("queued", image.status)
        image.update(data=image_file)
        return image.id

    def glance_image_create(self):
        aki_img_path = self.config.scenario.img_dir + "/" + \
            self.config.scenario.aki_img_file
        ari_img_path = self.config.scenario.img_dir + "/" + \
            self.config.scenario.ari_img_file
        ami_img_path = self.config.scenario.img_dir + "/" + \
            self.config.scenario.ami_img_file
        LOG.debug("paths: ami: %s, ari: %s, aki: %s"
                  % (ami_img_path, ari_img_path, aki_img_path))
        kernel_id = self._image_create('scenario-aki', 'aki', aki_img_path)
        ramdisk_id = self._image_create('scenario-ari', 'ari', ari_img_path)
        properties = {
            'properties': {'kernel_id': kernel_id, 'ramdisk_id': ramdisk_id}
        }
        self.image = self._image_create('scenario-ami', 'ami',
                                        path=ami_img_path,
                                        properties=properties)

    def nova_keypair_add(self):
        name = rand_name('scenario-keypair-')

        self.keypair = self.compute_client.keypairs.create(name=name)
        self.addCleanup(self.compute_client.keypairs.delete, self.keypair)
        self.assertEqual(name, self.keypair.name)

    def nova_boot(self):
        name = rand_name('scenario-server-')
        client = self.compute_client
        flavor_id = self.config.compute.flavor_ref
        self.server = client.servers.create(name=name, image=self.image,
                                            flavor=flavor_id,
                                            key_name=self.keypair.name)
        self.addCleanup(self.compute_client.servers.delete, self.server)
        self.assertEqual(name, self.server.name)
        self._wait_for_server_status('ACTIVE')

    def nova_list(self):
        servers = self.compute_client.servers.list()
        LOG.debug("server_list:%s" % servers)
        self.assertTrue(self.server in servers)

    def nova_show(self):
        got_server = self.compute_client.servers.get(self.server)
        LOG.debug("got server:%s" % got_server)
        self.assertEqual(self.server, got_server)

    def cinder_create(self):
        name = rand_name('scenario-volume-')
        LOG.debug("volume display-name:%s" % name)
        self.volume = self.volume_client.volumes.create(size=1,
                                                        display_name=name)
        LOG.debug("volume created:%s" % self.volume.display_name)
        self._wait_for_volume_status('available')

        self.addCleanup(self.volume_client.volumes.delete, self.volume)
        self.assertEqual(name, self.volume.display_name)

    def cinder_list(self):
        volumes = self.volume_client.volumes.list()
        self.assertTrue(self.volume in volumes)

    def cinder_show(self):
        volume = self.volume_client.volumes.get(self.volume.id)
        self.assertEqual(self.volume, volume)

    def nova_volume_attach(self):
        attach_volume_client = self.compute_client.volumes.create_server_volume
        volume = attach_volume_client(self.server.id,
                                      self.volume.id,
                                      '/dev/vdb')
        self.assertEqual(self.volume.id, volume.id)
        self._wait_for_volume_status('in-use')

    def nova_reboot(self):
        self.server.reboot()
        self._wait_for_server_status('ACTIVE')

    def nova_floating_ip_create(self):
        self.floating_ip = self.compute_client.floating_ips.create()
        self.addCleanup(self.floating_ip.delete)

    def nova_floating_ip_add(self):
        self.server.add_floating_ip(self.floating_ip)

    def nova_security_group_rule_create(self):
        sgs = self.compute_client.security_groups.list()
        for sg in sgs:
            if sg.name == 'default':
                secgroup = sg

        ruleset = {
            # ssh
            'ip_protocol': 'tcp',
            'from_port': 22,
            'to_port': 22,
            'cidr': '0.0.0.0/0',
            'group_id': None
        }
        sg_rule = self.compute_client.security_group_rules.create(secgroup.id,
                                                                  **ruleset)
        self.addCleanup(self.compute_client.security_group_rules.delete,
                        sg_rule.id)

    def ssh_to_server(self):
        username = self.config.scenario.ssh_user
        self.linux_client = RemoteClient(self.floating_ip.ip,
                                         username,
                                         pkey=self.keypair.private_key)

    def check_partitions(self):
        partitions = self.linux_client.get_partitions()
        self.assertEqual(1, partitions.count('vdb'))

    def nova_volume_detach(self):
        detach_volume_client = self.compute_client.volumes.delete_server_volume
        detach_volume_client(self.server.id, self.volume.id)
        self._wait_for_volume_status('available')

        volume = self.volume_client.volumes.get(self.volume.id)
        self.assertEqual('available', volume.status)

    def test_minimum_basic_scenario(self):
        self.glance_image_create()
        self.nova_keypair_add()
        self.nova_boot()
        self.nova_list()
        self.nova_show()
        self.cinder_create()
        self.cinder_list()
        self.cinder_show()
        self.nova_volume_attach()
        self.cinder_show()
        self.nova_reboot()

        self.nova_floating_ip_create()
        self.nova_floating_ip_add()
        self.nova_security_group_rule_create()
        self.ssh_to_server()
        self.check_partitions()

        self.nova_volume_detach()
Пример #29
0
    def test_verify_created_server_ephemeral_disk(self):
        # Verify that the ephemeral disk is created when creating server

        def create_flavor_with_extra_specs(self):
            flavor_with_eph_disk_name = data_utils.rand_name('eph_flavor')
            flavor_with_eph_disk_id = data_utils.rand_int_id(start=1000)
            ram = 64
            vcpus = 1
            disk = 0

            # Create a flavor with extra specs
            resp, flavor = (self.flavor_client.
                            create_flavor(flavor_with_eph_disk_name,
                                          ram, vcpus, disk,
                                          flavor_with_eph_disk_id,
                                          ephemeral=1))
            self.addCleanup(self.flavor_clean_up, flavor['id'])
            self.assertEqual(200, resp.status)

            return flavor['id']

        def create_flavor_without_extra_specs(self):
            flavor_no_eph_disk_name = data_utils.rand_name('no_eph_flavor')
            flavor_no_eph_disk_id = data_utils.rand_int_id(start=1000)

            ram = 64
            vcpus = 1
            disk = 0

            # Create a flavor without extra specs
            resp, flavor = (self.flavor_client.
                            create_flavor(flavor_no_eph_disk_name,
                                          ram, vcpus, disk,
                                          flavor_no_eph_disk_id))
            self.addCleanup(self.flavor_clean_up, flavor['id'])
            self.assertEqual(200, resp.status)

            return flavor['id']

        def flavor_clean_up(self, flavor_id):
            resp, body = self.flavor_client.delete_flavor(flavor_id)
            self.assertEqual(resp.status, 202)
            self.flavor_client.wait_for_resource_deletion(flavor_id)

        flavor_with_eph_disk_id = self.create_flavor_with_extra_specs()
        flavor_no_eph_disk_id = self.create_flavor_without_extra_specs()

        admin_pass = self.image_ssh_password

        resp, server_no_eph_disk = (self.
                                    create_test_server(
                                    wait_until='ACTIVE',
                                    adminPass=admin_pass,
                                    flavor=flavor_no_eph_disk_id))
        resp, server_with_eph_disk = (self.create_test_server(
                                      wait_until='ACTIVE',
                                      adminPass=admin_pass,
                                      flavor=flavor_with_eph_disk_id))
        # Get partition number of server without extra specs.
        linux_client = RemoteClient(server_no_eph_disk,
                                    self.ssh_user, self.password)
        partition_num = len(linux_client.get_partitions())

        linux_client = RemoteClient(server_with_eph_disk,
                                    self.ssh_user, self.password)
        self.assertEqual(partition_num + 1, linux_client.get_partitions())
Пример #30
0
    def test_integration_1(self):
        # EC2 1. integration test (not strict)
        image_ami = self.ec2_client.get_image(self.images["ami"]["image_id"])
        sec_group_name = data_utils.rand_name("securitygroup-")
        group_desc = sec_group_name + " security group description "
        security_group = self.ec2_client.create_security_group(sec_group_name,
                                                               group_desc)
        self.addResourceCleanUp(self.destroy_security_group_wait,
                                security_group)
        self.assertTrue(
            self.ec2_client.authorize_security_group(
                sec_group_name,
                ip_protocol="icmp",
                cidr_ip="0.0.0.0/0",
                from_port=-1,
                to_port=-1))
        self.assertTrue(
            self.ec2_client.authorize_security_group(
                sec_group_name,
                ip_protocol="tcp",
                cidr_ip="0.0.0.0/0",
                from_port=22,
                to_port=22))
        reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
                                    ramdisk_id=self.images["ari"]["image_id"],
                                    instance_type=self.instance_type,
                                    key_name=self.keypair_name,
                                    security_groups=(sec_group_name,))
        self.addResourceCleanUp(self.destroy_reservation,
                                reservation)
        volume = self.ec2_client.create_volume(1, self.zone)
        self.addResourceCleanUp(self.destroy_volume_wait, volume)
        instance = reservation.instances[0]
        LOG.info("state: %s", instance.state)
        if instance.state != "running":
            self.assertInstanceStateWait(instance, "running")

        address = self.ec2_client.allocate_address()
        rcuk_a = self.addResourceCleanUp(address.delete)
        self.assertTrue(address.associate(instance.id))

        rcuk_da = self.addResourceCleanUp(address.disassociate)
        # TODO(afazekas): ping test. dependecy/permission ?

        self.assertVolumeStatusWait(volume, "available")
        # NOTE(afazekas): it may be reports availble before it is available

        ssh = RemoteClient(address.public_ip,
                           CONF.compute.ssh_user,
                           pkey=self.keypair.material)
        text = data_utils.rand_name("Pattern text for console output -")
        resp = ssh.write_to_console(text)
        self.assertFalse(resp)

        def _output():
            output = instance.get_console_output()
            return output.output

        re_search_wait(_output, text)
        part_lines = ssh.get_partitions().split('\n')
        volume.attach(instance.id, "/dev/vdh")

        def _volume_state():
            volume.update(validate=True)
            return volume.status

        self.assertVolumeStatusWait(_volume_state, "in-use")
        re_search_wait(_volume_state, "in-use")

        # NOTE(afazekas):  Different Hypervisor backends names
        # differently the devices,
        # now we just test is the partition number increased/decrised

        def _part_state():
            current = ssh.get_partitions().split('\n')
            if current > part_lines:
                return 'INCREASE'
            if current < part_lines:
                return 'DECREASE'
            return 'EQUAL'

        state_wait(_part_state, 'INCREASE')
        part_lines = ssh.get_partitions().split('\n')

        # TODO(afazekas): Resource compare to the flavor settings

        volume.detach()

        self.assertVolumeStatusWait(_volume_state, "available")
        re_search_wait(_volume_state, "available")
        LOG.info("Volume %s state: %s", volume.id, volume.status)

        state_wait(_part_state, 'DECREASE')

        instance.stop()
        address.disassociate()
        self.assertAddressDissasociatedWait(address)
        self.cancelResourceCleanUp(rcuk_da)
        address.release()
        self.assertAddressReleasedWait(address)
        self.cancelResourceCleanUp(rcuk_a)

        LOG.info("state: %s", instance.state)
        if instance.state != "stopped":
            self.assertInstanceStateWait(instance, "stopped")
class OrchestrationVMwithMetadata(nuage_base.NuageBaseOrchestrationTest,
                                  NuageBaseTest):
    @classmethod
    def skip_checks(cls):
        super(OrchestrationVMwithMetadata, cls).skip_checks()
        if not CONF.compute_feature_enabled.metadata_service:
            raise cls.skipException('Test requires functional metadata agent')

    @classmethod
    def setup_credentials(cls):
        cls.set_network_resources()
        super(OrchestrationVMwithMetadata, cls).setup_credentials()

    @classmethod
    def setup_clients(cls):
        super(OrchestrationVMwithMetadata, cls).setup_clients()
        cls.floating_ips_client = cls.os_admin.floating_ips_client

    @decorators.attr(type='smoke')
    def test_metadata_agent_on_concurrent_deployment(self):
        """Verifies created neutron resources."""
        neutron_basic_template = self.load_template(
            'concurrent_deployment_of_vms_with_fip')
        keypair = self.create_keypair(manager=self.admin_manager)
        stack_name = data_utils.rand_name('heat')
        user_data = '#!/bin/sh\necho "pass" > /tmp/userdata.out'
        template = self.read_template('concurrent_deployment_of_vms_with_fip')
        network_name = data_utils.rand_name('priv_net')
        parameters = {
            'public_net': CONF.network.public_network_id,
            'private_net_name': network_name,
            'private_net_cidr': '97.0.0.0/24',
            'private_net_gateway': '97.0.0.1',
            'private_net_pool_start': '97.0.0.5',
            'private_net_pool_end': '97.0.0.100',
            'image': CONF.compute.image_ref,
            'flavor': CONF.compute.flavor_ref,
            'key_name': keypair['name'],
            'user_data': user_data
        }
        # create the stack
        stack_identifier = self.create_stack(stack_name, template, parameters)
        stack_id = stack_identifier.split('/')[1]

        self.client.wait_for_stack_status(stack_id, 'CREATE_COMPLETE')
        resources = (self.client.list_resources(stack_identifier)['resources'])

        test_resources = {}
        for resource in resources:
            test_resources[resource['logical_resource_id']] = resource

        resources = [
            ('vm1', neutron_basic_template['resources']['vm1']['type']),
            ('vm2', neutron_basic_template['resources']['vm2']['type']),
            ('vm3', neutron_basic_template['resources']['vm3']['type']),
            ('vm4', neutron_basic_template['resources']['vm4']['type']),
            ('vm5', neutron_basic_template['resources']['vm5']['type']),
            ('vm6', neutron_basic_template['resources']['vm6']['type']),
            ('vm7', neutron_basic_template['resources']['vm7']['type'])
        ]

        for resource_name, resource_type in resources:
            resource = test_resources.get(resource_name, None)
            server = NuageBaseTest.get_server(
                self,
                server_id=resource['physical_resource_id'],
                manager=self.admin_manager)
            fip = None
            for net in server['addresses'][network_name]:
                if net['OS-EXT-IPS:type'] == 'floating':
                    fip = net['addr']
            self.fip_acs = RemoteClient(
                ip_address=fip,
                username=CONF.validation.image_ssh_user,
                pkey=keypair['private_key'])
            self.assertTrue(
                test_utils.call_until_true(self.is_userdata_ready, 300, 30))
        self._clear_stacks()

    def is_userdata_ready(self):
        try:
            return 'pass' in self.fip_acs.exec_command('cat /tmp/userdata.out')
        except exceptions.SSHExecCommandFailed:
            return False
Пример #32
0
class TestMinimumBasicScenario(manager.OfficialClientTest):

    """
    This is a basic minimum scenario test.

    This test below:
    * across the multiple components
    * as a regular user
    * with and without optional parameters
    * check command outputs

    """

    def _wait_for_server_status(self, status):
        server_id = self.server.id
        self.status_timeout(self.compute_client.servers, server_id, status)

    def _wait_for_volume_status(self, status):
        volume_id = self.volume.id
        self.status_timeout(self.volume_client.volumes, volume_id, status)

    def _image_create(self, name, fmt, path, properties={}):
        name = rand_name("%s-" % name)
        image_file = open(path, "rb")
        self.addCleanup(image_file.close)
        params = {"name": name, "container_format": fmt, "disk_format": fmt, "is_public": "True"}
        params.update(properties)
        image = self.image_client.images.create(**params)
        self.addCleanup(self.image_client.images.delete, image)
        self.assertEqual("queued", image.status)
        image.update(data=image_file)
        return image.id

    def glance_image_create(self):
        aki_img_path = self.config.scenario.img_dir + "/" + self.config.scenario.aki_img_file
        ari_img_path = self.config.scenario.img_dir + "/" + self.config.scenario.ari_img_file
        ami_img_path = self.config.scenario.img_dir + "/" + self.config.scenario.ami_img_file
        LOG.debug("paths: ami: %s, ari: %s, aki: %s" % (ami_img_path, ari_img_path, aki_img_path))
        kernel_id = self._image_create("scenario-aki", "aki", aki_img_path)
        ramdisk_id = self._image_create("scenario-ari", "ari", ari_img_path)
        properties = {"properties": {"kernel_id": kernel_id, "ramdisk_id": ramdisk_id}}
        self.image = self._image_create("scenario-ami", "ami", path=ami_img_path, properties=properties)

    def nova_keypair_add(self):
        name = rand_name("scenario-keypair-")

        self.keypair = self.compute_client.keypairs.create(name=name)
        self.addCleanup(self.compute_client.keypairs.delete, self.keypair)
        self.assertEqual(name, self.keypair.name)

    def nova_boot(self):
        name = rand_name("scenario-server-")
        client = self.compute_client
        flavor_id = self.config.compute.flavor_ref
        self.server = client.servers.create(name=name, image=self.image, flavor=flavor_id, key_name=self.keypair.name)
        self.addCleanup(self.compute_client.servers.delete, self.server)
        self.assertEqual(name, self.server.name)
        self._wait_for_server_status("ACTIVE")

    def nova_list(self):
        servers = self.compute_client.servers.list()
        LOG.debug("server_list:%s" % servers)
        self.assertTrue(self.server in servers)

    def nova_show(self):
        got_server = self.compute_client.servers.get(self.server)
        LOG.debug("got server:%s" % got_server)
        self.assertEqual(self.server, got_server)

    def cinder_create(self):
        name = rand_name("scenario-volume-")
        LOG.debug("volume display-name:%s" % name)
        self.volume = self.volume_client.volumes.create(size=1, display_name=name)
        LOG.debug("volume created:%s" % self.volume.display_name)
        self._wait_for_volume_status("available")

        self.addCleanup(self.volume_client.volumes.delete, self.volume)
        self.assertEqual(name, self.volume.display_name)

    def cinder_list(self):
        volumes = self.volume_client.volumes.list()
        self.assertTrue(self.volume in volumes)

    def cinder_show(self):
        volume = self.volume_client.volumes.get(self.volume.id)
        self.assertEqual(self.volume, volume)

    def nova_volume_attach(self):
        attach_volume_client = self.compute_client.volumes.create_server_volume
        volume = attach_volume_client(self.server.id, self.volume.id, "/dev/vdb")
        self.assertEqual(self.volume.id, volume.id)
        self._wait_for_volume_status("in-use")

    def nova_reboot(self):
        self.server.reboot()
        self._wait_for_server_status("ACTIVE")

    def nova_floating_ip_create(self):
        self.floating_ip = self.compute_client.floating_ips.create()
        self.addCleanup(self.floating_ip.delete)

    def nova_floating_ip_add(self):
        self.server.add_floating_ip(self.floating_ip)

    def nova_security_group_rule_create(self):
        sgs = self.compute_client.security_groups.list()
        for sg in sgs:
            if sg.name == "default":
                secgroup = sg

        ruleset = {
            # ssh
            "ip_protocol": "tcp",
            "from_port": 22,
            "to_port": 22,
            "cidr": "0.0.0.0/0",
            "group_id": None,
        }
        sg_rule = self.compute_client.security_group_rules.create(secgroup.id, **ruleset)
        self.addCleanup(self.compute_client.security_group_rules.delete, sg_rule.id)

    def ssh_to_server(self):
        username = self.config.scenario.ssh_user
        self.linux_client = RemoteClient(self.floating_ip.ip, username, pkey=self.keypair.private_key)

    def check_partitions(self):
        partitions = self.linux_client.get_partitions()
        self.assertEqual(1, partitions.count("vdb"))

    def nova_volume_detach(self):
        detach_volume_client = self.compute_client.volumes.delete_server_volume
        detach_volume_client(self.server.id, self.volume.id)
        self._wait_for_volume_status("available")

        volume = self.volume_client.volumes.get(self.volume.id)
        self.assertEqual("available", volume.status)

    def test_minimum_basic_scenario(self):
        self.glance_image_create()
        self.nova_keypair_add()
        self.nova_boot()
        self.nova_list()
        self.nova_show()
        self.cinder_create()
        self.cinder_list()
        self.cinder_show()
        self.nova_volume_attach()
        self.cinder_show()
        self.nova_reboot()

        self.nova_floating_ip_create()
        self.nova_floating_ip_add()
        self.nova_security_group_rule_create()
        self.ssh_to_server()
        self.check_partitions()

        self.nova_volume_detach()
Пример #33
0
 def ssh_to_server(self):
     username = self.config.scenario.ssh_user
     self.linux_client = RemoteClient(self.floating_ip.ip, username, pkey=self.keypair.private_key)
Пример #34
0
 def test_can_log_into_created_server(self):
     # Check that the user can authenticate with the generated password
     linux_client = RemoteClient(self.server, self.ssh_user, self.password)
     self.assertTrue(linux_client.can_authenticate())
Пример #35
0
 def _check_ssh_connectivity(self, ip_address, username, pkey):
     ssh_client = RemoteClient(ip_address, username, pkey=pkey)
     self.assertTrue(ssh_client.can_authenticate())
Пример #36
0
    def test_verify_created_server_ephemeral_disk(self):
        # Verify that the ephemeral disk is created when creating server

        def create_flavor_with_extra_specs(self):
            flavor_with_eph_disk_name = data_utils.rand_name('eph_flavor')
            flavor_with_eph_disk_id = data_utils.rand_int_id(start=1000)
            ram = 512
            vcpus = 1
            disk = 10

            # Create a flavor with extra specs
            resp, flavor = (self.flavor_client.create_flavor(
                flavor_with_eph_disk_name,
                ram,
                vcpus,
                disk,
                flavor_with_eph_disk_id,
                ephemeral=1,
                swap=1024,
                rxtx=1))
            self.addCleanup(self.flavor_clean_up, flavor['id'])
            self.assertEqual(200, resp.status)

            return flavor['id']

        def create_flavor_without_extra_specs(self):
            flavor_no_eph_disk_name = data_utils.rand_name('no_eph_flavor')
            flavor_no_eph_disk_id = data_utils.rand_int_id(start=1000)

            ram = 512
            vcpus = 1
            disk = 10

            # Create a flavor without extra specs
            resp, flavor = (self.flavor_client.create_flavor(
                flavor_no_eph_disk_name, ram, vcpus, disk,
                flavor_no_eph_disk_id))
            self.addCleanup(self.flavor_clean_up, flavor['id'])
            self.assertEqual(200, resp.status)

            return flavor['id']

        def flavor_clean_up(self, flavor_id):
            resp, body = self.flavor_client.delete_flavor(flavor_id)
            self.assertEqual(resp.status, 202)
            self.flavor_client.wait_for_resource_deletion(flavor_id)

        flavor_with_eph_disk_id = self.create_flavor_with_extra_specs()
        flavor_no_eph_disk_id = self.create_flavor_without_extra_specs()

        admin_pass = self.image_ssh_password

        resp, server_no_eph_disk = (self.create_test_server(
            wait_until='ACTIVE',
            adminPass=admin_pass,
            flavor=flavor_no_eph_disk_id))
        resp, server_with_eph_disk = (self.create_test_server(
            wait_until='ACTIVE',
            adminPass=admin_pass,
            flavor=flavor_with_eph_disk_id))
        # Get partition number of server without extra specs.
        linux_client = RemoteClient(server_no_eph_disk, self.ssh_user,
                                    self.password)
        partition_num = len(linux_client.get_partitions())

        linux_client = RemoteClient(server_with_eph_disk, self.ssh_user,
                                    self.password)
        self.assertEqual(partition_num + 1, linux_client.get_partitions())