aboutsummaryrefslogtreecommitdiffstats
path: root/mcp/scripts/user-data.template
blob: 7dd718e63d735303d931764da3c8e4b854fa1e99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
SALT_REPO=repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.11
if [ "$(uname -i)" = "aarch64" ]; then
  SALT_REPO=linux.enea.com/saltstack/apt/ubuntu/16.04/arm64/2016.11
fi
wget -O - "https://${SALT_REPO}/SALTSTACK-GPG-KEY.pub" | sudo apt-key add -
echo "deb https://${SALT_REPO} xenial main" > /etc/apt/sources.list.d/salt.list
apt update
apt-get install -y salt-minion
rm /etc/salt/minion_id
rm -f /etc/salt/pki/minion/minion_master.pub
echo "id: $(hostname).${CLUSTER_DOMAIN}" > /etc/salt/minion
echo "master: ${SALT_MASTER}" >> /etc/salt/minion
service salt-minion restart
olor: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/python
#
# Authors:
# - peter.bandzi@cisco.com
# - morgan.richomme@orange.com
#
# src: Peter Bandzi
# https://github.com/pbandzi/parse-robot/blob/master/convert_robot_to_json.py
#
# Copyright (c) 2015 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
#
# 0.1: This script boots the VM1 and allocates IP address from Nova
# Later, the VM2 boots then execute cloud-init to ping VM1.
# After successful ping, both the VMs are deleted.
# 0.2: measure test duration and publish results under json format
#
#

import getopt
import json
import os
import sys
import xmltodict
import yaml

import functest.utils.functest_utils as functest_utils


def usage():
    print """Usage:
    get-json-from-robot.py --xml=<output.xml> --pod=<pod_name>
                           --installer=<installer> --database=<Database URL>
                           --scenaro=SCENARIO
    -x, --xml   xml file generated by robot test
    -p, --pod   POD name where the test come from
    -i, --installer
    -s, --scenario
    -h, --help  this message
    """
    sys.exit(2)


def populate_detail(test):
    detail = {}
    detail['test_name'] = test['@name']
    detail['test_status'] = test['status']
    detail['test_doc'] = test['doc']
    return detail


def parse_test(tests, details):
    try:
        for test in tests:
            details.append(populate_detail(test))
    except TypeError:
        # tests is not iterable
        details.append(populate_detail(tests))
    return details


def parse_suites(suites):
    data = {}
    details = []
    try:
        for suite in suites:
            data['details'] = parse_test(suite['test'], details)
    except TypeError:
        # suites is not iterable
        data['details'] = parse_test(suites['test'], details)
    return data


def main(argv):
    try:
        opts, args = getopt.getopt(argv,
                                   'x:p:i:s:h',
                                   ['xml=', 'pod=',
                                    'installer=',
                                    'scenario=',
                                    'help'])
    except getopt.GetoptError:
        usage()

    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage()
        elif opt in ('-x', '--xml'):
            xml_file = arg
        elif opt in ('-p', '--pod'):
            pod = arg
        elif opt in ('-i', '--installer'):
            installer = arg
        elif opt in ('-s', '--scenario'):
            scenario = arg
        else:
            usage()

    with open(xml_file, "r") as myfile:
        xml_input = myfile.read().replace('\n', '')

    # dictionary populated with data from xml file
    all_data = xmltodict.parse(xml_input)['robot']

    data = parse_suites(all_data['suite']['suite'])
    data['description'] = all_data['suite']['@name']
    data['version'] = all_data['@generator']
    data['test_project'] = "functest"
    data['case_name'] = "ODL"
    data['pod_name'] = pod
    data['installer'] = installer

    json.dumps(data, indent=4, separators=(',', ': '))

    # Only used from container, we can set up absolute path
    with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
        functest_yaml = yaml.safe_load(f)
        f.close()

    database = functest_yaml.get("results").get("test_db_url")
    build_tag = functest_utils.get_build_tag()

    try:
        # example:
        # python odlreport2db.py -x ~/Pictures/Perso/odl/output3.xml
        #                        -i fuel
        #                        -p opnfv-jump-2
        #                        -s os-odl_l2-ha
        version = functest_utils.get_version()

        # success criteria for ODL = 100% of tests OK
        status = "failed"
        try:
            tests_passed = 0
            tests_failed = 0
            for v in data['details']:
                if v['test_status']['@status'] == "PASS":
                    tests_passed += 1
                else:
                    tests_failed += 1

            if (tests_failed < 1):
                status = "passed"
        except:
            print("Unable to set criteria" % sys.exc_info()[0])
        functest_utils.push_results_to_db(database,
                                          "functest",
                                          data['case_name'],
                                          None,
                                          data['pod_name'],
                                          version,
                                          scenario,
                                          status,
                                          build_tag,
                                          data)
    except:
        print("Error pushing results into Database '%s'" % sys.exc_info()[0])


if __name__ == "__main__":
    main(sys.argv[1:])