Skip to content
Merged
19 changes: 19 additions & 0 deletions delfin/drivers/pure/flasharray/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,22 @@

PARSE_ALERT_SEVERITY_MAP = {'1': constants.Severity.WARNING,
'2': constants.Severity.INFORMATIONAL}

HOST_OS_TYPES_MAP = {
'linux': constants.HostOSTypes.LINUX,
'windows': constants.HostOSTypes.WINDOWS,
'solaris': constants.HostOSTypes.SOLARIS,
'hp-ux': constants.HostOSTypes.HP_UX,
'hpux': constants.HostOSTypes.HP_UX,
'aix': constants.HostOSTypes.AIX,
'xenserver': constants.HostOSTypes.XEN_SERVER,
'vmware esx': constants.HostOSTypes.VMWARE_ESX,
'esxi': constants.HostOSTypes.VMWARE_ESX,
'linux_vis': constants.HostOSTypes.LINUX_VIS,
'windows server 2012': constants.HostOSTypes.WINDOWS_SERVER_2012,
'oracle vm': constants.HostOSTypes.ORACLE_VM,
'oracle-vm-server': constants.HostOSTypes.ORACLE_VM,
'open vms': constants.HostOSTypes.OPEN_VMS,
'vms': constants.HostOSTypes.OPEN_VMS,
'unknown': constants.HostOSTypes.UNKNOWN
}
153 changes: 152 additions & 1 deletion delfin/drivers/pure/flasharray/pure_flasharray.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def list_alerts(self, context, query_para=None):
timestamp = (int(datetime.datetime.strptime
(opened, '%Y-%m-%dT%H:%M:%SZ').timestamp()
+ time_difference) *
consts.DEFAULT_LIST_ALERTS_TIME_CONVERSION) if\
consts.DEFAULT_LIST_ALERTS_TIME_CONVERSION) if \
opened is not None else None
if query_para is not None:
try:
Expand Down Expand Up @@ -362,3 +362,154 @@ def reset_connection(self, context, **kwargs):
@staticmethod
def get_access_url():
return 'https://{ip}'

def list_storage_host_initiators(self, context):
list_initiators = []
initiators = self.rest_handler.rest_call(
self.rest_handler.REST_HOST_URL)
for initiator in (initiators or []):
host_id = initiator.get('name')
self.get_initiator(initiator, list_initiators, host_id, 'iqn',
constants.InitiatorType.ISCSI)
self.get_initiator(initiator, list_initiators, host_id, 'wwn',
constants.InitiatorType.FC)
self.get_initiator(initiator, list_initiators, host_id, 'nqn',
constants.InitiatorType.NVME_OVER_FABRIC)
return list_initiators

def get_initiator(self, initiator, list_initiators, host_id, protocol,
network):
protocol_list = initiator.get(protocol)
if protocol_list:
for initiator_protocol in (protocol_list or []):
if 'wwn' in protocol:
initiator_protocol = self.get_splice_wwn(
initiator_protocol)
initiator_d = {
'native_storage_host_initiator_id': initiator_protocol,
'native_storage_host_id': host_id,
'name': initiator_protocol,
'type': network,
'status': constants.InitiatorStatus.UNKNOWN,
'wwn': initiator_protocol,
'storage_id': self.storage_id
}
list_initiators.append(initiator_d)

def list_storage_hosts(self, ctx):
host_list = []
hosts = self.rest_handler.rest_call(
self.rest_handler.REST_HOST_PERSONALITY_URL)
for host in (hosts or []):
name = host.get('name')
personality = host.get('personality').lower()\
if host.get('personality') else None
h = {
"name": name,
"storage_id": self.storage_id,
"native_storage_host_id": name,
"os_type": consts.HOST_OS_TYPES_MAP.get(
personality, constants.HostOSTypes.UNKNOWN),
"status": constants.HostStatus.NORMAL
}
host_list.append(h)
return host_list

