def create_share_network(self, name=None, description=None, nova_net_id=None, neutron_net_id=None, neutron_subnet_id=None, microversion=None): """Creates share network. :param name: text -- desired name of new share network :param description: text -- desired description of new share network :param nova_net_id: text -- ID of Nova network :param neutron_net_id: text -- ID of Neutron network :param neutron_subnet_id: text -- ID of Neutron subnet NOTE: 'nova_net_id' and 'neutron_net_id'/'neutron_subnet_id' are mutually exclusive. """ params = self._combine_share_network_data( name=name, description=description, nova_net_id=nova_net_id, neutron_net_id=neutron_net_id, neutron_subnet_id=neutron_subnet_id) share_network_raw = self.manila('share-network-create %s' % params, microversion=microversion) share_network = output_parser.details(share_network_raw) return share_network
def get_share_network(self, share_network, microversion=None): """Returns share network by its Name or ID.""" share_network_raw = self.manila('share-network-show %s' % share_network, microversion=microversion) share_network = output_parser.details(share_network_raw) return share_network
def access_allow(self, share_id, access_type, access_to, access_level, microversion=None): raw_access = self.manila( "access-allow --access-level %(level)s %(id)s %(type)s " "%(access_to)s" % {"level": access_level, "id": share_id, "type": access_type, "access_to": access_to}, microversion=microversion, ) return output_parser.details(raw_access)
def create_share_network( self, name=None, description=None, nova_net_id=None, neutron_net_id=None, neutron_subnet_id=None, microversion=None, ): """Creates share network. :param name: text -- desired name of new share network :param description: text -- desired description of new share network :param nova_net_id: text -- ID of Nova network :param neutron_net_id: text -- ID of Neutron network :param neutron_subnet_id: text -- ID of Neutron subnet NOTE: 'nova_net_id' and 'neutron_net_id'/'neutron_subnet_id' are mutually exclusive. """ params = self._combine_share_network_data( name=name, description=description, nova_net_id=nova_net_id, neutron_net_id=neutron_net_id, neutron_subnet_id=neutron_subnet_id, ) share_network_raw = self.manila("share-network-create %s" % params, microversion=microversion) share_network = output_parser.details(share_network_raw) return share_network
def update_share_network(self, share_network, name=None, description=None, nova_net_id=None, neutron_net_id=None, neutron_subnet_id=None, microversion=None): """Updates share-network by its name or ID. :param name: text -- new name for share network :param description: text -- new description for share network :param nova_net_id: text -- ID of some Nova network :param neutron_net_id: text -- ID of some Neutron network :param neutron_subnet_id: text -- ID of some Neutron subnet NOTE: 'nova_net_id' and 'neutron_net_id'/'neutron_subnet_id' are mutually exclusive. """ sn_params = self._combine_share_network_data( name=name, description=description, nova_net_id=nova_net_id, neutron_net_id=neutron_net_id, neutron_subnet_id=neutron_subnet_id) share_network_raw = self.manila( 'share-network-update %(sn)s %(params)s' % dict( sn=share_network, params=sn_params), microversion=microversion) share_network = output_parser.details(share_network_raw) return share_network
def update_all_share_metadata(self, share, data, microversion=None): metadata_raw = self._set_share_metadata(share, data, True, microversion=microversion) metadata = output_parser.details(metadata_raw) return metadata
def create_share_type(self, name=None, driver_handles_share_servers=True, snapshot_support=True, is_public=True, microversion=None): """Creates share type. :param name: text -- name of share type to use, if not set then autogenerated will be used :param driver_handles_share_servers: bool/str -- boolean or its string alias. Default is True. :param snapshot_support: bool/str -- boolean or its string alias. Default is True. :param is_public: bool/str -- boolean or its string alias. Default is True. """ if name is None: name = data_utils.rand_name('manilaclient_functional_test') dhss = driver_handles_share_servers if not isinstance(dhss, six.string_types): dhss = six.text_type(dhss) if not isinstance(snapshot_support, six.string_types): snapshot_support = six.text_type(snapshot_support) if not isinstance(is_public, six.string_types): is_public = six.text_type(is_public) cmd = ('type-create %(name)s %(dhss)s --is-public %(is_public)s ' '--snapshot-support %(snapshot_support)s') % { 'name': name, 'dhss': dhss, 'is_public': is_public, 'snapshot_support': snapshot_support} share_type_raw = self.manila(cmd, microversion=microversion) share_type = output_parser.details(share_type_raw) return share_type
def create_security_service(self, type='ldap', name=None, description=None, dns_ip=None, server=None, domain=None, user=None, password=None, microversion=None): """Creates security service. :param type: security service type (ldap, kerberos or active_directory) :param name: desired name of new security service. :param description: desired description of new security service. :param dns_ip: DNS IP address inside tenant's network. :param server: security service IP address or hostname. :param domain: security service domain. :param user: user of the new security service. :param password: password used by user. """ cmd = 'security-service-create %s ' % type cmd += self._combine_security_service_data(name=name, description=description, dns_ip=dns_ip, server=server, domain=domain, user=user, password=password) ss_raw = self.manila(cmd, microversion=microversion) security_service = output_parser.details(ss_raw) return security_service
def create_security_service(self, type='ldap', name=None, description=None, dns_ip=None, server=None, domain=None, user=None, password=None, microversion=None): """Creates security service. :param type: security service type (ldap, kerberos or active_directory) :param name: desired name of new security service. :param description: desired description of new security service. :param dns_ip: DNS IP address inside tenant's network. :param server: security service IP address or hostname. :param domain: security service domain. :param user: user of the new security service. :param password: password used by user. """ cmd = 'security-service-create %s ' % type cmd += self. _combine_security_service_data( name=name, description=description, dns_ip=dns_ip, server=server, domain=domain, user=user, password=password) ss_raw = self.manila(cmd, microversion=microversion) security_service = output_parser.details(ss_raw) return security_service
def update_share_network(self, share_network, name=None, description=None, nova_net_id=None, neutron_net_id=None, neutron_subnet_id=None, microversion=None): """Updates share-network by its name or ID. :param name: text -- new name for share network :param description: text -- new description for share network :param nova_net_id: text -- ID of some Nova network :param neutron_net_id: text -- ID of some Neutron network :param neutron_subnet_id: text -- ID of some Neutron subnet NOTE: 'nova_net_id' and 'neutron_net_id'/'neutron_subnet_id' are mutually exclusive. """ sn_params = self._combine_share_network_data( name=name, description=description, nova_net_id=nova_net_id, neutron_net_id=neutron_net_id, neutron_subnet_id=neutron_subnet_id) share_network_raw = self.manila( 'share-network-update %(sn)s %(params)s' % dict(sn=share_network, params=sn_params), microversion=microversion) share_network = output_parser.details(share_network_raw) return share_network
def get_share_metadata(self, share): """Returns list of all share metadata. :param share: str -- Name or ID of a share. """ metadata_raw = self.manila('metadata-show %s' % share) metadata = output_parser.details(metadata_raw) return metadata
def get_share_metadata(self, share, microversion=None): """Returns list of all share metadata. :param share: str -- Name or ID of a share. """ metadata_raw = self.manila("metadata-show %s" % share, microversion=microversion) metadata = output_parser.details(metadata_raw) return metadata
def test_details_with_normal_line_label_true(self): expected = { '__label': 'First Table', 'foo': 'BUILD', 'bar': 'ERROR', 'bee': 'None' } actual = output_parser.details(self.DETAILS_LINES1, with_label=True) self.assertEqual(expected, actual)
def get_share_metadata(self, share, microversion=None): """Returns list of all share metadata. :param share: str -- Name or ID of a share. """ metadata_raw = self.manila('metadata-show %s' % share, microversion=microversion) metadata = output_parser.details(metadata_raw) return metadata
def access_allow(self, share_id, access_type, access_to, access_level): raw_access = self.manila( 'access-allow --access-level %(level)s %(id)s %(type)s ' '%(access_to)s' % { 'level': access_level, 'id': share_id, 'type': access_type, 'access_to': access_to, }) return output_parser.details(raw_access)
def test_shutdown_active_controller_during_upload( self, glance, image_file, suffix, timeout=60): """Check that image is created successfully if during creating image to perform shutdown of active controller Steps: 1. Create image using URL Link 2. Shutdown active controller during creation of image 3. Check that image is present in list and image status is `active` 4. Delete created image 5. Check that image deleted """ # Find a primary controller primary_controller = self.env.primary_controller mac = primary_controller.data['mac'] self.primary_node = DevopsClient.get_node_by_mac( env_name=self.env_name, mac=mac) name = 'Test_{}'.format(suffix[:6]) image_url = settings.GLANCE_IMAGE_URL cmd = ('image-create --name {name} --container-format bare ' '--disk-format qcow2 --location {image_url}'.format( name=name, image_url=image_url)) image = parser.details(glance(cmd)) logger.info('Image starts to upload') # Shutdown primary controller self.env.warm_shutdown_nodes([self.primary_node]) image_list = parser.listing(glance('image-list')) assert image['id'] in [x['ID'] for x in image_list] image_data = parser.details(glance('image-show {id}'.format(**image))) assert image_data['status'] == 'active' logger.info('Image is active') glance('image-delete {id}'.format(**image)) images = parser.listing(glance('image-list')) assert image['id'] not in [x['ID'] for x in images]
def create_share(self, share_protocol, size, share_network=None, share_type=None, name=None, description=None, public=False, snapshot=None, metadata=None, microversion=None): """Creates a share. :param share_protocol: str -- share protocol of a share. :param size: int/str -- desired size of a share. :param share_network: str -- Name or ID of share network to use. :param share_type: str -- Name or ID of share type to use. :param name: str -- desired name of new share. :param description: str -- desired description of new share. :param public: bool -- should a share be public or not. Default is False. :param snapshot: str -- Name or ID of a snapshot to use as source. :param metadata: dict -- key-value data to provide with share creation. :param microversion: str -- API microversion that should be used. """ cmd = 'create %(share_protocol)s %(size)s ' % { 'share_protocol': share_protocol, 'size': size } if share_network is not None: cmd += '--share-network %s ' % share_network if share_type is not None: cmd += '--share-type %s ' % share_type if name is None: name = data_utils.rand_name('autotest_share_name') cmd += '--name %s ' % name if description is None: description = data_utils.rand_name('autotest_share_description') cmd += '--description %s ' % description if public: cmd += '--public' if snapshot is not None: cmd += '--snapshot %s ' % snapshot if metadata: metadata_cli = '' for k, v in metadata.items(): metadata_cli += '%(k)s=%(v)s ' % {'k': k, 'v': v} if metadata_cli: cmd += '--metadata %s ' % metadata_cli share_raw = self.manila(cmd, microversion=microversion) share = output_parser.details(share_raw) return share
def update_security_service(self, security_service, name=None, description=None, dns_ip=None, server=None, domain=None, user=None, password=None): cmd = 'security-service-update %s ' % security_service cmd += self. _combine_security_service_data( name=name, description=description, dns_ip=dns_ip, server=server, domain=domain, user=user, password=password) return output_parser.details(self.manila(cmd))
def create_share( self, share_protocol, size, share_network=None, share_type=None, name=None, description=None, public=False, snapshot=None, metadata=None, microversion=None, ): """Creates a share. :param share_protocol: str -- share protocol of a share. :param size: int/str -- desired size of a share. :param share_network: str -- Name or ID of share network to use. :param share_type: str -- Name or ID of share type to use. :param name: str -- desired name of new share. :param description: str -- desired description of new share. :param public: bool -- should a share be public or not. Default is False. :param snapshot: str -- Name or ID of a snapshot to use as source. :param metadata: dict -- key-value data to provide with share creation. :param microversion: str -- API microversion that should be used. """ cmd = "create %(share_protocol)s %(size)s " % {"share_protocol": share_protocol, "size": size} if share_network is not None: cmd += "--share-network %s " % share_network if share_type is not None: cmd += "--share-type %s " % share_type if name is None: name = data_utils.rand_name("autotest_share_name") cmd += "--name %s " % name if description is None: description = data_utils.rand_name("autotest_share_description") cmd += "--description %s " % description if public: cmd += "--public" if snapshot is not None: cmd += "--snapshot %s " % snapshot if metadata: metadata_cli = "" for k, v in metadata.items(): metadata_cli += "%(k)s=%(v)s " % {"k": k, "v": v} if metadata_cli: cmd += "--metadata %s " % metadata_cli share_raw = self.manila(cmd, microversion=microversion) share = output_parser.details(share_raw) return share
def test_shutdown_primary_controller( self, glance, image_file, suffix, timeout=60): """Check creating image after shutdown primary controller Steps: 1. Shutdown primary controller 2. Create image from `image_file` 3. Check that image is present in list and image status is `active` 4. Delete created image 5. Check that image deleted """ # Find a primary controller primary_controller = self.env.primary_controller mac = primary_controller.data['mac'] primary_node = DevopsClient.get_node_by_mac( env_name=self.env_name, mac=mac) # Shutdown primary controller self.env.warm_shutdown_nodes([primary_node]) name = 'Test_{}'.format(suffix[:6]) cmd = ('image-create --name {name} --container-format bare ' '--disk-format qcow2 --file {file}'.format( name=name, file=image_file)) image = parser.details(glance(cmd)) logger.info('Image starts to upload') image_list = parser.listing(glance('image-list')) assert image['id'] in [x['ID'] for x in image_list] image_data = parser.details(glance('image-show {id}'.format(**image))) assert image_data['status'] == 'active' logger.info('Image is active') glance('image-delete {id}'.format(**image)) images = parser.listing(glance('image-list')) assert image['id'] not in [x['ID'] for x in images]
def access_allow(self, share_id, access_type, access_to, access_level, microversion=None): raw_access = self.manila( 'access-allow --access-level %(level)s %(id)s %(type)s ' '%(access_to)s' % { 'level': access_level, 'id': share_id, 'type': access_type, 'access_to': access_to, }, microversion=microversion) return output_parser.details(raw_access)
def get_share_export_location(self, share, export_location_uuid, microversion=None): """Returns an export location by share and its UUID. :param share: str -- Name or ID of a share. :param export_location_uuid: str -- UUID of an export location. :param microversion: API microversion to be used for request. """ share_raw = self.manila( 'share-export-location-show %(share)s %(el_uuid)s' % { 'share': share, 'el_uuid': export_location_uuid, }, microversion=microversion) share = output_parser.details(share_raw) return share
def update_security_service(self, security_service, name=None, description=None, dns_ip=None, server=None, domain=None, user=None, password=None, microversion=None): cmd = 'security-service-update %s ' % security_service cmd += self._combine_security_service_data(name=name, description=description, dns_ip=dns_ip, server=server, domain=domain, user=user, password=password) return output_parser.details( self.manila(cmd, microversion=microversion))
def create_share(self, share_protocol, size, share_network=None, share_type=None, name=None, description=None, public=False, snapshot=None, metadata=None): """Creates a share. :param share_protocol: str -- share protocol of a share. :param size: int/str -- desired size of a share. :param share_network: str -- Name or ID of share network to use. :param share_type: str -- Name or ID of share type to use. :param name: str -- desired name of new share. :param description: str -- desired description of new share. :param public: bool -- should a share be public or not. Default is False. :param snapshot: str -- Name or ID of a snapshot to use as source. :param metadata: dict -- key-value data to provide with share creation. """ cmd = 'create %(share_protocol)s %(size)s ' % { 'share_protocol': share_protocol, 'size': size} if share_network is not None: cmd += '--share-network %s ' % share_network if share_type is not None: cmd += '--share-type %s ' % share_type if name is None: name = data_utils.rand_name('autotest_share_name') cmd += '--name %s ' % name if description is None: description = data_utils.rand_name('autotest_share_description') cmd += '--description %s ' % description if public: cmd += '--public' if snapshot is not None: cmd += '--snapshot %s ' % snapshot if metadata: metadata_cli = '' for k, v in metadata.items(): metadata_cli += '%(k)s=%(v)s ' % {'k': k, 'v': v} if metadata_cli: cmd += '--metadata %s ' % metadata_cli share_raw = self.manila(cmd) share = output_parser.details(share_raw) return share
def create_share_type(self, name=None, driver_handles_share_servers=True, snapshot_support=True, is_public=True, microversion=None): """Creates share type. :param name: text -- name of share type to use, if not set then autogenerated will be used :param driver_handles_share_servers: bool/str -- boolean or its string alias. Default is True. :param snapshot_support: bool/str -- boolean or its string alias. Default is True. :param is_public: bool/str -- boolean or its string alias. Default is True. """ if name is None: name = data_utils.rand_name('manilaclient_functional_test') dhss = driver_handles_share_servers if not isinstance(dhss, six.string_types): dhss = six.text_type(dhss) if not isinstance(snapshot_support, six.string_types): snapshot_support = six.text_type(snapshot_support) if not isinstance(is_public, six.string_types): is_public = six.text_type(is_public) cmd = ('type-create %(name)s %(dhss)s --is-public %(is_public)s ' '--snapshot-support %(snapshot_support)s') % { 'name': name, 'dhss': dhss, 'is_public': is_public, 'snapshot_support': snapshot_support } share_type_raw = self.manila(cmd, microversion=microversion) share_type = output_parser.details(share_type_raw) return share_type
def test_details_with_normal_line_label_true(self): expected = {'__label': 'First Table', 'foo': 'BUILD', 'bar': 'ERROR', 'bee': 'None'} actual = output_parser.details(self.DETAILS_LINES1, with_label=True) self.assertEqual(expected, actual)
def update_all_share_metadata(self, share, data, microversion=None): metadata_raw = self._set_share_metadata( share, data, True, microversion=microversion) metadata = output_parser.details(metadata_raw) return metadata
def get_share(self, share, microversion=None): """Returns a share by its Name or ID.""" share_raw = self.manila('show %s' % share, microversion=microversion) share = output_parser.details(share_raw) return share
def get_share_network(self, share_network, microversion=None): """Returns share network by its Name or ID.""" share_network_raw = self.manila( 'share-network-show %s' % share_network, microversion=microversion) share_network = output_parser.details(share_network_raw) return share_network
def update_all_share_metadata(self, share, data): metadata_raw = self._set_share_metadata(share, data, True) metadata = output_parser.details(metadata_raw) return metadata
def test_details_with_normal_line_label_false(self): expected = {'foo': 'BUILD', 'bar': 'ERROR', 'bee': 'None'} actual = output_parser.details(self.DETAILS_LINES1) self.assertEqual(expected, actual)