Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
21 changes: 19 additions & 2 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -323,6 +335,11 @@

- 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|bool == true

- name: execute cli "config load_minigraph -y" to apply new minigraph
become: true
shell: config load_minigraph -y
Expand Down
2 changes: 2 additions & 0 deletions ansible/lab
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ sonic_multi_asic:
vars:
hwsku: msft_multi_asic_vs
iface_speed: 40000
num_asics: 4
start_topo_service: True
hosts:
vlab-07:
ansible_host: 10.250.0.109
Expand Down
23 changes: 22 additions & 1 deletion ansible/testbed-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function usage
echo " $0 [options] refresh-dut <topo-name> <vault-password-file>"
echo " $0 [options] (connect-vms | disconnect-vms) <topo-name> <vault-password-file>"
echo " $0 [options] config-vm <topo-name> <vm-name> <vault-password-file>"
echo " $0 [options] (gen-mg | deploy-mg | test-mg) <topo-name> <inventory> <vault-password-file>"
echo " $0 [options] (gen-mg | deploy-mg | test-mg | copy-mg) <topo-name> <inventory> <vault-password-file>"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is the difference between copy-mg and deploy-mg?

Copy link
Copy Markdown
Contributor Author

@SuvarnaMeenakshi SuvarnaMeenakshi Feb 1, 2021

Choose a reason for hiding this comment

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

deploy_mg will create minigraph from templates and load the minigraph.
copy_mg will copy an existing minigraph, placed in ansible/minigraph/<dut_name>.topology.xml, and execute load_minigraph with the copied minigraph on DUT.
For multi-asic platform, minigraph creation from templates is not completed yet, so to load minigraph configuration for multi-asic vs, added a new option to help load a created minigraph, for example, we could load an existing minigraph from here:
https://github.com/Azure/sonic-mgmt/blob/4986dbd816b4bb6f539ddacb32cd99fc03678c5f/ansible/minigraph/vlab-07.t1-8-lag.xml

echo " $0 [options] (create-master | destroy-master) <k8s-server-name> <vault-password-file>"
echo
echo "Options:"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -513,6 +532,8 @@ case "${subcmd}" in
;;
test-mg) test_minigraph $@
;;
copy-mg) copy_load_minigraph $@
;;
create-master) start_k8s_vms $@
setup_k8s_vms $@
;;
Expand Down