Skip to content

[conn graph] add support for multiple graph files#2194

Merged
yxieca merged 5 commits intosonic-net:masterfrom
yxieca:graph
Sep 11, 2020
Merged

[conn graph] add support for multiple graph files#2194
yxieca merged 5 commits intosonic-net:masterfrom
yxieca:graph

Conversation

@yxieca
Copy link
Collaborator

@yxieca yxieca commented Sep 10, 2020

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

Before this change add-topo/remove-topo can only work with one inventory / graph file hard coded in conn_graph_facts.py. It is very inconvenient when deploying from a different inventory is needed.

How did you do it?

Put all graph files into a yaml list. When a testbed is requesting graph, parse all files in the list and find the graph file contains all duts of the testbed.

When getting the whole graph, provide dut list as anchor to match the right graph file.

For KVM test: if none of the graph file matches, fall back to an empty graph file so that the test won't fail at deployment stage. KVM test generally doesn't need graph otherwise. And for physical DUT, this empty graph file will cause other failure to stop deployment.

Signed-off-by: Ying Xie ying.xie@microsoft.com

How did you verify/test it?

add-topo/remove-topo from different inventories.

Put all graph files into a yaml list. When a testbed is requesting
graph, parse all files in the list and find the graph file contains
all duts of the testbed.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
@yxieca yxieca requested a review from a team September 10, 2020 05:22
@lgtm-com
Copy link

lgtm-com bot commented Sep 10, 2020

This pull request fixes 1 alert when merging 4c4b5e5 into 7d99e36 - view on LGTM.com

fixed alerts:

  • 1 for Unused import

@yxieca yxieca marked this pull request as draft September 10, 2020 06:07
When getting whole graph, the previous way was to not specifying
the dut. However, with multiple graph files, we need to provide
dut as anchor to match the graph file.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
@lgtm-com
Copy link

lgtm-com bot commented Sep 10, 2020

This pull request fixes 1 alert when merging 16a2b02 into 7d99e36 - view on LGTM.com

fixed alerts:

  • 1 for Unused import

@yxieca yxieca marked this pull request as ready for review September 10, 2020 17:57
@yxieca
Copy link
Collaborator Author

yxieca commented Sep 10, 2020

retest vsimage please

1 similar comment
@yxieca
Copy link
Collaborator Author

yxieca commented Sep 10, 2020

retest vsimage please

@lgtm-com
Copy link

lgtm-com bot commented Sep 10, 2020

This pull request fixes 1 alert when merging fbc5e2a into 7d99e36 - view on LGTM.com

fixed alerts:

  • 1 for Unused import

@yxieca yxieca marked this pull request as draft September 10, 2020 19:13
@lgtm-com
Copy link

lgtm-com bot commented Sep 10, 2020

This pull request fixes 1 alert when merging 00db93d into 7d99e36 - view on LGTM.com

fixed alerts:

  • 1 for Unused import

@yxieca yxieca marked this pull request as ready for review September 11, 2020 00:03
@yxieca yxieca requested a review from lguohan September 11, 2020 00:03
@theasianpianist
Copy link
Contributor

theasianpianist commented Sep 11, 2020

@yxieca
Copy link
Collaborator Author

yxieca commented Sep 11, 2020

Would this file also need to be change to reflect the unified graph?

https://github.com/Azure/sonic-mgmt/blob/7d99e36a9439571e9ed51cb4634a5b42cb0ff17c/ansible/group_vars/all/inv_mapping.yml#L3

I don't think so. That map is still correct. The official lab graph is lab_connection_graph.xml. The new file I added is a truly empty graph file.

@yxieca
Copy link
Collaborator Author

yxieca commented Sep 11, 2020

Would this file also need to be change to reflect the unified graph?

https://github.com/Azure/sonic-mgmt/blob/7d99e36a9439571e9ed51cb4634a5b42cb0ff17c/ansible/group_vars/all/inv_mapping.yml#L3

Lawrence, I looked at the pytest conn_graph code again and I think your question makes lots of sense. I think we could potentially ditch the inventory graph map file and use this lookup method for all. But I think we could come back with another PR for that change.

Find a graph file contains all devices in testbed.
"""
def find_graph(hostnames, anchor):
filename = LAB_GRAPHFILE_PATH + LAB_CONNECTION_GRAPH_FILE
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use os.path.join?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. But improve with another PR?

def find_graph(hostnames, anchor):
filename = LAB_GRAPHFILE_PATH + LAB_CONNECTION_GRAPH_FILE
with open(filename) as fd:
file_list = yaml.load(fd)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think pyyaml will complain about this when we flip to python3, did you try using safe_load instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't try. I prefer to get this merged as-is since it is tested. Then improve.

lab_graph.parse_graph()
if hostnames and lab_graph.contains_hosts(hostnames):
return lab_graph
if anchor and lab_graph.contains_hosts(anchor):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this is explained somewhere but what is anchor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Explained in the PR comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

The naming is still a little confusing to me, but this can be iterated on.

@yxieca yxieca merged commit 73ca00b into sonic-net:master Sep 11, 2020
@yxieca yxieca deleted the graph branch September 11, 2020 20:11
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
Update sonic-swss submodule pointer to include the following:

[BFD]Clean up state_db BFD entries on swss restart (sonic-net#2434)
Fix the Fec Mode Setting of gbsyncd (sonic-net#2430)
[neighsyncd] Enabling ipv4 link local entries for non-dualtor (sonic-net#2427)
tlm_teamd: Filter portchannel subinterface events from STATE_DB LAG_TABLE (sonic-net#2408)
PFCWD recovery changes using DLR_INIT (sonic-net#2316)
Dynamic port configuration - add port buffer cfg to the port ref counter (sonic-net#2194)

Signed-off-by: dprital <drorp@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants