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

Update the API of get_fcp_template_details to return physical wwpns #800

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

renpei123
Copy link
Contributor

Update the API of get_fcp_template_details to return physical wwpns

@renpei123 renpei123 force-pushed the 16418 branch 2 times, most recently from bd82c12 to 7d984a6 Compare January 8, 2024 09:45
@dongyanyang dongyanyang self-requested a review January 10, 2024 06:45
raw = result.fetchall()
for item in raw:
wwpn_phy.append(item['wwpn_phy'])
return wwpn_phy[0]
Copy link
Contributor

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

Copy link
Contributor Author

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().

@@ -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 = {}
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@jackydalong jackydalong left a comment

Choose a reason for hiding this comment

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

see my comments

@@ -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):
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -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:
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@renpei123 renpei123 force-pushed the 16418 branch 2 times, most recently from 50989db to 3ff1aad Compare January 11, 2024 08:15
@@ -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):
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -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 = {}
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -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})
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@renpei123 renpei123 force-pushed the 16418 branch 2 times, most recently from 84d937e to 39970fc Compare January 11, 2024 09:56
pchids.sort()
item["pchids"] = pchids
# Add pchid_to_phy_wwpn info
pchid_to_phy_wwpn_dict = self.db.get_wwpn_phy_from_pchids(pchids)
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@dongyanyang dongyanyang merged commit 9949ad2 into openmainframeproject:master Jan 11, 2024
2 checks passed
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.

4 participants