Merge "Huawei: Consider bandwidth when selecting port"
This commit is contained in:
commit
e8bca02605
cinder/volume/drivers/huawei
@ -75,13 +75,15 @@ class FCZoneHelper(object):
|
||||
if total_bandwidth:
|
||||
weight += float(lun_num) / float(total_bandwidth)
|
||||
|
||||
return weight
|
||||
bandwidth = float(ports_info[port]['bandwidth'])
|
||||
return (weight, 10000 / bandwidth)
|
||||
|
||||
def _get_weighted_ports_per_contr(self, ports, ports_info):
|
||||
port_weight_map = {}
|
||||
for port in ports:
|
||||
port_weight_map[port] = self._count_port_weight(port, ports_info)
|
||||
|
||||
LOG.debug("port_weight_map: %s", port_weight_map)
|
||||
sorted_ports = sorted(port_weight_map.items(), key=lambda d: d[1])
|
||||
weighted_ports = []
|
||||
count = 0
|
||||
@ -132,6 +134,7 @@ class FCZoneHelper(object):
|
||||
lun_info = self.client.get_lun_info(lun_id)
|
||||
lun_contr_id = lun_info['OWNINGCONTROLLER']
|
||||
engines = self.client.get_all_engines()
|
||||
LOG.debug("Get array engines: %s", engines)
|
||||
|
||||
for engine in engines:
|
||||
contrs = json.loads(engine['NODELIST'])
|
||||
|
@ -1810,23 +1810,8 @@ class HuaweiFCDriver(HuaweiBaseDriver, driver.FibreChannelDriver):
|
||||
fc_info = {'driver_volume_type': 'fibre_channel',
|
||||
'data': {}}
|
||||
else:
|
||||
portg_id = None
|
||||
if not self.fcsan:
|
||||
self.fcsan = fczm_utils.create_lookup_service()
|
||||
|
||||
if self.fcsan:
|
||||
zone_helper = fc_zone_helper.FCZoneHelper(self.fcsan,
|
||||
self.client)
|
||||
|
||||
(tgt_port_wwns, portg_id, init_targ_map) = (
|
||||
zone_helper.get_init_targ_map(wwns, host_id))
|
||||
else:
|
||||
(tgt_port_wwns, init_targ_map) = (
|
||||
self.client.get_init_targ_map(wwns))
|
||||
|
||||
for wwn in wwns:
|
||||
if self.client.is_fc_initiator_associated_to_host(wwn):
|
||||
self.client.remove_fc_from_host(wwn)
|
||||
fc_info, portg_id = self._delete_zone_and_remove_fc_initiators(
|
||||
wwns, host_id)
|
||||
if lungroup_id:
|
||||
if view_id and self.client.lungroup_associated(
|
||||
view_id, lungroup_id):
|
||||
@ -1859,10 +1844,6 @@ class HuaweiFCDriver(HuaweiBaseDriver, driver.FibreChannelDriver):
|
||||
if view_id:
|
||||
self.client.delete_mapping_view(view_id)
|
||||
|
||||
fc_info = {'driver_volume_type': 'fibre_channel',
|
||||
'data': {'target_wwn': tgt_port_wwns,
|
||||
'initiator_target_map': init_targ_map}}
|
||||
|
||||
# Deal with hypermetro connection.
|
||||
metadata = huawei_utils.get_volume_metadata(volume)
|
||||
LOG.info(_LI("Detach Volume, metadata is: %s."), metadata)
|
||||
@ -1877,3 +1858,29 @@ class HuaweiFCDriver(HuaweiBaseDriver, driver.FibreChannelDriver):
|
||||
fc_info)
|
||||
|
||||
return fc_info
|
||||
|
||||
def _delete_zone_and_remove_fc_initiators(self, wwns, host_id):
|
||||
# Get tgt_port_wwns and init_targ_map to remove zone.
|
||||
portg_id = None
|
||||
if not self.fcsan:
|
||||
self.fcsan = fczm_utils.create_lookup_service()
|
||||
if self.fcsan:
|
||||
zone_helper = fc_zone_helper.FCZoneHelper(self.fcsan,
|
||||
self.client)
|
||||
(tgt_port_wwns, portg_id, init_targ_map) = (
|
||||
zone_helper.get_init_targ_map(wwns, host_id))
|
||||
else:
|
||||
(tgt_port_wwns, init_targ_map) = (
|
||||
self.client.get_init_targ_map(wwns))
|
||||
|
||||
# Remove the initiators from host if need.
|
||||
if host_id:
|
||||
fc_initiators = self.client.get_host_fc_initiators(host_id)
|
||||
for wwn in wwns:
|
||||
if wwn in fc_initiators:
|
||||
self.client.remove_fc_from_host(wwn)
|
||||
|
||||
info = {'driver_volume_type': 'fibre_channel',
|
||||
'data': {'target_wwn': tgt_port_wwns,
|
||||
'initiator_target_map': init_targ_map}}
|
||||
return info, portg_id
|
||||
|
Loading…
x
Reference in New Issue
Block a user