def _set_qos_specs_to_volume(self, connection_info): """ :param connection_info :return: """ qos_para = {'maxReadBytes': 0, 'maxWriteBytes': 0, 'maxReadRequest': 0, 'maxWriteRequest': 0} key_cvt_map = {'read_bytes_sec': 'maxReadBytes', 'write_bytes_sec': 'maxWriteBytes', 'read_iops_sec': 'maxReadRequest', 'write_iops_sec': 'maxWriteRequest'} tune_opts = ['read_bytes_sec', 'write_bytes_sec', 'read_iops_sec', 'write_iops_sec'] tune_cvt_opts = ['read_bytes_sec', 'write_bytes_sec'] # Extract rate_limit control parameters if connection_info is None or 'data' not in connection_info: return specs = connection_info['data']['qos_specs'] vol_urn = connection_info.get('vol_urn') if vol_urn is None: return # because the volume can be detached and attach to another instance # qos maybe disassociated from volume type # between the up two operations # so if specs is none,set default value to FC. if specs is not None: if isinstance(specs, dict): for key, value in specs.iteritems(): if key in tune_opts: # convert byte to KB for FC,0 is no limited, # the value is at least 1 output_value = value if key in tune_cvt_opts: addition = 0 if output_value.isdigit(): if long(value) % 1024 != 0: addition = 1 output_value = long(value) / 1024 \ + addition qos_para[key_cvt_map[key]] = output_value else: LOG.debug(_('Unknown content in connection_info ' 'qos_specs: %s'), specs) return qos_specs_uri = utils.generate_uri_from_urn(vol_urn) \ + constant.VOL_URI_MAP['modio'] # Send Qos IO Specs to VRM with put method self.put(qos_specs_uri, data=qos_para, excp=fc_exc.SetQosIoFailure)
def get_cluster_detail_by_nodename(self, nodename): """get cluster by node name""" cluster_urn = self.get_cluster_urn_by_nodename(nodename) return self.get(utils.generate_uri_from_urn(cluster_urn))