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

[minigraph_facts] use mingraph on DUT to test #532

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
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
13 changes: 5 additions & 8 deletions ansible/library/minigraph_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
ns3 = "http://www.w3.org/2001/XMLSchema-instance"

ANSIBLE_USER_MINIGRAPH_PATH = os.path.expanduser('~/.ansible/minigraph')
ANSIBLE_LOCAL_MINIGRAPH_PATH = 'minigraph/{}.xml'
ANSIBLE_LOCAL_MINIGRAPH_PATH = '{}.xml'
ANSIBLE_USER_MINIGRAPH_MAX_AGE = 86400 # 24-hours (in seconds)

class minigraph_encoder(json.JSONEncoder):
Expand Down Expand Up @@ -383,15 +383,12 @@ def reconcile_mini_graph_locations(filename, hostname):
"""
if filename is not None:
# literal filename specified. read directly from the file.
root = ET.parse(filename).getroot()
mini_graph_path = filename
else:
# only the hostname was specified, determine the output path
mini_graph_path = os.path.join(ANSIBLE_USER_MINIGRAPH_PATH, hostname + '_minigraph.xml')
if os.path.exists(mini_graph_path) and file_age(mini_graph_path) < ANSIBLE_USER_MINIGRAPH_MAX_AGE:
# found a cached mini-graph, load it.
root = ET.parse(mini_graph_path).getroot()
mini_graph_path = '/etc/sonic/minigraph.xml'

root = ET.parse(mini_graph_path).getroot()
return mini_graph_path, root


Expand Down Expand Up @@ -620,7 +617,7 @@ def main():
local_file_path = ANSIBLE_LOCAL_MINIGRAPH_PATH.format(m_args['host'])
if 'filename' in m_args and m_args['filename'] is not None:
# literal filename specified
filename = "minigraph/%s" % m_args['filename']
filename = "%s" % m_args['filename']
elif os.path.exists(local_file_path):
# local project minigraph found for the hostname, use that file
filename = local_file_path
Expand All @@ -638,7 +635,7 @@ def main():


def print_parse_xml(hostname):
filename = '../minigraph/' + hostname + '.xml'
filename = hostname + '.xml'
results = parse_xml(filename, hostname)
print(json.dumps(results, indent=3, cls=minigraph_encoder))

Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/sonic-common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Gather minigraph facts
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
become: no
connection: local

- name: Set sonic_asic_type fact
set_fact:
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/acltb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# Gather minigraph facts
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
become: no
connection: local

- name: Read port reverse alias mapping
set_fact:
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/acltb_ranges_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
# Gather minigraph facts
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
become: no
connection: local

- name: Read port reverse alias mapping
set_fact:
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/bgp_fact.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Gather minigraph facts
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
become: no
connection: local

- name: Print bgp neighbors in minigraph
debug: msg="{{ minigraph_bgp }}"
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/bgp_flap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@

- name: recover minigraph facts about the device(above steps loaded neighbors configuration)
minigraph_facts: host="{{ inventory_hostname }}"
connection: local
become: no
1 change: 0 additions & 1 deletion ansible/roles/test/tasks/bgp_multipath_relax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
connection: local

- name: Find all V4 bgp neighbors from minigraph
set_fact:
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/bgp_nei_up.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

- name: Gathering minigraph facts about neighbor
minigraph_facts: host={{ name }} filename="{{ vmhost_num }}-{{ name }}.xml"
connection: local
become: no

- name: Configure BGP session of neighbor router to up
action: cisco template=bgp_neighbor_noshut.j2
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/bgp_speaker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

- name: Gather minigraph facts about the device
minigraph_facts: host={{inventory_hostname}}
become: no
connection: local

- name: print deployment id
debug: msg="{{deployment_id}}"
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/decap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
# Gather minigraph facts
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
become: no
connection: local

# Obtain loopback ip of the device
- name: Obtain loopback ip of the device
Expand Down
1 change: 0 additions & 1 deletion ansible/roles/test/tasks/dir_bcast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

- name: Gathering minigraph facts about the device
minigraph_facts: host={{inventory_hostname}}
connection: local

- debug : msg="Start dir_bcast Test"

Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/everflow_testbed/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
become: no
connection: local

- name: Print neighbors in minigraph
debug: msg="{{ minigraph_neighbors }}"
Expand Down
1 change: 0 additions & 1 deletion ansible/roles/test/tasks/fdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

- name: Gather minigraph facts about the device
minigraph_facts: host={{inventory_hostname}}
connection: local

- name: Remove existing IPs from PTF host
script: roles/test/files/helpers/remove_ip.sh
Expand Down
1 change: 0 additions & 1 deletion ansible/roles/test/tasks/fib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
connection: local

# Generate route file
- name: Generate route-port map information
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/interface_up_down.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
connection: local
become: no

- name: Ensure LLDP Daemon started and Enabled
become: true
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/lag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Gather minigraph facts
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
become: no
connection: local

- name: Print neighbors in minigraph
debug: msg="{{ minigraph_neighbors }}"
Expand Down
1 change: 0 additions & 1 deletion ansible/roles/test/tasks/lag_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

- name: gathering minigraph of the device configuration
minigraph_facts: host={{ inventory_hostname }}
connection: local

- name: Gathering lab graph facts about the device
conn_graph_facts: host={{ inventory_hostname }}
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/lagall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

- name: Read DUT minigraph facts.
minigraph_facts: host={{ inventory_hostname }}
connection: local
become: no

- set_fact:
dut_lag_members: []
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/lldp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
- name: Gathering minigraph facts about the device
minigraph_facts:
host: "{{ inventory_hostname }}"
become: no
connection: local

- name: Print neighbors in minigraph
debug: msg="{{ minigraph_neighbors }}"
Expand Down
1 change: 0 additions & 1 deletion ansible/roles/test/tasks/mac_update.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
connection: local

- include: mac_entry_update.yml
with_items: "{{ minigraph_interfaces }}"
1 change: 0 additions & 1 deletion ansible/roles/test/tasks/mtu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
connection: local

- debug : msg="Start MTU Test"

Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/pfc_wd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

- name: Gather minigraph facts about the device
minigraph_facts: host={{inventory_hostname}}
become: no
connection: local

- set_fact:
port_list: "{{minigraph_ports.keys()}}"
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/reboot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
connection: local
become: no
when: minigraph_interfaces is not defined

- include: interface.yml
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/sonic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
connection: local
become: no

# Set sonic_hwsku
- name: Set sonic_hwsku fact
Expand Down
2 changes: 0 additions & 2 deletions ansible/roles/test/tasks/test_sonic_by_tag.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
- name: Gathering minigraph facts about the device
minigraph_facts: host={{ inventory_hostname }}
connection: local
become: no
tags: always

### When calling the following tests, you need to provide a command line parameter
Expand Down