Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use __utils__ in salt.cloud #35483

Merged
merged 1 commit into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions salt/cloud/clouds/aliyun.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def list_nodes_full(call=None):
provider = comps[0]

__opts__['update_cachedir'] = True
salt.utils.cloud.cache_node_list(ret, provider, __opts__)
__utils__['cloud.cache_node_list'](ret, provider, __opts__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, since this is now being loaded by the loader we should have __opts__ already packed into utils.If so, we should go ahead and modify these utility functions to simply use the copy of opts they already have, IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left that in just in case someone else was using it for one of their functions in reference to something.

And then we can remove it in Carbon, instead of making a change to the function that we don't need to make back in an older release. But I can remove the opts if that is what should be done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine. If you want to do a deprecation path, we can do that but let's just go ahead and merge this as it is. Thanks.


return ret

Expand Down Expand Up @@ -594,7 +594,7 @@ def create(vm_):
if 'provider' in vm_:
vm_['driver'] = vm_.pop('provider')

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'starting create',
'salt/cloud/{0}/creating'.format(vm_['name']),
Expand All @@ -615,7 +615,7 @@ def create(vm_):
'securitygroup_id': get_securitygroup(vm_),
}

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'requesting instance',
'salt/cloud/{0}/requesting'.format(vm_['name']),
Expand Down Expand Up @@ -669,7 +669,7 @@ def __query_node_data(vm_name):
vm_['ssh_host'] = public_ip

# The instance is booted and accessible, let's Salt it!
ret = salt.utils.cloud.bootstrap(vm_, __opts__)
ret = __utils__['cloud.bootstrap'](vm_, __opts__)
ret.update(data.__dict__)

log.info('Created Cloud VM {0[name]!r}'.format(vm_))
Expand All @@ -679,7 +679,7 @@ def __query_node_data(vm_name):
)
)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'created instance',
'salt/cloud/{0}/created'.format(vm_['name']),
Expand Down Expand Up @@ -963,7 +963,7 @@ def destroy(name, call=None):
'-a or --action.'
)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'destroying instance',
'salt/cloud/{0}/destroying'.format(name),
Expand All @@ -978,7 +978,7 @@ def destroy(name, call=None):

node = query(params)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'destroyed instance',
'salt/cloud/{0}/destroyed'.format(name),
Expand Down
22 changes: 11 additions & 11 deletions salt/cloud/clouds/cloudstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def create(vm_):
if 'provider' in vm_:
vm_['driver'] = vm_.pop('provider')

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'starting create',
'salt/cloud/{0}/creating'.format(vm_['name']),
Expand Down Expand Up @@ -289,7 +289,7 @@ def create(vm_):
if get_project(conn, vm_) is not False:
kwargs['project'] = get_project(conn, vm_)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'requesting instance',
'salt/cloud/{0}/requesting'.format(vm_['name']),
Expand All @@ -311,7 +311,7 @@ def create(vm_):
for ex_blockdevicemapping in ex_blockdevicemappings:
if 'VirtualName' not in ex_blockdevicemapping:
ex_blockdevicemapping['VirtualName'] = '{0}-{1}'.format(vm_['name'], len(volumes))
salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'requesting volume',
'salt/cloud/{0}/requesting'.format(ex_blockdevicemapping['VirtualName']),
Expand Down Expand Up @@ -373,7 +373,7 @@ def create(vm_):
vm_['ssh_host'] = get_ip(data)
vm_['password'] = data.extra['password']
vm_['key_filename'] = get_key()
ret = salt.utils.cloud.bootstrap(vm_, __opts__)
ret = __utils__['cloud.bootstrap'](vm_, __opts__)

ret.update(data.__dict__)

