-
Notifications
You must be signed in to change notification settings - Fork 70
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
Update the API of get_fcp_template_details to return physical wwpns #800
Conversation
bd82c12
to
7d984a6
Compare
zvmsdk/database.py
Outdated
raw = result.fetchall() | ||
for item in raw: | ||
wwpn_phy.append(item['wwpn_phy']) | ||
return wwpn_phy[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SQL only return one row, so replace fetchall() to fetchone(). You can search existing example of fetchone()
change to something below
wwpn_phy = ''
...
raw = result.fetchone()
wwpn_phy = raw['wwpn_phy'])
return wwpn_phy
Please test after change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jackydalong Thanks a lot for your comment. Util method updated to support get wwpns of pchids, so still use fetchall().
zvmsdk/volumeop.py
Outdated
@@ -1916,11 +1916,17 @@ def get_fcp_templates_details(self, template_id_list=None, raw=False, | |||
pchids = list(set(pchids)) | |||
pchids.sort() | |||
base_info.update({"pchids": pchids}) | |||
wwpn_phy_dict = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here to introduce your code, like line 1911
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments
zvmsdk/database.py
Outdated
@@ -2271,6 +2271,26 @@ def delete_fcp_template(self, template_id): | |||
"template, template_sp_mapping and " | |||
"template_fcp_mapping tables" % template_id) | |||
|
|||
def get_wwpn_phy_from_pchid(self, pchid): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it support get wwpn_phys of multiple pchids
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
zvmsdk/volumeop.py
Outdated
@@ -1916,11 +1916,17 @@ def get_fcp_templates_details(self, template_id_list=None, raw=False, | |||
pchids = list(set(pchids)) | |||
pchids.sort() | |||
base_info.update({"pchids": pchids}) | |||
wwpn_phy_dict = {} | |||
for pchid in pchids: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the util method to support get wwpns of pchids, rather than make one sql query for each pchid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
50989db
to
3ff1aad
Compare
zvmsdk/database.py
Outdated
@@ -2271,6 +2271,32 @@ def delete_fcp_template(self, template_id): | |||
"template, template_sp_mapping and " | |||
"template_fcp_mapping tables" % template_id) | |||
|
|||
def get_wwpn_phys_from_pchids(self, pchids): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to wwpn_phys to wwpn_phy in the name, because it is wwpn_phy in sqlite DB table fcp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
zvmsdk/volumeop.py
Outdated
@@ -1916,11 +1916,16 @@ def get_fcp_templates_details(self, template_id_list=None, raw=False, | |||
pchids = list(set(pchids)) | |||
pchids.sort() | |||
base_info.update({"pchids": pchids}) | |||
# Add pchid_to_phy_wwpn info | |||
pchid_to_phy_wwpn_dict = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic should be moved outside 'if statistics' block. pchid_to_phy_wwpn_dict should be set no matter statistics is True or False.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
zvmsdk/volumeop.py
Outdated
@@ -1916,11 +1916,16 @@ def get_fcp_templates_details(self, template_id_list=None, raw=False, | |||
pchids = list(set(pchids)) | |||
pchids.sort() | |||
base_info.update({"pchids": pchids}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set 'pchids' should be moved outside 'if statistics' block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
84d937e
to
39970fc
Compare
zvmsdk/volumeop.py
Outdated
pchids.sort() | ||
item["pchids"] = pchids | ||
# Add pchid_to_phy_wwpn info | ||
pchid_to_phy_wwpn_dict = self.db.get_wwpn_phy_from_pchids(pchids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item["pchid_to_phy_wwpn"] = self.db.get_wwpn_phy_from_pchids(pchids)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Signed-off-by: Pei Ren <[email protected]>
Update the API of get_fcp_template_details to return physical wwpns