Allocation pools for demo subnet

This is useful in some cases:
when provider network is accessed via single network adapter,
and CIDR range is much broader then required.

Change-Id: Iddba498804d7a9639a08fef3e23f5af1d5c31d9f
This commit is contained in:
Evgeny Antyshev
2017-06-05 12:18:43 +00:00
parent 8d1cfb5d07
commit 213a194a3f
4 changed files with 36 additions and 5 deletions

View File

@@ -955,6 +955,9 @@ Provisioning demo config
**CONFIG_PROVISION_DEMO_FLOATRANGE** **CONFIG_PROVISION_DEMO_FLOATRANGE**
CIDR network address for the floating IP subnet. CIDR network address for the floating IP subnet.
**CONFIG_PROVISION_DEMO_ALLOCATION_POOLS**
Allocation pools in the floating IP subnet.
**CONFIG_PROVISION_IMAGE_URL** **CONFIG_PROVISION_IMAGE_URL**
A URL or local file location for an image to download and provision in Glance (defaults to a URL for a recent "cirros" image). A URL or local file location for an image to download and provision in Glance (defaults to a URL for a recent "cirros" image).

View File

@@ -15,6 +15,7 @@
""" """
Installs and configures Provisioning for demo usage and testing Installs and configures Provisioning for demo usage and testing
""" """
import json
from packstack.installer import basedefs from packstack.installer import basedefs
from packstack.installer import utils from packstack.installer import utils
@@ -98,6 +99,19 @@ def initConfig(controller):
"NEED_CONFIRM": False, "NEED_CONFIRM": False,
"CONDITION": False}, "CONDITION": False},
{"CMD_OPTION": "provision-demo-allocation-pools",
"PROMPT": ("Enter the allocation pools from the floating IP "
"subnet, as JSON list [\"start=ip1,end=ip2\", ...]"),
"OPTION_LIST": [],
"VALIDATORS": [],
"DEFAULT_VALUE": "[]",
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_PROVISION_DEMO_ALLOCATION_POOLS",
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "provision-image-name", {"CMD_OPTION": "provision-image-name",
"PROMPT": "Enter the name to be assigned to the demo image", "PROMPT": "Enter the name to be assigned to the demo image",
"OPTION_LIST": False, "OPTION_LIST": False,
@@ -351,3 +365,9 @@ def initConfig(controller):
def initSequences(controller): def initSequences(controller):
config = controller.CONF config = controller.CONF
# params modification
key = 'CONFIG_PROVISION_DEMO_ALLOCATION_POOLS'
value = config.get(key, "[]")
config[key] = json.loads(value)
if type(config[key]) is not list:
raise KeyError("Key %s is not a list: %s" % (key, config[key]))

View File

@@ -10,11 +10,14 @@ class packstack::provision ()
$password = hiera('CONFIG_KEYSTONE_DEMO_PW') $password = hiera('CONFIG_KEYSTONE_DEMO_PW')
$tenant_name = 'demo' $tenant_name = 'demo'
$floating_range = hiera('CONFIG_PROVISION_DEMO_FLOATRANGE') $floating_range = hiera('CONFIG_PROVISION_DEMO_FLOATRANGE')
$allocation_pools = hiera(
'CONFIG_PROVISION_DEMO_ALLOCATION_POOLS')
} elsif $provision_tempest { } elsif $provision_tempest {
$username = hiera('CONFIG_PROVISION_TEMPEST_USER') $username = hiera('CONFIG_PROVISION_TEMPEST_USER')
$password = hiera('CONFIG_PROVISION_TEMPEST_USER_PW') $password = hiera('CONFIG_PROVISION_TEMPEST_USER_PW')
$tenant_name = 'tempest' $tenant_name = 'tempest'
$floating_range = hiera('CONFIG_PROVISION_TEMPEST_FLOATRANGE') $floating_range = hiera('CONFIG_PROVISION_TEMPEST_FLOATRANGE')
$allocation_pools = []
if (empty($tempest_user) or empty($tempest_password)) { if (empty($tempest_user) or empty($tempest_password)) {
fail("Both CONFIG_PROVISION_TEMPEST_USER and fail("Both CONFIG_PROVISION_TEMPEST_USER and
CONFIG_PROVISION_TEMPEST_USER_PW need to be configured.") CONFIG_PROVISION_TEMPEST_USER_PW need to be configured.")
@@ -69,11 +72,12 @@ class packstack::provision ()
provider_physical_network => $public_physnet, provider_physical_network => $public_physnet,
} }
neutron_subnet { $public_subnet_name: neutron_subnet { $public_subnet_name:
ensure => 'present', ensure => 'present',
cidr => $floating_range, cidr => $floating_range,
enable_dhcp => false, allocation_pools => $allocation_pools,
network_name => $public_network_name, enable_dhcp => false,
tenant_name => $admin_tenant_name, network_name => $public_network_name,
tenant_name => $admin_tenant_name,
} }
neutron_network { $private_network_name: neutron_network { $private_network_name:
ensure => present, ensure => present,

View File

@@ -0,0 +1,4 @@
---
features:
- Introduced CONFIG_PROVISION_DEMO_ALLOCATION_POOLS
to restrict public subnet IP address allocations.