Skip to content
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
65 changes: 54 additions & 11 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,14 @@
- debug: msg="use_ptf_tacacs_server {{ use_ptf_tacacs_server }}"

- block:
- name: Load variables from topology file for topo_{{ topo }}.yml
include_vars: "vars/topo_{{ topo }}.yml"

- name: saved original minigraph file in SONiC DUT(ignore errors when file does not exist)
shell: mv /etc/sonic/minigraph.xml /etc/sonic/minigraph.xml.orig
become: true
ignore_errors: true
when: init_cfg_profile is not defined

- name: Update TACACS server address to PTF IP
set_fact:
Expand All @@ -438,6 +442,29 @@
template: src=templates/minigraph_template.j2
dest=/etc/sonic/minigraph.xml
become: true
when: init_cfg_profile is not defined

- block:
- name: Load variables from vars/init_cfg_profiles.yml
include_vars: "vars/init_cfg_profiles.yml"
- name: set cfg_profile to {{ init_cfg_profile }}
set_fact:
cfg_profile: "{{ init_cfg_profile }}"
- name: Set actual configuration value based on cfg_profile key
set_fact:
actual_config: "{{ lookup('vars', cfg_profile) }}"
- name: Debug actual configuration value
debug:
msg: "The actual configuration value is: {{ actual_config }}"
- name: Copy over config_db.json from file system for {{ cfg_profile }}
copy :
src: "{{ actual_config }}"
dest: /tmp/config_db.json
when: cfg_profile is defined
- name: Overwrite config_db.json
shell: cat /tmp/config_db.json > /etc/sonic/config_db.json
become: yes
when: init_cfg_profile is defined

- name: Test if configlet script exist
stat:
Expand Down Expand Up @@ -509,6 +536,7 @@
regexp: '^snmp_rocommunity:'
line: 'snmp_rocommunity: {{ snmp_rocommunity }}'
become: true
when: init_cfg_profile is not defined

- name: docker status
shell: docker ps
Expand Down Expand Up @@ -555,18 +583,33 @@
port_index_map: "{{ port_index_map | default({}) }}"
become: true

- name: execute cli "config load_minigraph --override_config -y" to apply new minigraph
become: true
shell: config load_minigraph --override_config -y
register: load_minigraph_result
failed_when:
- load_minigraph_result.rc != 0
- "'no such option: --override_config' not in load_minigraph_result.stderr"
- name: Use minigraph case
block:
- name: execute cli "config load_minigraph --override_config -y" to apply new minigraph
become: true
shell: config load_minigraph --override_config -y
register: load_minigraph_result
failed_when:
- load_minigraph_result.rc != 0
- "'no such option: --override_config' not in load_minigraph_result.stderr"

- name: execute cli "config load_minigraph -y" to apply new minigraph
become: true
shell: config load_minigraph -y
when: "'no such option: --override_config' in load_minigraph_result.stderr"
- name: execute cli "config load_minigraph -y" to apply new minigraph
become: true
shell: config load_minigraph -y
when: "'no such option: --override_config' in load_minigraph_result.stderr"

- name: remove DSCP_TO_TC_MAP for {{ hwsku }}. Some platform doesn't support this configuration
become: true
shell: redis-cli -n 4 del "DSCP_TO_TC_MAP|AZURE"
when:
- hwsku is defined
- hwsku == 'cisco-8101-p4-32x100-vs'
when: init_cfg_profile is not defined

- name: SONiC config reload to pick up config_db.json
command: config reload -y
become: yes
when: init_cfg_profile is defined

- name: Wait for switch to become reachable again
become: false
Expand Down
1 change: 1 addition & 0 deletions ansible/group_vars/all/creds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sonic_login: "admin"
sonic_default_passwords:
- "YourPaSsWoRd"
- "password"
- "admin"
sonic_password: "password"

