cloud roster: Don't stop if minion wasn't found in cloud cache index

The cloud roster retrieves a minions's profile, provider and driver
names from the cloud cache index and then issues the show_instance
action to get the minions's IP address. If the minion wasn't found in
the cloud cache index, the cloud roster stops. However, the cloud cache
index is only maintained by the EC2 driver, making the cloud roster only
usable with EC2.

Don't stop if a minion wasn't found in the cloud cache index, trying
show_instance anyway. In this way, although it's impossible to get the
minion's profile, the cloud roster is applicable to cloud providers
other than EC2.
This commit is contained in:
Sergei Zviagintsev 2017-03-11 16:40:33 +01:00
parent a6865e0283
commit d87b377ad2

View file

@ -50,11 +50,6 @@ def targets(tgt, tgt_type='glob', **kwargs): # pylint: disable=W0613
with salt.utils.fopen(cache, 'r') as fh_:
cache_data = msgpack.load(fh_)
indexed_minion = cache_data.get(tgt, None)
if indexed_minion is None:
return {}
client = salt.cloud.CloudClient(
os.path.join(os.path.dirname(__opts__['conf_file']), 'cloud')
)
@ -66,9 +61,17 @@ def targets(tgt, tgt_type='glob', **kwargs): # pylint: disable=W0613
if not_actioned and tgt in not_actioned:
return {}
provider = indexed_minion.get('provider', None)
profile = indexed_minion.get('profile', None)
driver = indexed_minion.get('driver', None)
indexed_minion = cache_data.get(tgt, None)
if indexed_minion:
provider = indexed_minion.get('provider', None)
driver = indexed_minion.get('driver', None)
profile = indexed_minion.get('profile', None)
else:
provider = next(iter(info))
driver = next(iter(info[provider]))
profile = None
vm_ = {
'provider': provider,
'profile': profile,