Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hpe 3par add host mapping view #798

Merged
merged 31 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e4b0270
3par add host mapping view
yuanyu-ghca Jan 11, 2022
e1494a8
3par add host mapping view
yuanyu-ghca Jan 19, 2022
431936e
Merge pull request #429 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Jan 19, 2022
e50231f
Merge branch 'master' into hpe_3par_hostmap
yuanyu-ghca Jan 19, 2022
1af34bb
3par add host mapping view
yuanyu-ghca Jan 19, 2022
4b5b8c9
Merge pull request #430 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Jan 19, 2022
a2cff2c
3par add host mapping view
yuanyu-ghca Jan 19, 2022
097fd82
Merge pull request #432 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Jan 19, 2022
12f6c85
Merge branch 'master' into hpe_3par_hostmap
yuanyu-ghca Jan 21, 2022
48dd99a
Handling view return issues
yuanyu-ghca Jan 21, 2022
868cd2b
Merge pull request #446 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Jan 21, 2022
727cf34
modify bug
yuanyu-ghca Jan 21, 2022
b739071
Merge pull request #449 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Jan 21, 2022
b869067
modify bug
yuanyu-ghca Jan 21, 2022
3f0f900
Merge pull request #451 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Jan 21, 2022
30ce97e
modify bug
yuanyu-ghca Jan 24, 2022
76a4479
Merge pull request #453 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Jan 24, 2022
84cafe6
Merge branch 'master' into hpe_3par_hostmap
yuanyu-ghca Jan 26, 2022
900c98d
modify bug
yuanyu-ghca Feb 8, 2022
7d94230
Merge pull request #482 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Feb 8, 2022
e6390af
Merge branch 'master' into hpe_3par_hostmap
yuanyu-ghca Feb 8, 2022
cd23dff
modify test unit
yuanyu-ghca Feb 8, 2022
609c793
Merge pull request #484 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Feb 8, 2022
adbf00e
modify bug
yuanyu-ghca Feb 8, 2022
f90629f
Merge pull request #487 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Feb 8, 2022
2a2fe7c
modify bug
yuanyu-ghca Feb 8, 2022
ea00d54
Merge pull request #488 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Feb 8, 2022
d9bad9c
Merge branch 'master' into hpe_3par_hostmap
yuanyu-ghca Feb 22, 2022
de2010c
Optimize disk status
yuanyu-ghca Feb 22, 2022
d1c6554
Merge pull request #512 from yuanyu-ghca/hpe_3par_hostmap
yuanyu-ghca Feb 22, 2022
dfe1d35
Merge branch 'master' into hpe_3par_hostmap
tanjiangyu-ghca May 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 252 additions & 0 deletions delfin/drivers/hpe/hpe_3par/component_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,255 @@ def parse_speed(self, speed_value):
err_msg = "analyse speed error: %s" % (six.text_type(err))
LOG.error(err_msg)
return speed

def list_storage_host_initiators(self, storage_id):
initiators = self.ssh_handler.list_storage_host_initiators()
initiators_list = []
wwn_set = set()
for initiator in (initiators or []):
if initiator:
wwn = initiator.get('wwn/iscsi_name', '').replace('-', '')
if wwn:
if wwn in wwn_set:
continue
wwn_set.add(wwn)
ip_addr = initiator.get('ip_addr')
type = constants.InitiatorType.FC
if ip_addr and ip_addr != 'n/a':
type = constants.InitiatorType.ISCSI
initiator_model = {
"name": wwn,
"storage_id": storage_id,
"native_storage_host_initiator_id": wwn,
"wwn": wwn,
"type": type,
"status": constants.InitiatorStatus.ONLINE,
"native_storage_host_id": initiator.get('id',
'').replace(
'-', ''),
}
initiators_list.append(initiator_model)
return initiators_list

