From 707469c08ade38c713eccdf4040221bf35cd92d3 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Fri, 15 Sep 2017 14:20:39 +0200 Subject: Create a role which prepares xci for functest Functest requires xci deployment to have: - A public neutron network - A subnet attached to the public neutron network - The gateway from the subnet attached to one interface The network and subnet creation are done via a script instead of using Ansible OpenStack module in order to get things working asap. These three tasks are implemented in a role This patch depends on a pending patch: https://gerrit.opnfv.org/gerrit/#/c/39517/2 Change-Id: I0635227153087fd9e25b76f0859f82bf48bfb930 Signed-off-by: Manuel Buil Signed-off-by: Fatih Degirmenci --- xci/playbooks/configure-opnfvhost.yml | 6 ++-- .../roles/prepare-functest/defaults/main.yml | 14 ++++++++++ .../roles/prepare-functest/tasks/main.yml | 32 ++++++++++++++++++++++ .../roles/prepare-functest/templates/env.j2 | 4 +++ .../templates/prepare-functest.sh.j2 | 12 ++++++++ 5 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 xci/playbooks/roles/prepare-functest/defaults/main.yml create mode 100644 xci/playbooks/roles/prepare-functest/tasks/main.yml create mode 100644 xci/playbooks/roles/prepare-functest/templates/env.j2 create mode 100644 xci/playbooks/roles/prepare-functest/templates/prepare-functest.sh.j2 (limited to 'xci') diff --git a/xci/playbooks/configure-opnfvhost.yml b/xci/playbooks/configure-opnfvhost.yml index 439201ef..7b16c5aa 100644 --- a/xci/playbooks/configure-opnfvhost.yml +++ b/xci/playbooks/configure-opnfvhost.yml @@ -146,10 +146,10 @@ name: "{{ docker_package_name }}" state: latest when: lookup('env', 'JENKINS_HOME') != "" - # install shade on opnfv host only if we are running as part of CI - - name: install shade + # install python-openstackclient on opnfv host only if we are running as part of CI + - name: install python-openstackclient pip: - name: shade + name: python-openstackclient state: present when: lookup('env', 'JENKINS_HOME') != "" diff --git a/xci/playbooks/roles/prepare-functest/defaults/main.yml b/xci/playbooks/roles/prepare-functest/defaults/main.yml new file mode 100644 index 00000000..a3638302 --- /dev/null +++ b/xci/playbooks/roles/prepare-functest/defaults/main.yml @@ -0,0 +1,14 @@ +--- +# Gateway parameters +gateway_ip: "10.10.10.1" +gateway_ip_mask: "10.10.10.1/24" +broadcast_ip: "10.10.10.255" +gateway_interface: "br-vlan" + +# Network parameters +external_network: "ext-net" + +# Subnet parameters +subnet_name: "ext-subnet" +allocation_pool: "start=10.10.10.5,end=10.10.10.254" +subnet_cidr: "10.10.10.0/24" diff --git a/xci/playbooks/roles/prepare-functest/tasks/main.yml b/xci/playbooks/roles/prepare-functest/tasks/main.yml new file mode 100644 index 00000000..9a380cd1 --- /dev/null +++ b/xci/playbooks/roles/prepare-functest/tasks/main.yml @@ -0,0 +1,32 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2017 SUSE Linux GmbH +# 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 +############################################################################## +- name: check if the gateway was already set + shell: "ip a | grep {{ gateway_ip }}" + register: gateway_ip_result + ignore_errors: True + +- name: add public network gateway + command: "ip addr add {{ gateway_ip_mask }} brd {{ broadcast_ip }} dev {{ gateway_interface }}" + when: gateway_ip_result|failed + +- name: prepare script to create networks for functest + template: + src: prepare-functest.sh.j2 + dest: /root/prepare-functest.sh + mode: 0755 + +- name: Create networks + shell: "/root/prepare-functest.sh" + +- name: prepare environment file for functest + template: + src: env.j2 + dest: /root/env + mode: 0755 diff --git a/xci/playbooks/roles/prepare-functest/templates/env.j2 b/xci/playbooks/roles/prepare-functest/templates/env.j2 new file mode 100644 index 00000000..52211b45 --- /dev/null +++ b/xci/playbooks/roles/prepare-functest/templates/env.j2 @@ -0,0 +1,4 @@ +INSTALLER_TYPE=osa +INSTALLER_IP="192.168.122.2" +EXTERNAL_NETWORK="{{ external_network }}" +DEPLOY_SCENARIO="os-nosdn-nofeature-noha" diff --git a/xci/playbooks/roles/prepare-functest/templates/prepare-functest.sh.j2 b/xci/playbooks/roles/prepare-functest/templates/prepare-functest.sh.j2 new file mode 100644 index 00000000..bb3a437b --- /dev/null +++ b/xci/playbooks/roles/prepare-functest/templates/prepare-functest.sh.j2 @@ -0,0 +1,12 @@ +#!/bin/bash + +source /root/openrc + +openstack --insecure network create --share --external \ + --provider-physical-network flat \ + --provider-network-type flat {{ external_network }} + +openstack --insecure subnet create --network {{ external_network }} \ + --allocation-pool {{ allocation_pool }} \ + --subnet-range {{ subnet_cidr }} --gateway {{ gateway_ip }} \ + --no-dhcp {{ subnet_name }} -- cgit 1.2.3-korg