blob: a34be31b4424fa92630a7b6ebf6f2182616a95c6 [file] [log] [blame]
Dennis Dmitriev0f624a82018-06-11 12:57:13 +03001common = new com.mirantis.mk.Common()
2
3def run_cmd(cmd, returnStdout=false) {
4 common.printMsg("Run shell command:\n" + cmd, "blue")
5 def VENV_PATH='/home/jenkins/fuel-devops30'
6 script = """\
7 set +x;
8 echo 'activate python virtualenv ${VENV_PATH}';
9 . ${VENV_PATH}/bin/activate;
10 bash -c 'set -ex; set -ex; ${cmd.stripIndent()}'
11 """
12 return sh(script: script, returnStdout: returnStdout)
13}
14
15def run_cmd_stdout(cmd) {
16 return run_cmd(cmd, true)
17}
18
19def generate_cookied_model() {
20 // do not fail if environment doesn't exists
21 def IPV4_NET_ADMIN=run_cmd_stdout("dos.py net-list ${ENV_NAME} | grep admin-pool01").trim().split().last()
22 def IPV4_NET_CONTROL=run_cmd_stdout("dos.py net-list ${ENV_NAME} | grep private-pool01").trim().split().last()
23 def IPV4_NET_TENANT=run_cmd_stdout("dos.py net-list ${ENV_NAME} | grep tenant-pool01").trim().split().last()
24 def IPV4_NET_EXTERNAL=run_cmd_stdout("dos.py net-list ${ENV_NAME} | grep external-pool01").trim().split().last()
25 println("IPV4_NET_ADMIN=" + IPV4_NET_ADMIN)
26 println("IPV4_NET_CONTROL=" + IPV4_NET_CONTROL)
27 println("IPV4_NET_TENANT=" + IPV4_NET_TENANT)
28 println("IPV4_NET_EXTERNAL=" + IPV4_NET_EXTERNAL)
29
30 def parameters = [
31 string(name: 'LAB_CONTEXT_NAME', value: "${LAB_CONFIG_NAME}"),
32 string(name: 'CLUSTER_NAME', value: "${LAB_CONFIG_NAME}"),
33 string(name: 'DOMAIN_NAME', value: "${LAB_CONFIG_NAME}.local"),
34 string(name: 'REPOSITORY_SUITE', value: "${MCP_VERSION}"),
35 string(name: 'SALT_MODELS_SYSTEM_COMMIT', value: "${MCP_VERSION}"),
36 string(name: 'COOKIECUTTER_TEMPLATE_COMMIT', value: "${MCP_VERSION}"),
37 string(name: 'TCP_QA_REVIEW', value: "${TCP_QA_REFS}"),
38 string(name: 'IPV4_NET_ADMIN', value: IPV4_NET_ADMIN),
39 string(name: 'IPV4_NET_CONTROL', value: IPV4_NET_CONTROL),
40 string(name: 'IPV4_NET_TENANT', value: IPV4_NET_TENANT),
41 string(name: 'IPV4_NET_EXTERNAL', value: IPV4_NET_EXTERNAL),
42 ]
43 common.printMsg("Start building job 'swarm-cookied-model-generator' with parameters:", "purple")
44 common.prettyPrint(parameters)
45 build job: 'swarm-cookied-model-generator',
46 parameters: parameters
47}
48
49def generate_configdrive_iso() {
50 def SALT_MASTER_IP=run_cmd_stdout("""\
51 export ENV_NAME=${ENV_NAME}
52 . ./tcp_tests/utils/env_salt
53 echo \$SALT_MASTER_IP
54 """).trim().split().last()
55 println("SALT_MASTER_IP=" + SALT_MASTER_IP)
56 def parameters = [
57 string(name: 'CLUSTER_NAME', value: "${LAB_CONFIG_NAME}"),
58 string(name: 'MODEL_URL', value: "http://cz8133.bud.mirantis.net:8098/${LAB_CONFIG_NAME}.git"),
59 string(name: 'MODEL_URL_OBJECT_TYPE', value: "git"),
60 booleanParam(name: 'DOWNLOAD_CONFIG_DRIVE', value: true),
61 string(name: 'MCP_VERSION', value: "${MCP_VERSION}"),
62 string(name: 'COMMON_SCRIPTS_COMMIT', value: "${MCP_VERSION}"),
63 string(name: 'NODE_NAME', value: "${NODE_NAME}"),
64 string(name: 'CONFIG_DRIVE_ISO_NAME', value: "${CFG01_CONFIG_IMAGE_NAME}"),
65 string(name: 'SALT_MASTER_DEPLOY_IP', value: SALT_MASTER_IP),
66 string(name: 'PIPELINE_REPO_URL', value: "https://github.com/Mirantis"),
67 booleanParam(name: 'PIPELINES_FROM_ISO', value: true),
68 string(name: 'MCP_SALT_REPO_URL', value: "http://apt.mirantis.com/xenial"),
69 string(name: 'MCP_SALT_REPO_KEY', value: "http://apt.mirantis.com/public.gpg"),
70 string(name: 'PIPELINE_LIBRARY_REF', value: "${PIPELINE_LIBRARY_REF}"),
71 string(name: 'MK_PIPELINES_REF', value: "${MK_PIPELINES_REF}"),
72 ]
73 common.printMsg("Start building job 'create-cfg-config-drive' with parameters:", "purple")
74 common.prettyPrint(parameters)
75 build job: 'create-cfg-config-drive',
76 parameters: parameters
77}
78
79def run_job_on_day01_node(stack_to_install) {
80 // stack_to_install="core,cicd"
81 def stack = "${stack_to_install}"
82 run_cmd("""\
83 export ENV_NAME=${ENV_NAME}
84 . ./tcp_tests/utils/env_salt
85 . ./tcp_tests/utils/env_jenkins_day01
86 JOB_PARAMETERS=\"{
87 \\\"SALT_MASTER_URL\\\": \\\"\${SALTAPI_URL}\\\",
88 \\\"STACK_INSTALL\\\": \\\"${stack}\\\"
89 }\"
90 JOB_PREFIX="[ {job_name}/{build_number}:${stack} {time} ] "
91 python ./tcp_tests/utils/run_jenkins_job.py --verbose --job-name=deploy_openstack --job-parameters="\$JOB_PARAMETERS" --job-output-prefix="\$JOB_PREFIX"
92 """)
93}
94
95def run_job_on_cicd_nodes(stack_to_install) {
96 // stack_to_install="k8s,calico,stacklight"
97 def stack = "${stack_to_install}"
98 run_cmd("""\
99 export ENV_NAME=${ENV_NAME}
100 . ./tcp_tests/utils/env_salt
101 . ./tcp_tests/utils/env_jenkins_cicd
102 JOB_PARAMETERS=\"{
103 \\\"SALT_MASTER_URL\\\": \\\"\${SALTAPI_URL}\\\",
104 \\\"STACK_INSTALL\\\": \\\"${stack}\\\"
105 }\"
106 JOB_PREFIX="[ {job_name}/{build_number}:${stack} {time} ] "
107 python ./tcp_tests/utils/run_jenkins_job.py --verbose --job-name=deploy_openstack --job-parameters="\$JOB_PARAMETERS" --job-output-prefix="\$JOB_PREFIX"
108 sleep 60 # Wait for IO calm down on cluster nodes
109 """)
110}
111
112
113// pretend a groovy class, DO NOT REMOVE
114return this