def list_storage_hosts(self, storage_id):
host_datas = self.rest_handler.list_storage_host()
host_list = []
if host_datas:
hosts = host_datas.get('members')
for host in (hosts or []):
if host and host.get('name'):
descriptors = host.get('descriptors')
comment = None
os = ''
ip_addr = None
if descriptors:
comment = descriptors.get('comment')
os = descriptors.get('os', '')
ip_addr = descriptors.get('IPAddr')
host_model = {
"name": host.get('name'),
"description": comment,
"storage_id": storage_id,
"native_storage_host_id": host.get('id'),
"os_type": consts.HOST_OS_MAP.get(
os, constants.HostOSTypes.UNKNOWN),
"status": constants.HostStatus.NORMAL,
"ip_address": ip_addr
}
host_list.append(host_model)
return host_list

def list_storage_host_groups(self, storage_id):
host_groups = self.ssh_handler.list_storage_host_groups()
host_group_list = []
result = {}
if host_groups:
hosts_map = self.ssh_handler.get_resources_ids(
self.ssh_handler.HPE3PAR_COMMAND_SHOWHOST_D,
consts.HOST_OR_VV_PATTERN)
for host_group in host_groups:
host_members = host_group.get('members')
host_ids = []
if hosts_map:
for host_name in (host_members or []):
host_id = hosts_map.get(host_name)
if host_id:
host_ids.append(host_id)
host_group_model = {
"name": host_group.get('name'),
"description": host_group.get('comment'),
"storage_id": storage_id,
"native_storage_host_group_id": host_group.get('id'),
"storage_hosts": ','.join(host_ids)
}
host_group_list.append(host_group_model)
storage_host_grp_relation_list = []
for storage_host_group in host_group_list:
storage_hosts = storage_host_group.pop('storage_hosts', None)
if not storage_hosts:
continue
storage_hosts = storage_hosts.split(',')

for storage_host in storage_hosts:
storage_host_group_relation = {
'storage_id': storage_id,
'native_storage_host_group_id': storage_host_group.get(
'native_storage_host_group_id'),
'native_storage_host_id': storage_host
}
storage_host_grp_relation_list \
.append(storage_host_group_relation)

result = {
'storage_host_groups': host_group_list,
'storage_host_grp_host_rels': storage_host_grp_relation_list
}
return result

def list_port_groups(self, storage_id):
views = self.ssh_handler.list_masking_views()
port_groups_list = []
port_list = []
for view in (views or []):
port = view.get('port', '').replace('-', '')
if port:
if port in port_list:
continue
port_list.append(port)
port_group_model = {
"name": "port_group_" + port,
"description": "port_group_" + port,
"storage_id": storage_id,
"native_port_group_id": "port_group_" + port,
"ports": port
}
port_groups_list.append(port_group_model)
port_group_relation_list = []
for port_group in port_groups_list:
ports = port_group.pop('ports', None)
if not ports:
continue
ports = ports.split(',')

for port in ports:
port_group_relation = {
'storage_id': storage_id,
'native_port_group_id':
port_group.get('native_port_group_id'),
'native_port_id': port
}
port_group_relation_list.append(port_group_relation)
result = {
'port_groups': port_groups_list,
'port_grp_port_rels': port_group_relation_list
}
return result

def list_volume_groups(self, storage_id):
volume_groups = self.ssh_handler.list_volume_groups()
volume_group_list = []
result = {}
if volume_groups:
volumes_map = self.ssh_handler.get_resources_ids(
self.ssh_handler.HPE3PAR_COMMAND_SHOWVV,
consts.HOST_OR_VV_PATTERN)
for volume_group in volume_groups:
volume_members = volume_group.get('members')
volume_ids = []
if volumes_map:
for volume_name in (volume_members or []):
volume_id = volumes_map.get(volume_name)
if volume_id:
volume_ids.append(volume_id)
volume_group_model = {
"name": volume_group.get('name'),
"description": volume_group.get('comment'),
"storage_id": storage_id,
"native_volume_group_id": volume_group.get('id'),
"volumes": ','.join(volume_ids)
}
volume_group_list.append(volume_group_model)
volume_group_relation_list = []
for volume_group in volume_group_list:
volumes = volume_group.pop('volumes', None)
if not volumes:
continue
volumes = volumes.split(',')

for volume in volumes:
volume_group_relation = {
'storage_id': storage_id,
'native_volume_group_id':
volume_group.get('native_volume_group_id'),
'native_volume_id': volume}
volume_group_relation_list.append(volume_group_relation)

