Skip to content

Instantly share code, notes, and snippets.

@johnsca
Created February 28, 2018 14:47
Show Gist options
  • Save johnsca/7666f44928f4f9d94a4c1c8e4bcf4e5f to your computer and use it in GitHub Desktop.
Save johnsca/7666f44928f4f9d94a4c1c8e4bcf4e5f to your computer and use it in GitHub Desktop.
class Bundle(dict)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._normalize_bundle()
def _normalize_bundle(self):
""" Normalizes bundle for things
like applications vs. services
"""
if 'services' in self:
self['applications'] = self.pop('services')
def to_yaml(self):
""" Returns yaml dump of bundle
"""
return yaml.dump(self,
default_flow_style=False)
@property
def applications(self):
""" Returns list of applications/services
"""
_applications = []
for app in self['applications'].keys():
_applications.append(self._get_application_fragment(app))
return _applications
@property
def machines(self):
""" Returns defined machines
"""
return self.get('machines', [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment