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

Syncing master to perf_coll_fw_enhance #683

Merged
merged 7 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions delfin/api/v1/port_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ def show(self, req, id):

port_groups = db.port_groups_get_all(
ctxt, marker, limit, sort_keys, sort_dirs, query_params, offset)

# Get Port Group to Port relation from DB
for port_group in port_groups:
params = {
"native_port_group_id":
port_group['native_port_group_id']
}
ports = db.port_grp_port_rels_get_all(
ctxt, filters=params)

native_port_id_list = []
for port in ports:
native_port_id_list.append(port['native_port_id'])

port_group['ports'] = native_port_id_list

return port_group_view.build_port_groups(port_groups)


Expand Down
17 changes: 17 additions & 0 deletions delfin/api/v1/storage_host_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ def show(self, req, id):

storage_host_groups = db.storage_host_groups_get_all(
ctxt, marker, limit, sort_keys, sort_dirs, query_params, offset)

# Get Storage Host Group to Host relation from DB
for host_group in storage_host_groups:
params = {
"native_storage_host_group_id":
host_group['native_storage_host_group_id']
}
hosts = db.storage_host_grp_host_rels_get_all(
ctxt, filters=params)

native_storage_host_id_list = []
for host in hosts:
native_storage_host_id_list.append(
host['native_storage_host_id'])

host_group['storage_hosts'] = native_storage_host_id_list

return storage_host_group_view\
.build_storage_host_groups(storage_host_groups)

Expand Down
16 changes: 16 additions & 0 deletions delfin/api/v1/volume_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ def show(self, req, id):

volume_groups = db.volume_groups_get_all(
ctxt, marker, limit, sort_keys, sort_dirs, query_params, offset)

# Get Volume Group to Volume relation from DB
for volume_group in volume_groups:
params = {
"native_volume_group_id":
volume_group['native_volume_group_id']
}
volumes = db.vol_grp_vol_rels_get_all(
ctxt, filters=params)

native_volume_id_list = []
for volume in volumes:
native_volume_id_list.append(volume['native_volume_id'])

volume_group['volumes'] = native_volume_id_list

return volume_group_view.build_volume_groups(volume_groups)


Expand Down
33 changes: 33 additions & 0 deletions delfin/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,39 @@ class ShareProtocol(object):
ALL = (CIFS, NFS, FTP, HDFS)


class HostStatus(object):
NORMAL = 'normal'
OFFLINE = 'offline'
ABNORMAL = 'abnormal'

ALL = (NORMAL, OFFLINE, ABNORMAL)


class HostOSTypes(object):
LINUX = 'Linux'
WINDOWS = 'Windows'
SOLARIS = 'Solaris'
HP_UX = 'HP-UX'
AIX = 'AIX'
XEN_SERVER = 'XenServer'
VMWARE_ESX = 'VMware ESX'
LINUX_VIS = 'LINUX_VIS'
WINDOWS_SERVER_2012 = 'Windows Server 2012'
ORACLE_VM = 'Oracle VM'
OPEN_VMS = 'Open VMS'

ALL = (LINUX, WINDOWS, SOLARIS, HP_UX, AIX, XEN_SERVER, VMWARE_ESX,
LINUX_VIS, WINDOWS_SERVER_2012, ORACLE_VM, OPEN_VMS)


class InitiatorStatus(object):
ONLINE = 'online'
OFFLINE = 'offline'
UNKNOWN = 'unknown'

ALL = (ONLINE, OFFLINE, UNKNOWN)


