def get_rename_payload(payload): if vol_obj.use == 'unclaimed': err_msg = 'Unclaimed Storage volume can not be renamed' LOG.error(err_msg) self.module.fail_json(msg=err_msg) if vol_obj.name != new_storage_vol_name: err_msg = ("Could not rename storage volume {0} in {1} as " "name {2} is already in use".format( vol_obj.name, self.cluster_name, new_storage_vol_name)) if self.all_vols: for each in self.all_vols: if each.name == new_storage_vol_name: LOG.error("%s", err_msg) self.module.fail_json(msg=err_msg) # Validate the new storage volume name status, msg = utils.validate_name(new_storage_vol_name, 63, 'new_storage_volume_name') if not status: LOG.error(msg) self.module.fail_json(msg=msg) else: LOG.info(msg) payload.append({ 'op': 'replace', 'path': '/name', 'value': new_storage_vol_name }) else: msg = 'The new storage volume and the existing '\ 'storage volume name are same.' LOG.info(msg) return payload
def check_dist_device_name(self, distributed_device_name, field): """ Checks whether given distributed device name is valid or not """ flag, msg = utils.validate_name(distributed_device_name, 63, field) if not flag: LOG.error(msg) self.module.fail_json(msg=msg) else: LOG.info(msg)
def name_check(self, extent_name, field): """Check the validity of extent name """ char_len = '63' status, msg = utils.validate_name(extent_name, char_len, field) if not status: LOG.error(msg) self.module.fail_json(msg=msg) else: LOG.info(msg)
def validate_name(self, name, field): # pylint: disable=R0201 """This method validates the name length and non-presence of special characters""" char_len = '36' status, msg = utils.validate_name(name, char_len, field) if not status: LOG.error(msg) self.module.fail_json(msg=msg) else: LOG.info(msg)
def check_name(self, name): """ Validates the storageview name """ status, msg = utils.validate_name(name, "36", "storageview name") if not status: LOG.error(msg) self.module.fail_json(msg=msg) else: LOG.info(msg)
def check_name_validity(self, migration_name, name): """ Check if the migration job name is valid """ char_len = "63" status, msg = utils.validate_name(migration_name, char_len, name) if not status: LOG.error(msg) self.module.fail_json(msg=msg) else: LOG.info(msg)
def check_task_validity(self, cg_name): """ Check if the consistency group name is valid string """ char_len = "63" status, msg = utils.validate_name(cg_name, char_len, 'cg_name') if not status: LOG.error(msg) self.module.fail_json(msg=msg) else: LOG.info(msg)
def check_task_validity(self, device_name, name): """ Check if the device_name is valid string """ char_len = "63" status, msg = utils.validate_name(device_name, char_len, name) if not status: LOG.error(msg) self.module.fail_json(msg=msg) else: LOG.info(msg)
def verify_new_volume_name(name, field='new_virtual_volume_name'): def exit_fail(msg): LOG.error(msg) self.module.fail_json(msg=msg) # if name is valid LOG.info('Valdating new virtual volume name') status, msg = utils.validate_name( name, 63, field) if not status: exit_fail(msg) msg = "Virtual volume {0} with same name already exists" \ " in ".format(name) # if name is already assigned to dist virtual volume vol, _ = self.get_distributed_virtual_volume(name) if vol and vol.locality == 'distributed': msg += 'distributed virtual volume' exit_fail(msg) # if name is already assigned to virtual volume in same cluster vol, _ = self.get_volume_by_name(name) if vol: msg += self.cluster_name exit_fail(msg)