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

add msa system pool volume disks alerts resources #761

Merged
merged 60 commits into from
Dec 24, 2021

Conversation

luojiagen
Copy link
Contributor

What this PR does / why we need it:
add msa system pool volume disks alerts resources
Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Release note:

@codecov
Copy link

codecov bot commented Oct 14, 2021

Codecov Report

Merging #761 (c847a98) into master (b004d74) will decrease coverage by 0.02%.
The diff coverage is 69.36%.

@@            Coverage Diff             @@
##           master     #761      +/-   ##
==========================================
- Coverage   70.60%   70.57%   -0.03%     
==========================================
  Files         170      173       +3     
  Lines       17235    17643     +408     
  Branches     2492     2569      +77     
==========================================
+ Hits        12168    12451     +283     
- Misses       4341     4432      +91     
- Partials      726      760      +34     
Impacted Files Coverage Δ
delfin/drivers/hpe/hpe_msa/ssh_handler.py 65.61% <65.61%> (ø)
delfin/drivers/hpe/hpe_msa/hpe_msastor.py 84.37% <84.37%> (ø)
delfin/drivers/hpe/hpe_msa/consts.py 100.00% <100.00%> (ø)

Copy link
Contributor Author

@luojiagen luojiagen left a comment

Choose a reason for hiding this comment

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

add msa system pool volume

delfin/drivers/hpe/hpe_msa/ssh_handler.py Show resolved Hide resolved
from delfin.drivers.utils.tools import Tools

try:
import xml.etree.cElementTree as ET
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the difference between line10 and 12?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The correct thing is except ImportError:
import xml.etree.ElementTree as ET I made a mistake in writing. I wrote an extra C

if 'is not a recognized command' in result:
raise exception.InvalidIpOrPort()
except Exception as e:
LOG.error("Failed to login msa storwize_svc %s" %
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why there is storwize_svc in this log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forget to delete the error log. It will be updated next time

def get_storage(self, storage_id):
try:
result = self.ssh_pool.do_exec('show system')
list = self.analysisDataToList(result, 'system')
Copy link
Collaborator

Choose a reason for hiding this comment

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

list is a type name of python, please do not use this as a variable name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The specification of Python has been relearned, and this problem has been changed. It will be updated next time


def get_storage(self, storage_id):
try:
result = self.ssh_pool.do_exec('show system')
Copy link
Collaborator

Choose a reason for hiding this comment

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

result is a meaningless variable name, please change it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The specification of Python has been relearned, and this problem has been changed. It will be updated next time

delfin/drivers/hpe/hpe_msa/hpe_msastor.py Outdated Show resolved Hide resolved

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.ssh_hanlder = ssh_handler.SSHHandler(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong spelling of word ssh_hanlder .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next version has been updated with parameters

LOG = logging.getLogger(__name__)


class SSHHandler():
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundant parentheses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next version has been updated

def login(self):
try:
pool_info = self.ssh_pool.do_exec('show pools')
if 'is not a recognized command' in pool_info:
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundant code. This if block has already judged in self.ssh_pool.do_exec() .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This judgment has been deleted

version_info = self.ssh_pool.do_exec('show version')
version_arr = self.handle_detail(version_info, 'versions')
if version_arr:
version_id = version_arr[0]\
Copy link
Contributor

Choose a reason for hiding this comment

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

No need of line break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line feed has been canceled

def parse_alert(alert):
try:
alert_model = dict()
alert_id = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Default values of below 4 local variable might should be None .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change value to None

alert_model['occur_time'] = int(round(now * SSHHandler.
SECONDS_TO_MS))
alert_model['description'] = description
alert_model['resource_type'] = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

If info cannot be attained from storage, it should be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Delete non-existent fields

alert_model['description'] = description
alert_model['resource_type'] = ''
alert_model['location'] = description
print(alert_model)
Copy link
Contributor

Choose a reason for hiding this comment

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

print syntax should be deleted in product environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted print

return alert_model
except Exception as e:
LOG.error(e)
msg = ("Failed to build alert model as some attributes missing "
Copy link
Contributor

Choose a reason for hiding this comment

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

How about msg = ("Failed to build alert model: %s.") % (six.text_type(e)) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prompt statement changed

@staticmethod
def handle_split(split_str, split_char, arr_number):
split_value = ''
if split_str is not None and split_str != '':
Copy link
Contributor

Choose a reason for hiding this comment

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

How about if split_str: xxx ?

Copy link
Contributor Author

@luojiagen luojiagen Nov 9, 2021

Choose a reason for hiding this comment

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

judgment statement changed

class Request:
def __init__(self):
self.environ = {'delfin.context': context.RequestContext()}
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

pass is redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

delete pass

}


class Request:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please confirm this class has been used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

delete this class function

delfin/drivers/hpe/hpe_msa/hpe_msastor.py Outdated Show resolved Hide resolved
def get_storage(self, storage_id):
try:
system_info = self.ssh_pool.do_exec('show system')
system_data = self.handle_detail(system_info, 'system')
Copy link
Collaborator

Choose a reason for hiding this comment

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

What would handle_detail do, this fucntion name is meaningless

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change the function name to handle_xml_to_json

for pool in pool_arr:
total_capacity += int(pool.get('total_capacity'))
disk_arr = self.list_storage_disks(storage_id)
disk_all = 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why named 'disk_all' instead of 'raw_capacity'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

use raw_capacity instead of disk_all

version_id = version_arr[0]\
.get('bundle-version')
if system_data:
pool_arr = self.list_storage_pools(storage_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

pool_arr -> pools

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Variable name changed

total_capacity = 0
for pool in pool_arr:
total_capacity += int(pool.get('total_capacity'))
disk_arr = self.list_storage_disks(storage_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

disk_arr -> disks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Variable name changed

def list_storage_ports(self, storage_id):
try:
ports_info = self.ssh_pool.do_exec('show ports')
ports_arr = ports_info.split('\n')
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the difference between ports_arr and ports_array

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Variable name changed

for child in ch.iter("PROPERTY"):
msg[child.get('name')] = child.text
port_detail.append(msg)
list_all_ports = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the difference between list_all_ports and list_ports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Variable name changed

ports_info = self.ssh_pool.do_exec('show ports')
ports_arr = ports_info.split('\n')
ports_array = ports_arr[1:len(ports_arr) - 1]
ports_xml = ''.join(ports_array)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it a xml data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Variable name changed

ports_xml = ''.join(ports_array)
xml_element = ET.fromstring(ports_xml)
port_detail = []
for ch in xml_element.iter("OBJECT"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does ch mean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Variable name changed

Copy link
Collaborator

@joseph-v joseph-v left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@wisererik wisererik left a comment

Choose a reason for hiding this comment

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

LGTM

@wisererik wisererik merged commit 34bdcf2 into sodafoundation:master Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants