Created
December 7, 2012 01:45
-
-
Save glassresistor/4230058 to your computer and use it in GitHub Desktop.
Fix for SmartDataCenter list_machines tag logic.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import env | |
def list_machines(*args, **kwargs): | |
""" | |
Wrapper for listing machines which match every tag. The current api behavior | |
is to return a list for any matching tags. | |
""" | |
tags = kwargs.get('tags') | |
lol_machines = [] # list of sets of machines | |
for key, value in tags.iteritems(): | |
kwargs['tags'] = { key: value, } | |
lol_machines.append(set(env.sdc.machines(*args, **kwargs))) | |
if len(lol_machines[-1]) == 0: | |
break | |
return list(set.intersection(*lol_machines)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment