Skip to content
Closed
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
8 changes: 8 additions & 0 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,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:
Expand Down Expand Up @@ -225,11 +231,13 @@
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
dest=/etc/sonic/minigraph.xml
become: true
when: copy is not defined or copy is defined and copy|bool == false

- name: Test if configlet script exist
stat:
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_minigraph
{
topology=$1
inventory=$2
passfile=$3
shift
shift
shift

echo "Copying 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 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_minigraph $@
;;
create-master) start_k8s_vms $@
setup_k8s_vms $@
;;
Expand Down