mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Protect against passing a map file in addition to VM names with --destroy
Fixes #24036
This commit is contained in:
parent
3aa5045138
commit
c6715e0404
1 changed files with 12 additions and 3 deletions
|
@ -166,12 +166,21 @@ class SaltCloud(parsers.SaltCloudParser):
|
|||
|
||||
elif self.options.destroy and (self.config.get('names', None) or
|
||||
self.config.get('map', None)):
|
||||
if self.config.get('map', None):
|
||||
log.info('Applying map from {0!r}.'.format(self.config['map']))
|
||||
map_file = self.config.get('map', None)
|
||||
names = self.config.get('names', ())
|
||||
if map_file is not None:
|
||||
if names != ():
|
||||
msg = 'Supplying a mapfile, \'{0}\', in addition to instance names {1} ' \
|
||||
'with the \'--destroy\' or \'-d\' function is not supported. ' \
|
||||
'Please choose to delete either the entire map file or individual ' \
|
||||
'instances.'.format(map_file, names)
|
||||
self.handle_exception(msg, SaltCloudSystemExit)
|
||||
|
||||
log.info('Applying map from \'{0}\'.'.format(map_file))
|
||||
matching = mapper.delete_map(query='list_nodes')
|
||||
else:
|
||||
matching = mapper.get_running_by_names(
|
||||
self.config.get('names', ()),
|
||||
names,
|
||||
profile=self.options.profile
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue