From de0b32bfd38d49fa2a329f48c33b11bd8aac6a22 Mon Sep 17 00:00:00 2001 From: Jamo Luhrsen Date: Tue, 12 Jun 2018 17:00:04 -0700 Subject: Run ODL CSIT on Apex from Cperf container This patch adds the ability to deploy a cperf container and execute ODL csit against an OPNFV deployment with ODL. The cperf job to execute csit requires an RC file, SSH key to access OPNFV nodes, and a yaml descriptor file that contains per node information about each control/compute node. This patch also adds triggering the cperf CSIT job inside of the 3rd party ODL netvirt verification suite. That job uses Apex snapshots to bring up deployment (no undercloud). Additionally this patch includes some changes to allow multi version snapshots to work. Multiple snapshots are now being created for different OpenStack branches along with noha or HA type topologies. This patch includes the ability to detect the desired scenario as triggered by ODL Netvirt gerrit. Now in ODL netvirt gerrit a user may provide: "check-opnfv -" style syntax to initiate 3rd Party OPNFV CI on a particular OS version/HA setup. Change-Id: I51a27545c985ce74c1c72fe0933eb451939a8c05 Signed-off-by: Jamo Luhrsen Signed-off-by: Tim Rozet Signed-off-by: Jamo Luhrsen --- jjb/cperf/parse-node-yaml.py | 71 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 jjb/cperf/parse-node-yaml.py (limited to 'jjb/cperf/parse-node-yaml.py') diff --git a/jjb/cperf/parse-node-yaml.py b/jjb/cperf/parse-node-yaml.py new file mode 100644 index 000000000..5a7575540 --- /dev/null +++ b/jjb/cperf/parse-node-yaml.py @@ -0,0 +1,71 @@ +############################################################################## +# Copyright (c) 2018 Tim Rozet (trozet@redhat.com) and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import argparse +import sys +import yaml + + +def get_node_data_by_number(node_type, node_number): + node_idx = 1 + for node_name, node_data in data['servers'].items(): + if node_type == node_data['type']: + if node_idx == node_number: + return node_name, node_data + else: + node_idx += 1 + + +def get_node_value(node_type, node_number, key): + node_name, node_data = get_node_data_by_number(node_type, node_number) + if not key and node_name is not None: + return node_name + elif node_data and isinstance(node_data, dict) and key in node_data: + return node_data[key] + + +def get_number_of_nodes(node_type): + nodes = data['servers'] + num_nodes = 0 + for node_name, node_data in nodes.items(): + if node_data['type'] == node_type: + num_nodes += 1 + return num_nodes + + +FUNCTION_MAP = {'num_nodes': + {'func': get_number_of_nodes, + 'args': ['node_type']}, + 'get_value': + {'func': get_node_value, + 'args': ['node_type', 'node_number', 'key']}, + } + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('command', choices=FUNCTION_MAP.keys()) + parser.add_argument('-f', '--file', + dest='node_file', + required=True) + parser.add_argument('--node-type', + default='controller', + required=False) + parser.add_argument('--node-number', + default=1, + type=int, + required=False) + parser.add_argument('-k', '--key', + required=False) + args = parser.parse_args(sys.argv[1:]) + with open(args.node_file, 'r') as fh: + data = yaml.safe_load(fh) + assert 'servers' in data + func = FUNCTION_MAP[args.command]['func'] + args = [getattr(args, x) for x in FUNCTION_MAP[args.command]['args']] + print(func(*args)) -- cgit 1.2.3-korg