def setUpClass(cls):
        super(AuthorizationTests, cls).setUpClass()
        cls.metadata = {'meta_key_1': 'meta_value_1',
                        'meta_key_2': 'meta_value_2'}
        cls.server = cls.server_behaviors.create_active_server(
            metadata=cls.metadata).entity
        cls.resources.add(cls.server.id, cls.servers_client.delete_server)

        image_name = rand_name('testimage')
        cls.image_meta = {'key1': 'value1', 'key2': 'value2'}
        image_resp = cls.servers_client.create_image(cls.server.id,
                                                     image_name,
                                                     cls.image_meta)
        assert image_resp.status_code == 202
        cls.image_id = cls.parse_image_id(image_resp)
        cls.image_behaviors.wait_for_image_status(
            cls.image_id, NovaImageStatusTypes.ACTIVE)
        cls.resources.add(cls.image_id, cls.images_client.delete_image)

        secondary_user = ComputeAuthorizationConfig()
        access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                   secondary_user)

        compute_service = access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url

        cls.flavors_client = FlavorsClient(url, access_data.token.id_,
                                           'json', 'json')
        cls.servers_client = ServersClient(url, access_data.token.id_,
                                           'json', 'json')
        cls.images_client = ImagesClient(url, access_data.token.id_,
                                         'json', 'json')
        cls.flavors_client.add_exception_handler(ExceptionHandler())
Beispiel #2
0
    def setUpClass(cls):
        super(ComputeAdminFixture, cls).setUpClass()

        # Setup admin client
        auth_config = ComputeAdminAuthConfig()
        user_config = ComputeAdminUserConfig()
        access_data = AuthProvider.get_access_data(auth_config, user_config)
        admin_endpoint_config = ComputeAdminEndpointConfig()
        compute_service = access_data.get_service(
            admin_endpoint_config.compute_endpoint_name)
        url = compute_service.get_endpoint(
            admin_endpoint_config.region).public_url
        cls.admin_flavors_client = FlavorsClient(url, access_data.token.id_,
                                                 'json', 'json')
        cls.admin_servers_client = ServersClient(url, access_data.token.id_,
                                                 'json', 'json')
        cls.admin_server_behaviors = ServerBehaviors(cls.admin_servers_client,
                                                     cls.servers_config,
                                                     cls.images_config,
                                                     cls.flavors_config)
        cls.admin_images_client = ImagesClient(url, access_data.token.id_,
                                               'json', 'json')
        cls.admin_images_behaviors = ImageBehaviors(cls.admin_images_client,
                                                    cls.admin_servers_client,
                                                    cls.images_config)
        cls.admin_hosts_client = HostsClient(url, access_data.token.id_,
                                             'json', 'json')
        cls.admin_quotas_client = QuotasClient(url, access_data.token.id_,
                                               'json', 'json')
        cls.admin_servers_client.add_exception_handler(ExceptionHandler())
Beispiel #3
0
    def setUpClass(cls):
        super(ComputeAdminFixture, cls).setUpClass()

        # Setup admin client
        auth_config = ComputeAdminAuthConfig()
        user_config = ComputeAdminUserConfig()
        access_data = AuthProvider.get_access_data(auth_config,
                                                   user_config)
        admin_endpoint_config = ComputeAdminEndpointConfig()
        compute_service = access_data.get_service(
            admin_endpoint_config.compute_endpoint_name)
        url = compute_service.get_endpoint(
            admin_endpoint_config.region).public_url

        client_args = {'url': url, 'auth_token': access_data.token.id_,
                       'serialize_format': cls.marshalling.serializer,
                       'deserialize_format': cls.marshalling.deserializer}

        cls.admin_flavors_client = FlavorsClient(**client_args)
        cls.admin_servers_client = ServersClient(**client_args)
        cls.admin_images_client = ImagesClient(**client_args)
        cls.admin_hosts_client = HostsClient(**client_args)
        cls.admin_quotas_client = QuotasClient(**client_args)
        cls.admin_hypervisors_client = HypervisorsClient(**client_args)
        cls.admin_server_behaviors = ServerBehaviors(cls.admin_servers_client,
                                                     cls.servers_config,
                                                     cls.images_config,
                                                     cls.flavors_config)
        cls.admin_images_behaviors = ImageBehaviors(cls.admin_images_client,
                                                    cls.admin_servers_client,
                                                    cls.images_config)
        cls.admin_servers_client.add_exception_handler(ExceptionHandler())
