Removed several uses of name.split('.')[0] in SoftLayer driver.

This code is breaking when server names with multiple periods are used - for
example, name=server1.prod.dc1 domain=example.com. Simply "split and use first
one isn't the reverse operation of "'.'.join([name, domain])" which is done
when VM is created here: 9dcd11c155 (diff-ac8112a3f8d2ebde0edf104797fe64d7)

We've been running with these changes for a while and don't have any issues
creating or destroying instances.

The caveat that some operations (such as destroying) through SoftLayer API
require hostname (without domain) is already documented in Salt and still
applies.
This commit is contained in:
Vitaliy Fuks 2017-07-01 02:07:00 +00:00 committed by rallytime
parent d347d1cf8f
commit 9a5ae2bba1
3 changed files with 1 additions and 16 deletions

View file

@ -730,15 +730,6 @@ class Cloud(object):
continue
for vm_name, details in six.iteritems(vms):
# If VM was created with use_fqdn with either of the softlayer drivers,
# we need to strip the VM name and only search for the short hostname.
if driver == 'softlayer' or driver == 'softlayer_hw':
ret = []
for name in names:
name = name.split('.')[0]
ret.append(name)
if vm_name not in ret:
continue
# XXX: The logic below can be removed once the aws driver
# is removed
elif vm_name not in names:

View file

@ -508,7 +508,7 @@ def list_nodes_full(mask='mask[id]', call=None):
conn = get_conn(service='SoftLayer_Account')
response = conn.getVirtualGuests()
for node_id in response:
hostname = node_id['hostname'].split('.')[0]
hostname = node_id['hostname']
ret[hostname] = node_id
__utils__['cloud.cache_node_list'](ret, __active_provider_name__.split(':')[0], __opts__)
return ret
@ -594,9 +594,6 @@ def destroy(name, call=None):
transport=__opts__['transport']
)
# If the VM was created with use_fqdn, the short hostname will be used instead.
name = name.split('.')[0]
node = show_instance(name, call='action')
conn = get_conn()
response = conn.deleteObject(id=node['id'])

View file

@ -526,9 +526,6 @@ def destroy(name, call=None):
transport=__opts__['transport']
)
# If the VM was created with use_fqdn, the short hostname will be used instead.
name = name.split('.')[0]
node = show_instance(name, call='action')
conn = get_conn(service='SoftLayer_Ticket')
response = conn.createCancelServerTicket(