# Enumerations for alert severity
class Severity(object):
FATAL = 'Fatal'
Expand Down
2 changes: 1 addition & 1 deletion delfin/db/sqlalchemy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@ def vol_grp_vol_rels_get_all(context, marker=None, limit=None,
with session.begin():
# Generate the query
query = _generate_paginate_query(context, session, models.
VolGrpVolRelation,
VolGrpVolRel,
marker, limit, sort_keys, sort_dirs,
filters, offset)
# No volume grp volume relation would match, return empty list
Expand Down
88 changes: 75 additions & 13 deletions delfin/drivers/fake_storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@

# Min and max are currently set to 1 to make sure at least one relation can be
# built in fake driver for host mapping elements
MIN_STORAGE_HOST_INITIATORS, MAX_STORAGE_HOST_INITIATORS = 1, 1
MIN_STORAGE_HOSTS, MAX_STORAGE_HOSTS = 1, 1
MIN_STORAGE_HOST_GROUPS, MAX_STORAGE_HOST_GROUPS = 1, 1
MIN_VOLUME_GROUPS, MAX_VOLUME_GROUPS = 1, 1
MIN_PORT_GROUPS, MAX_PORT_GROUPS = 1, 1
MIN_MASKING_VIEWS, MAX_MASKING_VIEWS = 1, 1
MIN_STORAGE_HOST_INITIATORS, MAX_STORAGE_HOST_INITIATORS = 1, 3
MIN_STORAGE_HOSTS, MAX_STORAGE_HOSTS = 1, 5
MIN_STORAGE_HOST_GROUPS, MAX_STORAGE_HOST_GROUPS = 1, 5
MIN_VOLUME_GROUPS, MAX_VOLUME_GROUPS = 1, 5
MIN_PORT_GROUPS, MAX_PORT_GROUPS = 1, 5
MAX_GROUP_RESOURCES_SIZE = 5
MIN_MASKING_VIEWS, MAX_MASKING_VIEWS = 1, 5


def get_range_val(range_str, t):
Expand Down Expand Up @@ -124,6 +125,10 @@ def __init__(self, **kwargs):
MIN_VOLUME, MAX_VOLUME = get_range_val(
CONF.fake_driver.fake_volume_range, int)
PAGE_LIMIT = int(CONF.fake_driver.fake_page_query_limit)
self.rd_volumes_count = random.randint(MIN_VOLUME, MAX_VOLUME)
self.rd_ports_count = random.randint(MIN_PORTS, MAX_PORTS)
self.rd_storage_hosts_count = random.randint(MIN_STORAGE_HOSTS,
MAX_STORAGE_HOSTS)

def _get_random_capacity(self):
total = random.randint(1000, 2000)
Expand Down Expand Up @@ -190,7 +195,7 @@ def list_storage_pools(self, ctx):

def list_volumes(self, ctx):
# Get a random number as the volume count.
rd_volumes_count = random.randint(MIN_VOLUME, MAX_VOLUME)
rd_volumes_count = self.rd_volumes_count
LOG.info("###########fake_volumes number for %s: %d" % (
self.storage_id, rd_volumes_count))
loops = math.ceil(rd_volumes_count / PAGE_LIMIT)
Expand Down Expand Up @@ -228,7 +233,7 @@ def list_controllers(self, ctx):
return ctrl_list

def list_ports(self, ctx):
rd_ports_count = random.randint(MIN_PORTS, MAX_PORTS)
rd_ports_count = self.rd_ports_count
LOG.info("###########fake_ports for %s: %d" % (self.storage_id,
rd_ports_count))
port_list = []
Expand Down Expand Up @@ -871,8 +876,7 @@ def list_storage_host_initiators(self, ctx):
return storage_host_initiators_list

def list_storage_hosts(self, ctx):
rd_storage_hosts_count = random.randint(MIN_STORAGE_HOSTS,
MAX_STORAGE_HOSTS)
rd_storage_hosts_count = self.rd_storage_hosts_count
LOG.info("###########fake_storage_hosts for %s: %d"
% (self.storage_id, rd_storage_hosts_count))
storage_host_list = []
Expand All @@ -890,33 +894,72 @@ def list_storage_hosts(self, ctx):
return storage_host_list

def list_storage_host_groups(self, ctx):
rd_storage_host_groups_count = random.randint(MIN_STORAGE_HOST_GROUPS,
MAX_STORAGE_HOST_GROUPS)
rd_storage_host_groups_count = random.randint(
MIN_STORAGE_HOST_GROUPS, MAX_STORAGE_HOST_GROUPS)
LOG.info("###########fake_storage_host_groups for %s: %d"
% (self.storage_id, rd_storage_host_groups_count))
storage_host_grp_list = []
for idx in range(rd_storage_host_groups_count):
# Create hosts in hosts group
host_name_list = []
storage_hosts_count = self.rd_storage_hosts_count - 1
if storage_hosts_count > 0:
for i in range(MAX_GROUP_RESOURCES_SIZE):
host_name = "storage_host_" + str(
random.randint(0, storage_hosts_count))
if host_name not in host_name_list:
host_name_list.append(host_name)

# Create comma separated list
storage_hosts = None
for host in host_name_list:
if storage_hosts:
storage_hosts = storage_hosts + "," + host
else:
storage_hosts = host

f = {
"name": "storage_host_group_" + str(idx),
"description": "storage_host_group_" + str(idx),
"storage_id": self.storage_id,
"native_storage_host_group_id": "storage_host_group_"
+ str(idx),
"storage_hosts": storage_hosts
}
storage_host_grp_list.append(f)
return storage_host_grp_list

def list_port_groups(self, ctx):
rd_port_groups_count = random.randint(MIN_PORT_GROUPS, MAX_PORT_GROUPS)
rd_port_groups_count = random.randint(MIN_PORT_GROUPS,
MAX_PORT_GROUPS)
LOG.info("###########fake_port_groups for %s: %d"
% (self.storage_id, rd_port_groups_count))
port_grp_list = []
for idx in range(rd_port_groups_count):
# Create ports in ports group
port_name_list = []
ports_count = self.rd_ports_count - 1
if ports_count > 0:
for i in range(MAX_GROUP_RESOURCES_SIZE):
port_name = "port_" + str(
random.randint(0, ports_count))
if port_name not in port_name_list:
port_name_list.append(port_name)

# Create comma separated list
ports = None
for port in port_name_list:
if ports:
ports = ports + "," + port
else:
ports = port

f = {
"name": "port_group_" + str(idx),
"description": "port_group_" + str(idx),
"storage_id": self.storage_id,
"native_port_group_id": "port_group_" + str(idx),
"ports": ports
}

port_grp_list.append(f)
Expand All @@ -929,11 +972,30 @@ def list_volume_groups(self, ctx):
% (self.storage_id, rd_volume_groups_count))
volume_grp_list = []
for idx in range(rd_volume_groups_count):
# Create volumes in volumes group
volume_name_list = []
volumes_count = self.rd_volumes_count - 1
if volumes_count > 0:
for i in range(MAX_GROUP_RESOURCES_SIZE):
volume_name = "volume_" + str(
random.randint(0, volumes_count))
if volume_name not in volume_name_list:
volume_name_list.append(volume_name)

