Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ad848a0
move external interface configuration into external_port.yml
lguohan Nov 24, 2018
95530d2
move docker tasks into docker.yml
lguohan Nov 24, 2018
94d60ba
move lab proxy from group_var/vm_host to group_var/all/env.yml
lguohan Nov 24, 2018
5aad6c2
add user to libvirt and docker group
lguohan Nov 24, 2018
2f49783
use absolute path for disk_image and cdrom_image
lguohan Nov 24, 2018
e5c9444
remove vlan sub-interface creation/removal from vm_topology.py
lguohan Nov 26, 2018
57d92aa
add playbook to create sonic vm
lguohan Nov 27, 2018
24e5ffd
change all driver to be e1000, then all interfaces are enumerated
lguohan Nov 27, 2018
25ac52e
add sonic kickstart to configure sonic mgmt ip
lguohan Nov 27, 2018
a914a06
add support to bind vm to kvm vm
lguohan Nov 27, 2018
039ce45
various fixes in the playbook
lguohan Nov 27, 2018
a1576fc
fix remove topo
lguohan Nov 28, 2018
eee840a
handle different init sonic password
lguohan Nov 28, 2018
a4ac85d
simply fixes
lguohan Jan 9, 2019
45f9e49
do not create local minigraph
lguohan Jan 9, 2019
23371ff
add inventory files for kvm testbed
lguohan Jan 9, 2019
f8712ff
add missing vlan_port.py
lguohan Jan 9, 2019
2f1cb58
add proxy env for downloading data
lguohan Jan 10, 2019
aa85c0f
rename external_iface to external_port
lguohan Jan 10, 2019
b99e757
add ansible_user to sudo group
lguohan Jan 10, 2019
f1a78b0
fix register name not to be the same as the external_port
lguohan Jan 10, 2019
b20e213
correct vlan_port inputs
lguohan Jan 10, 2019
9eb4af1
add become=yes for virt module
lguohan Jan 14, 2019
9ede8be
add vlan create/remove logic for {add,remove}_topo
lguohan Jan 15, 2019
02ec9d3
set dut_mgmt_port to empty for physical dut
lguohan Jan 15, 2019
757899d
start/stop vm when the dut is kvm type
lguohan Jan 15, 2019
23d9aa6
add vlan_port module to get/create/remove vlan tunnel port in
lguohan Jan 15, 2019
3b52105
Revert "add inventory files for kvm testbed"
lguohan Jan 15, 2019
900b7c0
run kvm_port in privileged mode to run virsh
lguohan Jan 15, 2019
7b1600b
allow to use user-defined testbed csv and vm inventory file
lguohan Jan 15, 2019
67980b4
add Virtual Switch Setup README
lguohan Jan 15, 2019
bb65c27
add refresh-dut in testbed cli to refresh a sonic kvm image
lguohan Jan 16, 2019
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
1 change: 0 additions & 1 deletion ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ roles/

