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

unity add host mapping view #795

Merged
merged 22 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e1fdddd
unity add host mapping view
tanjiangyu-ghca Jan 10, 2022
17d39b9
Merge pull request #415 from tanjiangyu-ghca/unity_host
ghca-cxl Jan 10, 2022
480a37a
Merge branch 'master' into unity_host
tanjiangyu-ghca Jan 10, 2022
f4010a2
Merge branch 'master' into unity_host
tanjiangyu-ghca Jan 20, 2022
57e46d4
unity change host os_type with unknown
tanjiangyu-ghca Jan 20, 2022
0c2773e
unity change host os_type with unknown
tanjiangyu-ghca Jan 20, 2022
75b7722
Merge pull request #438 from tanjiangyu-ghca/unity_host
tanjiangyu-ghca Jan 20, 2022
2e2691d
Merge branch 'sodafoundation:master' into unity_host
tanjiangyu-ghca Feb 9, 2022
6bc2cc9
unity change host status
tanjiangyu-ghca Feb 9, 2022
54a7e84
Merge pull request #490 from tanjiangyu-ghca/unity_host
tanjiangyu-ghca Feb 9, 2022
07f8491
Merge branch 'sodafoundation:master' into unity_host
tanjiangyu-ghca Feb 18, 2022
13077e8
unity mapping add mac os type
tanjiangyu-ghca Feb 18, 2022
b29d21c
Merge pull request #509 from tanjiangyu-ghca/unity_host
tanjiangyu-ghca Feb 18, 2022
409df9f
Merge branch 'master' into unity_host
tanjiangyu-ghca Apr 8, 2022
e6fac2a
Merge branch 'master' into unity_host
tanjiangyu-ghca Apr 22, 2022
173ce3f
Merge branch 'master' into unity_host
tanjiangyu-ghca May 18, 2022
71458f4
unity code rebase
tanjiangyu-ghca May 18, 2022
ec81232
Merge branch 'unity_host' of https://github.com/tanjiangyu-ghca/delfi…
tanjiangyu-ghca May 18, 2022
cee1edb
unity code rebase
tanjiangyu-ghca May 18, 2022
c6a8f23
Merge pull request #531 from tanjiangyu-ghca/unity_host
tanjiangyu-ghca May 18, 2022
e23c143
Merge branch 'master' into unity_host
tanjiangyu-ghca May 18, 2022
2ba5f98
Merge branch 'master' into unity_host
tanjiangyu-ghca May 20, 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
24 changes: 24 additions & 0 deletions delfin/drivers/dell_emc/unity/rest_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,27 @@ def get_quota_configs(self):
'fields=id,filesystem,treeQuota,quotaPolicy')
result_json = self.get_rest_info(url)
return result_json

def get_host_initiators(self, page):
url = '/api/types/hostInitiator/instances?%s&page=%s' % \
('fields=id,health,type,parentHost,initiatorId', page)
result_json = self.get_rest_info(url)
return result_json

def get_all_hosts(self, page):
url = '/api/types/host/instances?%s&page=%s' \
% ('fields=id,health,name,description,osType', page)
result_json = self.get_rest_info(url)
return result_json

def get_host_ip(self):
url = '/api/types/hostIPPort/instances?%s' % \
('fields=id,name,address,netmask,host')
result_json = self.get_rest_info(url)
return result_json

def get_host_lun(self, page):
url = '/api/types/hostLUN/instances?%s&page=%s' % \
('fields=id,host,lun', page)
result_json = self.get_rest_info(url)
return result_json
153 changes: 153 additions & 0 deletions delfin/drivers/dell_emc/unity/unity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,34 @@ class UnityStorDriver(driver.StorageDriver):
99: constants.DiskPhysicalType.VMDISK
}

