forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestbed_renumber_vm_topology.yml
99 lines (80 loc) · 3.59 KB
/
testbed_renumber_vm_topology.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# This Playbook renumber a topology on a server
#
#
# To renumber a topology please use following command
# ANSIBLE_SCP_IF_SSH=y ansible-playbook -i veos testbed_renumber_vm_topology.yml --vault-password-file=~/.password -l server_3 -e vm_set_name=first -e VM_base=VM0300 -e ptf_ip=10.255.0.255/23 -e topo=t0 -e duts_name=str-msn-2700-05 -e ptf_imagename="docker_ptf"
#
# Parameters
# -l server_3 - this playbook have to be limited to run only on one server
# -e vm_set_name=first - the name of vm_set
# -e duts_name=str-msn2700-02 - the new value of a dut name, the dut will be connected to the current testbed
# -e VM_base=VM0300 - the VM name which is used to as base to calculate VM name for this set
# -e ptf_ip=10.255.0.255/23 - the ip address and prefix of ptf container mgmt interface
# -e topo=t0 - the name of removed topo
# -e ptf_imagename=docker-ptf - name of a docker-image which will be used for the ptf docker container
- hosts: servers:&vm_host
gather_facts: no
vars_files:
- vars/docker_registry.yml
pre_tasks:
- set_fact: ansible_user="{{ vm_host_user }}"
when:
- vm_host_user is defined
- vm_host_user != 'use_own_value'
- set_fact: ansible_password="{{ vm_host_password }}"
when:
- vm_host_password is defined
- vm_host_password != 'use_own_value'
- set_fact: ansible_become_password="{{ vm_host_become_password }}"
when:
- vm_host_become_password is defined
- vm_host_become_password != 'use_own_value'
- name: Check for a single host
fail: msg="Please use -l server_X to limit this playbook to one host"
when: play_hosts|length != 1
- name: Check that variable testbed_name is defined
fail: msg="Define testbed_name variable with -e testbed_name=something"
when: testbed_name is not defined
- name: Check that variable vm_set_name is defined
fail: msg="Define vm_set_name variable with -e vm_set_name=something"
when: vm_set_name is not defined
- name: Check that variable duts_name is defined
fail: msg="Define duts_name variable with -e duts_name=something"
when: duts_name is not defined
- name: Check that variable VM_base is defined
fail: msg="Define VM_base variable with -e VM_base=something"
when: VM_base is not defined
- name: Check that variable ptf_ip is defined
fail: msg="Define ptf ip variable with -e ptf_ip=something"
when: ptf_ip is not defined
- name: Check that variable ptf_ipv6 is defined
fail: msg="Define ptf ipv6 variable with -e ptf_ipv6=something"
when: ptf_ipv6 is not defined
- name: Check that variable topo is defined
fail: msg="Define topo variable with -e topo=something"
when: topo is not defined
- set_fact:
base_topo: "{{ topo.split('_') | first }}"
- name: Check that variable topo is defined
fail: msg="Define topo variable with -e topo=something"
when: base_topo not in topologies
- name: Check that variable ptf_imagename is defined
fail: msg="Define ptf_imagename variable with -e ptf_imagename=something"
when: ptf_imagename is not defined
- name: Disable package installation
set_fact:
package_installation: false
- name: Load topo variables
include_vars: "vars/topo_{{ topo }}.yml"
- name: Read dut minigraph
conn_graph_facts:
host: "{{ duts_name }}"
delegate_to: localhost
when: duts_name.split(',')|length == 1
- name: Read duts minigraph
conn_graph_facts:
hosts: "{{ duts_name.split(',') }}"
delegate_to: localhost
when: duts_name.split(',')|length > 1
roles:
- { role: vm_set, action: 'renumber_topo' }