From e0e6759bb89f2213100df419bd7e55cd419f9a40 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Thu, 1 Aug 2019 15:46:18 +0800 Subject: [PATCH] [add-topo] Add support for specifying PTF docker image tag Signed-off-by: Xin Wang --- ansible/roles/vm_set/tasks/add_topo.yml | 16 +++++++++++++++- ansible/testbed-cli.sh | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ansible/roles/vm_set/tasks/add_topo.yml b/ansible/roles/vm_set/tasks/add_topo.yml index d80577c8999..88274ec4bb1 100644 --- a/ansible/roles/vm_set/tasks/add_topo.yml +++ b/ansible/roles/vm_set/tasks/add_topo.yml @@ -1,10 +1,24 @@ + +# The PTF image built from different branches may be incompatible. The ptf_imagetag variable added here is to +# support using different PTF images for different branches. When the ptf_imagetag variable is not specified, +# the PTF image with default "201811" tag will be used in this sonic-mgmt 201811 branch. When a different PTF +# image version is required, we can specify a different value for the ptf_imagetag variable somewhere to +# override the default value, for example, specify from command line: +# ./testbed-cli.sh add-topo - vault -e ptf_imagetag=myversion +# By using this practice, we suggest to add different tags for different PTF image versions in docker registry. +# And we suggest to add tag "201811" for PTF image built from the 201811 branch. +- name: Set default value for ptf_imagetag + set_fact: + ptf_imagetag: "201811" + when: ptf_imagetag is not defined + - name: Create a docker container ptf_{{ vm_set_name }} docker: registry: "{{ docker_registry_host }}" username: "{{ docker_registry_username }}" password: "{{ docker_registry_password }}" name: ptf_{{ vm_set_name }} - image: "{{ docker_registry_host }}/{{ ptf_imagename }}" + image: "{{ docker_registry_host }}/{{ ptf_imagename }}:{{ ptf_imagetag }}" pull: always state: reloaded net: none diff --git a/ansible/testbed-cli.sh b/ansible/testbed-cli.sh index 0979dd381c0..5d416b2ad63 100755 --- a/ansible/testbed-cli.sh +++ b/ansible/testbed-cli.sh @@ -34,6 +34,8 @@ function usage echo " $0 start-vms server-name vault-password-file -e autostart=yes" echo "To stop VMs on a server: $0 stop-vms 'server-name' ~/.password" echo "To deploy a topology on a server: $0 add-topo 'topo-name' ~/.password" + echo " Optional argument for add-topo:" + echo " -e ptf_imagetag= # Use PTF image with specified tag for creating PTF container" echo "To remove a topology on a server: $0 remove-topo 'topo-name' ~/.password" echo "To renumber a topology on a server: $0 renumber-topo 'topo-name' ~/.password" echo "To connect a topology: $0 connect-topo 'topo-name' ~/.password"