def resource_setup(cls): super(ShareServersAdminTest, cls).resource_setup() # create share type cls.share_type = cls.create_share_type() cls.share_type_id = cls.share_type['id'] # create share in this new share network cls.share = cls.create_share( share_type_id=cls.share_type_id) cls.share_network = cls.shares_v2_client.get_share_network( cls.shares_v2_client.share_network_id)['share_network'] if not cls.share_network["name"]: sn_id = cls.share_network["id"] cls.share_network = cls.shares_v2_client.update_share_network( sn_id, name="sn_%s" % sn_id) cls.sn_name_and_id = [ cls.share_network["name"], cls.share_network["id"], ] cls.share_net_info = ( utils.share_network_get_default_subnet(cls.share_network) if utils.share_network_subnets_are_supported() else cls.share_network) # Date should be like '2014-13-12T11:10:09.000000' cls.date_re = re.compile("^([0-9]{4}-[0-9]{2}-[0-9]{2}[A-Z]{1}" "[0-9]{2}:[0-9]{2}:[0-9]{2}).*$")
def resource_setup(cls): super(SecServicesMappingNegativeTest, cls).resource_setup() cls.sn = cls.create_share_network(cleanup_in_class=True, add_security_services=False) cls.share_net_info = (utils.share_network_get_default_subnet( cls.sn) if utils.share_network_subnets_are_supported() else cls.sn) cls.ss = cls.create_security_service(cleanup_in_class=True) cls.cl = cls.shares_client # create share type cls.share_type = cls.create_share_type() cls.share_type_id = cls.share_type['id']
def _create_secondary_share_network(self, old_share_network_id): old_share_network = self.shares_v2_client.get_share_network( old_share_network_id)['share_network'] share_net_info = ( utils.share_network_get_default_subnet(old_share_network) if utils.share_network_subnets_are_supported() else old_share_network) new_share_network = self.create_share_network( cleanup_in_class=True, neutron_net_id=share_net_info['neutron_net_id'], neutron_subnet_id=share_net_info['neutron_subnet_id']) return new_share_network['id']
def resource_setup(cls): super(ManageShareServersNegativeTest, cls).resource_setup() # create share type cls.st_name = data_utils.rand_name("manage-st-name") cls.extra_specs = { 'storage_protocol': CONF.share.capability_storage_protocol, 'driver_handles_share_servers': CONF.share.multitenancy_enabled, } cls.share_type = cls.create_share_type(name=cls.st_name, cleanup_in_class=True, extra_specs=cls.extra_specs) cls.original_share_network = cls.shares_v2_client.get_share_network( cls.shares_v2_client.share_network_id)['share_network'] cls.share_net_info = (utils.share_network_get_default_subnet( cls.original_share_network) if utils.share_network_subnets_are_supported() else cls.original_share_network)
def test_gateway_mtu_neutron_net_id_with_neutron(self): self.create_share(share_type_id=self.share_type_id, cleanup_in_class=False) share_net_details = self.shares_v2_client.get_share_network( self.shares_v2_client.share_network_id)['share_network'] share_net_info = ( utils.share_network_get_default_subnet(share_net_details) if utils.share_network_subnets_are_supported() else share_net_details) if utils.is_microversion_supported('2.18'): subnet_details = self.subnets_client.show_subnet( share_net_info['neutron_subnet_id']) self.assertEqual(subnet_details['subnet']['gateway_ip'], share_net_info['gateway']) if utils.is_microversion_supported('2.20'): network_details = self.networks_client.show_network( share_net_info['neutron_net_id']) self.assertEqual(network_details['network']['mtu'], share_net_info['mtu']) self.assertEqual(network_details['network']['id'], share_net_info['neutron_net_id'])
def test_manage_share_server(self, add_subnet_field): # Starting from v2.51 share network spans to multiple subnets. if add_subnet_field and not utils.is_microversion_supported('2.51'): msg = ("Manage share server with share network subnet is " "supported starting from microversion '2.51'.") raise self.skipException(msg) check_multiple_subnet = utils.is_microversion_ge( CONF.share.max_api_microversion, '2.70') if check_multiple_subnet: network_subnet = 'share_network_subnet_ids' else: network_subnet = 'share_network_subnet_id' # create a new share network to make sure that a new share server # will be created original_share_network = self.shares_v2_client.get_share_network( self.shares_v2_client.share_network_id)['share_network'] share_net_info = ( utils.share_network_get_default_subnet(original_share_network) if utils.share_network_subnets_are_supported() else original_share_network) share_network = self.create_share_network( neutron_net_id=share_net_info['neutron_net_id'], neutron_subnet_id=share_net_info['neutron_subnet_id'], cleanup_in_class=True) az = params = None if add_subnet_field: # Get a compatible availability zone az = self.get_availability_zones_matching_share_type( self.share_type)[0] az_subnet = self.shares_v2_client.create_subnet( share_network['id'], neutron_net_id=share_network['neutron_net_id'], neutron_subnet_id=share_network['neutron_subnet_id'], availability_zone=az)['share_network_subnet'] params = {network_subnet: az_subnet['id']} # create share share = self.create_share(share_type_id=self.share_type['id'], share_network_id=share_network['id'], availability_zone=az) share = self.shares_v2_client.get_share(share['id'])['share'] el = self.shares_v2_client.list_share_export_locations( share['id'])['export_locations'] share['export_locations'] = el share_server = self.shares_v2_client.show_share_server( share['share_server_id'])['share_server'] keys = [ "id", "host", "project_id", "status", "share_network_name", "created_at", "updated_at", "backend_details", "is_auto_deletable", "identifier", ] if add_subnet_field: keys.append(network_subnet) # all expected keys are present for key in keys: self.assertIn(key, share_server) # check that the share server is initially auto-deletable self.assertIs(True, share_server["is_auto_deletable"]) self.assertIsNotNone(share_server["identifier"]) if add_subnet_field and check_multiple_subnet: self.assertIn(az_subnet["id"], share_server[network_subnet]) elif add_subnet_field and not check_multiple_subnet: self.assertEqual(az_subnet["id"], share_server[network_subnet]) self._unmanage_share_and_wait(share) # Starting from microversion 2.49, any share server that has ever had # an unmanaged share will never be auto-deleted. share_server = self.shares_v2_client.show_share_server( share_server['id'])['share_server'] self.assertIs(False, share_server['is_auto_deletable']) # unmanage share server and manage it again self._unmanage_share_server_and_wait(share_server) managed_share_server = self._manage_share_server(share_server, fields=params) managed_share = self._manage_share( share, name="managed share that had ID %s" % share['id'], description="description for managed share", share_server_id=managed_share_server['id']) # check managed share server managed_share_server = self.shares_v2_client.show_share_server( managed_share_server['id'])['share_server'] # all expected keys are present in the managed share server for key in keys: self.assertIn(key, managed_share_server) # check that managed share server is used by the managed share self.assertEqual(managed_share['share_server_id'], managed_share_server['id']) # check that the managed share server is still not auto-deletable self.assertIs(False, managed_share_server["is_auto_deletable"]) # delete share self._delete_share_and_wait(managed_share) # delete share server self._delete_share_server_and_wait(managed_share_server['id']) if add_subnet_field: # delete the created subnet self.shares_v2_client.delete_subnet(share_network['id'], az_subnet['id'])