aboutsummaryrefslogtreecommitdiffstats
path: root/mcp/config/states/networks
blob: 5beabdb6a2a5483106c17c5e36f5dc901fa77600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/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
##############################################################################

CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x

# Determine public network based on external IPs from compute node
# NOTE: mask currently hardcoded to /24
PUBLIC_NET=$(salt --out yaml -C 'I@nova:compute and *01*' 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}')

[ -n "${PUBLIC_NET}" ] || PUBLIC_NET=$(salt --out yaml -C 'I@nova:compute and *01*' \
  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}')

[ -n "${PUBLIC_NET}" ] && PUBLIC_NET="${PUBLIC_NET%.*}.0/24" || PUBLIC_NET="10.16.0.0/24"

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 -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 -C 'I@nova:controller and *01*' 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"