X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=mcp%2Fconfig%2Fstates%2Fnetworks;h=e9a9f5190ff3abcb618fb538573fc915642eb5d8;hb=60cd82b0e2af9c8f34a97eacd4cee0893684e6ae;hp=505153a8a4b2a15324c7c9acaa713fcfb42eee86;hpb=c98e2683b290258eda15ffd1b02bcd907af47248;p=fuel.git diff --git a/mcp/config/states/networks b/mcp/config/states/networks index 505153a8a..e9a9f5190 100755 --- a/mcp/config/states/networks +++ b/mcp/config/states/networks @@ -1,26 +1,40 @@ -#!/bin/bash -set -x +#!/bin/bash -e +############################################################################## +# Copyright (c) 2017 Mirantis Inc., Enea AB 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 +############################################################################## -# Determine public network based on external IPs from compute node -# NOTE: mask currently hardcoded to /24 -PUBLIC_NET=$(salt --out yaml 'cmp*' pillar.get _param:external_address | \ - awk --re-interval '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/{print $2; exit}') +CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x -[ -n "${PUBLIC_NET}" ] || PUBLIC_NET=$(salt --out yaml 'cmp*' \ - pillar.get _param:openstack_compute_node01_external_address | \ - awk --re-interval '/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/{print $2; exit}') +source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh" -[ -n "${PUBLIC_NET}" ] && PUBLIC_NET="${PUBLIC_NET%.*}.0/24" || PUBLIC_NET="10.16.0.0/24" +PUBLIC_NET=$(get_nova_compute_pillar_data 'opnfv_net_public') +PUBLIC_NET_GATEWAY=$(get_nova_compute_pillar_data 'opnfv_net_public_gw') +POOL_START_IP=$(get_nova_compute_pillar_data 'opnfv_net_public_pool_start') +POOL_END_IP=$(get_nova_compute_pillar_data 'opnfv_net_public_pool_end') -salt 'ctl01*' cmd.run ". /root/keystonercv3; \ +# Default values +PUBLIC_NET="${PUBLIC_NET:-10.16.0.0/24}" +PUBLIC_NET_GATEWAY="${PUBLIC_NET_GATEWAY:-10.16.0.1}" +POOL_START_IP="${POOL_START_IP:-10.16.0.130}" +POOL_END_IP="${POOL_END_IP:-10.16.0.254}" + +# Print openstack status and setup network +salt -C 'I@nova:controller and *01*' cmd.run ". /root/keystonercv3; \ openstack compute service list; \ openstack network agent list; \ openstack stack list; \ openstack volume service list" -salt 'ctl01*' cmd.run ". /root/keystonercv3; \ +salt -C 'I@nova:controller and *01*' cmd.run ". /root/keystonercv3; \ openstack network create --external --default --provider-network-type flat \ - --provider-physical-network physnet1 floating_net" -salt 'ctl01*' cmd.run ". /root/keystonercv3; \ - openstack subnet create --gateway ${PUBLIC_NET%.*}.1 --no-dhcp \ - --allocation-pool start=${PUBLIC_NET%.*}.130,end=${PUBLIC_NET%.*}.254 \ - --network floating_net --subnet-range ${PUBLIC_NET} floating_subnet" + --provider-physical-network physnet1 floating_net" +salt -C 'I@nova:controller and *01*' cmd.run ". /root/keystonercv3; \ + openstack subnet create --gateway ${PUBLIC_NET_GATEWAY} --no-dhcp \ + --allocation-pool start=${POOL_START_IP},end=${POOL_END_IP} \ + --network floating_net --subnet-range ${PUBLIC_NET} floating_subnet" + +# Discover compute hosts after they are registered +salt -C 'I@nova:controller and *01*' state.sls_id nova_controller_discover_hosts nova