Beispiel #4
0
    def setUpClass(cls):
        super(ComputeFixture, cls).setUpClass()
        cls.flavors_config = FlavorsConfig()
        cls.images_config = ImagesConfig()
        cls.servers_config = ServersConfig()
        cls.compute_endpoint = ComputeEndpointConfig()
        cls.marshalling = MarshallingConfig()
        cls.config_drive_config = ConfigDriveConfig()

        cls.flavor_ref = cls.flavors_config.primary_flavor
        cls.flavor_ref_alt = cls.flavors_config.secondary_flavor
        cls.image_ref = cls.images_config.primary_image
        cls.image_ref_alt = cls.images_config.secondary_image
        cls.disk_path = cls.servers_config.instance_disk_path

        cls.endpoint_config = UserAuthConfig()
        cls.user_config = UserConfig()
        access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                   cls.user_config)
        # If authentication fails, halt
        if access_data is None:
            cls.assertClassSetupFailure('Authentication failed.')

        compute_service = access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url
        # If a url override was provided, use that value instead
        if cls.compute_endpoint.compute_endpoint_url:
            url = '{0}/{1}'.format(cls.compute_endpoint.compute_endpoint_url,
                                   cls.user_config.tenant_id)

        client_args = {'url': url, 'auth_token': access_data.token.id_,
                       'serialize_format': cls.marshalling.serializer,
                       'deserialize_format': cls.marshalling.deserializer}

        cls.flavors_client = FlavorsClient(**client_args)
        cls.servers_client = ServersClient(**client_args)
        cls.images_client = ImagesClient(**client_args)
        cls.keypairs_client = KeypairsClient(**client_args)
        cls.security_groups_client = SecurityGroupsClient(**client_args)
        cls.security_group_rule_client = SecurityGroupRulesClient(
            **client_args)
        cls.rescue_client = RescueClient(**client_args)
        cls.vnc_client = VncConsoleClient(**client_args)
        cls.console_output_client = ConsoleOutputClient(**client_args)
        cls.server_behaviors = ServerBehaviors(cls.servers_client,
                                               cls.servers_config,
                                               cls.images_config,
                                               cls.flavors_config)
        cls.image_behaviors = ImageBehaviors(cls.images_client,
                                             cls.servers_client,
                                             cls.images_config)
        cls.config_drive_behaviors = ConfigDriveBehaviors(cls.servers_client,
                                                          cls.servers_config,
                                                          cls.server_behaviors)
        cls.flavors_client.add_exception_handler(ExceptionHandler())
        cls.resources = ResourcePool()
    def setUpClass(cls):
        super(TestFixedIPsMultiple, cls).setUpClass()
        network_name = 'network_{0}'.format(cls.NAMES_PREFIX)
        cls.network = cls.create_server_network(name=network_name, ipv4=True)
        cls.delete_networks.append(cls.network.id)
        keypair_name = 'key_{0}'.format(cls.NAMES_PREFIX)
        cls.keypair = cls.create_keypair(name=keypair_name)
        cls.delete_keypairs.append(cls.keypair.name)
        svr_name = 'svr_{0}'.format(cls.NAMES_PREFIX)
        network_ids = [
            cls.public_network_id, cls.service_network_id, cls.network.id
        ]
        cls.server = cls.create_test_server(name=svr_name,
                                            key_name=cls.keypair.name,
                                            network_ids=network_ids,
                                            active_server=False)
        cls.server_persona = ServerPersona(server=cls.server,
                                           pnet=True,
                                           snet=True,
                                           inet=True,
                                           pnet_fix_ipv4_count=1,
                                           snet_fix_ipv4_count=1,
                                           inet_fix_ipv4_count=1,
                                           network=cls.network,
                                           keypair=cls.keypair,
                                           ssh_username='******')
        server_ids = [cls.server_persona.server.id]
        cls.delete_servers.extend(server_ids)

        cls.pub_net_id = cls.public_network_id
        cls.pri_net_id = cls.service_network_id
        cls.iso_net_id = cls.network.id
        cls.initial_pub_ip = cls.server_persona.pnet_fix_ipv4
        cls.initial_pri_ip = cls.server_persona.snet_fix_ipv4
        cls.initial_iso_ip = cls.server_persona.inet_fix_ipv4
        # Initial IPv4 counts, update as needed if using a specific server
        cls.ini_ips_count = 1
        # Multiple fixed IPs to add
        cls.FIXED_IPS_TO_ADD = cls.net.config.multiple_fixed_ips_to_add

        admin_user = ComputeAdminUserConfig()
        compute_admin_endpoint = ComputeAdminEndpointConfig()
        auth_endpoint_config = ComputeAdminAuthConfig()
        access_data = AuthProvider.get_access_data(auth_endpoint_config,
                                                   admin_user)
        compute_service = access_data.get_service(
            compute_admin_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            compute_admin_endpoint.region).public_url
        cls.servers_client = ServersClient(url, access_data.token.id_, 'json',
                                           'json')

        cls.add_msg = ('Unable to add a {0} network fixed IP to server {1} '
                       'Response: {2}')
        cls.rem_msg = ('Unable to remove a {0} network fixed IP of server {1} '
                       'Response: {2}')
