Skip to content

add Eternus mapping#821

Merged
wisererik merged 23 commits intosodafoundation:masterfrom
gh-ca:eternus-mapping
May 18, 2022
Merged

add Eternus mapping#821
wisererik merged 23 commits intosodafoundation:masterfrom
gh-ca:eternus-mapping

Conversation

@zhilong-xu
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 Feb 9, 2022

Codecov Report

Merging #821 (5c28a73) into master (effad04) will increase coverage by 0.44%.
The diff coverage is 92.61%.

@@            Coverage Diff             @@
##           master     #821      +/-   ##
==========================================
+ Coverage   70.87%   71.32%   +0.44%     
==========================================
  Files         182      182              
  Lines       20384    20823     +439     
  Branches     3087     3177      +90     
==========================================
+ Hits        14448    14852     +404     
- Misses       4953     4966      +13     
- Partials      983     1005      +22     
Impacted Files Coverage Δ
delfin/drivers/fujitsu/eternus/eternus_stor.py 88.88% <91.07%> (+2.58%) ⬆️
delfin/drivers/fujitsu/eternus/cli_handler.py 84.21% <100.00%> (ø)
delfin/drivers/fujitsu/eternus/consts.py 100.00% <100.00%> (ø)
delfin/drivers/fake_storage/__init__.py 94.40% <0.00%> (ø)

Copy link
Contributor

Choose a reason for hiding this comment

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

The host_fc_list returned by self.get_data already contains an empty list. You do not need to add [].
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been modified

Copy link
Contributor

Choose a reason for hiding this comment

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

The consts.HOST_TOTAL has been transferred in the self.get_data method. Why does it need to be checked?
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I deleted the first validation, but the two previous validations were done for different data sources

def get_access_url():
return 'https://{ip}'

def list_storage_host_initiators(self, ctx):
Copy link
Contributor

Choose a reason for hiding this comment

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

The function is too long. You are advised to extract functions for each type of processing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have extracted

Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate code. The structure is the same but the parameter values are different. The method should be extracted and transferred as input parameters.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have extracted

iscsi_name = host_iscsi.get('name')
state = host_status.get(iscsi_name)
os = host_iscsi.get('os')
os = os.lower() if os else None
Copy link
Contributor

Choose a reason for hiding this comment

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

It is recommended that this operation be processed in self.get_iscsi_host() and then returned.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get_iscsi_host is a public function. List_storage_host_initiators and list_storage_hosts are both used. If you put this code after get_iscsi_host,The function will no longer be a public function, resulting in duplicate code

Copy link
Contributor

Choose a reason for hiding this comment

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

The return value of the split() method is a list, and no additional judgment of or [] is required.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been modified

for status_row in status_list:
if len(status_row) < consts.HOST_PATH_STATUS_TOTAL:
continue
host_name = status_row[consts.HOST_PATH_STATUS_NAME]
Copy link
Contributor

Choose a reason for hiding this comment

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

The two variables are used only once, and the constant consts.HOST_PATH_STATUS_NAME can be read. Therefore, you do not need to define the two variables separately. You need to delete the two variables.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only used it once, but you can't use Arabic numerals directly in a function because it's a very common behavior, so you can think about it a little bit

Copy link
Contributor

Choose a reason for hiding this comment

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

Storage_id is not changed in later use. You do not need to define a variable to reference it. You can directly use self.storage_id.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been modified

Copy link
Contributor

Choose a reason for hiding this comment

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

If ctx is not used, set this parameter to None. Otherwise, use from delfin.context import RequestContext instead.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been modified

Copy link
Contributor

Choose a reason for hiding this comment

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

The assert should compare a complete piece of data rather than a field value. Otherwise, the unit test is useless.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been modified

Copy link
Contributor

Choose a reason for hiding this comment

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

It is recommended that the code be placed in the next line for better readability.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been modified

Copy link
Contributor

Choose a reason for hiding this comment

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

These three sentences can be combined using a list derivation expression, which is more efficient.
length_list.extend([len(identify) for identify in host_row_str.split()])
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been modified

"storage_id": self.storage_id,
"native_storage_host_id": fc_name,
"os_type": consts.HOST_OS_TYPES_MAP.get(
os, constants.HostOSTypes.UNKNOWN),
Copy link
Contributor

Choose a reason for hiding this comment

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

Format it, there should be a hierarchy.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has been 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

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 59475e2 into sodafoundation:master May 18, 2022
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

Comments