k8s_master_login: "ubuntu"
Expand Down
6 changes: 6 additions & 0 deletions ansible/group_vars/all/labinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"Arista-7170-64C": "Arista",
"Arista-VM": "Arista",
"Nexus-3064-NX": "Nexus",
"cisco-8101-p4-32x100-vs" : "Cisco",
"Force10-S6100": "Force10",
"Force10-S6000": "Force10"
},
Expand All @@ -23,6 +24,11 @@
"passwd": ["password", "123456"],
"enable": ["", null]
},
"Cisco": {
"user": "admin",
"passwd": ["admin"],
"enable": ["admin"]
},
"Force10": {
"user": "admin",
"passwd": ["password"],
Expand Down
2 changes: 1 addition & 1 deletion ansible/group_vars/sonic/variables
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ barefoot_hwskus: [ "montara", "mavericks", "Arista-7170-64C", "newport", "Arista
marvell_hwskus: [ "et6448m" ]
innovium_tl7_hwskus: ["Wistron_sw_to3200k_32x100" , "Wistron_sw_to3200k"]

cisco_hwskus: ["Cisco-8102-C64", "Cisco-8111-O32", "Cisco-8111-O64", "Cisco-8122-O64", "Cisco-8800-LC-48H-C48"]
cisco_hwskus: ["Cisco-8102-C64", "Cisco-8111-O32", "Cisco-8111-O64", "Cisco-8122-O64", "Cisco-8800-LC-48H-C48", "cisco-8101-p4-32x100-vs"]
cisco-8000_gb_hwskus: ["Cisco-8102-C64", "Cisco-88-LC0-36FH-M-O36", "Cisco-8101-O8C48", "Cisco-8101-O32", "Cisco-88-LC0-36FH-O36"]
cisco-8000_gr_hwskus: ["Cisco-8111-O32", "Cisco-8111-O64"]
cisco-8000_gr2_hwskus: ["Cisco-8122-O64"]
Expand Down
11 changes: 11 additions & 0 deletions ansible/lab
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ all:
sonic_multi_asic_2:
sonic_msft_sup:
sonic_msft_lc_100G:
sonic_cisco_vs:
fanout:
hosts:
str-7260-10:
Expand Down Expand Up @@ -223,3 +224,13 @@ sonic_msft_lc_100G:
loopback4096_ip: [3.3.3.7/32,3.3.3.8/32]
loopback4096_ipv6: [2603:10e2:400::7/128,2603:10e2:400::8/128]
ansible_host: 2.2.2.5

sonic_cisco_vs:
vars:
hwsku: cisco-8101-p4-32x100-vs
iface_speed: 100000
hosts:
vlab-c-01:
hwsku: cisco-8101-p4-32x100-vs
ansible_host: 10.250.0.125
ansible_hostv6: fec0::ffff:afa:13
5 changes: 5 additions & 0 deletions ansible/library/topo_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ def parse_topo_defintion(self, topo_definition, po_map, dut_num, neigh_type='VMs
vmconfig[vm]['peer_ipv6'][dut_index] = ipv6_addr.upper()
vmconfig[vm]['ipv6mask'][dut_index] = ipv6_mask
vmconfig[vm]['ip_intf'][dut_index] = intf

# Configuration is provided via init_cfg_profile, no need to go through the topo file
if "init_cfg_profile" in topo_definition['configuration'][vm]:
continue

# bgp
vmconfig[vm]['bgp_asn'] = topo_definition['configuration'][vm]['bgp']['asn']
dut_asn = topo_definition['configuration_properties']['common']['dut_asn']
Expand Down
4 changes: 4 additions & 0 deletions ansible/module_utils/port_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ def get_port_alias_to_name_map(hwsku, asic_name=None):
elif hwsku == "Arista-7060DX5-32":
for i in range(1, 33):
port_alias_to_name_map["Ethernet%d/1" % i] = "Ethernet%d" % ((i - 1) * 8)
elif hwsku == "cisco-8101-p4-32x100-vs":
# this device simulates 32 ports, with 4 as the step for port naming.
for i in range(0, 32, 4):
port_alias_to_name_map["Ethernet%d" % i] = "Ethernet%d" % i
else:
if "Arista-7800" in hwsku:
assert False, "Please add port_alias_to_name_map for new modular SKU %s." % hwsku
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/sonic/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This is also the case for handlers using listen.

- name: SONiC update config db
command: config reload -y
command: config reload -y -f
become: yes
listen: "Update config db"

Expand Down
121 changes: 85 additions & 36 deletions ansible/roles/sonic/tasks/vsonic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,96 @@

- name: Set SONiC backplane port name
set_fact: bp_ifname="Ethernet{{ fp_num.stdout|int + 1 }}"
when: '"hwsku" not in configuration[hostname]'

- name: Set SONiC backplane port name for cisco-8101-p4-32x100-vs
set_fact: bp_ifname="Ethernet{{ fp_num.stdout|int *4 }}"
when: '"hwsku" in configuration[hostname] and configuration[hostname]["hwsku"]=="cisco-8101-p4-32x100-vs"'

- set_fact:
mgmt_ip: "{{ ansible_host }}/{{ mgmt_prefixlen }}"
mgmt_gw: "{{ vm_mgmt_gw | default(mgmt_gw) }}"

- name: create mgmt config
template: src="configdb-mgmt.j2"
dest=config-mgmt.json
when: hostname in configuration

- name: create device metadata config
shell: >
sonic-cfggen -H -k Force10-S6000 --preset empty
| jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"'
| jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"'
| jq '.DEVICE_METADATA.localhost.deployment_id="1"'
> config-metadata.json
when: hostname in configuration

- name: create interface config
shell: >
sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini -k SONiC-VM --print-data
| jq '.PORT[].admin_status |= "up"'
> config-port.json
when: hostname in configuration

- name: create topo config
template: src="configdb.j2"
dest=config-topo.json
when: hostname in configuration

- name: create config db json
shell: |
set -e
sonic-cfggen -j config-mgmt.json -j config-metadata.json -j config-port.json -j config-topo.json --print-data > /etc/sonic/config_db.json
rm -f config-mgmt.json config-metadata.json config-port.json config-topo.json
become: yes
when: hostname in configuration
notify:
- Update config db
- wait for SONiC update config db to finish
- name: create config via mininet config
block:
- name: create mgmt config
template: src="configdb-mgmt.j2"
dest=config-mgmt.json

- name: create device metadata config for {{ configuration[hostname]['hwsku'] }}
shell: >
sonic-cfggen -H -k {{ configuration[hostname]['hwsku'] }} --preset empty
| jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"'
| jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"'
| jq '.DEVICE_METADATA.localhost.deployment_id="1"'
> config-metadata.json
when: '"hwsku" in configuration[hostname]'

- name: create device metadata config
shell: >
sonic-cfggen -H -k Force10-S6000 --preset empty
| jq '.DEVICE_METADATA.localhost.hostname="{{ hostname }}"'
| jq '.DEVICE_METADATA.localhost.bgp_asn="{{ configuration[hostname]['bgp']['asn'] }}"'
| jq '.DEVICE_METADATA.localhost.deployment_id="1"'
> config-metadata.json
when: '"hwsku" not in configuration[hostname]'

- name: create interface config for {{ configuration[hostname]['hwsku'] }}
shell: >
sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/{{ configuration[hostname]['hwsku'] }}/port_config.ini -k {{ configuration[hostname]['hwsku'] }} --print-data
| jq '.PORT[].admin_status |= "up"'
> config-port.json
when: '"hwsku" in configuration[hostname]'

- name: create interface config
shell: >
sonic-cfggen -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini -k SONiC-VM --print-data
| jq '.PORT[].admin_status |= "up"'
> config-port.json
when: '"hwsku" not in configuration[hostname]'

- name: create topo config
template: src="configdb.j2"
dest=config-topo.json

- name: create config db json
shell: |
set -e
sonic-cfggen -j config-mgmt.json -j config-metadata.json -j config-port.json -j config-topo.json --print-data > /etc/sonic/config_db.json
rm -f config-mgmt.json config-metadata.json config-port.json config-topo.json
become: yes
notify:
- Update config db
- wait for SONiC update config db to finish
when: hostname in configuration and "init_cfg_profile" not in configuration[hostname]

- name: Update config via provided json
block:
- name: Get playbook directory
debug:
msg: "The playbook dir {{ playbook_dir }}"
- name: Load variables from vars/init_cfg_profiles.yml
include_vars: "vars/init_cfg_profiles.yml"
- name: set cfg_profile to {{ configuration[hostname].init_cfg_profile }}
set_fact:
cfg_profile: "{{ configuration[hostname].init_cfg_profile }}"
- name: Set actual configuration value based on cfg_profile key
set_fact:
actual_config: "{{ lookup('vars', cfg_profile) }}"
- name: Debug actual configuration value
debug:
msg: "The actual configuration value is: {{ actual_config }}"
- name: Copy over config_db.json from file system
copy :
src: "{{ playbook_dir }}/{{ actual_config }}"
dest: /tmp/config_db.json
- name: Overwrite config_db.json
shell: cat /tmp/config_db.json > /etc/sonic/config_db.json
become: yes
notify:
- Update config db
- wait for SONiC update config db to finish
when: hostname in configuration and configuration[hostname]['init_cfg_profile'] is defined

- name: Load PTF image
block:
Expand Down
6 changes: 3 additions & 3 deletions ansible/roles/vm_set/library/sonic_kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def login(self, user, passwords):
break

for password in passwords:
index = self.pair(user, [r'assword:', r'\$'])
index = self.pair(user, [r'assword:', r'\$', r'\#'])
if index == 0:
index = self.pair(password, [r'login:', r'\$'])
index = self.pair(password, [r'login:', r'\$', r'\#'])
if index == 1:
break

Expand All @@ -73,7 +73,7 @@ def configure(self, seq):
else:
(action, wait_for, timeout) = cmd
self.pair(action, wait_for, timeout)
self.pair('exit', [r'\$'])
self.pair('exit', [r'\$', r'\#'])

return

Expand Down
Loading