Exemplo n.º 1
0
    def _create_share_and_share_network(self):
        name = data_utils.rand_name('autotest_share_name')
        description = data_utils.rand_name('autotest_share_description')

        common_share_network = self.client.get_share_network(
            self.client.share_network)
        share_net_info = (
            utils.get_default_subnet(self.user_client,
                                     common_share_network['id'])
            if utils.share_network_subnets_are_supported()
            else common_share_network)
        neutron_net_id = (
            share_net_info['neutron_net_id']
            if 'none' not in share_net_info['neutron_net_id'].lower()
            else None)
        neutron_subnet_id = (
            share_net_info['neutron_subnet_id']
            if 'none' not in share_net_info['neutron_subnet_id'].lower()
            else None)
        share_network = self.client.create_share_network(
            neutron_net_id=neutron_net_id,
            neutron_subnet_id=neutron_subnet_id,
        )

        self.share = self.create_share(
            share_protocol=self.protocol,
            size=1,
            name=name,
            description=description,
            share_network=share_network['id'],
            client=self.client,
            wait_for_creation=True
        )
        self.share = self.client.get_share(self.share['id'])
        return self.share, share_network
    def test_create_delete_share_network(self, net_data):
        share_subnet_support = utils.share_network_subnets_are_supported()
        share_subnet_fields = ([
            'neutron_net_id', 'neutron_subnet_id', 'availability_zone'
        ] if share_subnet_support else [])
        sn = self.create_share_network(cleanup_in_class=False, **net_data)
        default_subnet = (utils.get_default_subnet(self.user_client, sn['id'])
                          if share_subnet_support else None)

        expected_data = {
            'name': 'None',
            'description': 'None',
            'neutron_net_id': 'None',
            'neutron_subnet_id': 'None',
        }
        expected_data.update(net_data)
        share_network_expected_data = [(k, v)
                                       for k, v in expected_data.items()
                                       if k not in share_subnet_fields]
        share_subnet_expected_data = [(k, v) for k, v in expected_data.items()
                                      if k in share_subnet_fields]

        for k, v in share_network_expected_data:
            self.assertEqual(v, sn[k])
        for k, v in share_subnet_expected_data:
            self.assertEqual(v, default_subnet[k])

        self.admin_client.delete_share_network(sn['id'])
        self.admin_client.wait_for_share_network_deletion(sn['id'])
    def _list_share_networks_with_filters(self, filters):
        assert_subnet_fields = utils.share_network_subnets_are_supported()
        share_subnet_fields = (['neutron_subnet_id', 'neutron_net_id']
                               if assert_subnet_fields else [])
        share_network_filters = [(k, v) for k, v in filters.items()
                                 if k not in share_subnet_fields]
        share_network_subnet_filters = [(k, v) for k, v in filters.items()
                                        if k in share_subnet_fields]
        share_networks = self.admin_client.list_share_networks(filters=filters)

        self.assertGreater(len(share_networks), 0)
        self.assertTrue(any(self.sn['id'] == sn['id']
                            for sn in share_networks))
        for sn in share_networks:
            try:
                share_network = self.admin_client.get_share_network(sn['id'])
                default_subnet = (utils.get_default_subnet(
                    self.user_client, sn['id'])
                                  if assert_subnet_fields else None)
            except tempest_lib_exc.NotFound:
                # NOTE(vponomaryov): Case when some share network was deleted
                # between our 'list' and 'get' requests. Skip such case.
                continue
            for k, v in share_network_filters:
                self.assertIn(k, share_network)
                self.assertEqual(v, share_network[k])
            for k, v in share_network_subnet_filters:
                self.assertIn(k, default_subnet)
                self.assertEqual(v, default_subnet[k])
    def _create_share_and_share_network(self):
        name = data_utils.rand_name('autotest_share_name')
        description = data_utils.rand_name('autotest_share_description')

        common_share_network = self.client.get_share_network(
            self.client.share_network)
        share_net_info = utils.get_default_subnet(self.client,
                                                  common_share_network['id'])

        neutron_net_id = (share_net_info['neutron_net_id'] if 'none'
                          not in share_net_info['neutron_net_id'].lower() else
                          None)
        neutron_subnet_id = (
            share_net_info['neutron_subnet_id'] if 'none'
            not in share_net_info['neutron_subnet_id'].lower() else None)
        share_network = self.client.create_share_network(
            neutron_net_id=neutron_net_id,
            neutron_subnet_id=neutron_subnet_id,
        )
        share_type = self.create_share_type(
            data_utils.rand_name('test_share_type'),
            driver_handles_share_servers=True)

        share = self.create_share(share_protocol=self.protocol,
                                  size=1,
                                  name=name,
                                  description=description,
                                  share_type=share_type['ID'],
                                  share_network=share_network['id'],
                                  client=self.client,
                                  wait_for_creation=True)
        share = self.client.get_share(share['id'])
        return share, share_network
Exemplo n.º 5
0
    def test_get_share_network_subnet(self):
        default_subnet = utils.get_default_subnet(self.user_client,
                                                  self.sn['id'])

        subnet = self.user_client.get_share_network_subnet(
            self.sn['id'], default_subnet['id'])

        self.assertEqual(self.neutron_net_id, subnet['neutron_net_id'])
        self.assertEqual(self.neutron_subnet_id, subnet['neutron_subnet_id'])
Exemplo n.º 6
0
    def setUp(self):
        super(SharesTestMigration, self).setUp()

        self.old_type = self.create_share_type(
            data_utils.rand_name('test_share_type'),
            driver_handles_share_servers=True)
        self.new_type = self.create_share_type(
            data_utils.rand_name('test_share_type'),
            driver_handles_share_servers=True)
        self.error_type = self.create_share_type(
            data_utils.rand_name('test_share_type'),
            driver_handles_share_servers=True,
            extra_specs={'cause_error': 'no_valid_host'})

        self.old_share_net = self.get_user_client().get_share_network(
            self.get_user_client().share_network)
        share_net_info = (utils.get_default_subnet(self.get_user_client(),
                                                   self.old_share_net['id'])
                          if utils.share_network_subnets_are_supported() else
                          self.old_share_net)
        self.new_share_net = self.create_share_network(
            neutron_net_id=share_net_info['neutron_net_id'],
            neutron_subnet_id=share_net_info['neutron_subnet_id'])