sonic_test/ # same kind of structure as above, but for the integration test role,
# see http://github.com/Azure/sonic-integrationtest
sonic_vm/ # for a future, vm based deployment of sonic
sonic_s6000/ # place Dell s6000 specific tasks here
sonic_msn2700/ # place Mellanox msn2700 specific tasks here
```
7 changes: 1 addition & 6 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

- block:
- name: Gathering testbed information
test_facts: testbed_name="{{ testbed_name }}"
test_facts: testbed_name="{{ testbed_name }}" testbed_file="{{ testbed_file }}"
connection: local

- fail: msg="The DUT you are trying to run test does not belongs to this testbed"
Expand Down Expand Up @@ -92,11 +92,6 @@
intf_names: "{{ intf_names | default({}) | combine({item.key: port_alias[item.value[0]|int:item.value[-1]|int+1] }) }}"
with_dict: interface_to_vms

- name: create minigraph file in ansible minigraph folder
template: src=templates/minigraph_template.j2
dest=minigraph/{{ inventory_hostname}}.{{ topo }}.xml
connection: local

- block:
- name: saved original minigraph file in SONiC DUT(ignore errors when file doesnot exist)
shell: mv /etc/sonic/minigraph.xml /etc/sonic/minigraph.xml.orig
Expand Down
2 changes: 1 addition & 1 deletion ansible/doc/README.new.testbed.Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ For each host device that you add; define or verify the:
- mgmt_bridge
- mgmt_prefixlen (this should match with the mgmt_subnet_mask_length)
- mgmt_gw
- external_iface
- external_port

### veos_groups section:
**USAGE**: veos
Expand Down
2 changes: 1 addition & 1 deletion ansible/doc/README.testbed.Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Once you are in the docker, you need to modify the testbed configuration files t
- Update server management IP in [```ansible/veos```](../veos).
- Update testbed server credentials in [```ansible/group_vars/vm_host/creds.yml```](../group_vars/vm_host/creds.yml).
- Update server network configuration for VM and PTF management interface in [```ansible/host_vars/STR-ACS-SERV-01.yml```](../host_vars/STR-ACS-SERV-01.yml).
- ```external_iface```: server trunk port name (connected to the fanout switch)
- ```external_port```: server trunk port name (connected to the fanout switch)
- ```mgmt_gw```: ip of gateway for VM mgmt interfaces
- ```mgmt_prefixlen```: prefixlen for management interfaces
- Check that ansible could reach this device by command ```ansible -m ping -i veos vm_host_1```.
Expand Down
123 changes: 123 additions & 0 deletions ansible/doc/README.testbed.VsSetup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Testbed Setup
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @lguohan . Is there a list of tests which are supported on this virtual testbed?


This document describes the steps to setup the virtual switch based testbed and deploy a topology.

## Prepare testbed server

- Install Ubuntu 18.04 amd64 server. To setup a T0 topology, the server needs to have 10GB free memory.
- Setup internal management network.

```
brctl addbr br1
ifconfig br1 10.250.0.1/24
ifconfig br1 up
```

- Download vEOS image from [arista](https://www.arista.com/en/support/software-download).
- Copy below image files to ```~/veos-vm/images``` on your testbed server.
- ```Aboot-veos-serial-8.0.0.iso```
- ```vEOS-lab-4.15.9M.vmdk```

## Setup docker registry for *PTF* docker

PTF docker is used to send and receive packets to test data plane.

- Build PTF docker
```
git clone --recursive https://github.com/Azure/sonic-buildimage.git
make configure PLATFORM=generic
make target/docker-ptf.gz
```

- Setup [docker registry](https://docs.docker.com/registry/) and upload *docker-ptf* to the docker registry.

## Build or download *sonic-mgmt* docker image

ansible playbook in *sonic-mgmt* repo requires to setup ansible and various dependencies.
We have built a *sonic-mgmt* docker that installs all dependencies, and you can build
the docker and run ansible playbook inside the docker.

- Build *sonic-mgmt* docker
```
git clone --recursive https://github.com/Azure/sonic-buildimage.git
make configure PLATFORM=generic
make target/docker-sonic-mgmt.gz
```

Pre-built *sonic-mgmt* can also be downloaded from [here](https://sonic-jenkins.westus2.cloudapp.azure.com/job/bldenv/job/docker-sonic-mgmt/lastSuccessfulBuild/artifact/target/docker-sonic-mgmt.gz).

## Download sonic-vs image

- Download sonic-vs image from [here](https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-vs-image/lastSuccessfulBuild/artifact/target/sonic-vs.img.gz)
- unzip the image and move it into ```~/sonic-vm/images/```

## Clone sonic-mgmt repo

```
git clone https://github.com/Azure/sonic-mgmt
```

- Modify veos.vtb to use the user name to login linux host. Add public key authorized\_keys for your user.
Put the private key inside the sonic-mgmt docker container. Make sure you can login into box using
```ssh yourusername@172.17.0.1``` without any password prompt inside the docker container.

```
lgh@gulv-vm2:/data/sonic/sonic-mgmt/ansible$ git diff
diff --git a/ansible/veos.vtb b/ansible/veos.vtb
index 4ea5a7a..4cfc448 100644
--- a/ansible/veos.vtb
+++ b/ansible/veos.vtb
@@ -1,5 +1,5 @@
[vm_host_1]
-STR-ACS-VSERV-01 ansible_host=172.17.0.1 ansible_user=use_own_value
+STR-ACS-VSERV-01 ansible_host=172.17.0.1 ansible_user=lgh