Beispiel #6
0
    def setUpClass(cls):
        super(ComputeFixture, cls).setUpClass()
        cls.flavors_config = FlavorsConfig()
        cls.images_config = ImagesConfig()
        cls.servers_config = ServersConfig()
        cls.compute_endpoint = ComputeEndpointConfig()

        cls.flavor_ref = cls.flavors_config.primary_flavor
        cls.flavor_ref_alt = cls.flavors_config.secondary_flavor
        cls.image_ref = cls.images_config.primary_image
        cls.image_ref_alt = cls.images_config.secondary_image
        cls.disk_path = cls.servers_config.instance_disk_path

        cls.endpoint_config = UserAuthConfig()
        user_config = UserConfig()
        access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                   user_config)

        compute_service = access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url
        cls.flavors_client = FlavorsClient(url, access_data.token.id_, 'json',
                                           'json')
        cls.servers_client = ServersClient(url, access_data.token.id_, 'json',
                                           'json')
        cls.images_client = ImagesClient(url, access_data.token.id_, 'json',
                                         'json')
        cls.keypairs_client = KeypairsClient(url, access_data.token.id_,
                                             'json', 'json')
        cls.sec_groups_client = SecurityGroupsClient(url,
                                                     access_data.token.id_,
                                                     'json', 'json')
        cls.rescue_client = RescueClient(url, access_data.token.id_, 'json',
                                         'json')
        cls.server_behaviors = ServerBehaviors(cls.servers_client,
                                               cls.servers_config,
                                               cls.images_config,
                                               cls.flavors_config)
        cls.image_behaviors = ImageBehaviors(cls.images_client,
                                             cls.servers_client,
                                             cls.images_config)
        cls.flavors_client.add_exception_handler(ExceptionHandler())
        cls.resources = ResourcePool()
