Skip to content

Commit 1a2685f

Browse files
committed
VM Base to be selectable by user
User can specify the VM base dyanmically during deploy the test environment. 1. add/remove topo - add a new argument to specify the VM Base nubmer The usage will be ./testbed-cli.sh -b VM0108 add-topo 1-1_t0 ~/.password​ 2. deploy minigraph - fix to deploy correct VM METADAT in to minigraph when user specify vm_base dynamically. The vm_base can be assgined from 2 sources, one is read from testbed.csv file, another is from extra argument. assigned from testbed.csv file ansible-playbook -i lab config_sonic_basedon_testbed.yml -l as7816-64x -e testbed_name=2-1_t0 -e deploy=true -e save=true assigned from extra arguments ansible-playbook -i lab config_sonic_basedon_testbed.yml -l as7816-64x -e vm_base=VM0108 -e topo=t0 -e deploy=true -e save=true
1 parent 7d99e36 commit 1a2685f

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

ansible/config_sonic_basedon_testbed.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,15 @@
7575
VM_topo: "{% if 'ptf' in topo %}False{% else %}True{% endif %}"
7676
remote_dut: "{{ ansible_ssh_host }}"
7777

78-
- name: gather testbed VM informations
78+
- name: gather testbed VM informations from testbed_facts
7979
testbed_vm_info: base_vm={{ testbed_facts['vm_base'] }} topo={{ testbed_facts['topo'] }} vm_file={{ vm_file }}
8080
delegate_to: localhost
81-
when: "VM_topo | bool"
81+
when: "VM_topo | bool and testbed_name is defined"
82+
83+
- name: gather testbed VM informations from extra variables
84+
testbed_vm_info: base_vm={{ vm_base }} topo={{ topo }} vm_file={{ vm_file }}
85+
delegate_to: localhost
86+
when: "VM_topo | bool and testbed_name is not defined"
8287

8388
- name: find interface name mapping and individual interface speed if defined
8489
port_alias: hwsku="{{ hwsku }}"

ansible/testbed-cli.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ function usage
1919
echo " -m <vmfile> : virtual machine file name (default: 'veos')"
2020
echo " -k <vmtype> : vm type (veos|ceos) (default: 'veos')"
2121
echo " -n <vm_num> : vm num (default: 0)"
22+
echo " -b <vmbase> : Specify the VM Base ID the format is VM0100, VM0201 (default: parsing from testbed.csv)"
23+
2224
echo
2325
echo "Positional Arguments:"
2426
echo " <server-name> : Hostname of server on which to start VMs"
2527
echo " <vault-password-file> : Path to file containing Ansible Vault password"
2628
echo " <topo-name> : Name of the target topology"
2729
echo " <inventory> : Name of the Ansible inventory containing the DUT"
30+
echo " <vmbase> : Specify the VM base ID and the format is VM01xx or VM02xx (xx = 01~63, default: parsing from testbed.csv)"
31+
echo " Cost of VMs 0VM 4VMs 6VMs 8VMs 24VMs 32VMs 64VMs"
32+
echo " Topologies ptf32 t0 t0-16 t0-56 t1-lag t1 t1-64"
33+
echo " ptf64 t0-64 t1-64-lag"
34+
echo " t0-64-32"
35+
echo " t0-52"
36+
echo " t0-116"
2837
echo
2938
echo "To start all VMs on a server: $0 start-vms 'server-name' ~/.password"
3039
echo "To restart a subset of VMs:"
@@ -90,7 +99,12 @@ function read_file
9099
ptf_ip=${line_arr[5]}
91100
ptf_ipv6=${line_arr[6]}
92101
server=${line_arr[7]}
93-
vm_base=${line_arr[8]}
102+
if test -z "$vmbase"
103+
then
104+
vm_base=${line_arr[8]}
105+
else
106+
vm_base=${vmbase}
107+
fi
94108
dut=${line_arr[9]//;/,}
95109
duts=${dut//[\[\] ]/}
96110
}
@@ -325,8 +339,9 @@ vmfile=veos
325339
tbfile=testbed.csv
326340
vm_type=veos
327341
vm_num=0
342+
vmbase=''
328343

329-
while getopts "t:m:k:n:" OPTION; do
344+
while getopts "t:m:k:n:b:" OPTION; do
330345
case $OPTION in
331346
t)
332347
tbfile=$OPTARG
@@ -340,6 +355,9 @@ while getopts "t:m:k:n:" OPTION; do
340355
n)
341356
vm_num=$OPTARG
342357
;;
358+
b)
359+
vmbase=$OPTARG
360+
;;
343361
*)
344362
usage
345363
esac

0 commit comments

Comments
 (0)