-
Notifications
You must be signed in to change notification settings - Fork 1k
add support for virtual testbed #774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 95530d2
move docker tasks into docker.yml
lguohan 94d60ba
move lab proxy from group_var/vm_host to group_var/all/env.yml
lguohan 5aad6c2
add user to libvirt and docker group
lguohan 2f49783
use absolute path for disk_image and cdrom_image
lguohan e5c9444
remove vlan sub-interface creation/removal from vm_topology.py
lguohan 57d92aa
add playbook to create sonic vm
lguohan 24e5ffd
change all driver to be e1000, then all interfaces are enumerated
lguohan 25ac52e
add sonic kickstart to configure sonic mgmt ip
lguohan a914a06
add support to bind vm to kvm vm
lguohan 039ce45
various fixes in the playbook
lguohan a1576fc
fix remove topo
lguohan eee840a
handle different init sonic password
lguohan a4ac85d
simply fixes
lguohan 45f9e49
do not create local minigraph
lguohan 23371ff
add inventory files for kvm testbed
lguohan f8712ff
add missing vlan_port.py
lguohan 2f1cb58
add proxy env for downloading data
lguohan aa85c0f
rename external_iface to external_port
lguohan b99e757
add ansible_user to sudo group
lguohan f1a78b0
fix register name not to be the same as the external_port
lguohan b20e213
correct vlan_port inputs
lguohan 9eb4af1
add become=yes for virt module
lguohan 9ede8be
add vlan create/remove logic for {add,remove}_topo
lguohan 02ec9d3
set dut_mgmt_port to empty for physical dut
lguohan 757899d
start/stop vm when the dut is kvm type
lguohan 23d9aa6
add vlan_port module to get/create/remove vlan tunnel port in
lguohan 3b52105
Revert "add inventory files for kvm testbed"
lguohan 900b7c0
run kvm_port in privileged mode to run virsh
lguohan 7b1600b
allow to use user-defined testbed csv and vm inventory file
lguohan 67980b4
add Virtual Switch Setup README
lguohan bb65c27
add refresh-dut in testbed cli to refresh a sonic kvm image
lguohan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # Testbed Setup | ||
|
|
||
| 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 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| root_path: /home/azure/veos-vm | ||
| root_path: veos-vm | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not a root path in this case
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?