Beispiel #7
0
    def setUpClass(cls):
        """
        Perform actions that setup the necessary resources for testing.

        The following resources are created during this setup:
            - Creates an active server with metadata.
            - Creates an image with metadata and waits for active status.
        """
        super(AuthorizationTests, cls).setUpClass()
        cls.metadata = {
            'meta_key_1': 'meta_value_1',
            'meta_key_2': 'meta_value_2'
        }
        cls.server = cls.server_behaviors.create_active_server(
            metadata=cls.metadata).entity
        cls.resources.add(cls.server.id, cls.servers_client.delete_server)

        image_name = rand_name('testimage')
        cls.image_meta = {'user_key1': 'value1', 'user_key2': 'value2'}
        image_resp = cls.servers_client.create_image(cls.server.id, image_name,
                                                     cls.image_meta)
        assert image_resp.status_code == 202
        cls.image_id = cls.parse_image_id(image_resp)
        cls.image_behaviors.wait_for_image_status(cls.image_id,
                                                  NovaImageStatusTypes.ACTIVE)
        cls.resources.add(cls.image_id, cls.images_client.delete_image)

        secondary_user = ComputeAuthorizationConfig()
        compute_endpoint = ComputeEndpointConfig()
        auth_endpoint_config = UserAuthConfig()
        access_data = AuthProvider.get_access_data(auth_endpoint_config,
                                                   secondary_user)

        compute_service = access_data.get_service(
            compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(compute_endpoint.region).public_url

        cls.flavors_client = FlavorsClient(url, access_data.token.id_, 'json',
                                           'json')
        cls.servers_client = ServersClient(url, access_data.token.id_, 'json',
                                           'json')
        cls.images_client = ImagesClient(url, access_data.token.id_, 'json',
                                         'json')
        cls.flavors_client.add_exception_handler(ExceptionHandler())
Beispiel #8
0
 def __init__(self):
     self.compute_auth_composite = _ComputeAuthComposite()
     self.config = ServersConfig()
     self.client = ServersClient(**self.compute_auth_composite.client_args)
     self.behaviors = None
Beispiel #9
0
    def setUpClass(cls):
        super(ImagesIntegrationFixture, cls).setUpClass()
        cls.object_storage_client = cls.client
        cls.object_storage_behaviors = cls.behaviors

        # Work around to create compute/obj storage additional user composites
        auth_endpoint_config = UserAuthConfig()
        compute_endpoint = ComputeEndpointConfig()
        images_config = ImagesConfig()
        flavors_config = FlavorsConfig()
        marshalling_config = MarshallingConfig()
        object_storage_config = ObjectStorageConfig()
        object_storage_api_config = ObjectStorageAPIConfig()
        servers_config = ServersConfig()
        user_config_alt_one = AltOneUserConfig()

        access_data_alt_one = AuthProvider.get_access_data(
            auth_endpoint_config, user_config_alt_one)

        # Create compute clients and behaviors for alt_one user
        compute_service_alt_one = access_data_alt_one.get_service(
            compute_endpoint.compute_endpoint_name)
        compute_url_check_alt_one = compute_service_alt_one.get_endpoint(
            compute_endpoint.region)
        # If compute endpoint validation fails, fail immediately
        if compute_url_check_alt_one is None:
            cls.assertClassSetupFailure('Compute endpoint validation failed')
        compute_url_alt_one = compute_service_alt_one.get_endpoint(
            compute_endpoint.region).public_url

        cls.compute_alt_one_images_client = ComputeImagesClient(
            compute_url_alt_one, access_data_alt_one.token.id_,
            marshalling_config.serializer, marshalling_config.deserializer)

        cls.compute_alt_one_servers_client = ServersClient(
            compute_url_alt_one, access_data_alt_one.token.id_,
            marshalling_config.serializer, marshalling_config.deserializer)

        cls.compute_alt_one_images_behaviors = ComputeImageBehaviors(
            images_client=cls.compute_alt_one_images_client,
            servers_client=cls.compute_alt_one_servers_client,
            config=images_config)

        cls.compute_alt_one_servers_behaviors = ServerBehaviors(
            servers_client=cls.compute_alt_one_servers_client,
            images_client=cls.compute_alt_one_images_client,
            servers_config=servers_config, images_config=images_config,
            flavors_config=flavors_config)

        # Create object storage client and behaviors for alt_one user
        object_storage_service_alt_one = access_data_alt_one.get_service(
            object_storage_config.identity_service_name)
        object_storage_url_check_alt_one = (
            object_storage_service_alt_one.get_endpoint(
                object_storage_config.region))
        # If endpoint validation fails, fail immediately
        if object_storage_url_check_alt_one is None:
            cls.assertClassSetupFailure('Endpoint validation failed')
        storage_url_alt_one = object_storage_service_alt_one.get_endpoint(
            object_storage_config.region).public_url

        cls.object_storage_alt_one_client = ObjectStorageAPIClient(
            storage_url_alt_one, access_data_alt_one.token.id_)

        cls.object_storage_alt_one_behaviors = ObjectStorageAPI_Behaviors(
            cls.object_storage_alt_one_client, object_storage_api_config)

        # Needed in order to allow assertions on exceptions
        cls.compute.flavors.client.delete_exception_handler(
            cls.compute_exception_handler)
class TestFixedIPsConnectivity(NetworkingComputeFixture, ScenarioMixin):
    """
    Testing connectivity between servers by adding fixed ips to existing
    servers.

    """
    NAMES_PREFIX = 'fixed_ips_connectivity'
    PRIVATE_KEY_PATH = '/root/pkey'
    MAX_RETRIES = 5

    admin_user = ComputeAdminUserConfig()
    compute_admin_endpoint = ComputeAdminEndpointConfig()
    auth_endpoint_config = ComputeAdminAuthConfig()
    access_data = AuthProvider.get_access_data(auth_endpoint_config,
                                               admin_user)
    compute_service = access_data.get_service(
        compute_admin_endpoint.compute_endpoint_name)
    url = compute_service.get_endpoint(
        compute_admin_endpoint.region).public_url
    servers_client = ServersClient(url, access_data.token.id_, 'json', 'json')

    SSH_COMMAND = ('ssh -o UserKnownHostsFile=/dev/null '
                   '-o StrictHostKeyChecking=no -o ConnectTimeout=60 '
                   '-i {private_key_path} {user}@{ip_address}')

    ssh_msg = ('Failed remote ssh connection from ' 'server {0} to server {1}')

    @classmethod
    def setUpClass(cls):
        super(TestFixedIPsConnectivity, cls).setUpClass()
        network_name = 'network_{0}'.format(cls.NAMES_PREFIX)
        cls.network = cls.create_server_network(name=network_name, ipv4=True)
        cls.delete_networks.append(cls.network.id)
        keypair_name = 'key_{0}'.format(cls.NAMES_PREFIX)
        cls.keypair = cls.create_keypair(name=keypair_name)
        cls.delete_keypairs.append(cls.keypair.name)
        svr_name_1 = 'svr_1_{0}'.format(cls.NAMES_PREFIX)
        svr_name_2 = 'svr_2_{0}'.format(cls.NAMES_PREFIX)
        network_ids = [
            cls.public_network_id, cls.service_network_id, cls.network.id
        ]
        cls.server1 = cls.create_test_server(name=svr_name_1,
                                             key_name=cls.keypair.name,
                                             network_ids=network_ids,
                                             active_server=False)
        cls.server2 = cls.create_test_server(name=svr_name_2,
                                             key_name=cls.keypair.name,
                                             network_ids=network_ids,
                                             active_server=False)
        cls.servers = [cls.server1, cls.server2]

        cls.FIXED_IPS_TO_ADD = cls.net.config.fixed_ips_to_add
        cls.PNET_FIX_IPv4_COUNT = cls.FIXED_IPS_TO_ADD + 1
        cls.SNET_FIX_IPv4_COUNT = cls.FIXED_IPS_TO_ADD + 1
        cls.INET_FIX_IPv4_COUNT = cls.FIXED_IPS_TO_ADD + 1
        cls.TOTAL_INITIAL_IPS_SERVER = 3
        cls.TOTAL_NETWORKS_ATTACHED_TO_SERVER = 3
        cls.TOTAL_IPS_SERVER = cls.TOTAL_INITIAL_IPS_SERVER + \
            (cls.FIXED_IPS_TO_ADD * cls.TOTAL_NETWORKS_ATTACHED_TO_SERVER)
        # Add fixed IPs to servers
        for server in cls.servers:
            cls.add_fixed_ips_network(server,
                                      cls.public_network_id,
                                      number_fixed_ips=cls.FIXED_IPS_TO_ADD)
            cls.add_fixed_ips_network(server,
                                      cls.service_network_id,
                                      number_fixed_ips=cls.FIXED_IPS_TO_ADD)
            cls.add_fixed_ips_network(server,
                                      cls.network.id,
                                      number_fixed_ips=cls.FIXED_IPS_TO_ADD)

        cls.server_persona1 = ServerPersona(
            server=cls.server1,
            pnet=True,
            snet=True,
            inet=True,
            pnet_fix_ipv4_count=cls.PNET_FIX_IPv4_COUNT,
            snet_fix_ipv4_count=cls.SNET_FIX_IPv4_COUNT,
            inet_fix_ipv4_count=cls.INET_FIX_IPv4_COUNT,
            network=cls.network,
            keypair=cls.keypair,
            ssh_username='******')
        cls.server_persona2 = ServerPersona(
            server=cls.server2,
            pnet=True,
            snet=True,
            inet=True,
            pnet_fix_ipv4_count=cls.PNET_FIX_IPv4_COUNT,
            snet_fix_ipv4_count=cls.SNET_FIX_IPv4_COUNT,
            inet_fix_ipv4_count=cls.INET_FIX_IPv4_COUNT,
            network=cls.network,
            keypair=cls.keypair,
            ssh_username='******')
        server_ids = [
            cls.server_persona1.server.id, cls.server_persona2.server.id
        ]
        cls.delete_servers.extend(server_ids)

        cls._transfer_private_key_to_vm(
            cls.server_persona1.remote_client.ssh_client,
            cls.keypair.private_key, cls.PRIVATE_KEY_PATH)
        cls._transfer_private_key_to_vm(
            cls.server_persona2.remote_client.ssh_client,
            cls.keypair.private_key, cls.PRIVATE_KEY_PATH)

    @tags('admin', 'positive')
    def test_server_ifconfig(self):
        """Testing ifconfig on servers"""
        servers = [self.server_persona1, self.server_persona2]
        for server in servers:
            ips = []
            ips.extend(server.pnet_fix_ipv4)
            ips.extend(server.snet_fix_ipv4)
            ips.extend(server.inet_fix_ipv4)
            rm_client = server.remote_client
            ifconfig_ips = []
            stdout = None
            retry_count = 0
            while stdout is None or len(ifconfig_ips) != self.TOTAL_IPS_SERVER:
                del ifconfig_ips[:]
                if retry_count < self.MAX_RETRIES:
                    ifconfig_output = rm_client.ssh_client.\
                        execute_shell_command("hostname -I")
                    stdout = ifconfig_output.stdout
                    pattern = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
                    matches = pattern.finditer(stdout)
                    for match in matches:
                        ifconfig_ips.append(match.group())
                if len(ifconfig_ips) == self.TOTAL_IPS_SERVER or \
                        retry_count == self.MAX_RETRIES:
                    break
                retry_count += 1
            server_ip_not_found = False
            for ip in ips:
                if ip not in ifconfig_ips:
                    server_ip_not_found = True
                    break
            self.assertFalse(server_ip_not_found,
                             msg="server {} ip {} not found in output of "
                             "ifconfig {}".format(server, ip, ifconfig_ips))

    @tags('admin', 'positive')
    def test_public_ping(self):
        """Testing ping on servers with public network"""
        msg_err = 'Public ping to IP address {0} - FAILED'
        msg_ok = 'Public ping to IP address {0} - OK'

        pub_ipv4_addr = []
        pub_ipv4_addr.extend(self.server_persona1.pnet_fix_ipv4)
        pub_ipv4_addr.extend(self.server_persona2.pnet_fix_ipv4)
        all_pub_ips_ping_result = []
        failure_flag = False
        for ip_addr in pub_ipv4_addr:
            ip_addr_reachable = PingClient.ping(ip_addr, 4)
            if ip_addr_reachable:
                all_pub_ips_ping_result.append(msg_ok.format(ip_addr))
            else:
                all_pub_ips_ping_result.append(msg_err.format(ip_addr))
                failure_flag = True
        msg = 'Got connectivity failures. Ping Results: {0}'

        # Fail the test if any ping failure is found
        self.assertFalse(failure_flag, msg.format(all_pub_ips_ping_result))

    @tags('admin', 'positive')
    def test_remote_public_ping(self):
        """Testing public network remote ping on servers"""
        self._test_remote_ping(port_type='pnet')

    @tags('admin', 'positive')
    def test_remote_private_ping(self):
        """Testing private network remote ping on servers"""
        self._test_remote_ping(port_type='snet')

    @tags('admin', 'positive')
    def test_remote_isolated_ping(self):
        """Testing isolated network remote ping on servers"""
        self._test_remote_ping(port_type='inet')

    def _test_remote_ping(self, port_type):
        """Testing remote ping on servers"""
        conn = Connectivity(self.server_persona2, self.server_persona1)
        icmp_basic = dict(port_type=port_type, protocol='icmp', ip_version=4)
        rp = conn.verify_personas_conn(**icmp_basic)
        result = rp[0]
        ping_result = result['connection']
        self.assertTrue(ping_result, rp)

    @tags('admin', 'positive')
    def test_remote_public_ssh(self):
        """Testing Public remote ssh on servers"""
        self._test_remote_ssh(self.server_persona1.pnet_fix_ipv4[0])

    @tags('admin', 'positive')
    def test_remote_private_ssh(self):
        """Testing ServiceNet remote ssh on servers"""
        self._test_remote_ssh(self.server_persona1.snet_fix_ipv4[0])

    @tags('admin', 'positive')
    def test_remote_isolated_ssh(self):
        """Testing isolated network A remote ssh on servers"""
        self._test_remote_ssh(self.server_persona1.inet_fix_ipv4[0])

    def _test_remote_ssh(self, target_ip_addr):
        """Testing remote ssh on servers"""
        rc2 = self.server_persona2.remote_client
        ssh_cmd = self.SSH_COMMAND.format(
            private_key_path=self.PRIVATE_KEY_PATH,
            user=self.server_persona1.ssh_username,
            ip_address=target_ip_addr)
        stdout = None
        ssh_connection_established = False
        retry_count = 0
        while stdout is None or not stdout.endswith('# '):
            if retry_count < self.MAX_RETRIES:
                output = rc2.ssh_client.execute_shell_command(ssh_cmd)
                stdout = output.stdout
            retry_count += 1
            if retry_count == self.MAX_RETRIES:
                break
        if stdout.endswith('# '):
            ssh_connection_established = True
        self.assertTrue(
            ssh_connection_established,
            self.ssh_msg.format(self.server_persona2.pnet_fix_ipv4[0],
                                target_ip_addr))

    @classmethod
    def add_fixed_ips_network(cls, server, network, number_fixed_ips):
        # Add fixed IP's to server
        for _ in range(number_fixed_ips):
            cls.servers_client.add_fixed_ip(server.id, network)
Beispiel #11
0
    def setUpClass(cls):
        """
        Initialize autoscale configs, behaviors and client
        """
        super(AutoscaleFixture, cls).setUpClass()
        cls.resources = ResourcePool()
        cls.autoscale_config = AutoscaleConfig()
        cls.endpoint_config = UserAuthConfig()
        user_config = UserConfig()
        access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                   user_config)
        server_service = access_data.get_service(
            cls.autoscale_config.server_endpoint_name)
        load_balancer_service = access_data.get_service(
            cls.autoscale_config.load_balancer_endpoint_name)
        server_url = server_service.get_endpoint(
            cls.autoscale_config.region).public_url
        lbaas_url = load_balancer_service.get_endpoint(
            cls.autoscale_config.region).public_url

        cls.tenant_id = cls.autoscale_config.tenant_id

        env = os.environ['OSTNG_CONFIG_FILE']
        if ('preprod' in env.lower()) or ('dev' in env.lower()):
            cls.url = str(cls.autoscale_config.server_endpoint) + '/' + str(
                cls.tenant_id)
        else:
            autoscale_service = access_data.get_service(
                cls.autoscale_config.autoscale_endpoint_name)
            cls.url = autoscale_service.get_endpoint(
                cls.autoscale_config.region).public_url

        cls.autoscale_client = AutoscalingAPIClient(cls.url,
                                                    access_data.token.id_,
                                                    'json', 'json')
        cls.server_client = ServersClient(server_url, access_data.token.id_,
                                          'json', 'json')
        cls.lbaas_client = LbaasAPIClient(lbaas_url, access_data.token.id_,
                                          'json', 'json')
        cls.autoscale_behaviors = AutoscaleBehaviors(cls.autoscale_config,
                                                     cls.autoscale_client)
        cls.gc_name = cls.autoscale_config.gc_name
        cls.gc_cooldown = int(cls.autoscale_config.gc_cooldown)
        cls.gc_min_entities = int(cls.autoscale_config.gc_min_entities)
        cls.gc_min_entities_alt = int(cls.autoscale_config.gc_min_entities_alt)
        cls.gc_max_entities = int(cls.autoscale_config.gc_max_entities)
        cls.lc_name = cls.autoscale_config.lc_name
        cls.lc_flavor_ref = cls.autoscale_config.lc_flavor_ref
        cls.lc_image_ref = cls.autoscale_config.lc_image_ref
        cls.lc_image_ref_alt = cls.autoscale_config.lc_image_ref_alt
        cls.sp_name = rand_name(cls.autoscale_config.sp_name)
        cls.sp_cooldown = int(cls.autoscale_config.sp_cooldown)
        cls.sp_change = int(cls.autoscale_config.sp_change)
        cls.sp_change_percent = int(cls.autoscale_config.sp_change_percent)
        cls.sp_desired_capacity = int(cls.autoscale_config.sp_desired_capacity)
        cls.sp_policy_type = cls.autoscale_config.sp_policy_type
        cls.upd_sp_change = int(cls.autoscale_config.upd_sp_change)
        cls.lc_load_balancers = cls.autoscale_config.lc_load_balancers
        cls.sp_list = cls.autoscale_config.sp_list
        cls.wb_name = rand_name(cls.autoscale_config.wb_name)
        cls.load_balancer_1 = int(cls.autoscale_config.load_balancer_1)
        cls.load_balancer_2 = int(cls.autoscale_config.load_balancer_2)
        cls.load_balancer_3 = int(cls.autoscale_config.load_balancer_3)
        cls.lb_other_region = int(cls.autoscale_config.lb_other_region)
        cls.interval_time = int(cls.autoscale_config.interval_time)
        cls.timeout = int(cls.autoscale_config.timeout)
        cls.scheduler_interval = OtterConstants.SCHEDULER_INTERVAL
        cls.scheduler_batch = OtterConstants.SCHEDULER_BATCH
        cls.max_maxentities = OtterConstants.MAX_MAXENTITIES
        cls.max_cooldown = OtterConstants.MAX_COOLDOWN
        cls.max_groups = OtterConstants.MAX_GROUPS
        cls.max_policies = OtterConstants.MAX_POLICIES
        cls.max_webhooks = OtterConstants.MAX_WEBHOOKS
        cls.limit_value_all = OtterConstants.LIMIT_VALUE_ALL
        cls.limit_unit_all = OtterConstants.LIMIT_UNIT_ALL
        cls.limit_value_webhook = OtterConstants.LIMIT_VALUE_WEBHOOK
        cls.limit_unit_webhook = OtterConstants.LIMIT_UNIT_WEBHOOK
        cls.non_autoscale_username = cls.autoscale_config.non_autoscale_username
        cls.non_autoscale_password = cls.autoscale_config.non_autoscale_password
        cls.non_autoscale_tenant = cls.autoscale_config.non_autoscale_tenant
