def test_getters(self): action = PlumberyActionLoader.load('noop', {'parameter': 'ok'}) self.assertEqual(action.get_label(), 'noop') self.assertEqual(action.get_parameter('parameter'), 'ok') parameters = PlumberyParameters({'goofy': 'ok'}) action = PlumberyActionLoader.load('noop', parameters) self.assertEqual(action.get_label(), 'noop') self.assertEqual(action.get_parameter('goofy'), 'ok')
def process_all_blueprints(self, action): """ Handles all blueprints at this facility :param action: the action to perform, e.g., 'start' :type action: ``str`` or :class:`plumbery.PlumberyAction` """ if isinstance(action, str): action = PlumberyActionLoader.load(action) self.power_on() action.enter(self) basement = self.list_basement() for name in basement: blueprint = self.get_blueprint(name) action.process(blueprint) for name in self.expand_blueprint('*'): if name not in basement: blueprint = self.get_blueprint(name) action.process(blueprint) action.quit()
def test_static_load(self): actions = ( 'ansible', 'build', 'configure', 'destroy', 'information', 'noop', 'ping', 'prepare', 'start', 'stop', 'wipe', ) for label in actions: action = PlumberyActionLoader.load(label, {}) self.assertEqual(action.get_label(), label) action.begin(engine=None) action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.end()
def test_static_load(self): actions = ('ansible', 'build', 'configure', 'destroy', 'information', 'noop', 'ping', 'prepare', 'start', 'stop', 'wipe', ) for label in actions: action = PlumberyActionLoader.load(label, {}) self.assertEqual(action.get_label(), label) action.begin(engine=None) action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.end()
def test_loader_ok(self): action = PlumberyActionLoader.load('noop') action.begin(engine=None) action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.enter(facility=None) action.process(blueprint=None) action.process(blueprint=None) action.quit() action.end()
def process_blueprint(self, action, names): """ Handles one blueprint at this facility :param action: the action to perform, e.g., 'start' :type action: ``str`` or :class:`plumbery.PlumberyAction` :param names: the name(s) of the targeted blueprint(s) :type names: ``str`` or ``list`` of ``str`` """ if isinstance(action, str): action = PlumberyActionLoader.load(action) self.power_on() action.enter(self) for name in self.expand_blueprint(names): blueprint = self.get_blueprint(name) action.process(blueprint) action.quit()
def test_loader_unknown_class(self): with self.assertRaises(ImportError): PlumberyActionLoader.load('*123*')