# Create comma separated list
volumes = None
for volume in volume_name_list:
if volumes:
volumes = volumes + "," + volume
else:
volumes = volume

f = {
"name": "volume_group_" + str(idx),
"description": "volume_group_" + str(idx),
"storage_id": self.storage_id,
"native_volume_group_id": "volume_group_" + str(idx),
"volumes": volumes
}
volume_grp_list.append(f)
return volume_grp_list
Expand Down
26 changes: 26 additions & 0 deletions delfin/drivers/huawei/oceanstor/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,32 @@
THICK_LUNTYPE = '0'
THIN_LUNTYPE = '1'

HOST_OS = [
constants.HostOSTypes.LINUX,
constants.HostOSTypes.WINDOWS,
constants.HostOSTypes.SOLARIS,
constants.HostOSTypes.HP_UX,
constants.HostOSTypes.AIX,
constants.HostOSTypes.XEN_SERVER,
constants.HostOSTypes.VMWARE_ESX,
constants.HostOSTypes.LINUX_VIS,
constants.HostOSTypes.WINDOWS_SERVER_2012,
constants.HostOSTypes.ORACLE_VM,
constants.HostOSTypes.OPEN_VMS,
]

HOST_RUNNINGSTATUS_NORMAL = '1'
INITIATOR_RUNNINGSTATUS_UNKNOWN = '0'
INITIATOR_RUNNINGSTATUS_ONLINE = '27'
INITIATOR_RUNNINGSTATUS_OFFLINE = '28'
ISCSI_INITIATOR_TYPE = 222
FC_INITIATOR_TYPE = 223
IB_INITIATOR_TYPE = 16499
ISCSI_INITIATOR_DESCRIPTION = 'iSCSI Initiator'
FC_INITIATOR_DESCRIPTION = 'FC Initiator'
IB_INITIATOR_DESCRIPTION = 'IB Initiator'
UNKNOWN_INITIATOR_DESCRIPTION = 'Unknown Initiator'

OCEANSTOR_METRICS = {
'iops': '22',
'readIops': '25',
Expand Down
Loading