OS_TYPE_MAP = {'AIX': constants.HostOSTypes.AIX,
'Citrix XenServer': constants.HostOSTypes.XEN_SERVER,
'HP-UX': constants.HostOSTypes.HP_UX,
'IBM VIOS': constants.HostOSTypes.UNKNOWN,
'Linux': constants.HostOSTypes.LINUX,
'Mac OS': constants.HostOSTypes.UNKNOWN,
'Solaris': constants.HostOSTypes.SOLARIS,
'VMware ESXi': constants.HostOSTypes.VMWARE_ESX,
'Windows Client': constants.HostOSTypes.WINDOWS,
'Windows Server': constants.HostOSTypes.WINDOWS
}
INITIATOR_STATUS_MAP = {5: constants.InitiatorStatus.ONLINE,
7: constants.InitiatorStatus.ONLINE,
15: constants.InitiatorStatus.ONLINE,
20: constants.InitiatorStatus.ONLINE,
10: constants.InitiatorStatus.OFFLINE
}
HOST_STATUS_MAP = {5: constants.HostStatus.NORMAL,
7: constants.HostStatus.NORMAL,
15: constants.HostStatus.NORMAL,
20: constants.HostStatus.NORMAL,
10: constants.HostStatus.ABNORMAL
}
INITIATOR_TYPE_MAP = {0: constants.InitiatorType.UNKNOWN,
1: constants.InitiatorType.FC,
2: constants.InitiatorType.ISCSI
}

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.rest_handler = rest_handler.RestHandler(**kwargs)
Expand Down Expand Up @@ -650,3 +678,128 @@ def clear_alert(self, context, alert):
@staticmethod
def get_access_url():
return 'https://{ip}'

def list_storage_host_initiators(self, context):
try:
initiator_list = []
page = 1
while True:
initiators = self.rest_handler.get_host_initiators(page)
if not initiators:
return initiator_list
if 'entries' not in initiators or \
len(initiators['entries']) < 1:
break
init_entries = initiators.get('entries')
for initiator in init_entries:
content = initiator.get('content')
if not content:
continue
health_value = content.get('health', {}).get('value')
status = UnityStorDriver.INITIATOR_STATUS_MAP.get(
health_value,
constants.InitiatorStatus.UNKNOWN
)
init_result = {
"name": content.get('initiatorId'),
"storage_id": self.storage_id,
"native_storage_host_initiator_id": content.get('id'),
"wwn": content.get('initiatorId'),
"status": status,
"type": UnityStorDriver.INITIATOR_TYPE_MAP.get(
content.get('type')),
"native_storage_host_id": content.get(
'parentHost', {}).get('id')
}
initiator_list.append(init_result)
page += 1
return initiator_list
except Exception as e:
LOG.error("Failed to get initiators from unity")
raise e

def list_storage_hosts(self, context):
try:
host_list = []
page = 1
while True:
hosts = self.rest_handler.get_all_hosts(page)
if not hosts:
return host_list
if 'entries' not in hosts or len(hosts['entries']) < 1:
break
ips = self.rest_handler.get_host_ip()
host_entries = hosts.get('entries')
for host in host_entries:
host_ip = None
content = host.get('content')
if not content:
continue
health_value = content.get('health', {}).get('value')
status = UnityStorDriver.HOST_STATUS_MAP.get(
health_value,
constants.HostStatus.OFFLINE
)
if ips:
ip_entries = ips.get('entries')
for ip in ip_entries:
ip_content = ip.get('content')
if not ip_content:
continue
if ip_content.get('host', {}).get('id') \
== content.get('id'):
host_ip = ip_content.get('address')
break
if content.get('osType'):
if 'VMware ESXi' in content.get('osType'):
os_type = constants.HostOSTypes.VMWARE_ESX
else:
os_type = UnityStorDriver.OS_TYPE_MAP.get(
content.get('osType'),
constants.HostOSTypes.UNKNOWN)
else:
os_type = None
host_result = {
"name": content.get('name'),
"description": content.get('description'),
"storage_id": self.storage_id,
"native_storage_host_id": content.get('id'),
"os_type": os_type,
"status": status,
"ip_address": host_ip
}
host_list.append(host_result)
page += 1
return host_list
except Exception as e:
LOG.error("Failed to get host metrics from unity")
raise e

def list_masking_views(self, context):
try:
view_list = []
page = 1
while True:
views = self.rest_handler.get_host_lun(page)
if not views:
return view_list
if 'entries' not in views or len(views['entries']) < 1:
break
view_entries = views.get('entries')
for view in view_entries:
content = view.get('content')
view_result = {
"name": content.get('id'),
"native_storage_host_id":
content.get('host', {}).get('id'),
"storage_id": self.storage_id,
"native_volume_id": content.get('lun', {}).get('id'),
"native_masking_view_id": content.get('id'),
}
view_list.append(view_result)
page += 1
return view_list

except Exception as e:
LOG.error("Failed to get view metrics from unity")
raise e
Loading