Beispiel #12
0
    def setUpClass(cls):
        super(ComputeIntegrationFixture, cls).setUpClass()
        cls.flavors_config = FlavorsConfig()
        cls.servers_config = ServersConfig()
        cls.compute_endpoint = ComputeEndpointConfig()

        # Instantiate servers client
        compute_service = cls.access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        alt_compute_service = cls.alt_access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        compute_url_check = compute_service.get_endpoint(
            cls.compute_endpoint.region)
        alt_compute_url_check = alt_compute_service.get_endpoint(
            cls.compute_endpoint.region)
        # If compute endpoint validation fails, fail immediately
        if compute_url_check is None:
            cls.assertClassSetupFailure('Compute endpoint validation failed')
        # If compute endpoint validation fails, fail immediately
        if alt_compute_url_check is None:
            cls.assertClassSetupFailure('Compute endpoint validation failed')
        cls.compute_url = compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url
        cls.alt_compute_url = alt_compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url

        client_args = {
            'url': cls.compute_url,
            'auth_token': cls.access_data.token.id_,
            'serialize_format': cls.serialize_format,
            'deserialize_format': cls.deserialize_format
        }
        cls.servers_client = ServersClient(**client_args)
        alt_client_args = {
            'url': cls.alt_compute_url,
            'auth_token': cls.alt_access_data.token.id_,
            'serialize_format': cls.serialize_format,
            'deserialize_format': cls.deserialize_format
        }
        cls.alt_servers_client = ServersClient(**alt_client_args)

        # Instantiate compute images client and behavior
        cls.compute_images_client = ComputeImagesClient(**client_args)
        cls.alt_compute_images_client = ComputeImagesClient(**alt_client_args)
        cls.compute_image_behaviors = ComputeImageBehaviors(
            images_client=cls.compute_images_client,
            servers_client=cls.servers_client,
            config=cls.images_config)
        cls.alt_compute_image_behaviors = ComputeImageBehaviors(
            images_client=cls.alt_compute_images_client,
            servers_client=cls.alt_servers_client,
            config=cls.images_config)

        # Instantiate servers behavior
        cls.server_behaviors = ServerBehaviors(
            servers_client=cls.servers_client,
            images_client=cls.compute_images_client,
            servers_config=cls.servers_config,
            images_config=cls.images_config,
            flavors_config=cls.flavors_config)
        cls.alt_server_behaviors = ServerBehaviors(
            servers_client=cls.alt_servers_client,
            images_client=cls.alt_compute_images_client,
            servers_config=cls.servers_config,
            images_config=cls.images_config,
            flavors_config=cls.flavors_config)