result = {
'volume_groups': volume_group_list,
'vol_grp_vol_rels': volume_group_relation_list
}
return result

def list_masking_views(self, storage_id):
views = self.ssh_handler.list_masking_views()
views_list = []
if views:
hosts_map = self.ssh_handler.get_resources_ids(
self.ssh_handler.HPE3PAR_COMMAND_SHOWHOST_D,
consts.HOST_OR_VV_PATTERN)
hosts_group_map = self.ssh_handler.get_resources_ids(
self.ssh_handler.HPE3PAR_COMMAND_SHOWHOSTSET_D,
consts.HOST_OR_VV_PATTERN)
volumes_map = self.ssh_handler.get_resources_ids(
self.ssh_handler.HPE3PAR_COMMAND_SHOWVV,
consts.HOST_OR_VV_PATTERN)
volumes_group_map = self.ssh_handler.get_resources_ids(
self.ssh_handler.HPE3PAR_COMMAND_SHOWVVSET_D,
consts.HOST_OR_VV_PATTERN)
host_vv_set = set()
for view in views:
vv_name = view.get('vvname')
host_name = view.get('hostname')
if vv_name and host_name:
host_vv_key = '%s_%s' % (host_name, vv_name)
host_vv_key = host_vv_key.replace(' ', '')
if host_vv_key in host_vv_set:
continue
host_vv_set.add(host_vv_key)
port = view.get('port', '').replace('-', '')
lun_id = view.get('lun')
wwn = view.get('host_wwn/iscsi_name', '').replace('-', '')
native_port_group_id = None
if port:
lun_id = '%s_%s' % (lun_id, port)
native_port_group_id = 'port_group_%s' % port
if wwn:
lun_id = '%s_%s' % (lun_id, wwn)
lun_id = '%s_%s' % (lun_id, host_vv_key)
view_model = {
'native_masking_view_id': lun_id,
"name": view.get('lun'),
'native_port_group_id': native_port_group_id,
"storage_id": storage_id
}
if 'set:' in vv_name:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to validate mandatory fields are set in masking view.

From file <>/delfin/drivers/driver.py, function list_masking_views() comments, mandatory fields:

From host side: Mandatorily one of the (native_storage_host_group_id | native_storage_host_id)
From volume side: Mandatorily one of the (native_volume_group_id | native_volume_id)
From port side: Optionally (native_port_group_id)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified

vv_set_id = volumes_group_map.get(
vv_name.replace('set:', ''))
view_model['native_volume_group_id'] = vv_set_id
else:
vv_id = volumes_map.get(vv_name)
view_model['native_volume_id'] = vv_id
if 'set:' in host_name:
host_set_id = hosts_group_map.get(
host_name.replace('set:', ''))
view_model[
'native_storage_host_group_id'] = host_set_id
else:
host_id = hosts_map.get(host_name)
view_model['native_storage_host_id'] = host_id
if (view_model.get('native_storage_host_id')
or view_model.get('native_storage_host_group_id')) \
and (view_model.get('native_volume_id')
or view_model.get('native_volume_group_id')):
views_list.append(view_model)
return views_list
38 changes: 37 additions & 1 deletion delfin/drivers/hpe/hpe_3par/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@
"ShareDir\\s+State"
VFS_PATTERN = "^\\s*VFS\\s+FPG\\s+IPAddr\\s+State"
IPV4_PATTERN = "^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$"

HOST_OR_VV_SET_PATTERN = "^\\s*Id\\s+Name\\s+Members\\s+Comment"
HOST_OR_VV_PATTERN = "^\\s*Id\\s+Name\\s+"
VLUN_PATTERN = "^\\s*Lun\\s+VVName\\s+HostName"

