If external_up is set to None, don't stacktrace, just use the private ip.

This commit is contained in:
rallytime 2015-10-01 16:37:17 -06:00
parent 2ebf790f9f
commit 8dc047dc18
2 changed files with 17 additions and 17 deletions

View file

@ -233,11 +233,14 @@ deleted when you destroy an instance, set delete_boot_pd to True.
ssh_interface
-------------
.. versionadded:: 2015.5.0
Specify whether to use public or private IP for deploy script.
Valid options are:
* private_ips: The salt-master is also hosted with GCE
* public_ips: The salt-master is hosted outside of GCE
- private_ips: The salt-master is also hosted with GCE
- public_ips: The salt-master is hosted outside of GCE
external_ip
-----------
@ -245,8 +248,9 @@ external_ip
Per instance setting: Used a named fixed IP address to this host.
Valid options are:
* ephemeral - The host will use a GCE ephemeral IP
* None - No external IP will be configured on this host.
- ephemeral: The host will use a GCE ephemeral IP
- None: No external IP will be configured on this host.
Optionally, pass the name of a GCE address to use a fixed IP address.
If the address does not already exist, it will be created.

View file

@ -431,18 +431,13 @@ def __get_host(node, vm_):
'''
Return public IP, private IP, or hostname for the libcloud 'node' object
'''
if __get_ssh_interface(vm_) == 'private_ips':
if __get_ssh_interface(vm_) == 'private_ips' or vm_['external_ip'] is None:
ip_address = node.private_ips[0]
log.info('Salt node data. Private_ip: {0}'.format(ip_address))
else:
ip_address = node.public_ips[0]
log.info('Salt node data. Public_ip: {0}'.format(ip_address))
# if len(node.public_ips) > 0:
# return node.public_ips[0]
# if len(node.private_ips) > 0:
# return node.private_ips[0]
if len(ip_address) > 0:
return ip_address
@ -2041,9 +2036,16 @@ def create(vm_=None, call=None):
external_ip = config.get_cloud_config_value(
'external_ip', vm_, __opts__, default='ephemeral'
)
if isinstance(external_ip, str) and external_ip.lower() == 'ephemeral':
if external_ip.lower() == 'ephemeral':
external_ip = 'ephemeral'
elif external_ip == 'None':
external_ip = None
else:
region = '-'.join(kwargs['location'].name.split('-')[:2])
kwargs['external_ip'] = __create_orget_address(conn, kwargs['external_ip'], region)
kwargs['external_ip'] = external_ip
vm_['external_ip'] = external_ip
if LIBCLOUD_VERSION_INFO > (0, 15, 1):
@ -2061,12 +2063,6 @@ def create(vm_=None, call=None):
'\'pd-standard\', \'pd-ssd\''
)
if 'external_ip' in kwargs and kwargs['external_ip'] == "None":
kwargs['external_ip'] = None
elif kwargs['external_ip'] != 'ephemeral':
region = '-'.join(kwargs['location'].name.split('-')[:2])
kwargs['external_ip'] = __create_orget_address(conn, kwargs['external_ip'], region)
log.info('Creating GCE instance {0} in {1}'.format(vm_['name'],
kwargs['location'].name)
)