From 78240b4083d7e807e7dbe9ae0d96b0e361461569 Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi Date: Thu, 28 Jan 2021 01:12:24 -0800 Subject: [PATCH 1/7] [multi-asic]: Changes to start topology service before loading minigraph. Topolgy service should be started only for multi-asic vs. Add support to copy a generated minigraph and load it on the device. Signed-off-by: SuvarnaMeenakshi --- ansible/config_sonic_basedon_testbed.yml | 22 ++++++++++++++++++++-- ansible/lab | 1 + ansible/testbed-cli.sh | 23 ++++++++++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index 13618e16301..51d092427b5 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -48,6 +48,11 @@ - fail: msg="The DUT you are trying to run test does not belongs to this testbed" when: inventory_hostname not in testbed_facts['duts'] + - name: Set default num_asic + set_fact: + num_asics: 1 + when: num_asics is not defined + - name: Set default dut index set_fact: dut_index: "{{ testbed_facts['duts_map'][inventory_hostname]|int }}" @@ -66,11 +71,11 @@ delegate_to: localhost - name: find interface name mapping and individual interface speed if defined from dut - port_alias: hwsku="{{ hwsku }}" + port_alias: hwsku="{{ hwsku }}" num_asic="{{ num_asics }}" when: deploy is defined and deploy|bool == true - name: find interface name mapping and individual interface speed if defined with local data - port_alias: hwsku="{{ hwsku }}" + port_alias: hwsku="{{ hwsku }}" num_asic="{{ num_asics }}" delegate_to: localhost when: deploy is not defined or deploy|bool == false @@ -230,6 +235,13 @@ template: src=templates/minigraph_template.j2 dest=/etc/sonic/minigraph.xml become: true + when: copy|bool == false + + - name: copy existing minigraph file for SONiC device + template: src=minigraph/{{ inventory_hostname }}.{{ topo }}.xml + dest=/etc/sonic/minigraph.xml + become: true + when: copy|bool == true - name: Test if configlet script exist stat: @@ -323,6 +335,12 @@ - debug: msg={{ docker_status.stdout_lines }} + - name: start topology service for multi-asic platform + become: true + shell: systemctl start topology.service + when: num_asics > 1 + ignore_errors: true + - name: execute cli "config load_minigraph -y" to apply new minigraph become: true shell: config load_minigraph -y diff --git a/ansible/lab b/ansible/lab index 806ea9bd3b4..5cbf6c08880 100644 --- a/ansible/lab +++ b/ansible/lab @@ -104,6 +104,7 @@ sonic_multi_asic: vars: hwsku: msft_multi_asic_vs iface_speed: 40000 + num_asics: 4 hosts: vlab-07: ansible_host: 10.250.0.109 diff --git a/ansible/testbed-cli.sh b/ansible/testbed-cli.sh index 361120c4d65..dc20f3a2624 100755 --- a/ansible/testbed-cli.sh +++ b/ansible/testbed-cli.sh @@ -12,7 +12,7 @@ function usage echo " $0 [options] refresh-dut " echo " $0 [options] (connect-vms | disconnect-vms) " echo " $0 [options] config-vm " - echo " $0 [options] (gen-mg | deploy-mg | test-mg) " + echo " $0 [options] (gen-mg | deploy-mg | test-mg | copy-mg) " echo " $0 [options] (create-master | destroy-master) " echo echo "Options:" @@ -52,6 +52,7 @@ function usage echo "To configure a VM on a server: $0 config-vm 'topo-name' 'vm-name' ~/.password" echo "To generate minigraph for DUT in a topology: $0 gen-mg 'topo-name' 'inventory' ~/.password" echo "To deploy minigraph to DUT in a topology: $0 deploy-mg 'topo-name' 'inventory' ~/.password" + echo "To copy and load generated minigraph to DUT in a topology: $0 copy-mg 'topo-name' 'inventory' ~/.password" echo " gen-mg, deploy-mg, test-mg supports enabling/disabling data ACL with parameter" echo " -e enable_data_plane_acl=true" echo " -e enable_data_plane_acl=false" @@ -393,6 +394,24 @@ function test_minigraph echo Done } +function copy_load_minigraph +{ + topology=$1 + inventory=$2 + passfile=$3 + shift + shift + shift + + echo "Deploying minigraph '$topology'" + + read_file $topology + + ansible-playbook -i "$inventory" config_sonic_basedon_testbed.yml --vault-password-file="$passfile" -l "$duts" -e testbed_name="$topology" -e testbed_file=$tbfile -e vm_file=$vmfile -e deploy=true -e save=true -e copy=true $@ + + echo Done +} + function config_vm { echo "Configure VM $2" @@ -513,6 +532,8 @@ case "${subcmd}" in ;; test-mg) test_minigraph $@ ;; + copy-mg) copy_load_minigraph $@ + ;; create-master) start_k8s_vms $@ setup_k8s_vms $@ ;; From 3a51c53b4f3caff319c0983d97af1eb4fc1821e8 Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi Date: Fri, 29 Jan 2021 09:50:19 -0800 Subject: [PATCH 2/7] Add a new flag to check if topology service has to be started before loading minigraph. This will be required for multi-asic vs hwsku. Signed-off-by: SuvarnaMeenakshi --- ansible/config_sonic_basedon_testbed.yml | 3 +-- ansible/lab | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index 51d092427b5..647ee9aefb5 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -338,8 +338,7 @@ - name: start topology service for multi-asic platform become: true shell: systemctl start topology.service - when: num_asics > 1 - ignore_errors: true + when: start_topo_service|bool == true - name: execute cli "config load_minigraph -y" to apply new minigraph become: true diff --git a/ansible/lab b/ansible/lab index 5cbf6c08880..d961d8494c8 100644 --- a/ansible/lab +++ b/ansible/lab @@ -104,7 +104,8 @@ sonic_multi_asic: vars: hwsku: msft_multi_asic_vs iface_speed: 40000 - num_asics: 4 + num_asics: 4 + start_topo_service: True hosts: vlab-07: ansible_host: 10.250.0.109 From 182f28b6ccb2ed0346bffd939f69f8323021c8fa Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi Date: Mon, 1 Feb 2021 12:06:46 -0800 Subject: [PATCH 3/7] Look for copy flag value only if copy is defined. Signed-off-by: SuvarnaMeenakshi --- ansible/config_sonic_basedon_testbed.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index 647ee9aefb5..a2a0496a8c9 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -235,13 +235,13 @@ template: src=templates/minigraph_template.j2 dest=/etc/sonic/minigraph.xml become: true - when: copy|bool == false + when: copy is not defined or copy is defined and copy|bool == false - name: copy existing minigraph file for SONiC device template: src=minigraph/{{ inventory_hostname }}.{{ topo }}.xml dest=/etc/sonic/minigraph.xml become: true - when: copy|bool == true + when: copy is defined and copy|bool == true - name: Test if configlet script exist stat: From 03cc935326e6d3ed315489ab29d1e64dc1595f95 Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi Date: Tue, 2 Feb 2021 12:08:09 -0800 Subject: [PATCH 4/7] Use start_topo_service only when defined. Signed-off-by: SuvarnaMeenakshi --- ansible/config_sonic_basedon_testbed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index a2a0496a8c9..dc5d37d8469 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -338,7 +338,7 @@ - name: start topology service for multi-asic platform become: true shell: systemctl start topology.service - when: start_topo_service|bool == true + when: start_topo_service is defined and start_topo_service|bool == true - name: execute cli "config load_minigraph -y" to apply new minigraph become: true From a3895c5850bcfba5df97a06588d174f8f95075e0 Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi Date: Tue, 16 Feb 2021 00:09:41 -0800 Subject: [PATCH 5/7] Modify copy option to just copy the existing minigraph to the device. Signed-off-by: SuvarnaMeenakshi --- ansible/config_sonic_basedon_testbed.yml | 13 +++++++------ ansible/lab | 2 +- ansible/testbed-cli.sh | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index dc5d37d8469..33a191a3863 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -158,6 +158,12 @@ delegate_to: localhost when: local_minigraph is defined and local_minigraph|bool == true + - name: copy existing minigraph file for SONiC device + copy: src=minigraph/{{ inventory_hostname }}.{{ topo }}.xml + dest=/etc/sonic/minigraph.xml + become: true + when: copy is defined and copy|bool == true + - block: - name: Init telemetry keys set_fact: @@ -230,6 +236,7 @@ shell: mv /etc/sonic/minigraph.xml /etc/sonic/minigraph.xml.orig become: true ignore_errors: true + when: copy is not defined or copy is defined and copy|bool == false - name: create new minigraph file for SONiC device template: src=templates/minigraph_template.j2 @@ -237,12 +244,6 @@ become: true when: copy is not defined or copy is defined and copy|bool == false - - name: copy existing minigraph file for SONiC device - template: src=minigraph/{{ inventory_hostname }}.{{ topo }}.xml - dest=/etc/sonic/minigraph.xml - become: true - when: copy is defined and copy|bool == true - - name: Test if configlet script exist stat: path: vars/configlet/{{ topo }}/apply_clet.sh diff --git a/ansible/lab b/ansible/lab index d961d8494c8..e48cb634474 100644 --- a/ansible/lab +++ b/ansible/lab @@ -104,7 +104,7 @@ sonic_multi_asic: vars: hwsku: msft_multi_asic_vs iface_speed: 40000 - num_asics: 4 + num_asics: 6 start_topo_service: True hosts: vlab-07: diff --git a/ansible/testbed-cli.sh b/ansible/testbed-cli.sh index dc20f3a2624..f2c99d7db7e 100755 --- a/ansible/testbed-cli.sh +++ b/ansible/testbed-cli.sh @@ -394,7 +394,7 @@ function test_minigraph echo Done } -function copy_load_minigraph +function copy_minigraph { topology=$1 inventory=$2 @@ -407,7 +407,7 @@ function copy_load_minigraph read_file $topology - ansible-playbook -i "$inventory" config_sonic_basedon_testbed.yml --vault-password-file="$passfile" -l "$duts" -e testbed_name="$topology" -e testbed_file=$tbfile -e vm_file=$vmfile -e deploy=true -e save=true -e copy=true $@ + ansible-playbook -i "$inventory" config_sonic_basedon_testbed.yml --vault-password-file="$passfile" -l "$duts" -e testbed_name="$topology" -e testbed_file=$tbfile -e vm_file=$vmfile -e copy=true $@ echo Done } @@ -532,7 +532,7 @@ case "${subcmd}" in ;; test-mg) test_minigraph $@ ;; - copy-mg) copy_load_minigraph $@ + copy-mg) copy_minigraph $@ ;; create-master) start_k8s_vms $@ setup_k8s_vms $@ From 21c3fc5a3ffc69d6bb8c1b7205bda1611472584a Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi Date: Mon, 22 Feb 2021 23:37:43 -0800 Subject: [PATCH 6/7] Remove multi-asic specific changes. Signed-off-by: SuvarnaMeenakshi --- ansible/config_sonic_basedon_testbed.yml | 14 ++------------ ansible/lab | 2 -- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index 33a191a3863..195132e1d97 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -48,11 +48,6 @@ - fail: msg="The DUT you are trying to run test does not belongs to this testbed" when: inventory_hostname not in testbed_facts['duts'] - - name: Set default num_asic - set_fact: - num_asics: 1 - when: num_asics is not defined - - name: Set default dut index set_fact: dut_index: "{{ testbed_facts['duts_map'][inventory_hostname]|int }}" @@ -71,11 +66,11 @@ delegate_to: localhost - name: find interface name mapping and individual interface speed if defined from dut - port_alias: hwsku="{{ hwsku }}" num_asic="{{ num_asics }}" + port_alias: hwsku="{{ hwsku }}" when: deploy is defined and deploy|bool == true - name: find interface name mapping and individual interface speed if defined with local data - port_alias: hwsku="{{ hwsku }}" num_asic="{{ num_asics }}" + port_alias: hwsku="{{ hwsku }}" delegate_to: localhost when: deploy is not defined or deploy|bool == false @@ -336,11 +331,6 @@ - debug: msg={{ docker_status.stdout_lines }} - - name: start topology service for multi-asic platform - become: true - shell: systemctl start topology.service - when: start_topo_service is defined and start_topo_service|bool == true - - name: execute cli "config load_minigraph -y" to apply new minigraph become: true shell: config load_minigraph -y diff --git a/ansible/lab b/ansible/lab index e48cb634474..806ea9bd3b4 100644 --- a/ansible/lab +++ b/ansible/lab @@ -104,8 +104,6 @@ sonic_multi_asic: vars: hwsku: msft_multi_asic_vs iface_speed: 40000 - num_asics: 6 - start_topo_service: True hosts: vlab-07: ansible_host: 10.250.0.109 From 976d0c250373eca7d6a31c77b1dfffbbc30e6bb9 Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi Date: Mon, 22 Feb 2021 23:39:15 -0800 Subject: [PATCH 7/7] Modify comment. Signed-off-by: SuvarnaMeenakshi --- ansible/testbed-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/testbed-cli.sh b/ansible/testbed-cli.sh index f2c99d7db7e..4faedc1c67a 100755 --- a/ansible/testbed-cli.sh +++ b/ansible/testbed-cli.sh @@ -403,7 +403,7 @@ function copy_minigraph shift shift - echo "Deploying minigraph '$topology'" + echo "Copying minigraph '$topology'" read_file $topology