Beispiel #13
0
    def setUpClass(cls):
        super(ComputeFixture, cls).setUpClass()
        cls.flavors_config = FlavorsConfig()
        cls.images_config = ImagesConfig()
        cls.servers_config = ServersConfig()
        cls.compute_endpoint = ComputeEndpointConfig()
        cls.marshalling = MarshallingConfig()
        cls.config_drive_config = ConfigDriveConfig()
        cls.cloud_init_config = CloudInitConfig()

        cls.flavor_ref = cls.flavors_config.primary_flavor
        cls.flavor_ref_alt = cls.flavors_config.secondary_flavor
        cls.image_ref = cls.images_config.primary_image
        cls.image_ref_alt = cls.images_config.secondary_image
        cls.disk_path = cls.servers_config.instance_disk_path
        cls.split_ephemeral_disk_enabled = \
            cls.servers_config.split_ephemeral_disk_enabled
        cls.ephemeral_disk_max_size = \
            cls.servers_config.ephemeral_disk_max_size
        cls.disk_format_type = cls.servers_config.disk_format_type
        cls.expected_networks = cls.servers_config.expected_networks
        cls.file_injection_enabled = \
            cls.servers_config.personality_file_injection_enabled

        cls.endpoint_config = UserAuthConfig()
        cls.user_config = UserConfig()
        cls.access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                       cls.user_config)
        # If authentication fails, halt
        if cls.access_data is None:
            cls.assertClassSetupFailure('Authentication failed.')

        compute_service = cls.access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url
        # If a url override was provided, use that value instead
        if cls.compute_endpoint.compute_endpoint_url:
            url = '{0}/{1}'.format(cls.compute_endpoint.compute_endpoint_url,
                                   cls.user_config.tenant_id)

        client_args = {'url': url, 'auth_token': cls.access_data.token.id_,
                       'serialize_format': cls.marshalling.serializer,
                       'deserialize_format': cls.marshalling.deserializer}

        cls.flavors_client = FlavorsClient(**client_args)
        cls.servers_client = ServersClient(**client_args)
        cls.boot_from_volume_client = VolumesBootClient(**client_args)
        cls.images_client = ImagesClient(**client_args)
        cls.keypairs_client = KeypairsClient(**client_args)
        cls.security_groups_client = SecurityGroupsClient(**client_args)
        cls.security_group_rule_client = SecurityGroupRulesClient(
            **client_args)
        cls.volume_attachments_client = VolumeAttachmentsAPIClient(
            url=url, auth_token=cls.access_data.token.id_,
            serialize_format=cls.marshalling.serializer,
            deserialize_format=cls.marshalling.deserializer)
        cls.rescue_client = RescueClient(**client_args)
        cls.vnc_client = VncConsoleClient(**client_args)
        cls.console_output_client = ConsoleOutputClient(**client_args)
        cls.limits_client = LimitsClient(**client_args)
        cls.server_behaviors = ServerBehaviors(
            servers_client=cls.servers_client,
            images_client=cls.images_client,
            servers_config=cls.servers_config,
            images_config=cls.images_config,
            flavors_config=cls.flavors_config)
        cls.volume_server_behaviors = VolumeServerBehaviors(
            servers_client=cls.servers_client,
            images_client=cls.images_client,
            servers_config=cls.servers_config,
            images_config=cls.images_config,
            flavors_config=cls.flavors_config,
            server_behaviors=cls.server_behaviors,
            boot_from_volume_client=cls.boot_from_volume_client)
        cls.image_behaviors = ImageBehaviors(cls.images_client,
                                             cls.servers_client,
                                             cls.images_config)
        cls.config_drive_behaviors = ConfigDriveBehaviors(cls.servers_client,
                                                          cls.servers_config,
                                                          cls.server_behaviors)
        cls.flavors_client.add_exception_handler(ExceptionHandler())
        cls.resources = ResourcePool()
        cls.addClassCleanup(cls.resources.release)