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

svc 3par vnx controller add cpu count #940

Closed
wants to merge 16 commits into from

Conversation

tanjiangyu-ghca
Copy link
Contributor

What this PR does / why we need it:

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 Nov 17, 2022

Codecov Report

Merging #940 (841bc42) into master (9ad2996) will decrease coverage by 0.02%.
The diff coverage is 68.18%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #940      +/-   ##
==========================================
- Coverage   71.36%   71.33%   -0.03%     
==========================================
  Files         187      187              
  Lines       23067    23079      +12     
  Branches     3508     3510       +2     
==========================================
+ Hits        16462    16464       +2     
- Misses       5490     5495       +5     
- Partials     1115     1120       +5     
Impacted Files Coverage Δ
delfin/drivers/fujitsu/eternus/eternus_stor.py 88.88% <ø> (ø)
delfin/drivers/hpe/hpe_3par/ssh_handler.py 78.74% <54.54%> (-1.26%) ⬇️
...rivers/dell_emc/vnx/vnx_block/component_handler.py 64.08% <66.66%> (+0.01%) ⬆️
delfin/drivers/hpe/hpe_msa/ssh_handler.py 67.28% <66.66%> (-0.01%) ⬇️
delfin/drivers/hpe/hpe_3par/component_handler.py 74.50% <100.00%> (+0.12%) ⬆️
delfin/drivers/hpe/hpe_3par/consts.py 100.00% <100.00%> (ø)
delfin/drivers/ibm/storwize_svc/ssh_handler.py 74.46% <100.00%> (+0.03%) ⬆️
delfin/drivers/fake_storage/__init__.py 94.41% <0.00%> (-0.77%) ⬇️

@@ -306,18 +306,20 @@ def list_controllers(self, storage_id):
memory_size = int(controller.get('memory_size_for_the_sp',
'0')) * units.Mi
cpu_info = ''
cpu_count = None
if cpus:
cpu_info = cpus.get(
controller.get('serial_number_for_the_sp', ''), '')
Copy link
Contributor

Choose a reason for hiding this comment

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

When cpus.get() returns an empty string, cpu_info is an empty string, so cpu_count should be None.

Copy link
Contributor

Choose a reason for hiding this comment

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

modified

if 'Cores' in titles:
node_id = str_info[0]
cpu_info = ' '.join(str_info[5:])
if obj_map.get(node_id):
Copy link
Contributor

Choose a reason for hiding this comment

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

It's recommended to use dict.setdefault() instead of if ... else ... .

cpu_map = obj_map.setdefault(node_id, {})
cpu_map[cpu_info] = int(str_info[2])

Copy link
Contributor

Choose a reason for hiding this comment

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

modified

else:
cpu_info_map = {}
cpu_info_map[cpu_info] = 1
obj_map[node_id] = cpu_info_map
Copy link
Contributor

Choose a reason for hiding this comment

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

It's recommended to type like obj_map[node_id] = {cpu_info: 1} .

Copy link
Contributor

Choose a reason for hiding this comment

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

modified

@@ -306,18 +306,21 @@ def list_controllers(self, storage_id):
memory_size = int(controller.get('memory_size_for_the_sp',
'0')) * units.Mi
cpu_info = ''
cpu_count = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

When if cpus in the next line returns False, cpu_count should be None.

Copy link
Contributor

Choose a reason for hiding this comment

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

modified

obj_map[node_id] = cpu_info_map
node_id = str_info[0]
cpu_info = str_info[4]
if obj_map.get(node_id):
Copy link
Contributor

Choose a reason for hiding this comment

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

We should always try to avoid using if ... esle ... , it's recommended to develop like:

cpu_map = obj_map.get(node_id, {})
cpu_map[cpu_info] = cpu_map.get(cpu_info, 0) + 1

Copy link
Contributor

Choose a reason for hiding this comment

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

modified

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

@joseph-v
Copy link
Collaborator

Another PR with same commits #960 is merged.

@joseph-v joseph-v closed this Dec 19, 2022
@yuanyu-ghca yuanyu-ghca deleted the 20221115cpucount branch December 29, 2022 01:20
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.

7 participants