def list_storage_host_groups(self, context):
host_groups = self.rest_handler.rest_call(
self.rest_handler.REST_HGROUP_URL)
host_group_list = []
storage_host_grp_relation_list = []
for hgroup in (host_groups or []):
name = hgroup.get('name')
hg = {
'native_storage_host_group_id': name,
'name': name,
'storage_id': self.storage_id
}
host_group_list.append(hg)
for host in (hgroup.get('hosts') or []):
host_relation = {
'native_storage_host_group_id': name,
'storage_id': self.storage_id,
'native_storage_host_id': host
}
storage_host_grp_relation_list.append(host_relation)
result = {
'storage_host_groups': host_group_list,
'storage_host_grp_host_rels': storage_host_grp_relation_list
}
return result

def list_volume_groups(self, context):
volume_groups = self.rest_handler.rest_call(
self.rest_handler.REST_VOLUME_GROUP_URL)
vol_group_list = []
vol_grp_vol_relation_list = []
for volume_group in (volume_groups or []):
name = volume_group.get('name')
vol_g = {
'name': name,
'storage_id': self.storage_id,
'native_volume_group_id': name
}
vol_group_list.append(vol_g)
for volume_id in (volume_group.get('volumes') or []):
volume_group_relation = {
'storage_id': self.storage_id,
'native_volume_group_id': name,
'native_volume_id': volume_id
}
vol_grp_vol_relation_list.append(volume_group_relation)
result = {
'volume_groups': vol_group_list,
'vol_grp_vol_rels': vol_grp_vol_relation_list
}
return result

def list_masking_views(self, context):
list_masking_views = []
view_id_dict = {}
hgroup_views = self.rest_handler.rest_call(
self.rest_handler.REST_HGROUP_CONNECT_URL)
for hgroup_view in (hgroup_views or []):
hgroup_name = hgroup_view.get('name')
native_volume_id = hgroup_view.get('vol')
native_masking_view_id = '{}{}'.format(
hgroup_name, native_volume_id)
if view_id_dict.get(hgroup_name):
continue
view_id_dict[native_masking_view_id] = hgroup_name
view = {
'native_masking_view_id': native_masking_view_id,
'name': native_masking_view_id,
'native_storage_host_group_id': hgroup_name,
'native_volume_id': native_volume_id,
'storage_id': self.storage_id
}
list_masking_views.append(view)

masking_views = self.rest_handler.rest_call(
self.rest_handler.REST_HOST_CONNECT_URL)
for masking_view in (masking_views or []):
hgroup = masking_view.get('hgroup')
host_id = masking_view.get('name')
native_volume_id = masking_view.get('vol')
hgroup_name = '{}{}'.format(hgroup, native_volume_id)
if view_id_dict.get(hgroup_name) is not None and\
view_id_dict.get(hgroup_name) in hgroup:
continue
native_masking_view_id = '{}{}{}'.format(
host_id, hgroup, native_volume_id)
if view_id_dict.get(native_masking_view_id):
continue
view_id_dict[native_masking_view_id] = native_masking_view_id
view = {
'native_masking_view_id': native_masking_view_id,
'name': native_masking_view_id,
'native_storage_host_id': host_id,
'native_volume_id': native_volume_id,
'storage_id': self.storage_id
}
list_masking_views.append(view)
return list_masking_views
6 changes: 6 additions & 0 deletions delfin/drivers/pure/flasharray/rest_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class RestHandler(RestClient):
REST_ALERTS_URL = '/api/1.17/message?flagged=true&open=true'
REST_AUTH_URL = '/api/1.17/auth/apitoken'
REST_SESSION_URL = '/api/1.17/auth/session'
REST_HOST_URL = '/api/1.17/host'
REST_HOST_PERSONALITY_URL = '/api/1.17/host?personality=true'
REST_HOST_CONNECT_URL = '/api/1.17/host?connect=true'
REST_HGROUP_CONNECT_URL = '/api/1.17/hgroup?connect=true'
REST_HGROUP_URL = '/api/1.17/hgroup'
REST_VOLUME_GROUP_URL = '/api/1.17/vgroup'

def __init__(self, **kwargs):
super(RestHandler, self).__init__(**kwargs)
Expand Down
Loading