Merge pull request #42302 from rallytime/cloud-utils-fire-event-deprecation

Remove sock_dir deprecation warning from salt.utils.cloud.fire_event
This commit is contained in:
Mike Place 2017-07-17 09:35:58 -05:00 committed by GitHub
commit c7b3f6a09a
4 changed files with 32 additions and 21 deletions

View File

@ -131,3 +131,11 @@ For ``smartos`` some grains have been deprecated. These grains will be removed i
- The ``hypervisor_uuid`` has been replaced with ``mdata:sdc:server_uuid`` grain. - The ``hypervisor_uuid`` has been replaced with ``mdata:sdc:server_uuid`` grain.
- The ``datacenter`` has been replaced with ``mdata:sdc:datacenter_name`` grain. - The ``datacenter`` has been replaced with ``mdata:sdc:datacenter_name`` grain.
Utils Deprecations
------------------
The ``salt.utils.cloud.py`` file had the following change:
- The ``fire_event`` function now requires a ``sock_dir`` argument. It was previously
optional.

View File

@ -277,6 +277,7 @@ def create(vm_):
'event', 'event',
'starting create', 'starting create',
'salt/cloud/{0}/creating'.format(vm_['name']), 'salt/cloud/{0}/creating'.format(vm_['name']),
sock_dir=__opts__['sock_dir'],
args=__utils__['cloud.filter_event']('creating', vm_, ['name', 'profile', 'provider', 'driver']), args=__utils__['cloud.filter_event']('creating', vm_, ['name', 'profile', 'provider', 'driver']),
transport=__opts__['transport'] transport=__opts__['transport']
) )
@ -316,6 +317,7 @@ def create(vm_):
'event', 'event',
'requesting instance', 'requesting instance',
'salt/cloud/{0}/requesting'.format(vm_['name']), 'salt/cloud/{0}/requesting'.format(vm_['name']),
sock_dir=__opts__['sock_dir'],
args={ args={
'kwargs': __utils__['cloud.filter_event']( 'kwargs': __utils__['cloud.filter_event'](
'requesting', 'requesting',
@ -339,12 +341,13 @@ def create(vm_):
if 'VirtualName' not in ex_blockdevicemapping: if 'VirtualName' not in ex_blockdevicemapping:
ex_blockdevicemapping['VirtualName'] = '{0}-{1}'.format(vm_['name'], len(volumes)) ex_blockdevicemapping['VirtualName'] = '{0}-{1}'.format(vm_['name'], len(volumes))
__utils__['cloud.fire_event']( __utils__['cloud.fire_event'](
'event', 'event',
'requesting volume', 'requesting volume',
'salt/cloud/{0}/requesting'.format(ex_blockdevicemapping['VirtualName']), 'salt/cloud/{0}/requesting'.format(ex_blockdevicemapping['VirtualName']),
{'kwargs': {'name': ex_blockdevicemapping['VirtualName'], sock_dir=__opts__['sock_dir'],
'device': ex_blockdevicemapping['DeviceName'], args={'kwargs': {'name': ex_blockdevicemapping['VirtualName'],
'size': ex_blockdevicemapping['VolumeSize']}}, 'device': ex_blockdevicemapping['DeviceName'],
'size': ex_blockdevicemapping['VolumeSize']}},
) )
try: try:
volumes[ex_blockdevicemapping['DeviceName']] = conn.create_volume( volumes[ex_blockdevicemapping['DeviceName']] = conn.create_volume(
@ -418,6 +421,7 @@ def create(vm_):
'event', 'event',
'created instance', 'created instance',
'salt/cloud/{0}/created'.format(vm_['name']), 'salt/cloud/{0}/created'.format(vm_['name']),
sock_dir=__opts__['sock_dir'],
args=__utils__['cloud.filter_event']('created', vm_, ['name', 'profile', 'provider', 'driver']), args=__utils__['cloud.filter_event']('created', vm_, ['name', 'profile', 'provider', 'driver']),
transport=__opts__['transport'] transport=__opts__['transport']
) )
@ -439,7 +443,8 @@ def destroy(name, conn=None, call=None):
'event', 'event',
'destroying instance', 'destroying instance',
'salt/cloud/{0}/destroying'.format(name), 'salt/cloud/{0}/destroying'.format(name),
{'name': name}, sock_dir=__opts__['sock_dir'],
args={'name': name},
) )
if not conn: if not conn:
@ -463,7 +468,8 @@ def destroy(name, conn=None, call=None):
'event', 'event',
'detaching volume', 'detaching volume',
'salt/cloud/{0}/detaching'.format(volume.name), 'salt/cloud/{0}/detaching'.format(volume.name),
{'name': volume.name}, sock_dir=__opts__['sock_dir'],
args={'name': volume.name},
) )
if not conn.detach_volume(volume): if not conn.detach_volume(volume):
log.error('Failed to Detach volume: {0}'.format(volume.name)) log.error('Failed to Detach volume: {0}'.format(volume.name))
@ -473,7 +479,8 @@ def destroy(name, conn=None, call=None):
'event', 'event',
'detached volume', 'detached volume',
'salt/cloud/{0}/detached'.format(volume.name), 'salt/cloud/{0}/detached'.format(volume.name),
{'name': volume.name}, sock_dir=__opts__['sock_dir'],
args={'name': volume.name},
) )
log.info('Destroying volume: {0}'.format(volume.name)) log.info('Destroying volume: {0}'.format(volume.name))
@ -481,7 +488,8 @@ def destroy(name, conn=None, call=None):
'event', 'event',
'destroying volume', 'destroying volume',
'salt/cloud/{0}/destroying'.format(volume.name), 'salt/cloud/{0}/destroying'.format(volume.name),
{'name': volume.name}, sock_dir=__opts__['sock_dir'],
args={'name': volume.name},
) )
if not conn.destroy_volume(volume): if not conn.destroy_volume(volume):
log.error('Failed to Destroy volume: {0}'.format(volume.name)) log.error('Failed to Destroy volume: {0}'.format(volume.name))
@ -491,7 +499,8 @@ def destroy(name, conn=None, call=None):
'event', 'event',
'destroyed volume', 'destroyed volume',
'salt/cloud/{0}/destroyed'.format(volume.name), 'salt/cloud/{0}/destroyed'.format(volume.name),
{'name': volume.name}, sock_dir=__opts__['sock_dir'],
args={'name': volume.name},
) )
log.info('Destroying VM: {0}'.format(name)) log.info('Destroying VM: {0}'.format(name))
ret = conn.destroy_node(node) ret = conn.destroy_node(node)
@ -505,7 +514,8 @@ def destroy(name, conn=None, call=None):
'event', 'event',
'destroyed instance', 'destroyed instance',
'salt/cloud/{0}/destroyed'.format(name), 'salt/cloud/{0}/destroyed'.format(name),
{'name': name}, sock_dir=__opts__['sock_dir'],
args={'name': name},
) )
if __opts__['delete_sshkeys'] is True: if __opts__['delete_sshkeys'] is True:
salt.utils.cloud.remove_sshkey(node.public_ips[0]) salt.utils.cloud.remove_sshkey(node.public_ips[0])

View File

@ -524,6 +524,7 @@ def create(vm_):
'event', 'event',
'waiting for ssh', 'waiting for ssh',
'salt/cloud/{0}/waiting_for_ssh'.format(name), 'salt/cloud/{0}/waiting_for_ssh'.format(name),
sock_dir=__opts__['sock_dir'],
args={'ip_address': vm_['ssh_host']}, args={'ip_address': vm_['ssh_host']},
transport=__opts__['transport'] transport=__opts__['transport']
) )

View File

@ -1782,18 +1782,10 @@ def filter_event(tag, data, defaults):
return ret return ret
def fire_event(key, msg, tag, args=None, sock_dir=None, transport='zeromq'): def fire_event(key, msg, tag, sock_dir, args=None, transport='zeromq'):
''' '''
Fire deploy action Fire deploy action
''' '''
if sock_dir is None:
salt.utils.warn_until(
'Oxygen',
'`salt.utils.cloud.fire_event` requires that the `sock_dir`'
'parameter be passed in when calling the function.'
)
sock_dir = __opts__['sock_dir']
event = salt.utils.event.get_event( event = salt.utils.event.get_event(
'master', 'master',
sock_dir, sock_dir,