diff options
author | Peter Mikus <pmikus@cisco.com> | 2019-12-03 12:53:24 +0000 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2019-12-03 15:02:08 +0000 |
commit | 53fb7dad59b185992aaed1ec2e470c547693caf2 (patch) | |
tree | 434b319374a93fd6cf271b185a7a4cb1b32caa1f /resources/tools/virl | |
parent | 7482d7a93bf3f7af2f82d2986deaf83f3cd65f92 (diff) |
Remove: VIRL
Signed-off-by: Peter Mikus <pmikus@cisco.com>
Change-Id: I2b1672412e19f15cb46246fffa931351cd3d518b
Diffstat (limited to 'resources/tools/virl')
-rw-r--r-- | resources/tools/virl/README.md | 18 | ||||
-rwxr-xr-x | resources/tools/virl/bin/kill-idle-testcases | 29 | ||||
-rwxr-xr-x | resources/tools/virl/bin/list-testcases | 19 | ||||
-rwxr-xr-x | resources/tools/virl/bin/start-testcase | 569 | ||||
-rwxr-xr-x | resources/tools/virl/bin/start-testcase-DMM | 542 | ||||
-rwxr-xr-x | resources/tools/virl/bin/start-testcase-TLDK | 542 | ||||
-rwxr-xr-x | resources/tools/virl/bin/stop-testcase | 27 | ||||
-rw-r--r-- | resources/tools/virl/topologies/double-ring-nested.centos7.virl | 301 | ||||
-rw-r--r-- | resources/tools/virl/topologies/double-ring-nested.centos7.yaml | 98 | ||||
-rw-r--r-- | resources/tools/virl/topologies/double-ring-nested.xenial.virl | 362 | ||||
-rw-r--r-- | resources/tools/virl/topologies/double-ring-nested.xenial.yaml | 98 |
11 files changed, 0 insertions, 2605 deletions
diff --git a/resources/tools/virl/README.md b/resources/tools/virl/README.md deleted file mode 100644 index fe4edd8853..0000000000 --- a/resources/tools/virl/README.md +++ /dev/null @@ -1,18 +0,0 @@ -## VIRL scripts - -This directory, and subdirectories, contain files required for automated VIRL testing. These files -are based on the following assumptions: - - - Files in this directory are installed on the VIRL server host, and scripts in bin/ directory - are executable by the user used in the bootstrap.sh script in the root directory of this - project - - - the VIRL server has a "server" image, as well as a "vPP" image that is accepting a cloud-init - configuration and is ready to receive a VPP upgrade. - - - the VIRL server has an NFS export that can be mounted by VIRL VMs, or there is an NFS server - with an export mounted by the VIRL server and mountable by VIRL VMs. - - - the bin/start_testcase script has hardcoded default values both in variable assignments - near the beginning of the file, as well as in "parser.add_argument", "default=" options. - These may need to be updated. diff --git a/resources/tools/virl/bin/kill-idle-testcases b/resources/tools/virl/bin/kill-idle-testcases deleted file mode 100755 index 39a7961ba2..0000000000 --- a/resources/tools/virl/bin/kill-idle-testcases +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2016 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -IDLE_THRESHOLD=3600 # 1 hour - -CURR_TIME=$(date +%s) -for s in /nfs/scratch/* -do - s_time=$(cat $s/start_time) - age=$[$CURR_TIME - $s_time] - s2=$(basename $s) - if [ $age -gt $IDLE_THRESHOLD ] - then - echo "Simulation $s is older than $IDLE_THRESHOLD seconds (age $age), killing it..." - stop-testcase $s2 - fi -done diff --git a/resources/tools/virl/bin/list-testcases b/resources/tools/virl/bin/list-testcases deleted file mode 100755 index 73c05303fe..0000000000 --- a/resources/tools/virl/bin/list-testcases +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2017 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -VIRL_USER="tb4-virl" # VIRL credentials (what one would enter in VMMaestro) -VIRL_PASSWORD="Cisco1234" - -virl_std_client --json --quiet -u $VIRL_USER -p $VIRL_PASSWORD simengine-list diff --git a/resources/tools/virl/bin/start-testcase b/resources/tools/virl/bin/start-testcase deleted file mode 100755 index 9e63f8da92..0000000000 --- a/resources/tools/virl/bin/start-testcase +++ /dev/null @@ -1,569 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2016 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""This script is handling starting of VIRL simulations.""" - -__author__ = 'ckoester@cisco.com' - -import argparse -import netifaces -import os -import paramiko -import random -import re -import shutil -import sys -import tempfile -import time - -import requests - -IPS_PER_SIMULATION = 5 - - -def indent(lines, amount, fillchar=' '): - """Indent the string by amount of fill chars. - - :param lines: String to indent. - :param amount: Number of fill chars. - :param fillchar: Filling character. - :type lines: str - :type amount: int - :type fillchar: str - :returns: Indented string. - :rtype: str - """ - padding = amount * fillchar - return padding + ('\n'+padding).join(lines.split('\n')) - - -def print_to_stderr(msg, end='\n'): - """Writes any text to stderr. - - :param msg: Message to print. - :param end: By default print new line at the end. - :type msg: str - :type end: str - """ - try: - sys.stderr.write(str(msg) + end) - except ValueError: - pass - - -def get_assigned_interfaces(args, network="flat"): - """Retrieve assigned interfaces in openstack network. - - :param args: Command line params. - :param network: Openstack network. - :type args: ArgumentParser - :type network: str - :returns: Assigned interfaces. - :rtype: list - :raises RuntimeError: If response is not 200. - """ - req = requests.get('http://{}/openstack/rest/ports/{}' - .format(args.virl_ip, network), - auth=(args.username, args.password)) - if req.status_code == 200: - return req.json() - else: - raise RuntimeError("ERROR: Retrieving ports in use - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - - -def get_assigned_interfaces_count(args, network="flat"): - """Count assigned interfaces in openstack network. - - :param args: Command line params. - :param network: Openstack network. - :type args: ArgumentParser - :type network: str - :returns: Assigned interfaces count. - :rtype: int - """ - return len(get_assigned_interfaces(args, network=network)) - - -def check_ip_addresses(args): - """Check IP address availability. - - :param args: Command line params. - :type args: ArgumentParser - :raises RuntimeError: If not enough free addresses available. - """ - for i in range(args.wait_count): - if (args.quota - - get_assigned_interfaces_count(args) >= IPS_PER_SIMULATION): - break - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Attempt {} out of {}, waiting for free " - "IP addresses".format(i, args.wait_count)) - # Wait random amount of time within range 1-3 minutes - time.sleep(random.randint(60,180)) - else: - raise RuntimeError("ERROR: Not enough IP addresses to run simulation") - - -def check_virl_resources(args): - """Check virl resources availability. - - :param args: Command line params. - :type args: ArgumentParser - """ - check_ip_addresses(args) - -# -# FIXME: Right now, this is really coded like a shell script, as one big -# function executed in sequence. This should be broken down into multiple -# functions. -# - - -def main(): - """ Main function.""" - # - # Get our default interface IP address. This will become the default - # value for the "NFS Server IP" option. - # - gws = netifaces.gateways() - addrs = netifaces.ifaddresses(gws['default'][netifaces.AF_INET][1]) - default_addr = addrs[netifaces.AF_INET][0]['addr'] - - # - # Verify CLI parameters and try to download our VPP image into a temporary - # file first - # - parser = argparse.ArgumentParser() - parser.add_argument("topology", help="the base topology to be started") - parser.add_argument("packages", help="Path to the VPP .deb(s) or .rpm(s) " + - "that is/are to be installed", nargs='+') - parser.add_argument("-c", "--copy", help="Copy the VPP packages, " + - "leaving the originals in place. Default is to " + - "move them.", action='store_true') - parser.add_argument("-k", "--keep", help="Keep (do not delete) the " + - "simulation in case of error", action='store_true') - parser.add_argument("-v", "--verbosity", action="count", default=0) - parser.add_argument("-nip", "--nfs-server-ip", help="NFS server (our) IP " + - "default is derived from routing table: " + - "{}".format(default_addr), default=default_addr) - parser.add_argument("-ns", "--nfs-scratch-directory", - help="Server location for NFS scratch directory", - default="/nfs/scratch") - parser.add_argument("-nc", "--nfs-common-directory", - help="Server location for NFS common (read-only) " + - "directory", default="/nfs/common") - parser.add_argument("-wc", "--wait-count", - help="number of intervals to wait for simulation to " + - "be ready", type=int, default=48) - parser.add_argument("-wt", "--wait-time", - help="length of a single interval to wait for " + - "simulation to be ready", type=int, default=5) - parser.add_argument("-vip", "--virl-ip", - help="VIRL IP and Port (e.g. 127.0.0.1:19399)", - default="127.0.0.1:19399") - parser.add_argument("-u", "--username", help="VIRL username", - default="tb4-virl") - parser.add_argument("-au", "--admin-username", help="VIRL admin username", - default="uwmadmin") - parser.add_argument("-p", "--password", help="VIRL password", - default="Cisco1234") - parser.add_argument("-su", "--ssh-user", help="SSH username", - default="cisco") - parser.add_argument("-e", "--expiry", help="Simulation expiry", - default="120") - parser.add_argument("-spr", "--ssh-privkey", help="SSH private keyfile", - default="/home/jenkins-in/.ssh/id_rsa_virl") - parser.add_argument("-spu", "--ssh-pubkey", help="SSH public keyfile", - default="/home/jenkins-in/.ssh/id_rsa_virl.pub") - parser.add_argument("-r", "--release", help="VM disk image/release " + - "(ex. \"csit-ubuntu-16.04.1_2016-12-19_1.6\")", - default="csit-ubuntu-16.04.1_2016-12-19_1.6") - parser.add_argument("--topology-directory", help="Topology directory", - default="/home/jenkins-in/testcase-infra/topologies") - parser.add_argument("-q", "--quota", - help="VIRL quota for max number of allowed IPs", - type=int, default=74) - parser.add_argument("-si", "--skip-install", help="Skip VPP installation", - action='store_true') - - args = parser.parse_args() - - # - # Check if topology and template exist - # - if args.verbosity >= 2: - print_to_stderr("DEBUG: Running with topology {}" - .format(args.topology)) - - topology_virl_filename = os.path.join(args.topology_directory, - args.topology + ".virl") - topology_yaml_filename = os.path.join(args.topology_directory, - args.topology + ".yaml") - - if not os.path.isfile(topology_virl_filename): - print_to_stderr("ERROR: Topology VIRL file {} does not exist" - .format(topology_virl_filename)) - sys.exit(1) - if not os.path.isfile(topology_yaml_filename): - print_to_stderr("ERROR: Topology YAML file {} does not exist" - .format(topology_yaml_filename)) - sys.exit(1) - - # - # Check if VPP package exists - # - if not args.skip_install: - for package in args.packages: - if args.verbosity >= 2: - print_to_stderr("DEBUG: Checking if file {} exists" - .format(package)) - if not os.path.isfile(package): - print_to_stderr("ERROR: Required package {} does not exist" - .format(package)) - sys.exit(1) - - # - # Start VIRL topology - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Starting VIRL topology") - temp_handle, temp_topology = tempfile.mkstemp() - with open(args.ssh_pubkey, 'r') as pubkey_file: - pub_key = pubkey_file.read().replace('\n', '') - with open(temp_topology, 'w') as new_file, \ - open(topology_virl_filename, 'r') as old_file: - for line in old_file: - line = line.replace(" - VIRL-USER-SSH-PUBLIC-KEY", " - "+pub_key) - line = line.replace("$$NFS_SERVER_SCRATCH$$", - args.nfs_server_ip+":"+args.nfs_scratch_directory) - line = line.replace("$$NFS_SERVER_COMMON$$", - args.nfs_server_ip+":"+args.nfs_common_directory) - line = line.replace("$$VM_IMAGE$$", "server-"+args.release) - new_file.write(line) - os.close(temp_handle) - - try: - data = open(temp_topology, 'rb') - check_virl_resources(args) - req = requests.post('http://' + args.virl_ip + '/simengine/rest/launch', - auth=(args.username, args.password), - data=data) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("{}" - .format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - new_file.close() - if req.status_code != 200: - raise RuntimeError("ERROR: Launching VIRL simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - os.remove(temp_topology) - sys.exit(1) - - # If we got here, we had a good response. The response content is the - # session ID. - session_id = req.content - if args.verbosity >= 1: - print_to_stderr("DEBUG: VIRL simulation session-id: {}" - .format(session_id)) - - # Set session expiry to autokill sessions if not done from jenkins - if not args.keep: - if args.verbosity >= 1: - print_to_stderr("DEBUG: Setting expire for session-id: {}" - .format(session_id)) - try: - req = requests.put('http://' + args.virl_ip + - '/simengine/rest/admin-update/' + session_id + - '/expiry', - auth=(args.admin_username, args.password), - params={'user': args.username, - 'expires': args.expiry}) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("{}" - .format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - if req.status_code != 200: - raise RuntimeError("ERROR: Setting expiry to simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - os.remove(temp_topology) - print "{}".format(session_id) - sys.exit(1) - - # - # Create simulation scratch directory. Move topology file into that - # directory. Copy or move debian packages into that directory. - # - scratch_directory = os.path.join(args.nfs_scratch_directory, session_id) - os.mkdir(scratch_directory) - shutil.move(temp_topology, os.path.join(scratch_directory, - "virl_topology.virl")) - os.mkdir(os.path.join(scratch_directory, "vpp")) - for package in args.packages: - if args.copy: - shutil.copy(package, os.path.join(scratch_directory, "vpp", - os.path.basename(package))) - else: - shutil.move(package, os.path.join(scratch_directory, "vpp", - os.path.basename(package))) - - # - # Wait for simulation to become active - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Waiting for simulation to become active") - - sim_is_started = False - nodelist = [] - - count = args.wait_count - while (count > 0) and not sim_is_started: - time.sleep(args.wait_time) - count -= 1 - - req = requests.get('http://' + args.virl_ip + '/simengine/rest/nodes/' + - session_id, auth=(args.username, args.password)) - data = req.json() - - active = 0 - total = 0 - - # Flush the node list every time, keep the last one - nodelist = [] - - # Hosts are the keys of the inner dictionary - for key in data[session_id].keys(): - if data[session_id][key]['management-proxy'] == "self": - continue - nodelist.append(key) - total += 1 - if data[session_id][key]['state'] == "ACTIVE": - active += 1 - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Attempt {} out of {}, total {} hosts, " - "{} active".format(args.wait_count-count, - args.wait_count, total, active)) - if active == total: - sim_is_started = True - - if not sim_is_started: - print_to_stderr("ERROR: Simulation nodes never changed to ACTIVE state") - print_to_stderr("Last VIRL response:") - print_to_stderr(data) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - - if args.verbosity >= 2: - print_to_stderr("DEBUG: Nodes: {}" - .format(", ".join(nodelist))) - - # - # Fetch simulation's IPs and create files - # (ansible hosts file, topology YAML file) - # - try: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/interfaces/' + session_id, - auth=(args.username, args.password), - params={'fetch-state': '1'}) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("DEBUG: - Request Text") - print_to_stderr("{}".format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - if req.status_code != 200: - raise RuntimeError("ERROR:Fetching IP's of simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - data = req.json() - - # Populate node addresses - nodeaddrs = {} - topology = {} - for key in nodelist: - nodetype = re.split('[0-9]', key)[0] - if not nodetype in nodeaddrs: - nodeaddrs[nodetype] = {} - nodeaddrs[nodetype][key] = re.split('\\/', \ - data[session_id][key]['management']['ip-address'])[0] - if args.verbosity >= 2: - print_to_stderr("DEBUG: Node {} is of type {} and has mgmt IP {}" - .format(key, nodetype, nodeaddrs[nodetype][key])) - - topology[key] = {} - for key2 in data[session_id][key]: - topology[key]["nic-"+key2] = data[session_id][key][key2] - if 'ip-address' in topology[key]["nic-"+key2]: - if topology[key]["nic-"+key2]['ip-address'] is not None: - topology[key]["nic-"+key2]['ip-addr'] = re.split('\\/', \ - topology[key]["nic-"+key2]['ip-address'])[0] - - # Write ansible file - ansiblehosts = open(os.path.join(scratch_directory, 'ansible-hosts'), 'w') - for key1 in nodeaddrs: - ansiblehosts.write("[{}]\n".format(key1)) - for key2 in nodeaddrs[key1]: - ansiblehosts.write("{} hostname={}\n".format(nodeaddrs[key1][key2], - key2)) - ansiblehosts.close() - - # Process topology YAML template - with open(args.ssh_privkey, 'r') as privkey_file: - priv_key = indent(privkey_file.read(), 6) - - with open(os.path.join(scratch_directory, "topology.yaml"), 'w') as \ - new_file, open(topology_yaml_filename, 'r') as old_file: - for line in old_file: - new_file.write(line.format(priv_key=priv_key, topology=topology)) - - # - # Wait for hosts to become reachable over SSH - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Waiting for hosts to become reachable over SSH") - - missing = -1 - count = args.wait_count - while (count > 0) and missing != 0: - time.sleep(args.wait_time) - count -= 1 - - missing = 0 - for key in nodelist: - if not os.path.exists(os.path.join(scratch_directory, key)): - missing += 1 - if args.verbosity >= 2: - print_to_stderr("DEBUG: Attempt {} out of {}, waiting for {} hosts" - .format(args.wait_count-count, args.wait_count, - missing)) - - if missing != 0: - print_to_stderr("ERROR: Simulation started OK but {} hosts never " - "mounted their NFS directory".format(missing)) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - - # - # Upgrade VPP - # - if not args.skip_install: - if args.verbosity >= 1: - print_to_stderr("DEBUG: Uprading VPP") - - for key1 in nodeaddrs: - if not key1 == 'tg': - for key2 in nodeaddrs[key1]: - ipaddr = nodeaddrs[key1][key2] - if args.verbosity >= 2: - print_to_stderr("DEBUG: Upgrading VPP on node {}" - .format(ipaddr)) - paramiko.util.log_to_file(os.path.join(scratch_directory, - "ssh.log")) - client = paramiko.SSHClient() - client.load_system_host_keys() - client.load_host_keys("/dev/null") - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect(ipaddr, username=args.ssh_user, - key_filename=args.ssh_privkey) - if 'centos' in args.topology: - if args.verbosity >= 1: - print_to_stderr("DEBUG: Installing RPM packages") - vpp_install_command = 'sudo rpm -ivh /scratch/vpp/*.rpm' - elif 'trusty' in args.topology or 'xenial' in args.topology: - if args.verbosity >= 1: - print_to_stderr("DEBUG: Installing DEB packages") - vpp_install_command = 'sudo dpkg -i --force-all ' \ - '/scratch/vpp/*.deb' - else: - print_to_stderr("ERROR: Unsupported OS requested: {}" - .format(args.topology)) - vpp_install_command = '' - _, stdout, stderr = \ - client.exec_command(vpp_install_command) - c_stdout = stdout.read() - c_stderr = stderr.read() - if args.verbosity >= 2: - print_to_stderr("DEBUG: Command output was:") - print_to_stderr(c_stdout) - print_to_stderr("DEBUG: Command stderr was:") - print_to_stderr(c_stderr) - - # - # Write a file with timestamp to scratch directory. We can use this to track - # how long a simulation has been running. - # - with open(os.path.join(scratch_directory, 'start_time'), 'a') as \ - timestampfile: - timestampfile.write('{}\n'.format(int(time.time()))) - - # - # Declare victory - # - if args.verbosity >= 1: - print_to_stderr("SESSION ID: {}".format(session_id)) - - print "{}".format(session_id) - -if __name__ == "__main__": - sys.exit(main()) diff --git a/resources/tools/virl/bin/start-testcase-DMM b/resources/tools/virl/bin/start-testcase-DMM deleted file mode 100755 index c6a7c2dda2..0000000000 --- a/resources/tools/virl/bin/start-testcase-DMM +++ /dev/null @@ -1,542 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2018 Huawei Technologies Co.,Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""This script is handling starting of VIRL simulations.""" - -import argparse -import netifaces -import os -import paramiko -import random -import re -import shutil -import sys -import tempfile -import time - -import requests - -IPS_PER_SIMULATION = 5 - -def indent(lines, amount, fillchar=' '): - """Indent the string by amount of fill chars. - - :param lines: String to indent. - :param amount: Number of fill chars. - :param fillchar: Filling character. - :type lines: str - :type amount: int - :type fillchar: str - :returns: Indented string. - :rtype: str - """ - padding = amount * fillchar - return padding + ('\n'+padding).join(lines.split('\n')) - -def print_to_stderr(msg, end='\n'): - """Writes any text to stderr. - - :param msg: Message to print. - :param end: By default print new line at the end. - :type msg: str - :type end: str - """ - try: - sys.stderr.write(str(msg) + end) - except ValueError: - pass - -def get_assigned_interfaces(args, network="flat"): - """Retrieve assigned interfaces in openstack network. - - :param args: Command line params. - :param network: Openstack network. - :type args: ArgumentParser - :type network: str - :returns: Assigned interfaces. - :rtype: list - :raises RuntimeError: If response is not 200. - """ - req = requests.get('http://{}/openstack/rest/ports/{}' - .format(args.virl_ip, network), - auth=(args.username, args.password)) - if req.status_code == 200: - return req.json() - else: - raise RuntimeError("ERROR: Retrieving ports in use - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - -def get_assigned_interfaces_count(args, network="flat"): - """Count assigned interfaces in openstack network. - - :param args: Command line params. - :param network: Openstack network. - :type args: ArgumentParser - :type network: str - :returns: Assigned interfaces count. - :rtype: int - """ - return len(get_assigned_interfaces(args, network=network)) - -def check_ip_addresses(args): - """Check IP address availability. - - :param args: Command line params. - :type args: ArgumentParser - :raises RuntimeError: If not enough free addresses available. - """ - for i in range(args.wait_count): - if args.quota - \ - get_assigned_interfaces_count(args) >= IPS_PER_SIMULATION: - break - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Attempt {} out of {}, waiting for free " - "IP addresses".format(i, args.wait_count)) - # Wait random amount of time within range 1-3 minutes - time.sleep(random.randint(60, 180)) - else: - raise RuntimeError("ERROR: Not enough IP addresses to run simulation") - -def check_virl_resources(args): - """Check virl resources availability. - - :param args: Command line params. - :type args: ArgumentParser - """ - check_ip_addresses(args) - -# -# FIXME: Right now, this is really coded like a shell script, as one big -# function executed in sequence. This should be broken down into multiple -# functions. -# -def main(): - """ Main function.""" - # - # Get our default interface IP address. This will become the default - # value for the "NFS Server IP" option. - # - gws = netifaces.gateways() - addrs = netifaces.ifaddresses(gws['default'][netifaces.AF_INET][1]) - default_addr = addrs[netifaces.AF_INET][0]['addr'] - - # - # Verify CLI parameters and try to download our VPP image into a temporary - # file first - # - parser = argparse.ArgumentParser() - parser.add_argument("topology", help="the base topology to be started") - parser.add_argument("packages", help="Path to the dmm package file that " + - "is/are to be installed", nargs='+') - parser.add_argument("-c", "--copy", help="Copy the dmm packages, " + - "leaving the originals in place. Default is to " + - "move them.", action='store_true') - parser.add_argument("-k", "--keep", help="Keep (do not delete) the " + - "simulation in case of error", action='store_true') - parser.add_argument("-v", "--verbosity", action="count", default=0) - parser.add_argument("-nip", "--nfs-server-ip", help="NFS server (our) IP " + - "default is derived from routing table: " + - "{}".format(default_addr), default=default_addr) - parser.add_argument("-ns", "--nfs-scratch-directory", - help="Server location for NFS scratch diretory", - default="/nfs/scratch") - parser.add_argument("-nc", "--nfs-common-directory", - help="Server location for NFS common (read-only) " + - "directory", default="/nfs/common") - parser.add_argument("-wc", "--wait-count", - help="number of intervals to wait for simulation to " + - "be ready", type=int, default=24) - parser.add_argument("-wt", "--wait-time", - help="length of a single interval to wait for " + - "simulation to be ready", type=int, default=5) - parser.add_argument("-vip", "--virl-ip", - help="VIRL IP and Port (e.g. 127.0.0.1:19399)", - default="127.0.0.1:19399") - parser.add_argument("-u", "--username", help="VIRL username", - default="tb4-virl") - parser.add_argument("-au", "--admin-username", help="VIRL admin username", - default="uwmadmin") - parser.add_argument("-p", "--password", help="VIRL password", - default="Cisco1234") - parser.add_argument("-su", "--ssh-user", help="SSH username", - default="cisco") - parser.add_argument("-e", "--expiry", help="Simulation expiry", - default="120") - parser.add_argument("-spr", "--ssh-privkey", help="SSH private keyfile", - default="/home/jenkins-in/.ssh/id_rsa_virl") - parser.add_argument("-spu", "--ssh-pubkey", help="SSH public keyfile", - default="/home/jenkins-in/.ssh/id_rsa_virl.pub") - parser.add_argument("-r", "--release", help="VM disk image/release " + - "(ex. \"csit-ubuntu-16.04.1_2016-12-19_1.6\")", - default="csit-ubuntu-16.04.1_2016-12-19_1.6") - parser.add_argument("--topology-directory", help="Topology directory", - default="/home/jenkins-in/testcase-infra/topologies") - parser.add_argument("-q", "--quota", - help="VIRL quota for max number of allowed IPs", - type=int, default=74) - - args = parser.parse_args() - - # - # Check if topology and template exist - # - if args.verbosity >= 2: - print_to_stderr("DEBUG: Running with topology {}" - .format(args.topology)) - - topology_virl_filename = os.path.join(args.topology_directory, - args.topology + ".virl") - topology_yaml_filename = os.path.join(args.topology_directory, - args.topology + ".yaml") - - if not os.path.isfile(topology_virl_filename): - print_to_stderr("ERROR: Topology VIRL file {} does not exist" - .format(topology_virl_filename)) - sys.exit(1) - if not os.path.isfile(topology_yaml_filename): - print_to_stderr("ERROR: Topology YAML file {} does not exist" - .format(topology_yaml_filename)) - sys.exit(1) - - # - # Check if DMM package exists - # - for package in args.packages: - if args.verbosity >= 2: - print_to_stderr("DEBUG: Checking if file {} exists" - .format(package)) - if not os.path.isfile(package): - print_to_stderr("ERROR: DMM package {} does not exist." - .format(package)) - sys.exit(1) - - # - # Start VIRL topology - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Starting VIRL topology") - temp_handle, temp_topology = tempfile.mkstemp() - with open(args.ssh_pubkey, 'r') as pubkey_file: - pub_key = pubkey_file.read().replace('\n', '') - with open(temp_topology, 'w') as new_file, \ - open(topology_virl_filename, 'r') as old_file: - for line in old_file: - line = line.replace(" - VIRL-USER-SSH-PUBLIC-KEY", " - "+pub_key) - line = line.replace("$$NFS_SERVER_SCRATCH$$", \ - args.nfs_server_ip+":"+args.nfs_scratch_directory) - line = line.replace("$$NFS_SERVER_COMMON$$", \ - args.nfs_server_ip+":"+args.nfs_common_directory) - line = line.replace("$$VM_IMAGE$$", "server-"+args.release) - new_file.write(line) - os.close(temp_handle) - - try: - data = open(temp_topology, 'rb') - check_virl_resources(args) - req = requests.post('http://' + args.virl_ip + '/simengine/rest/launch', - auth=(args.username, args.password), - data=data) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("{}" - .format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - new_file.close() - if req.status_code != 200: - raise RuntimeError("ERROR: Launching VIRL simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - os.remove(temp_topology) - sys.exit(1) - - # If we got here, we had a good response. The response content is the - # session ID. - session_id = req.content - if args.verbosity >= 1: - print_to_stderr("DEBUG: VIRL simulation session-id: {}" - .format(session_id)) - - # Set session expiry to autokill sessions if not done from jenkins - if not args.keep: - if args.verbosity >= 1: - print_to_stderr("DEBUG: Setting expire for session-id: {}" - .format(session_id)) - try: - req = requests.put('http://' + args.virl_ip + - '/simengine/rest/admin-update/' + session_id + - '/expiry', - auth=(args.admin_username, args.password), - params={'user': args.username, - 'expires': args.expiry}) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("{}" - .format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - if req.status_code != 200: - raise RuntimeError("ERROR: Setting expiry to simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - os.remove(temp_topology) - print "{}".format(session_id) - sys.exit(1) - - # - # Create simulation scratch directory. Move topology file into that - # directory. Copy or move DMM packages into that directory. - # - scratch_directory = os.path.join(args.nfs_scratch_directory, session_id) - os.mkdir(scratch_directory) - shutil.move(temp_topology, os.path.join(scratch_directory, - "virl_topology.virl")) - os.mkdir(os.path.join(scratch_directory, "dmmtest")) - for package in args.packages: - if args.copy: - shutil.copy(package, os.path.join(scratch_directory, "dmmtest", - os.path.basename(package))) - else: - shutil.move(package, os.path.join(scratch_directory, "dmmtest", - os.path.basename(package))) - - # - # Wait for simulation to become active - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Waiting for simulation to become active") - - sim_is_started = False - nodelist = [] - - count = args.wait_count - while (count > 0) and not sim_is_started: - time.sleep(args.wait_time) - count -= 1 - - req = requests.get('http://' + args.virl_ip + '/simengine/rest/nodes/' + - session_id, auth=(args.username, args.password)) - data = req.json() - - active = 0 - total = 0 - - # Flush the node list every time, keep the last one - nodelist = [] - - # Hosts are the keys of the inner dictionary - for key in data[session_id].keys(): - if data[session_id][key]['management-proxy'] == "self": - continue - nodelist.append(key) - total += 1 - if data[session_id][key]['state'] == "ACTIVE": - active += 1 - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Attempt {} out of {}, total {} hosts, " - "{} active".format(args.wait_count-count, - args.wait_count, total, active)) - if active == total: - sim_is_started = True - - if not sim_is_started: - print_to_stderr("ERROR: Simulation nodes never changed to ACTIVE state") - print_to_stderr("Last VIRL response:") - print_to_stderr(data) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - - if args.verbosity >= 2: - print_to_stderr("DEBUG: Nodes: {}" - .format(", ".join(nodelist))) - - # - # Fetch simulation's IPs and create files - # (ansible hosts file, topology YAML file) - # - try: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/interfaces/' + session_id, - auth=(args.username, args.password), - params={'fetch-state': '1'}) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("DEBUG: - Request Text") - print_to_stderr("{}".format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - if req.status_code != 200: - raise RuntimeError("ERROR:Fetching IP's of simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - data = req.json() - - # Populate node addresses - nodeaddrs = {} - topology = {} - for key in nodelist: - nodetype = re.split('[0-9]', key)[0] - if not nodetype in nodeaddrs: - nodeaddrs[nodetype] = {} - nodeaddrs[nodetype][key] = re.split('\\/', \ - data[session_id][key]['management']['ip-address'])[0] - if args.verbosity >= 2: - print_to_stderr("DEBUG: Node {} is of type {} and has mgmt IP {}" - .format(key, nodetype, nodeaddrs[nodetype][key])) - - topology[key] = {} - for key2 in data[session_id][key]: - topology[key]["nic-"+key2] = data[session_id][key][key2] - if 'ip-address' in topology[key]["nic-"+key2]: - if topology[key]["nic-"+key2]['ip-address'] is not None: - topology[key]["nic-"+key2]['ip-addr'] = re.split('\\/', \ - topology[key]["nic-"+key2]['ip-address'])[0] - - # Write ansible file - ansiblehosts = open(os.path.join(scratch_directory, 'ansible-hosts'), 'w') - for key1 in nodeaddrs: - ansiblehosts.write("[{}]\n".format(key1)) - for key2 in nodeaddrs[key1]: - ansiblehosts.write("{} hostname={}\n".format(nodeaddrs[key1][key2], - key2)) - ansiblehosts.close() - - # Process topology YAML template - with open(args.ssh_privkey, 'r') as privkey_file: - priv_key = indent(privkey_file.read(), 6) - - with open(os.path.join(scratch_directory, "topology.yaml"), 'w') as \ - new_file, open(topology_yaml_filename, 'r') as old_file: - for line in old_file: - new_file.write(line.format(priv_key=priv_key, topology=topology)) - - # - # Wait for hosts to become reachable over SSH - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Waiting for hosts to become reachable over SSH") - - missing = -1 - count = args.wait_count - while (count > 0) and missing != 0: - time.sleep(args.wait_time) - count -= 1 - - missing = 0 - for key in nodelist: - if not os.path.exists(os.path.join(scratch_directory, key)): - missing += 1 - if args.verbosity >= 2: - print_to_stderr("DEBUG: Attempt {} out of {}, waiting for {} hosts" - .format(args.wait_count-count, args.wait_count, - missing)) - - if missing != 0: - print_to_stderr("ERROR: Simulation started OK but {} hosts never " - "mounted their NFS directory".format(missing)) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - - # - # just decompress the DMM tar packages - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Uprading DMM") - - for key1 in nodeaddrs: - if not key1 == 'tg': - for key2 in nodeaddrs[key1]: - ipaddr = nodeaddrs[key1][key2] - if args.verbosity >= 2: - print_to_stderr("DEBUG: Upgrading DMM on node {}" - .format(ipaddr)) - paramiko.util.log_to_file(os.path.join(scratch_directory, - "ssh.log")) - client = paramiko.SSHClient() - client.load_system_host_keys() - client.load_host_keys("/dev/null") - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect(ipaddr, username=args.ssh_user, - key_filename=args.ssh_privkey) - _, stdout, stderr = \ - client.exec_command('cd /scratch/dmmtest/ && sudo tar zxf dmm_depends.tar.gz') - c_stdout = stdout.read() - c_stderr = stderr.read() - if args.verbosity >= 2: - print_to_stderr("DEBUG: Command output was:") - print_to_stderr(c_stdout) - print_to_stderr("DEBUG: Command stderr was:") - print_to_stderr(c_stderr) - - # - # Write a file with timestamp to scratch directory. We can use this to track - # how long a simulation has been running. - # - with open(os.path.join(scratch_directory, 'start_time'), 'a') as \ - timestampfile: - timestampfile.write('{}\n'.format(int(time.time()))) - - # - # Declare victory - # - if args.verbosity >= 1: - print_to_stderr("SESSION ID: {}".format(session_id)) - - print "{}".format(session_id) - -if __name__ == "__main__": - sys.exit(main())
\ No newline at end of file diff --git a/resources/tools/virl/bin/start-testcase-TLDK b/resources/tools/virl/bin/start-testcase-TLDK deleted file mode 100755 index f6021dacbd..0000000000 --- a/resources/tools/virl/bin/start-testcase-TLDK +++ /dev/null @@ -1,542 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2017 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""This script is handling starting of VIRL simulations.""" - -import argparse -import netifaces -import os -import paramiko -import random -import re -import shutil -import sys -import tempfile -import time - -import requests - -IPS_PER_SIMULATION = 5 - -def indent(lines, amount, fillchar=' '): - """Indent the string by amount of fill chars. - - :param lines: String to indent. - :param amount: Number of fill chars. - :param fillchar: Filling character. - :type lines: str - :type amount: int - :type fillchar: str - :returns: Indented string. - :rtype: str - """ - padding = amount * fillchar - return padding + ('\n'+padding).join(lines.split('\n')) - -def print_to_stderr(msg, end='\n'): - """Writes any text to stderr. - - :param msg: Message to print. - :param end: By default print new line at the end. - :type msg: str - :type end: str - """ - try: - sys.stderr.write(str(msg) + end) - except ValueError: - pass - -def get_assigned_interfaces(args, network="flat"): - """Retrieve assigned interfaces in openstack network. - - :param args: Command line params. - :param network: Openstack network. - :type args: ArgumentParser - :type network: str - :returns: Assigned interfaces. - :rtype: list - :raises RuntimeError: If response is not 200. - """ - req = requests.get('http://{}/openstack/rest/ports/{}' - .format(args.virl_ip, network), - auth=(args.username, args.password)) - if req.status_code == 200: - return req.json() - else: - raise RuntimeError("ERROR: Retrieving ports in use - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - -def get_assigned_interfaces_count(args, network="flat"): - """Count assigned interfaces in openstack network. - - :param args: Command line params. - :param network: Openstack network. - :type args: ArgumentParser - :type network: str - :returns: Assigned interfaces count. - :rtype: int - """ - return len(get_assigned_interfaces(args, network=network)) - -def check_ip_addresses(args): - """Check IP address availability. - - :param args: Command line params. - :type args: ArgumentParser - :raises RuntimeError: If not enough free addresses available. - """ - for i in range(args.wait_count): - if args.quota - \ - get_assigned_interfaces_count(args) >= IPS_PER_SIMULATION: - break - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Attempt {} out of {}, waiting for free " - "IP addresses".format(i, args.wait_count)) - # Wait random amount of time within range 1-3 minutes - time.sleep(random.randint(60, 180)) - else: - raise RuntimeError("ERROR: Not enough IP addresses to run simulation") - -def check_virl_resources(args): - """Check virl resources availability. - - :param args: Command line params. - :type args: ArgumentParser - """ - check_ip_addresses(args) - -# -# FIXME: Right now, this is really coded like a shell script, as one big -# function executed in sequence. This should be broken down into multiple -# functions. -# -def main(): - """ Main function.""" - # - # Get our default interface IP address. This will become the default - # value for the "NFS Server IP" option. - # - gws = netifaces.gateways() - addrs = netifaces.ifaddresses(gws['default'][netifaces.AF_INET][1]) - default_addr = addrs[netifaces.AF_INET][0]['addr'] - - # - # Verify CLI parameters and try to download our VPP image into a temporary - # file first - # - parser = argparse.ArgumentParser() - parser.add_argument("topology", help="the base topology to be started") - parser.add_argument("packages", help="Path to the tldk package file that " + - "is/are to be installed", nargs='+') - parser.add_argument("-c", "--copy", help="Copy the tldk packages, " + - "leaving the originals in place. Default is to " + - "move them.", action='store_true') - parser.add_argument("-k", "--keep", help="Keep (do not delete) the " + - "simulation in case of error", action='store_true') - parser.add_argument("-v", "--verbosity", action="count", default=0) - parser.add_argument("-nip", "--nfs-server-ip", help="NFS server (our) IP " + - "default is derived from routing table: " + - "{}".format(default_addr), default=default_addr) - parser.add_argument("-ns", "--nfs-scratch-directory", - help="Server location for NFS scratch diretory", - default="/nfs/scratch") - parser.add_argument("-nc", "--nfs-common-directory", - help="Server location for NFS common (read-only) " + - "directory", default="/nfs/common") - parser.add_argument("-wc", "--wait-count", - help="number of intervals to wait for simulation to " + - "be ready", type=int, default=24) - parser.add_argument("-wt", "--wait-time", - help="length of a single interval to wait for " + - "simulation to be ready", type=int, default=5) - parser.add_argument("-vip", "--virl-ip", - help="VIRL IP and Port (e.g. 127.0.0.1:19399)", - default="127.0.0.1:19399") - parser.add_argument("-u", "--username", help="VIRL username", - default="tb4-virl") - parser.add_argument("-au", "--admin-username", help="VIRL admin username", - default="uwmadmin") - parser.add_argument("-p", "--password", help="VIRL password", - default="Cisco1234") - parser.add_argument("-su", "--ssh-user", help="SSH username", - default="cisco") - parser.add_argument("-e", "--expiry", help="Simulation expiry", - default="120") - parser.add_argument("-spr", "--ssh-privkey", help="SSH private keyfile", - default="/home/jenkins-in/.ssh/id_rsa_virl") - parser.add_argument("-spu", "--ssh-pubkey", help="SSH public keyfile", - default="/home/jenkins-in/.ssh/id_rsa_virl.pub") - parser.add_argument("-r", "--release", help="VM disk image/release " + - "(ex. \"csit-ubuntu-14.04.4_2016-05-25_1.0\")", - default="csit-ubuntu-14.04.4_2016-05-25_1.0") - parser.add_argument("--topology-directory", help="Topology directory", - default="/home/jenkins-in/testcase-infra/topologies") - parser.add_argument("-q", "--quota", - help="VIRL quota for max number of allowed IPs", - type=int, default=74) - - args = parser.parse_args() - - # - # Check if topology and template exist - # - if args.verbosity >= 2: - print_to_stderr("DEBUG: Running with topology {}" - .format(args.topology)) - - topology_virl_filename = os.path.join(args.topology_directory, - args.topology + ".virl") - topology_yaml_filename = os.path.join(args.topology_directory, - args.topology + ".yaml") - - if not os.path.isfile(topology_virl_filename): - print_to_stderr("ERROR: Topology VIRL file {} does not exist" - .format(topology_virl_filename)) - sys.exit(1) - if not os.path.isfile(topology_yaml_filename): - print_to_stderr("ERROR: Topology YAML file {} does not exist" - .format(topology_yaml_filename)) - sys.exit(1) - - # - # Check if TLDK package exists - # - for package in args.packages: - if args.verbosity >= 2: - print_to_stderr("DEBUG: Checking if file {} exists" - .format(package)) - if not os.path.isfile(package): - print_to_stderr("ERROR: TLDK package {} does not exist." - .format(package)) - sys.exit(1) - - # - # Start VIRL topology - # - if args.verbosity >= 1: - print "DEBUG: Starting VIRL topology" - temp_handle, temp_topology = tempfile.mkstemp() - with open(args.ssh_pubkey, 'r') as pubkey_file: - pub_key = pubkey_file.read().replace('\n', '') - with open(temp_topology, 'w') as new_file, \ - open(topology_virl_filename, 'r') as old_file: - for line in old_file: - line = line.replace(" - VIRL-USER-SSH-PUBLIC-KEY", " - "+pub_key) - line = line.replace("$$NFS_SERVER_SCRATCH$$", \ - args.nfs_server_ip+":"+args.nfs_scratch_directory) - line = line.replace("$$NFS_SERVER_COMMON$$", \ - args.nfs_server_ip+":"+args.nfs_common_directory) - line = line.replace("$$VM_IMAGE$$", "server-"+args.release) - new_file.write(line) - os.close(temp_handle) - - try: - data = open(temp_topology, 'rb') - check_virl_resources(args) - req = requests.post('http://' + args.virl_ip + '/simengine/rest/launch', - auth=(args.username, args.password), - data=data) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("{}" - .format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - new_file.close() - if req.status_code != 200: - raise RuntimeError("ERROR: Launching VIRL simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - os.remove(temp_topology) - sys.exit(1) - - # If we got here, we had a good response. The response content is the - # session ID. - session_id = req.content - if args.verbosity >= 1: - print_to_stderr("DEBUG: VIRL simulation session-id: {}" - .format(session_id)) - - # Set session expiry to autokill sessions if not done from jenkins - if not args.keep: - if args.verbosity >= 1: - print_to_stderr("DEBUG: Setting expire for session-id: {}" - .format(session_id)) - try: - req = requests.put('http://' + args.virl_ip + - '/simengine/rest/admin-update/' + session_id + - '/expiry', - auth=(args.admin_username, args.password), - params={'user': args.username, - 'expires': args.expiry}) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("{}" - .format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - if req.status_code != 200: - raise RuntimeError("ERROR: Setting expiry to simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - os.remove(temp_topology) - print "{}".format(session_id) - sys.exit(1) - - # - # Create simulation scratch directory. Move topology file into that - # directory. Copy or move TLDK packages into that directory. - # - scratch_directory = os.path.join(args.nfs_scratch_directory, session_id) - os.mkdir(scratch_directory) - shutil.move(temp_topology, os.path.join(scratch_directory, - "virl_topology.virl")) - os.mkdir(os.path.join(scratch_directory, "tldktest")) - for package in args.packages: - if args.copy: - shutil.copy(package, os.path.join(scratch_directory, "tldktest", - os.path.basename(package))) - else: - shutil.move(package, os.path.join(scratch_directory, "tldktest", - os.path.basename(package))) - - # - # Wait for simulation to become active - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Waiting for simulation to become active") - - sim_is_started = False - nodelist = [] - - count = args.wait_count - while (count > 0) and not sim_is_started: - time.sleep(args.wait_time) - count -= 1 - - req = requests.get('http://' + args.virl_ip + '/simengine/rest/nodes/' + - session_id, auth=(args.username, args.password)) - data = req.json() - - active = 0 - total = 0 - - # Flush the node list every time, keep the last one - nodelist = [] - - # Hosts are the keys of the inner dictionary - for key in data[session_id].keys(): - if data[session_id][key]['management-proxy'] == "self": - continue - nodelist.append(key) - total += 1 - if data[session_id][key]['state'] == "ACTIVE": - active += 1 - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Attempt {} out of {}, total {} hosts, " - "{} active".format(args.wait_count-count, - args.wait_count, total, active)) - if active == total: - sim_is_started = True - - if not sim_is_started: - print_to_stderr("ERROR: Simulation nodes never changed to ACTIVE state") - print_to_stderr("Last VIRL response:") - print_to_stderr(data) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except shutil.Error: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - - if args.verbosity >= 2: - print_to_stderr("DEBUG: Nodes: {}" - .format(", ".join(nodelist))) - - # - # Fetch simulation's IPs and create files - # (ansible hosts file, topology YAML file) - # - try: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/interfaces/' + session_id, - auth=(args.username, args.password), - params={'fetch-state': '1'}) - if args.verbosity >= 2: - print_to_stderr("DEBUG: - Request URL {}" - .format(req.url)) - print_to_stderr("DEBUG: - Request Text") - print_to_stderr("{}".format(req.text)) - print_to_stderr("DEBUG: - Response Code {}" - .format(req.status_code)) - if req.status_code != 200: - raise RuntimeError("ERROR:Fetching IP's of simulation - " - "Status other than 200 HTTP OK:\n{}" - .format(req.content)) - except (requests.exceptions.RequestException, - RuntimeError) as ex_error: - print_to_stderr(ex_error) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except shutil.Error: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - data = req.json() - - # Populate node addresses - nodeaddrs = {} - topology = {} - for key in nodelist: - nodetype = re.split('[0-9]', key)[0] - if not nodetype in nodeaddrs: - nodeaddrs[nodetype] = {} - nodeaddrs[nodetype][key] = re.split('\\/', \ - data[session_id][key]['management']['ip-address'])[0] - if args.verbosity >= 2: - print_to_stderr("DEBUG: Node {} is of type {} and has mgmt IP {}" - .format(key, nodetype, nodeaddrs[nodetype][key])) - - topology[key] = {} - for key2 in data[session_id][key]: - topology[key]["nic-"+key2] = data[session_id][key][key2] - if 'ip-address' in topology[key]["nic-"+key2]: - if topology[key]["nic-"+key2]['ip-address'] is not None: - topology[key]["nic-"+key2]['ip-addr'] = re.split('\\/', \ - topology[key]["nic-"+key2]['ip-address'])[0] - - # Write ansible file - ansiblehosts = open(os.path.join(scratch_directory, 'ansible-hosts'), 'w') - for key1 in nodeaddrs: - ansiblehosts.write("[{}]\n".format(key1)) - for key2 in nodeaddrs[key1]: - ansiblehosts.write("{} hostname={}\n".format(nodeaddrs[key1][key2], - key2)) - ansiblehosts.close() - - # Process topology YAML template - with open(args.ssh_privkey, 'r') as privkey_file: - priv_key = indent(privkey_file.read(), 6) - - with open(os.path.join(scratch_directory, "topology.yaml"), 'w') as \ - new_file, open(topology_yaml_filename, 'r') as old_file: - for line in old_file: - new_file.write(line.format(priv_key=priv_key, topology=topology)) - - # - # Wait for hosts to become reachable over SSH - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Waiting for hosts to become reachable over SSH") - - missing = -1 - count = args.wait_count - while (count > 0) and missing != 0: - time.sleep(args.wait_time) - count -= 1 - - missing = 0 - for key in nodelist: - if not os.path.exists(os.path.join(scratch_directory, key)): - missing += 1 - if args.verbosity >= 2: - print_to_stderr("DEBUG: Attempt {} out of {}, waiting for {} hosts" - .format(args.wait_count-count, args.wait_count, - missing)) - - if missing != 0: - print_to_stderr("ERROR: Simulation started OK but {} hosts never " - "mounted their NFS directory".format(missing)) - if not args.keep: - req = requests.get('http://' + args.virl_ip + - '/simengine/rest/stop/' + session_id, - auth=(args.username, args.password)) - try: - shutil.rmtree(scratch_directory) - except shutil.Error: - print_to_stderr("ERROR: Removing scratch directory") - print "{}".format(session_id) - sys.exit(1) - - # - # just decompress the TLDK tar packages - # - if args.verbosity >= 1: - print_to_stderr("DEBUG: Uprading TLDK") - - for key1 in nodeaddrs: - if not key1 == 'tg': - for key2 in nodeaddrs[key1]: - ipaddr = nodeaddrs[key1][key2] - if args.verbosity >= 2: - print_to_stderr("DEBUG: Upgrading TLDK on node {}" - .format(ipaddr)) - paramiko.util.log_to_file(os.path.join(scratch_directory, - "ssh.log")) - client = paramiko.SSHClient() - client.load_system_host_keys() - client.load_host_keys("/dev/null") - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - client.connect(ipaddr, username=args.ssh_user, - key_filename=args.ssh_privkey) - _, stdout, stderr = \ - client.exec_command('cd /scratch/tldktest/ && sudo tar zxf tldk_depends.tar.gz') - c_stdout = stdout.read() - c_stderr = stderr.read() - if args.verbosity >= 2: - print_to_stderr("DEBUG: Command output was:") - print_to_stderr(c_stdout) - print_to_stderr("DEBUG: Command stderr was:") - print_to_stderr(c_stderr) - - # - # Write a file with timestamp to scratch directory. We can use this to track - # how long a simulation has been running. - # - with open(os.path.join(scratch_directory, 'start_time'), 'a') as \ - timestampfile: - timestampfile.write('{}\n'.format(int(time.time()))) - - # - # Declare victory - # - if args.verbosity >= 1: - print_to_stderr("SESSION ID: {}".format(session_id)) - - print "{}".format(session_id) - -if __name__ == "__main__": - sys.exit(main())
\ No newline at end of file diff --git a/resources/tools/virl/bin/stop-testcase b/resources/tools/virl/bin/stop-testcase deleted file mode 100755 index 572d5d6e8d..0000000000 --- a/resources/tools/virl/bin/stop-testcase +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2016 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -VIRL_USER="tb4-virl" # VIRL credentials (what one would enter in VMMaestro) -VIRL_PASSWORD="Cisco1234" - -NFS_SCRATCH_SERVERDIR="/nfs/scratch" # Our own (NFS server) IP address, and directory locations. - -TESTCASE=$1 - -if [ "x${TESTCASE}" != "x" ] -then - virl_std_client -u $VIRL_USER -p $VIRL_PASSWORD simengine-stop --session-id $TESTCASE - sudo rm -fr ${NFS_SCRATCH_SERVERDIR}/${TESTCASE} -fi diff --git a/resources/tools/virl/topologies/double-ring-nested.centos7.virl b/resources/tools/virl/topologies/double-ring-nested.centos7.virl deleted file mode 100644 index 218851e449..0000000000 --- a/resources/tools/virl/topologies/double-ring-nested.centos7.virl +++ /dev/null @@ -1,301 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<topology xmlns="http://www.cisco.com/VIRL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="0.9" xsi:schemaLocation="http://www.cisco.com/VIRL https://raw.github.com/CiscoVIRL/schema/v0.9/virl.xsd"> - <extensions> - <entry key="management_network" type="String">flat</entry> - </extensions> - <node name="tg1" type="SIMPLE" subtype="server" location="570,238" vmImage="$$VM_IMAGE$$"> - <extensions> - <entry key="config" type="String">#cloud-config -hostname: tg1 -manage_etc_hosts: false -nfs_server_scratch: $$NFS_SERVER_SCRATCH$$ -nfs_server_common: $$NFS_SERVER_COMMON$$ -runcmd: -- hostnamectl set-hostname tg1 -- systemctl start rc-local -- touch /tmp/before-sed -- sed -i 's/^\s*PasswordAuthentication\s\+no/PasswordAuthentication yes/' /etc/ssh/sshd_config -- sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config -- sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/' /etc/ssh/sshd_config -- service ssh restart -- service sshd restart -- ln -s /sbin/lspci /usr/bin/lspci -- ln -s /sbin/pidof /usr/bin/pidof -users: -- default -- gecos: User configured by VIRL Configuration Engine 0.21.4 - lock-passwd: false - name: cisco - plain-text-passwd: cisco - shell: /bin/bash - ssh-authorized-keys: - - VIRL-USER-SSH-PUBLIC-KEY - - VIRL-USER-SSH-PUBLIC-KEY - sudo: ALL=(ALL) NOPASSWD:ALL -write_files: -- path: /usr/local/sbin/cloud-instance-name - content: | - #!/usr/bin/python2.7 - import pickle - print pickle.loads(open('/var/lib/cloud/instance/obj.pkl', 'rb').read()).metadata['name'] - owner: root:root - permissions: '0755' -- path: /etc/rc.local - owner: root:root - permissions: '0755' - content: |- - #!/bin/sh - grep -q nfs_server_scratch /var/lib/cloud/instance/user-data.txt || exit 1 - grep -q nfs_server_common /var/lib/cloud/instance/user-data.txt || exit 1 - nfs_server_scratch=$(grep -E '^nfs_server_scratch:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - nfs_server_common=$(grep -E '^nfs_server_common:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - instance_name=$(/usr/local/sbin/cloud-instance-name | cut -f 3 -d '<' | cut -f 1 -d '>') - echo My instance name is $instance_name - - MAXCOUNT=12 - RETRY=5 - - mkdir -p /scratch - mkdir -p /mnt/common - - echo "Mounting NFS directories" - count=0 - while [ $count -lt $MAXCOUNT ] && ! mount -t nfs "${nfs_server_scratch}/${instance_name}" /scratch - do - sleep 5 - count=$[$count+1] - done - - mount -t nfs "${nfs_server_common}" /mnt/common - - mkdir /scratch/$(hostname) - cp /VERSION /scratch/$(hostname)/ - - exit 0 -</entry> - <entry key="Auto-generate config" type="Boolean">false</entry> - </extensions> - <interface id="0" name="eth1"/> - <interface id="1" name="eth2"/> - <interface id="2" name="eth3"/> - <interface id="3" name="eth4"/> - <interface id="4" name="eth5"/> - <interface id="5" name="eth6"/> - </node> - <node name="sut1" type="SIMPLE" subtype="vPP" location="425,26" vmImage="$$VM_IMAGE$$"> - <extensions> - <entry key="config" type="string">#cloud-config -hostname: sut1 -manage_etc_hosts: false -nfs_server_scratch: $$NFS_SERVER_SCRATCH$$ -nfs_server_common: $$NFS_SERVER_COMMON$$ -runcmd: -- hostnamectl set-hostname sut1 -- systemctl start rc-local -- sed -i 's/^\s*PasswordAuthentication\s\+no/PasswordAuthentication yes/' /etc/ssh/sshd_config -- sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config -- sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/' /etc/ssh/sshd_config -- service ssh restart -- service sshd restart -- sed -i 's/no-pci//' /opt/cisco/vpe/etc/qn.conf -- sed -i 's/1024/1024 decimal-interface-names/g' /opt/cisco/vpe/etc/qn.conf -- ln -s /dev/null /etc/sysctl.d/80-vpp.conf -- ln -s /sbin/pidof /usr/bin/pidof -- ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-system-x86_64 -- ln -s /sbin/fuser /usr/bin/fuser -users: -- default -- gecos: User configured by VIRL Configuration Engine 0.21.4 - lock-passwd: false - name: cisco - plain-text-passwd: cisco - shell: /bin/bash - ssh-authorized-keys: - - VIRL-USER-SSH-PUBLIC-KEY - - VIRL-USER-SSH-PUBLIC-KEY - sudo: ALL=(ALL) NOPASSWD:ALL -write_files: -- path: /usr/local/sbin/cloud-instance-name - content: | - #!/usr/bin/python2.7 - import pickle - print pickle.loads(open('/var/lib/cloud/instance/obj.pkl', 'rb').read()).metadata['name'] - owner: root:root - permissions: '0755' -- path: /etc/rc.local - owner: root:root - permissions: '0755' - content: |- - #!/bin/sh - grep -q nfs_server_scratch /var/lib/cloud/instance/user-data.txt || exit 1 - grep -q nfs_server_common /var/lib/cloud/instance/user-data.txt || exit 1 - nfs_server_scratch=$(grep -E '^nfs_server_scratch:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - nfs_server_common=$(grep -E '^nfs_server_common:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - instance_name=$(/usr/local/sbin/cloud-instance-name | cut -f 3 -d '<' | cut -f 1 -d '>') - echo My instance name is $instance_name - - MAXCOUNT=12 - RETRY=5 - - mkdir -p /scratch - mkdir -p /mnt/common - - echo "Mounting NFS directories" - count=0 - while [ $count -lt $MAXCOUNT ] && ! mount -t nfs "${nfs_server_scratch}/${instance_name}" /scratch - do - sleep 5 - count=$[$count+1] - done - - mount -t nfs "${nfs_server_common}" /mnt/common - - # Overwrite nested VM image with latest as per NFS - if [ -f /mnt/common/nested-vm-current.img ] - then - rm -f /var/lib/vm/vhost-nested.img - cp /mnt/common/nested-vm-current.img /var/lib/vm/vhost-nested.img - fi - - mkdir /scratch/$(hostname) - cp /VERSION /scratch/$(hostname)/ - cat /var/lib/vm/vhost-nested.img | strings | grep NESTED_VERSION= > /scratch/$(hostname)/NESTED_VERSION - - exit 0 -- path: /etc/sysctl.d/90-csit.conf - owner: root:root - content: | - # Number of 2MB hugepages desired - vm.nr_hugepages=1024 - - # Must be greater than or equal to (2 * vm.nr_hugepages). - vm.max_map_count=20000 - - # All groups allowed to access hugepages - vm.hugetlb_shm_group=0 - - # Shared Memory Max must be greator or equal to the total size of hugepages. - # For 2MB pages, TotalHugepageSize = vm.nr_hugepages * 2 * 1024 * 1024 - # If the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax) - # is greater than the calculated TotalHugepageSize then set this parameter - # to current shmmax value. - kernel.shmmax=2147483648 -</entry> - </extensions> - <interface id="0" name="GigabitEthernet0/4/0"/> - <interface id="1" name="GigabitEthernet0/5/0"/> - <interface id="2" name="GigabitEthernet0/6/0"/> - <interface id="3" name="GigabitEthernet0/7/0"/> - </node> - <node name="sut2" type="SIMPLE" subtype="vPP" location="748,26" vmImage="$$VM_IMAGE$$"> - <extensions> - <entry key="config" type="string">#cloud-config -hostname: sut2 -manage_etc_hosts: false -nfs_server_scratch: $$NFS_SERVER_SCRATCH$$ -nfs_server_common: $$NFS_SERVER_COMMON$$ -runcmd: -- hostnamectl set-hostname sut2 -- systemctl start rc-local -- sed -i 's/^\s*PasswordAuthentication\s\+no/PasswordAuthentication yes/' /etc/ssh/sshd_config -- sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config -- sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/' /etc/ssh/sshd_config -- service ssh restart -- service sshd restart -- sed -i 's/no-pci//' /opt/cisco/vpe/etc/qn.conf -- sed -i 's/1024/1024 decimal-interface-names/g' /opt/cisco/vpe/etc/qn.conf -- ln -s /dev/null /etc/sysctl.d/80-vpp.conf -- ln -s /sbin/pidof /usr/bin/pidof -- ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-system-x86_64 -- ln -s /sbin/fuser /usr/bin/fuser -users: -- default -- gecos: User configured by VIRL Configuration Engine 0.21.4 - lock-passwd: false - name: cisco - plain-text-passwd: cisco - shell: /bin/bash - ssh-authorized-keys: - - VIRL-USER-SSH-PUBLIC-KEY - - VIRL-USER-SSH-PUBLIC-KEY - sudo: ALL=(ALL) NOPASSWD:ALL -write_files: -- path: /usr/local/sbin/cloud-instance-name - content: | - #!/usr/bin/python2.7 - import pickle - print pickle.loads(open('/var/lib/cloud/instance/obj.pkl', 'rb').read()).metadata['name'] - owner: root:root - permissions: '0755' -- path: /etc/rc.local - owner: root:root - permissions: '0755' - content: |- - #!/bin/sh - grep -q nfs_server_scratch /var/lib/cloud/instance/user-data.txt || exit 1 - grep -q nfs_server_common /var/lib/cloud/instance/user-data.txt || exit 1 - nfs_server_scratch=$(grep -E '^nfs_server_scratch:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - nfs_server_common=$(grep -E '^nfs_server_common:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - instance_name=$(/usr/local/sbin/cloud-instance-name | cut -f 3 -d '<' | cut -f 1 -d '>') - echo My instance name is $instance_name - - MAXCOUNT=12 - RETRY=5 - - mkdir -p /scratch - mkdir -p /mnt/common - - echo "Mounting NFS directories" - count=0 - while [ $count -lt $MAXCOUNT ] && ! mount -t nfs "${nfs_server_scratch}/${instance_name}" /scratch - do - sleep 5 - count=$[$count+1] - done - - mount -t nfs "${nfs_server_common}" /mnt/common - - # Overwrite nested VM image with latest as per NFS - if [ -f /mnt/common/nested-vm-current.img ] - then - rm -f /var/lib/vm/vhost-nested.img - cp /mnt/common/nested-vm-current.img /var/lib/vm/vhost-nested.img - fi - - mkdir /scratch/$(hostname) - cp /VERSION /scratch/$(hostname)/ - cat /var/lib/vm/vhost-nested.img | strings | grep NESTED_VERSION= > /scratch/$(hostname)/NESTED_VERSION - - exit 0 -- path: /etc/sysctl.d/90-csit.conf - owner: root:root - content: | - # Number of 2MB hugepages desired - vm.nr_hugepages=1024 - - # Must be greater than or equal to (2 * vm.nr_hugepages). - vm.max_map_count=20000 - - # All groups allowed to access hugepages - vm.hugetlb_shm_group=0 - - # Shared Memory Max must be greator or equal to the total size of hugepages. - # For 2MB pages, TotalHugepageSize = vm.nr_hugepages * 2 * 1024 * 1024 - # If the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax) - # is greater than the calculated TotalHugepageSize then set this parameter - # to current shmmax value. - kernel.shmmax=2147483648 -</entry> - </extensions> - <interface id="0" name="GigabitEthernet0/4/0"/> - <interface id="1" name="GigabitEthernet0/5/0"/> - <interface id="2" name="GigabitEthernet0/6/0"/> - <interface id="3" name="GigabitEthernet0/7/0"/> - </node> - <connection dst="/virl:topology/virl:node[1]/virl:interface[3]" src="/virl:topology/virl:node[2]/virl:interface[1]"/> - <connection dst="/virl:topology/virl:node[1]/virl:interface[4]" src="/virl:topology/virl:node[2]/virl:interface[2]"/> - <connection dst="/virl:topology/virl:node[2]/virl:interface[3]" src="/virl:topology/virl:node[3]/virl:interface[3]"/> - <connection dst="/virl:topology/virl:node[2]/virl:interface[4]" src="/virl:topology/virl:node[3]/virl:interface[4]"/> - <connection dst="/virl:topology/virl:node[1]/virl:interface[5]" src="/virl:topology/virl:node[3]/virl:interface[1]"/> - <connection dst="/virl:topology/virl:node[1]/virl:interface[6]" src="/virl:topology/virl:node[3]/virl:interface[2]"/> -</topology> diff --git a/resources/tools/virl/topologies/double-ring-nested.centos7.yaml b/resources/tools/virl/topologies/double-ring-nested.centos7.yaml deleted file mode 100644 index d35e24b777..0000000000 --- a/resources/tools/virl/topologies/double-ring-nested.centos7.yaml +++ /dev/null @@ -1,98 +0,0 @@ ---- -metadata: - version: 0.1 - schema: - - resources/topology_schemas/3_node_topology.sch.yaml - - resources/topology_schemas/topology.sch.yaml - tags: [hw, 3-node] - -nodes: - TG: - type: TG - host: "{topology[tg1][nic-management][ip-addr]}" - arch: x86_64 - port: 22 - username: cisco - priv_key: | -{priv_key} - interfaces: - port3: - mac_address: "{topology[tg1][nic-2][hw-addr]}" - pci_address: "0000:00:06.0" - link: link1 - driver: virtio-pci - port4: - mac_address: "{topology[tg1][nic-3][hw-addr]}" - pci_address: "0000:00:07.0" - link: link4 - driver: virtio-pci - port5: - mac_address: "{topology[tg1][nic-4][hw-addr]}" - pci_address: "0000:00:08.0" - link: link2 - driver: virtio-pci - port6: - mac_address: "{topology[tg1][nic-5][hw-addr]}" - pci_address: "0000:00:09.0" - link: link5 - driver: virtio-pci - DUT1: - type: DUT - host: "{topology[sut1][nic-management][ip-addr]}" - arch: x86_64 - port: 22 - username: cisco - honeycomb: - user: admin - passwd: admin - port: 8183 - netconf_port: 2831 - priv_key: | -{priv_key} - interfaces: - port1: - mac_address: "{topology[sut1][nic-0][hw-addr]}" - pci_address: "0000:00:04.0" - link: link1 - port2: - mac_address: "{topology[sut1][nic-1][hw-addr]}" - pci_address: "0000:00:05.0" - link: link4 - port3: - mac_address: "{topology[sut1][nic-2][hw-addr]}" - pci_address: "0000:00:06.0" - link: link3 - port4: - mac_address: "{topology[sut1][nic-3][hw-addr]}" - pci_address: "0000:00:07.0" - link: link6 - DUT2: - type: DUT - host: "{topology[sut2][nic-management][ip-addr]}" - arch: x86_64 - port: 22 - username: cisco - honeycomb: - user: admin - passwd: admin - port: 8183 - netconf_port: 2831 - priv_key: | -{priv_key} - interfaces: - port1: - mac_address: "{topology[sut2][nic-0][hw-addr]}" - pci_address: "0000:00:04.0" - link: link2 - port2: - mac_address: "{topology[sut2][nic-1][hw-addr]}" - pci_address: "0000:00:05.0" - link: link5 - port3: - mac_address: "{topology[sut2][nic-2][hw-addr]}" - pci_address: "0000:00:06.0" - link: link3 - port4: - mac_address: "{topology[sut2][nic-3][hw-addr]}" - pci_address: "0000:00:07.0" - link: link6 diff --git a/resources/tools/virl/topologies/double-ring-nested.xenial.virl b/resources/tools/virl/topologies/double-ring-nested.xenial.virl deleted file mode 100644 index 65733f9caf..0000000000 --- a/resources/tools/virl/topologies/double-ring-nested.xenial.virl +++ /dev/null @@ -1,362 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<topology xmlns="http://www.cisco.com/VIRL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="0.9" xsi:schemaLocation="http://www.cisco.com/VIRL https://raw.github.com/CiscoVIRL/schema/v0.9/virl.xsd"> - <extensions> - <entry key="management_network" type="String">flat</entry> - </extensions> - <node name="tg1" type="SIMPLE" subtype="server" location="570,238" vmImage="$$VM_IMAGE$$"> - <extensions> - <entry key="config" type="String">#cloud-config -bootcmd: -- ln -s -t /etc/rc.d /etc/rc.local -hostname: tg1 -manage_etc_hosts: true -nfs_server_scratch: $$NFS_SERVER_SCRATCH$$ -nfs_server_common: $$NFS_SERVER_COMMON$$ -runcmd: -- systemctl start getty@ttyS0.service -- systemctl start rc-local -- touch /tmp/before-sed -- sed -i 's/^\s*PasswordAuthentication\s\+no/PasswordAuthentication yes/' /etc/ssh/sshd_config -- echo "UseDNS no" >> /etc/ssh/sshd_config -- service ssh restart -- service sshd restart -users: -- default -- gecos: User configured by VIRL Configuration Engine 0.21.4 - lock-passwd: false - name: cisco - plain-text-passwd: cisco - shell: /bin/bash - ssh-authorized-keys: - - VIRL-USER-SSH-PUBLIC-KEY - - VIRL-USER-SSH-PUBLIC-KEY - sudo: ALL=(ALL) NOPASSWD:ALL -write_files: -- path: /etc/init/ttyS0.conf - owner: root:root - content: | - # ttyS0 - getty - # This service maintains a getty on ttyS0 from the point the system is - # started until it is shut down again. - start on stopped rc or RUNLEVEL=[12345] - stop on runlevel [!12345] - respawn - exec /sbin/getty -L 115200 ttyS0 vt102 - permissions: '0644' -- path: /etc/systemd/system/dhclient@.service - content: | - [Unit] - Description=Run dhclient on %i interface - After=network.target - [Service] - Type=oneshot - ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease - RemainAfterExit=yes - owner: root:root - permissions: '0644' -- path: /usr/local/sbin/cloud-instance-name - content: | - #!/usr/bin/python3.5 - import pickle - print(pickle.loads(open('/var/lib/cloud/instance/obj.pkl', 'rb').read(), encoding="ACSII").metadata['name']) - owner: root:root - permissions: '0755' -- path: /etc/rc.local - owner: root:root - permissions: '0755' - content: |- - #!/bin/sh - grep -q nfs_server_scratch /var/lib/cloud/instance/user-data.txt || exit 1 - grep -q nfs_server_common /var/lib/cloud/instance/user-data.txt || exit 1 - nfs_server_scratch=$(grep -E '^nfs_server_scratch:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - nfs_server_common=$(grep -E '^nfs_server_common:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - instance_name=$(/usr/local/sbin/cloud-instance-name | cut -f 3 -d '<' | cut -f 1 -d '>') - echo My instance name is $instance_name - - MAXCOUNT=12 - RETRY=5 - - mkdir -p /scratch - mkdir -p /mnt/common - - echo "Mounting NFS directories" - count=0 - while [ $count -lt $MAXCOUNT ] && ! mount -t nfs "${nfs_server_scratch}/${instance_name}" /scratch - do - sleep 5 - count=$[$count+1] - done - - mount -t nfs "${nfs_server_common}" /mnt/common - - mkdir /scratch/$(hostname) - cp /VERSION /scratch/$(hostname)/ - - exit 0 -</entry> - <entry key="Auto-generate config" type="Boolean">false</entry> - </extensions> - <interface id="0" name="eth1"/> - <interface id="1" name="eth2"/> - <interface id="2" name="eth3"/> - <interface id="3" name="eth4"/> - <interface id="4" name="eth5"/> - <interface id="5" name="eth6"/> - </node> - <node name="sut1" type="SIMPLE" subtype="vPP" location="425,26" vmImage="$$VM_IMAGE$$"> - <extensions> - <entry key="config" type="string">#cloud-config -bootcmd: -- ln -s -t /etc/rc.d /etc/rc.local -hostname: sut1 -manage_etc_hosts: true -nfs_server_scratch: $$NFS_SERVER_SCRATCH$$ -nfs_server_common: $$NFS_SERVER_COMMON$$ -runcmd: -- systemctl start getty@ttyS0.service -- systemctl start rc-local -- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config -- echo "UseDNS no" >> /etc/ssh/sshd_config -- service ssh restart -- service sshd restart -- sed -i 's/no-pci//' /opt/cisco/vpe/etc/qn.conf -- sed -i 's/1024/1024 decimal-interface-names/g' /opt/cisco/vpe/etc/qn.conf -- ln -s /dev/null /etc/sysctl.d/80-vpp.conf -users: -- default -- gecos: User configured by VIRL Configuration Engine 0.21.4 - lock-passwd: false - name: cisco - plain-text-passwd: cisco - shell: /bin/bash - ssh-authorized-keys: - - VIRL-USER-SSH-PUBLIC-KEY - - VIRL-USER-SSH-PUBLIC-KEY - sudo: ALL=(ALL) NOPASSWD:ALL -write_files: -- path: /etc/init/ttyS0.conf - owner: root:root - content: | - # ttyS0 - getty - # This service maintains a getty on ttyS0 from the point the system is - # started until it is shut down again. - start on stopped rc or RUNLEVEL=[12345] - stop on runlevel [!12345] - respawn - exec /sbin/getty -L 115200 ttyS0 vt102 - permissions: '0644' -- path: /etc/systemd/system/dhclient@.service - content: | - [Unit] - Description=Run dhclient on %i interface - After=network.target - [Service] - Type=oneshot - ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease - RemainAfterExit=yes - owner: root:root - permissions: '0644' -- path: /usr/local/sbin/cloud-instance-name - content: | - #!/usr/bin/python3.5 - import pickle - print(pickle.loads(open('/var/lib/cloud/instance/obj.pkl', 'rb').read(), encoding="ACSII").metadata['name']) - owner: root:root - permissions: '0755' -- path: /etc/rc.local - owner: root:root - permissions: '0755' - content: |- - #!/bin/sh - grep -q nfs_server_scratch /var/lib/cloud/instance/user-data.txt || exit 1 - grep -q nfs_server_common /var/lib/cloud/instance/user-data.txt || exit 1 - nfs_server_scratch=$(grep -E '^nfs_server_scratch:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - nfs_server_common=$(grep -E '^nfs_server_common:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - instance_name=$(/usr/local/sbin/cloud-instance-name | cut -f 3 -d '<' | cut -f 1 -d '>') - echo My instance name is $instance_name - - MAXCOUNT=12 - RETRY=5 - - mkdir -p /scratch - mkdir -p /mnt/common - - echo "Mounting NFS directories" - count=0 - while [ $count -lt $MAXCOUNT ] && ! mount -t nfs "${nfs_server_scratch}/${instance_name}" /scratch - do - sleep 5 - count=$[$count+1] - done - - mount -t nfs "${nfs_server_common}" /mnt/common - - # Overwrite nested VM image with latest as per NFS - if [ -f /mnt/common/nested-vm-current.img ] - then - rm -f /var/lib/vm/vhost-nested.img - cp /mnt/common/nested-vm-current.img /var/lib/vm/vhost-nested.img - fi - - mkdir /scratch/$(hostname) - cp /VERSION /scratch/$(hostname)/ - cat /var/lib/vm/vhost-nested.img | strings | grep NESTED_VERSION= > /scratch/$(hostname)/NESTED_VERSION - - exit 0 -- path: /etc/sysctl.d/90-csit.conf - owner: root:root - content: | - # Number of 2MB hugepages desired - vm.nr_hugepages=1024 - - # Must be greater than or equal to (2 * vm.nr_hugepages). - vm.max_map_count=20000 - - # All groups allowed to access hugepages - vm.hugetlb_shm_group=0 - - # Shared Memory Max must be greator or equal to the total size of hugepages. - # For 2MB pages, TotalHugepageSize = vm.nr_hugepages * 2 * 1024 * 1024 - # If the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax) - # is greater than the calculated TotalHugepageSize then set this parameter - # to current shmmax value. - kernel.shmmax=2147483648 -</entry> - </extensions> - <interface id="0" name="GigabitEthernet0/4/0"/> - <interface id="1" name="GigabitEthernet0/5/0"/> - <interface id="2" name="GigabitEthernet0/6/0"/> - <interface id="3" name="GigabitEthernet0/7/0"/> - </node> - <node name="sut2" type="SIMPLE" subtype="vPP" location="748,26" vmImage="$$VM_IMAGE$$"> - <extensions> - <entry key="config" type="string">#cloud-config -bootcmd: -- ln -s -t /etc/rc.d /etc/rc.local -hostname: sut2 -manage_etc_hosts: true -nfs_server_scratch: $$NFS_SERVER_SCRATCH$$ -nfs_server_common: $$NFS_SERVER_COMMON$$ -runcmd: -- systemctl start getty@ttyS0.service -- systemctl start rc-local -- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config -- echo "UseDNS no" >> /etc/ssh/sshd_config -- service ssh restart -- service sshd restart -- sed -i 's/no-pci//' /opt/cisco/vpe/etc/qn.conf -- sed -i 's/1024/1024 decimal-interface-names/g' /opt/cisco/vpe/etc/qn.conf -- ln -s /dev/null /etc/sysctl.d/80-vpp.conf -users: -- default -- gecos: User configured by VIRL Configuration Engine 0.21.4 - lock-passwd: false - name: cisco - plain-text-passwd: cisco - shell: /bin/bash - ssh-authorized-keys: - - VIRL-USER-SSH-PUBLIC-KEY - - VIRL-USER-SSH-PUBLIC-KEY - sudo: ALL=(ALL) NOPASSWD:ALL -write_files: -- path: /etc/init/ttyS0.conf - owner: root:root - content: | - # ttyS0 - getty - # This service maintains a getty on ttyS0 from the point the system is - # started until it is shut down again. - start on stopped rc or RUNLEVEL=[12345] - stop on runlevel [!12345] - respawn - exec /sbin/getty -L 115200 ttyS0 vt102 - permissions: '0644' -- path: /etc/systemd/system/dhclient@.service - content: | - [Unit] - Description=Run dhclient on %i interface - After=network.target - [Service] - Type=oneshot - ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease - RemainAfterExit=yes - owner: root:root - permissions: '0644' -- path: /usr/local/sbin/cloud-instance-name - content: | - #!/usr/bin/python3.5 - import pickle - print(pickle.loads(open('/var/lib/cloud/instance/obj.pkl', 'rb').read(), encoding="ACSII").metadata['name']) - owner: root:root - permissions: '0755' -- path: /etc/rc.local - owner: root:root - permissions: '0755' - content: |- - #!/bin/sh - grep -q nfs_server_scratch /var/lib/cloud/instance/user-data.txt || exit 1 - grep -q nfs_server_common /var/lib/cloud/instance/user-data.txt || exit 1 - nfs_server_scratch=$(grep -E '^nfs_server_scratch:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - nfs_server_common=$(grep -E '^nfs_server_common:' /var/lib/cloud/instance/user-data.txt | awk '{ print $2 }') - instance_name=$(/usr/local/sbin/cloud-instance-name | cut -f 3 -d '<' | cut -f 1 -d '>') - echo My instance name is $instance_name - - MAXCOUNT=12 - RETRY=5 - - mkdir -p /scratch - mkdir -p /mnt/common - - echo "Mounting NFS directories" - count=0 - while [ $count -lt $MAXCOUNT ] && ! mount -t nfs "${nfs_server_scratch}/${instance_name}" /scratch - do - sleep 5 - count=$[$count+1] - done - - mount -t nfs "${nfs_server_common}" /mnt/common - - # Overwrite nested VM image with latest as per NFS - if [ -f /mnt/common/nested-vm-current.img ] - then - rm -f /var/lib/vm/vhost-nested.img - cp /mnt/common/nested-vm-current.img /var/lib/vm/vhost-nested.img - fi - - mkdir /scratch/$(hostname) - cp /VERSION /scratch/$(hostname)/ - cat /var/lib/vm/vhost-nested.img | strings | grep NESTED_VERSION= > /scratch/$(hostname)/NESTED_VERSION - - exit 0 -- path: /etc/sysctl.d/90-csit.conf - owner: root:root - content: | - # Number of 2MB hugepages desired - vm.nr_hugepages=1024 - - # Must be greater than or equal to (2 * vm.nr_hugepages). - vm.max_map_count=20000 - - # All groups allowed to access hugepages - vm.hugetlb_shm_group=0 - - # Shared Memory Max must be greator or equal to the total size of hugepages. - # For 2MB pages, TotalHugepageSize = vm.nr_hugepages * 2 * 1024 * 1024 - # If the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax) - # is greater than the calculated TotalHugepageSize then set this parameter - # to current shmmax value. - kernel.shmmax=2147483648 -</entry> - </extensions> - <interface id="0" name="GigabitEthernet0/4/0"/> - <interface id="1" name="GigabitEthernet0/5/0"/> - <interface id="2" name="GigabitEthernet0/6/0"/> - <interface id="3" name="GigabitEthernet0/7/0"/> - </node> - <connection dst="/virl:topology/virl:node[1]/virl:interface[3]" src="/virl:topology/virl:node[2]/virl:interface[1]"/> - <connection dst="/virl:topology/virl:node[1]/virl:interface[4]" src="/virl:topology/virl:node[2]/virl:interface[2]"/> - <connection dst="/virl:topology/virl:node[2]/virl:interface[3]" src="/virl:topology/virl:node[3]/virl:interface[3]"/> - <connection dst="/virl:topology/virl:node[2]/virl:interface[4]" src="/virl:topology/virl:node[3]/virl:interface[4]"/> - <connection dst="/virl:topology/virl:node[1]/virl:interface[5]" src="/virl:topology/virl:node[3]/virl:interface[1]"/> - <connection dst="/virl:topology/virl:node[1]/virl:interface[6]" src="/virl:topology/virl:node[3]/virl:interface[2]"/> -</topology> diff --git a/resources/tools/virl/topologies/double-ring-nested.xenial.yaml b/resources/tools/virl/topologies/double-ring-nested.xenial.yaml deleted file mode 100644 index d35e24b777..0000000000 --- a/resources/tools/virl/topologies/double-ring-nested.xenial.yaml +++ /dev/null @@ -1,98 +0,0 @@ ---- -metadata: - version: 0.1 - schema: - - resources/topology_schemas/3_node_topology.sch.yaml - - resources/topology_schemas/topology.sch.yaml - tags: [hw, 3-node] - -nodes: - TG: - type: TG - host: "{topology[tg1][nic-management][ip-addr]}" - arch: x86_64 - port: 22 - username: cisco - priv_key: | -{priv_key} - interfaces: - port3: - mac_address: "{topology[tg1][nic-2][hw-addr]}" - pci_address: "0000:00:06.0" - link: link1 - driver: virtio-pci - port4: - mac_address: "{topology[tg1][nic-3][hw-addr]}" - pci_address: "0000:00:07.0" - link: link4 - driver: virtio-pci - port5: - mac_address: "{topology[tg1][nic-4][hw-addr]}" - pci_address: "0000:00:08.0" - link: link2 - driver: virtio-pci - port6: - mac_address: "{topology[tg1][nic-5][hw-addr]}" - pci_address: "0000:00:09.0" - link: link5 - driver: virtio-pci - DUT1: - type: DUT - host: "{topology[sut1][nic-management][ip-addr]}" - arch: x86_64 - port: 22 - username: cisco - honeycomb: - user: admin - passwd: admin - port: 8183 - netconf_port: 2831 - priv_key: | -{priv_key} - interfaces: - port1: - mac_address: "{topology[sut1][nic-0][hw-addr]}" - pci_address: "0000:00:04.0" - link: link1 - port2: - mac_address: "{topology[sut1][nic-1][hw-addr]}" - pci_address: "0000:00:05.0" - link: link4 - port3: - mac_address: "{topology[sut1][nic-2][hw-addr]}" - pci_address: "0000:00:06.0" - link: link3 - port4: - mac_address: "{topology[sut1][nic-3][hw-addr]}" - pci_address: "0000:00:07.0" - link: link6 - DUT2: - type: DUT - host: "{topology[sut2][nic-management][ip-addr]}" - arch: x86_64 - port: 22 - username: cisco - honeycomb: - user: admin - passwd: admin - port: 8183 - netconf_port: 2831 - priv_key: | -{priv_key} - interfaces: - port1: - mac_address: "{topology[sut2][nic-0][hw-addr]}" - pci_address: "0000:00:04.0" - link: link2 - port2: - mac_address: "{topology[sut2][nic-1][hw-addr]}" - pci_address: "0000:00:05.0" - link: link5 - port3: - mac_address: "{topology[sut2][nic-2][hw-addr]}" - pci_address: "0000:00:06.0" - link: link3 - port4: - mac_address: "{topology[sut2][nic-3][hw-addr]}" - pci_address: "0000:00:07.0" - link: link6 |