From 7b5b8625b7ed20d0c1fe798b3bc14b30848d8b28 Mon Sep 17 00:00:00 2001 From: Mark McClain Date: Fri, 11 Dec 2015 16:37:03 -0500 Subject: [PATCH] fix ASTARA_MANAGEMENT_PREFIX and make subnet create dynamic Change-Id: I0c93b525d008808c9717d508b2af950ed200d278 Closes-Bug: 1525417 --- astara/api/astara_client.py | 1 - astara/api/nova.py | 8 +++++--- devstack/plugin.sh | 8 ++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/astara/api/astara_client.py b/astara/api/astara_client.py index 883813a5..2a11525e 100644 --- a/astara/api/astara_client.py +++ b/astara/api/astara_client.py @@ -21,7 +21,6 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils -ASTARA_ULA_PREFIX = 'fdca:3ba5:a17a:acda::/64' ASTARA_MGT_SERVICE_PORT = 5000 ASTARA_BASE_PATH = '/v1/' diff --git a/astara/api/nova.py b/astara/api/nova.py index bba48d53..9dbc53aa 100644 --- a/astara/api/nova.py +++ b/astara/api/nova.py @@ -17,9 +17,9 @@ from datetime import datetime import time +import netaddr from novaclient import client from novaclient import exceptions as novaclient_exceptions - from oslo_config import cfg from oslo_log import log as logging @@ -376,7 +376,7 @@ debug: - verbose: true bootcmd: - - /usr/local/bin/%(boot_command)s %(mac_address)s %(ip_address)s/64 + - /usr/local/bin/%(boot_command)s %(mac_address)s %(ip_address)s/%(prefix)d users: - name: astara @@ -405,10 +405,12 @@ def _ssh_key(): def format_userdata(mgt_port): + mgt_net = netaddr.IPNetwork(cfg.CONF.management_prefix) ctxt = { 'ssh_public_key': _ssh_key(), 'mac_address': mgt_port.mac_address, 'ip_address': mgt_port.fixed_ips[0].ip_address, - 'boot_command': cfg.CONF.astara_boot_command + 'boot_command': cfg.CONF.astara_boot_command, + 'prefix': mgt_net.prefixlen } return TEMPLATE % ctxt diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 852ef48b..54b93a38 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -32,7 +32,7 @@ ROUTER_INSTANCE_FLAVOR_DISK=${ROUTER_INSTANCE_FLAVOR_DISK:-5} ROUTER_INSTANCE_FLAVOR_CPUS=${ROUTER_INSTANCE_FLAVOR_CPUS:-1} PUBLIC_INTERFACE_DEFAULT='eth0' -ASTARA_MANAGEMENT_PREFIX=${ASTARA_MANGEMENT_PREFIX:-"fdca:3ba5:a17a:acda::/64"} +ASTARA_MANAGEMENT_PREFIX=${ASTARA_MANAGEMENT_PREFIX:-"fdca:3ba5:a17a:acda::/64"} ASTARA_MANAGEMENT_PORT=${ASTARA_MANAGEMENT_PORT:-5000} ASTARA_API_PORT=${ASTARA_API_PORT:-44250} @@ -213,7 +213,11 @@ function pre_start_astara() { # Remove the ipv6 subnet created automatically before adding our own. _remove_subnets mgt - typeset mgt_subnet_id=$(neutron $auth_args subnet-create mgt fdca:3ba5:a17a:acda::/64 --ip-version=6 --ipv6_address_mode=slaac --enable_dhcp | grep ' id ' | awk '{ print $4 }') + local subnet_create_args="" + if [[ "$ASTARA_MANAGEMENT_PREFIX" =~ ':' ]]; then + subnet_create_args="--ip-version=6 --ipv6_address_mode=slaac --enable_dhcp" + fi + typeset mgt_subnet_id=$(neutron $auth_args subnet-create mgt $ASTARA_MANAGEMENT_PREFIX $subnet_create_args | grep ' id ' | awk '{ print $4 }') iniset $ASTARA_CONF DEFAULT management_subnet_id $mgt_subnet_id # Remove the private network created by devstack