Expand All @@ -387,7 +387,7 @@ def create(vm_):
)
)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'created instance',
'salt/cloud/{0}/created'.format(vm_['name']),
Expand All @@ -412,7 +412,7 @@ def destroy(name, conn=None, call=None):
'-a or --action.'
)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'destroying instance',
'salt/cloud/{0}/destroying'.format(name),
Expand All @@ -436,7 +436,7 @@ def destroy(name, conn=None, call=None):
)
continue
log.info('Detaching volume: {0}'.format(volume.name))
salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'detaching volume',
'salt/cloud/{0}/detaching'.format(volume.name),
Expand All @@ -446,15 +446,15 @@ def destroy(name, conn=None, call=None):
log.error('Failed to Detach volume: {0}'.format(volume.name))
return False
log.info('Detached volume: {0}'.format(volume.name))
salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'detached volume',
'salt/cloud/{0}/detached'.format(volume.name),
{'name': volume.name},
)

log.info('Destroying volume: {0}'.format(volume.name))
salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'destroying volume',
'salt/cloud/{0}/destroying'.format(volume.name),
Expand All @@ -464,7 +464,7 @@ def destroy(name, conn=None, call=None):
log.error('Failed to Destroy volume: {0}'.format(volume.name))
return False
log.info('Destroyed volume: {0}'.format(volume.name))
salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'destroyed volume',
'salt/cloud/{0}/destroyed'.format(volume.name),
Expand All @@ -478,7 +478,7 @@ def destroy(name, conn=None, call=None):
log.info('Destroyed VM: {0}'.format(name))
# Fire destroy action
event = salt.utils.event.SaltEvent('master', __opts__['sock_dir'])
salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'destroyed instance',
'salt/cloud/{0}/destroyed'.format(name),
Expand Down
16 changes: 8 additions & 8 deletions salt/cloud/clouds/digital_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def create(vm_):
if 'provider' in vm_:
vm_['driver'] = vm_.pop('provider')

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'starting create',
'salt/cloud/{0}/creating'.format(vm_['name']),
Expand Down Expand Up @@ -366,7 +366,7 @@ def create(vm_):
raise SaltCloudConfigError("'ipv6' should be a boolean value.")
kwargs['ipv6'] = ipv6

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'requesting instance',
'salt/cloud/{0}/requesting'.format(vm_['name']),
Expand Down Expand Up @@ -423,7 +423,7 @@ def __query_node_data(vm_name):
ip_address = network['ip_address']
vm_['key_filename'] = key_filename
vm_['ssh_host'] = ip_address
ret = salt.utils.cloud.bootstrap(vm_, __opts__)
ret = __utils__['cloud.bootstrap'](vm_, __opts__)
ret.update(data)

log.info('Created Cloud VM {0[name]!r}'.format(vm_))
Expand All @@ -433,7 +433,7 @@ def __query_node_data(vm_name):
)
)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'created instance',
'salt/cloud/{0}/created'.format(vm_['name']),
Expand Down Expand Up @@ -530,7 +530,7 @@ def show_instance(name, call=None):
'The show_instance action must be called with -a or --action.'
)
node = _get_node(name)
salt.utils.cloud.cache_node(node, __active_provider_name__, __opts__)
__utils__['cloud.cache_node'](node, __active_provider_name__, __opts__)
return node


Expand Down Expand Up @@ -686,7 +686,7 @@ def destroy(name, call=None):
'-a or --action.'
)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'destroying instance',
'salt/cloud/{0}/destroying'.format(name),
Expand All @@ -709,7 +709,7 @@ def destroy(name, call=None):
if delete_record:
delete_dns_record(name)

salt.utils.cloud.fire_event(
__utils__['cloud.fire_event'](
'event',
'destroyed instance',
'salt/cloud/{0}/destroyed'.format(name),
Expand All @@ -718,7 +718,7 @@ def destroy(name, call=None):
)

if __opts__.get('update_cachedir', False) is True:
salt.utils.cloud.delete_minion_cachedir(name, __active_provider_name__.split(':')[0], __opts__)
__utils__['cloud.delete_minion_cachedir'](name, __active_provider_name__.split(':')[0], __opts__)

return node

Expand Down
Loading