[vm_host:children]
vm_host_1
```

## Run sonic-mgmt docker

```
docker run -v $PWD:/data -it docker-sonic-mgmt bash
```

From now on, all steps are running inside the *sonic-mgmt* docker.

## Setup Arista VMs in the server

```
./testbed-cli.sh -m veos.vtb start-vms server_1 password.txt
```
- please note: Here "password.txt" is the ansible vault password file name/path. Ansible allows user use ansible vault to encrypt password files. By default, this shell script require a password file. If you are not using ansible vault, just create an empty file and pass the filename to the command line. The file name and location is created and maintained by user.

Check that all VMs are up and running: ```ansible -m ping -i veos server_1```

## Deploy T0 topology

```
./testbed-cli.sh -t vtestbed.csv -m veos.vtb add-topo vms-kvm-t0 password.txt
```

## Deploy minigraph on the DUT

```
./testbed-cli.sh -t vtestbed.csv -m veos.vtb deploy-mg vms-kvm-t0 lab password.txt
```

You should be login into the sonic kvm using IP: 10.250.0.101 using admin:password.
You should see BGP sessions up in sonic.

```
admin@vlab-01:~$ show ip bgp sum
BGP router identifier 10.1.0.32, local AS number 65100
RIB entries 12807, using 1401 KiB of memory
Peers 8, using 36 KiB of memory
Peer groups 2, using 112 bytes of memory

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.0.0.57 4 64600 3208 12 0 0 0 00:00:22 6400
10.0.0.59 4 64600 3208 593 0 0 0 00:00:22 6400
10.0.0.61 4 64600 3205 950 0 0 0 00:00:21 6400
10.0.0.63 4 64600 3204 950 0 0 0 00:00:21 6400
```
28 changes: 15 additions & 13 deletions ansible/fanout_connect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
when:
- dut is not defined

- set_fact:
server: "{{ inventory_hostname|lower }}"
server_port: "{{ external_iface }}"
- block:
- set_fact:
server: "{{ inventory_hostname|lower }}"
server_port: "{{ external_port }}"

- debug: msg="Connect {{ server }}:{{ server_port }} to {{ dut }}"
- debug: msg="Connect {{ server }}:{{ server_port }} to {{ dut }}"

- name: get the username running the deploy
command: whoami
connection: local
become: no
register: calling_username
changed_when: false
- name: get the username running the deploy
command: whoami
connection: local
become: no
register: calling_username
changed_when: false

- set_fact: userid={{ calling_username.stdout }}
- set_fact: userid={{ calling_username.stdout }}

- set_fact: connect_leaf=false
- set_fact: connect_leaf=false

- include: roles/fanout/tasks/rootfanout_connect.yml
- include: roles/fanout/tasks/rootfanout_connect.yml
when: external_port is defined
5 changes: 5 additions & 0 deletions ansible/group_vars/all/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# if your lab needs http(s) proxy to access Internet
# Uncomment following section and provide correct http(s) proxy
#proxy_env:
# http_proxy: http://10.252.0.99:3128
# https_proxy: http://10.252.0.99:3128
8 changes: 1 addition & 7 deletions ansible/group_vars/vm_host/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root_path: /home/azure/veos-vm
root_path: veos-vm
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not a root path in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll fix in a separate pr.

vm_images_url: https://acsbe.blob.core.windows.net/vmimages
cd_image_filename: Aboot-veos-serial-8.0.0.iso
hdd_image_filename: vEOS-lab-4.15.9M.vmdk
Expand All @@ -7,9 +7,3 @@ skip_image_downloading: false
vm_console_base: 7000
memory: 2097152
max_fp_num: 4

# proxy
proxy_env:
http_proxy: http://10.252.0.99:3128
https_proxy: http://10.252.0.99:3128

2 changes: 1 addition & 1 deletion ansible/host_vars/STR-ACS-SERV-01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ mgmt_bridge: br1
mgmt_prefixlen: 23
mgmt_gw: 10.255.0.1
vm_mgmt_gw: 10.254.0.1
external_iface: p4p1
external_port: p4p1

3 changes: 1 addition & 2 deletions ansible/host_vars/STR-ACS-SERV-02.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mgmt_bridge: br1
mgmt_prefixlen: 23
mgmt_gw: 10.255.0.1
external_iface: p4p1

external_port: p4p1
6 changes: 6 additions & 0 deletions ansible/host_vars/STR-ACS-VSERV-01.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mgmt_bridge: br1
mgmt_prefixlen: 24
mgmt_gw: 10.250.0.1
vm_mgmt_gw: 10.250.0.1

internal_mgmt_port: True
1 change: 1 addition & 0 deletions ansible/lab
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ iface_speed='40000'

[sonic_s6000]
lab-s6000-01 ansible_host=10.251.0.189
vlab-01 ansible_host=10.250.0.101

[sonic_s6000:vars]
hwsku="Force10-S6000"
Expand Down
57 changes: 57 additions & 0 deletions ansible/roles/vm_set/library/kvm_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/python

import re
import sys
import time
import subprocess
from ansible.module_utils.basic import *

DOCUMENTATION = '''
module: kvm_port
version_added: "0.1"
author: Guohan Lu (gulv@microsoft.com)
short_description: Gather management and front panel ports from KVM-based DUT
'''

EXAMPLES = '''
- name: Get front panel and mgmt port for kvm vm
kvm_port:
vmname: "{{ dut_name }}"
'''

def main():

module = AnsibleModule(argument_spec=dict(
vmname = dict(required=True),
))

vmname = module.params['vmname']

try:
output = subprocess.check_output(
"virsh domiflist %s" % vmname,
env={"LIBVIRT_DEFAULT_URI": "qemu:///system"},
shell=True)
except subprocess.CalledProcessError:
module.fail_json(msg="failed to iflist dom %s" % vmname)

mgmt_port = None
fp_ports = []

for l in output.split('\n'):
fds = re.split('\s+', l)
if len(fds) != 5:
continue
if fds[1] == "ethernet":
if mgmt_port == None:
mgmt_port = fds[0]
else:
fp_ports.append(fds[0])

if mgmt_port == None:
module.fail_json(msg="failed to find mgmt port")

module.exit_json(changed=False, ansible_facts={'dut_mgmt_port': mgmt_port, 'dut_fp_ports': fp_ports})

if __name__ == "__main__":
main()
Loading