Merge "Ensure default manila share type exists"

This commit is contained in:
Zuul 2023-10-24 15:58:15 +00:00 committed by Gerrit Code Review
commit 096ed1fbde
4 changed files with 28 additions and 0 deletions

View File

@ -27,6 +27,7 @@ get_shares_by_name = _client.get_shares_by_name
delete_share = _client.delete_share
extend_share = _client.extend_share
list_shares = _client.list_shares
ensure_default_share_type_exists = _client.ensure_default_share_type_exists
# Waiters
wait_for_share_status = _waiters.wait_for_share_status

View File

@ -105,3 +105,22 @@ def get_shares_by_name(share_name, client=None):
s for s in share_list if s['name'] == share_name
]
return shares
def list_share_types(client=None):
return manila_client(client).share_types.list()
def create_share_type(name, spec_driver_handles_share_servers,
client=None):
return manila_client(client).share_types.create(
name, spec_driver_handles_share_servers)
def ensure_default_share_type_exists(client=None):
name = CONF.tobiko.manila.default_share_type_name
dhss = CONF.tobiko.manila.spec_driver_handles_share_servers
for share_type in list_share_types(client=client):
if share_type.name == name:
return
create_share_type(name, dhss, client=client)

View File

@ -25,6 +25,13 @@ OPTIONS = [
cfg.IntOpt('size',
default=1,
help="Default size in GB for shares created by share tests."),
cfg.StrOpt('default_share_type_name',
default='default',
help="Default share type's name"),
cfg.BoolOpt('spec_driver_handles_share_servers',
default=False,
help="Specifies whether the driver handles the share servers "
"or not"),
]

View File

@ -41,6 +41,7 @@ class ManilaApiTestCase(testtools.TestCase):
LOG.debug('skipping creation of manila resources')
cls.share = manila.get_shares_by_name(manila.SHARE_NAME)[0]
else:
manila.ensure_default_share_type_exists()
cls.share = manila.create_share(name=manila.SHARE_NAME)
manila.wait_for_share_status(cls.share['id'])