def add_dev_to_lio(self, in_wwn=None): """ Add an rbd device to the LIO configuration :param in_wwn: optional wwn identifying the rbd image to clients (must match across gateways) :return: LIO LUN object """ self.logger.info("(LUN.add_dev_to_lio) Adding image " "'{}' to LIO".format(self.config_key)) # extract control parameter overrides (if any) or use default controls = self.controls.copy() for k in ['max_data_area_mb']: if controls.get(k, None) is None: controls[k] = getattr(settings.config, k, None) control_string = gen_control_string(controls) if control_string: self.logger.debug("control=\"{}\"".format(control_string)) new_lun = None try: # config string = rbd identifier / config_key (pool/image) / # optional osd timeout cfgstring = "rbd/{}/{};osd_op_timeout={}".format( self.pool, self.image, settings.config.osd_op_timeout) if (settings.config.cephconf != '/etc/ceph/ceph.conf'): cfgstring += ";conf={}".format(settings.config.cephconf) new_lun = UserBackedStorageObject(name=self.config_key, config=cfgstring, size=self.size_bytes, wwn=in_wwn, control=control_string) except RTSLibError as err: self.error = True self.error_msg = ("failed to add {} to LIO - " "error({})".format(self.config_key, str(err))) self.logger.error(self.error_msg) return None try: new_lun.set_attribute("cmd_time_out", 0) new_lun.set_attribute("qfull_time_out", settings.config.qfull_timeout) except RTSLibError as err: self.error = True self.error_msg = ("Could not set LIO device attribute " "cmd_time_out/qfull_time_out for device: {}. " "Kernel not supported. - " "error({})".format(self.config_key, str(err))) self.logger.error(self.error_msg) new_lun.delete() return None self.logger.info("(LUN.add_dev_to_lio) Successfully added {}" " to LIO".format(self.config_key)) return new_lun
def _add_dev_to_lio_user_rbd(self, in_wwn=None): """ Add an rbd device to the LIO configuration (`USER_RBD`) :param in_wwn: optional wwn identifying the rbd image to clients (must match across gateways) :return: LIO LUN object """ # extract control parameter overrides (if any) or use default controls = {} for k in ['max_data_area_mb', 'hw_max_sectors']: controls[k] = getattr(self, k) control_string = gen_control_string(controls) if control_string: self.logger.debug("control=\"{}\"".format(control_string)) new_lun = None try: # config string = rbd identifier / config_key (pool/image) / # optional osd timeout cfgstring = "rbd/{}/{};osd_op_timeout={}".format( self.pool, self.image, self.osd_op_timeout) if (settings.config.cephconf != '/etc/ceph/ceph.conf'): cfgstring += ";conf={}".format(settings.config.cephconf) if (settings.config.cluster_client_name != 'client.admin'): client_id = settings.config.cluster_client_name.split('.', 1)[1] cfgstring += ";id={}".format(client_id) new_lun = UserBackedStorageObject(name=self.backstore_object_name, config=cfgstring, size=self.size_bytes, wwn=in_wwn, control=control_string) except (RTSLibError, IOError) as err: self.error = True self.error_msg = ("failed to add {} to LIO - " "error({})".format(self.config_key, str(err))) self.logger.error(self.error_msg) return None try: new_lun.set_attribute("cmd_time_out", 0) new_lun.set_attribute("qfull_time_out", self.qfull_timeout) except RTSLibError as err: self.error = True self.error_msg = ("Could not set LIO device attribute " "cmd_time_out/qfull_time_out for device: {}. " "Kernel not supported. - " "error({})".format(self.config_key, str(err))) self.logger.error(self.error_msg) new_lun.delete() return None return new_lun