CONTROLLER_STATUS_MAP = {
'OK': constants.ControllerStatus.NORMAL,
'NORMAL': constants.ControllerStatus.NORMAL,
Expand All @@ -668,7 +673,7 @@
}
DISK_STATUS_MAP = {
'NORMAL': constants.DiskStatus.NORMAL,
'DEGRADED': constants.DiskStatus.ABNORMAL,
'DEGRADED': constants.DiskStatus.DEGRADED,
'FAILED': constants.DiskStatus.ABNORMAL,
'NEW': constants.DiskStatus.ABNORMAL
}
Expand Down Expand Up @@ -705,3 +710,34 @@
1: "control",
2: "data"
}
HOST_OS_MAP = {
'AIX': constants.HostOSTypes.AIX,
'Citrix Xen Server 5.x/6.x': constants.HostOSTypes.XEN_SERVER,
'Citrix Xen Server 7.x': constants.HostOSTypes.XEN_SERVER,
'HP-UX': constants.HostOSTypes.HP_UX,
'HP-UX (11i v1,11i v2)': constants.HostOSTypes.HP_UX,
'HP-UX (11i v3)': constants.HostOSTypes.HP_UX,
'OpenVMS': constants.HostOSTypes.OPEN_VMS,
'Oracle VM x86': constants.HostOSTypes.ORACLE_VM,
'Solaris 11': constants.HostOSTypes.SOLARIS,
'Solaris 9/10': constants.HostOSTypes.SOLARIS,
'VMware (ESXi)': constants.HostOSTypes.VMWARE_ESX,
'ESXI6.0': constants.HostOSTypes.VMWARE_ESX,
'ESX 4.x/5.x': constants.HostOSTypes.VMWARE_ESX,
'Windows 2003': constants.HostOSTypes.WINDOWS,
'Windows 2008/2008 R2': constants.HostOSTypes.WINDOWS,
'Windows 2012': constants.HostOSTypes.WINDOWS_SERVER_2012,
'Windows 2012 / WS2012 R2': constants.HostOSTypes.WINDOWS_SERVER_2012,
'Windows Server 2016': constants.HostOSTypes.WINDOWS,
'Red Hat Enterprise Linux': constants.HostOSTypes.LINUX,
'OE Linux UEK (5.x, 6.x)': constants.HostOSTypes.LINUX,
'OE Linux UEK 7.x': constants.HostOSTypes.LINUX,
'RHE Linux (5.x, 6.x)': constants.HostOSTypes.LINUX,
'RHE Linux (Pre RHEL 5)': constants.HostOSTypes.LINUX,
'RHE Linux 7.x': constants.HostOSTypes.LINUX,
'SuSE (10.x, 11.x)': constants.HostOSTypes.LINUX,
'SuSE': constants.HostOSTypes.LINUX,
'SuSE 12.x': constants.HostOSTypes.LINUX,
'SuSE Linux (Pre SLES 10)': constants.HostOSTypes.LINUX,
'SuSE Virtualization': constants.HostOSTypes.LINUX
}
21 changes: 15 additions & 6 deletions delfin/drivers/hpe/hpe_3par/hpe_3parstor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,20 @@ def parse_alert(context, alert):
def clear_alert(self, context, alert):
return self.alert_handler.clear_alert(context, alert)

def list_filesystems(self, context):
pass
def list_storage_host_initiators(self, context):
return self.comhandler.list_storage_host_initiators(self.storage_id)

def list_qtrees(self, context):
pass
def list_storage_hosts(self, context):
return self.comhandler.list_storage_hosts(self.storage_id)

def list_shares(self, context):
pass
def list_storage_host_groups(self, context):
return self.comhandler.list_storage_host_groups(self.storage_id)

def list_port_groups(self, context):
return self.comhandler.list_port_groups(self.storage_id)

def list_volume_groups(self, context):
return self.comhandler.list_volume_groups(self.storage_id)

def list_masking_views(self, context):
return self.comhandler.list_masking_views(self.storage_id)
7 changes: 7 additions & 0 deletions delfin/drivers/hpe/hpe_3par/rest_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class RestHandler(object):

REST_ALERTS_URL = '/api/v1/eventlog?query="category EQ 2"'

REST_HOSTS_URL = '/api/v1/hosts'

REST_AUTH_KEY = 'X-HP3PAR-WSAPI-SessionKey'

session_lock = None
Expand Down Expand Up @@ -196,3 +198,8 @@ def get_all_volumes(self):
rejson = self.get_resinfo_call(RestHandler.REST_VOLUMES_URL,
method='GET')
return rejson

def list_storage_host(self):
rejson = self.get_resinfo_call(RestHandler.REST_HOSTS_URL,
method='GET')
return rejson
Loading