def create_share(cls, share_protocol=None, size=None, share_network=None, share_type=None, name=None, description=None, public=False, snapshot=None, metadata=None, client=None, cleanup_in_class=False, wait_for_creation=True): if client is None: client = cls.get_admin_client() data = { 'share_protocol': share_protocol or client.share_protocol, 'size': size or 1, 'name': name, 'description': description, 'public': public, 'snapshot': snapshot, 'metadata': metadata, } share_network = share_network or client.share_network share_type = share_type or CONF.share_type if share_network: data['share_network'] = share_network if share_type: data['share_type'] = share_type share = client.create_share(**data) resource = { "type": "share", "id": share["id"], "client": client, } if cleanup_in_class: cls.class_resources.insert(0, resource) else: cls.method_resources.insert(0, resource) if wait_for_creation: client.wait_for_share_status(share['id'], 'available') return share
def create_message(cls, client=None, wait_for_creation=True, cleanup_in_class=False, microversion=None): """Trigger a 'no valid host' situation to generate a message.""" if client is None: client = cls.get_admin_client() extra_specs = { 'vendor_name': 'foobar', } share_type_name = data_utils.rand_name("share-type") cls.create_share_type( name=share_type_name, extra_specs=extra_specs, driver_handles_share_servers=False, client=client, cleanup_in_class=cleanup_in_class, microversion=microversion) share_name = data_utils.rand_name("share") share = cls.create_share( name=share_name, share_type=share_type_name, cleanup_in_class=cleanup_in_class, microversion=microversion, wait_for_creation=False, client=client) client.wait_for_share_status(share['id'], "error") message = client.wait_for_message(share['id']) resource = { "type": "message", "id": message["ID"], "client": client, "microversion": microversion, } if cleanup_in_class: cls.class_resources.insert(0, resource) else: cls.method_resources.insert(0, resource) return message
def create_share(cls, share_protocol=None, size=None, share_network=None, share_type=None, name=None, description=None, public=False, snapshot=None, metadata=None, client=None, cleanup_in_class=False, wait_for_creation=True, microversion=None): if client is None: client = cls.get_admin_client() data = { 'share_protocol': share_protocol or client.share_protocol, 'size': size or 1, 'name': name, 'description': description, 'public': public, 'snapshot': snapshot, 'metadata': metadata, 'microversion': microversion, } share_network = share_network or client.share_network share_type = share_type or CONF.share_type if share_network: data['share_network'] = share_network if share_type: data['share_type'] = share_type share = client.create_share(**data) resource = { "type": "share", "id": share["id"], "client": client, "microversion": microversion, } if cleanup_in_class: cls.class_resources.insert(0, resource) else: cls.method_resources.insert(0, resource) if wait_for_creation: client.wait_for_share_status(share['id'], 'available') return share