Skip to content
Permalink
Browse files

Make `request_floating_ip` a config parameter for cluster and node te…

…mplates.
  • Loading branch information...
riccardomurri committed Mar 8, 2019
1 parent 9e5c8d8 commit 5789b44a04afd3580181a9961bd6243e88339f36
Showing with 34 additions and 14 deletions.
  1. +15 −8 docs/configure.rst
  2. +5 −3 elasticluster/conf.py
  3. +14 −3 elasticluster/providers/openstack.py
@@ -451,14 +451,7 @@ Valid configuration keys for ``openstack``
the environment variable is used instead.

``request_floating_ip``
request assignment of a "floating IP" when the instance is
started. Valid values are ``yes`` (or ``True`` or ``1``) and ``no``
(or ``False`` or ``0``; default). Some cloud providers do not
automatically assign a public IP to the instances, but this is often
needed if you want to connect to the VM from outside. Setting
``request_floating_ip`` to ``yes`` will force `elasticluster` to
request such a floating IP if the instance doesn't get one
automatically.
**See ``request_floating_ip`` in the ``[cluster/...]`` section instead.**


Examples
@@ -1171,6 +1164,20 @@ Additional optional configuration keys for OpenStack clouds
gigabytes. There is no default; this option is mandatory of
``boot_disk_type`` is also specified.

``floating_network_id``
If ``request_floating_ip`` (which see below) is true, then
request that the floating IP be allocated on this network.

``request_floating_ip``
Request assignment of a "floating IP" when the instance is
started. Valid values are ``yes`` (or ``True`` or ``1``) and
``no`` (or ``False`` or ``0``; default). Some cloud providers do
not automatically assign a public IP to the instances, but this is
often needed if you want to connect to the VM from
outside. Setting ``request_floating_ip`` to ``yes`` will force
ElastiCluster to request such a floating IP if the instance
doesn't get one automatically.


Examples
--------
@@ -122,6 +122,7 @@
Optional("min_cpu_platform"): nonempty_str,
# only on OpenStack
Optional('floating_network_id'): str,
Optional("request_floating_ip"): boolean,
# allow other string keys w/out restrictions
Optional(str): str,
},
@@ -138,6 +139,7 @@
Optional("min_cpu_platform"): nonempty_str,
# only on OpenStack
Optional('floating_network_id'): str,
Optional("request_floating_ip"): boolean,
# allow other string keys w/out restrictions
Optional(str): str,
},
@@ -219,15 +221,14 @@
Optional("user_domain_name"): nonempty_str,
Optional("project_domain_name"): nonempty_str,
Optional("project_name"): nonempty_str,
Optional("request_floating_ip"): boolean,
Optional("request_floating_ip"): boolean, ## DEPRECATED, place in cluster or node config
Optional("region_name"): nonempty_str,
Optional("compute_api_version"): Or('1.1', '2'),
Optional("image_api_version"): Or('1', '2'),
Optional("network_api_version"): Or('2.0'),
Optional("volume_api_version"): Or('1', '2', '3'),
Optional("identity_api_version"): Or('3', '2'), # no default, can auto-detect
## DEPRECATED, use `compute_api_version` instead
Optional("nova_api_version"): nova_api_version,
Optional("nova_api_version"): nova_api_version, ## DEPRECATED, use `compute_api_version` instead
},

'libcloud': {
@@ -688,6 +689,7 @@ def _gather_node_kind_info(kind_name, cluster_name, cluster_conf):
'tags'
# OpenStack only
'floating_network_id',
'request_floating_ip',
#'user_key_name', ## from `login/*`
#'user_key_private', ## from `login/*`
#'user_key_public', ## from `login/*`
@@ -153,7 +153,6 @@ def __init__(self,
auth_url=None,
user_domain_name="default", project_domain_name="default",
region_name=None, storage_path=None,
request_floating_ip=False,
compute_api_version=DEFAULT_OS_COMPUTE_API_VERSION,
image_api_version=DEFAULT_OS_IMAGE_API_VERSION,
network_api_version=DEFAULT_OS_NETWORK_API_VERSION,
@@ -163,6 +162,7 @@ def __init__(self,
# this is deprecated in favor of `compute_api_version`
nova_api_version=None,
cacert=None, # keep in sync w/ default in novaclient.Client()
request_floating_ip=None, ## DEPRECATED, will be removed
):
# OpenStack connection params
self._os_auth_url = self._get_os_config_value('auth URL', auth_url, ['OS_AUTH_URL']).rstrip('/')
@@ -199,10 +199,17 @@ def __init__(self,
self.cinder_client = None

# local state
self.request_floating_ip = request_floating_ip
self._instances = {}
self._cached_instances = {}

if request_floating_ip is not None:
warn('Deprecated parameter `request_floating_ip` given'
' to OpenStackProvider; place it in the cluster'
' or node configuration instead.', DeprecationWarning)
self._request_floating_ip_default = request_floating_ip



def to_vars_dict(self):
"""
Return local state which is relevant for the cluster setup process.
@@ -541,7 +548,11 @@ def start_instance(self, key_name, public_key_path, private_key_path,
vm = self.nova_client.servers.create(node_name, image_id, flavor, **vm_start_args)

# allocate and attach a floating IP, if requested
if self.request_floating_ip:
request_floating_ip = kwargs.get(
'request_floating_ip',
self._request_floating_ip_default)

if request_floating_ip:

# wait for server to come up (otherwise floating IP can't be associated)
log.info("Waiting for instance `%s` (%s) to come up ...", node_name, vm.id)

0 comments on commit 5789b44

Please sign in to comment.
You can’t perform that action at this time.