mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
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:
parent
a6865e0283
commit
d87b377ad2
1 changed files with 11 additions and 8 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue