Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions ansible/library/conn_graph_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,28 @@
Retrive lab fanout switches physical and vlan connections
add to Ansible facts
options:
host: [fanout switch name|Server name|Sonic Switch Name]
requred: True
host:
[fanout switch name|Server name|Sonic Switch Name]
required: False
hosts:
List of hosts. Applicable for multi-DUT and single-DUT setup. The host option for single DUT setup is kept
for backward compatibility.
required: False
anchor:
List of hosts. When no host and hosts is provided, the anchor option must be specified with list of hosts.
This option is to supply the relevant list of hosts for looking up the connection graph xml file which has
all the supplied hosts. The whole graph will be returned when this option is used. This is for configuring
the root fanout switch.
required: False
filepath:
Path of the connection graph xml file. Override the default path for looking up connection graph xml file.
required: False
filename:
Name of the connection graph xml file. Override the behavior of looking up connection graph xml file. When
this option is specified, always use the specified connection graph xml file.
required: False

Mutually exclusive options: host, hosts, anchor

Ansible_facts:
device_info: The device(host) type and hwsku
Expand Down Expand Up @@ -273,7 +293,7 @@ def main():
filepath=dict(required=False),
anchor=dict(required=False, type='list'),
),
mutually_exclusive=[['host', 'hosts']],
mutually_exclusive=[['host', 'hosts', 'anchor']],
supports_check_mode=True
)
m_args = module.params
Expand All @@ -291,14 +311,14 @@ def main():
LAB_GRAPHFILE_PATH = m_args['filepath']

if m_args['filename']:
filename = m_args['filename']
filename = os.path.join(LAB_GRAPHFILE_PATH, m_args['filename'])
lab_graph = Parse_Lab_Graph(filename)
lab_graph.parse_graph()
else:
# When calling passed in anchor instead of hostnames,
# the caller is asking to return the whole graph. This
# is needed when configuring the root fanout switch.
target = hostnames if hostnames else anchor
target = anchor if anchor else hostnames
lab_graph = find_graph(target)

device_info = []
Expand Down