Skip to content
Open
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
9 changes: 7 additions & 2 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@
VM_topo: "{% if 'ptf' in topo %}False{% else %}True{% endif %}"
remote_dut: "{{ ansible_ssh_host }}"

- name: gather testbed VM informations
- name: gather testbed VM informations from testbed_facts
testbed_vm_info: base_vm={{ testbed_facts['vm_base'] }} topo={{ testbed_facts['topo'] }} vm_file={{ vm_file }}
delegate_to: localhost
when: "VM_topo | bool"
when: "VM_topo | bool and testbed_name is defined"

- name: gather testbed VM informations from extra variables
testbed_vm_info: base_vm={{ vm_base }} topo={{ topo }} vm_file={{ vm_file }}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The updated file config_sonic_basedon_testbed.yml is called by testbed-cli.sh in generate_minigraph, deploy_minigraph and test_minigraph. Let's take generate_minigraph as an example:

function generate_minigraph
{
  topology=$1
  inventory=$2
  passfile=$3
  shift
  shift
  shift

  echo "Generating 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 local_minigraph=true $@

  echo Done
}

According to the ansible-playbook command line, variables vm_base and topo are not passed to the playbook. I suspect that in this playbook, variables vm_base and topo are undefined.

delegate_to: localhost
when: "VM_topo | bool and testbed_name is not defined"

- name: find interface name mapping and individual interface speed if defined
port_alias: hwsku="{{ hwsku }}"
Expand Down
22 changes: 20 additions & 2 deletions ansible/testbed-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ function usage
echo " -m <vmfile> : virtual machine file name (default: 'veos')"
echo " -k <vmtype> : vm type (veos|ceos) (default: 'veos')"
echo " -n <vm_num> : vm num (default: 0)"
echo " -b <vmbase> : Specify the VM Base ID the format is VM0100, VM0201 (default: parsing from testbed.csv)"

echo
echo "Positional Arguments:"
echo " <server-name> : Hostname of server on which to start VMs"
echo " <vault-password-file> : Path to file containing Ansible Vault password"
echo " <topo-name> : Name of the target topology"
echo " <inventory> : Name of the Ansible inventory containing the DUT"
echo " <vmbase> : Specify the VM base ID and the format is VM01xx or VM02xx (xx = 01~63, default: parsing from testbed.csv)"
echo " Cost of VMs 0VM 4VMs 6VMs 8VMs 24VMs 32VMs 64VMs"
echo " Topologies ptf32 t0 t0-16 t0-56 t1-lag t1 t1-64"
echo " ptf64 t0-64 t1-64-lag"
echo " t0-64-32"
echo " t0-52"
echo " t0-116"
echo
echo "To start all VMs on a server: $0 start-vms 'server-name' ~/.password"
echo "To restart a subset of VMs:"
Expand Down Expand Up @@ -90,7 +99,12 @@ function read_file
ptf_ip=${line_arr[5]}
ptf_ipv6=${line_arr[6]}
server=${line_arr[7]}
vm_base=${line_arr[8]}
if test -z "$vmbase"
then
vm_base=${line_arr[8]}
else
vm_base=${vmbase}
fi
dut=${line_arr[9]//;/,}
duts=${dut//[\[\] ]/}
}
Expand Down Expand Up @@ -325,8 +339,9 @@ vmfile=veos
tbfile=testbed.csv
vm_type=veos
vm_num=0
vmbase=''

while getopts "t:m:k:n:" OPTION; do
while getopts "t:m:k:n:b:" OPTION; do
case $OPTION in
t)
tbfile=$OPTARG
Expand All @@ -340,6 +355,9 @@ while getopts "t:m:k:n:" OPTION; do
n)
vm_num=$OPTARG
;;
b)
vmbase=$OPTARG
;;
*)
usage
esac
Expand Down