def test_getters(self):
        action = PlumberyActionLoader.from_shelf('dummy', {'dummy': 'ok'})
        self.assertEqual(action.get_type(), 'dummy')
        self.assertEqual(action.get_parameter('dummy'), 'ok')

        parameters = PlumberyParameters({'goofy': 'ok'})
        action = PlumberyActionLoader.from_shelf('dummy', parameters)
        self.assertEqual(action.get_type(), 'dummy')
        self.assertEqual(action.get_parameter('goofy'), 'ok')
Exemplo n.º 2
0
    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')
Exemplo n.º 3
0
    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')
Exemplo n.º 4
0
    def test_getters(self):
        action = PlumberyActionLoader.from_shelf('dummy', {'dummy': 'ok'})
        self.assertEqual(action.get_type(), 'dummy')
        self.assertEqual(action.get_parameter('dummy'), 'ok')

        parameters = PlumberyParameters({'goofy': 'ok'})
        action = PlumberyActionLoader.from_shelf('dummy', parameters)
        self.assertEqual(action.get_type(), 'dummy')
        self.assertEqual(action.get_parameter('goofy'), 'ok')
Exemplo n.º 5
0
    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.from_shelf(action)

        self.power_on()
        action.enter(self)

        basement = self.list_basement()
        for name in basement:
            blueprint = self.get_blueprint(name)
            action.handle(blueprint)

        for name in self.expand_blueprint('*'):
            if name not in basement:
                blueprint = self.get_blueprint(name)
                action.handle(blueprint)

        action.quit()
Exemplo n.º 6
0
    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()
Exemplo n.º 7
0
    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()
Exemplo n.º 8
0
    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()
Exemplo n.º 9
0
    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()
Exemplo n.º 10
0
    def test_loader_ok(self):

        action = PlumberyActionLoader.from_shelf('dummy')
        action.ignite(engine=None)
        action.enter(facility=None)
        action.handle(blueprint=None)
        action.handle(blueprint=None)
        action.quit()
        action.enter(facility=None)
        action.handle(blueprint=None)
        action.handle(blueprint=None)
        action.quit()
        action.enter(facility=None)
        action.handle(blueprint=None)
        action.handle(blueprint=None)
        action.quit()
        action.reap()
Exemplo n.º 11
0
    def test_loader_ok(self):

        action = PlumberyActionLoader.from_shelf('dummy')
        action.ignite(engine=None)
        action.enter(facility=None)
        action.handle(blueprint=None)
        action.handle(blueprint=None)
        action.quit()
        action.enter(facility=None)
        action.handle(blueprint=None)
        action.handle(blueprint=None)
        action.quit()
        action.enter(facility=None)
        action.handle(blueprint=None)
        action.handle(blueprint=None)
        action.quit()
        action.reap()
Exemplo n.º 12
0
    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()
Exemplo n.º 13
0
    def test_dynamic_load(self):

        actions = PlumberyActionLoader.load_all()

        expected = ['ansible',
                   'build',
                   'configure',
                   'destroy',
                   'information',
                   'inventory',
                   'noop',
                   'ping',
                   'prepare',
                   'start',
                   'stop',
                   'wipe',
                  ]

        self.assertEqual(sorted(actions.keys()), expected)
Exemplo n.º 14
0
    def test_dynamic_load(self):

        actions = PlumberyActionLoader.load_all()

        expected = [
            'ansible',
            'build',
            'configure',
            'destroy',
            'information',
            'inventory',
            'noop',
            'ping',
            'prepare',
            'start',
            'stop',
            'wipe',
        ]

        self.assertEqual(sorted(actions.keys()), expected)
Exemplo n.º 15
0
    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()
Exemplo n.º 16
0
    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.from_shelf(action)

        self.power_on()
        action.enter(self)

        for name in self.expand_blueprint(names):

            blueprint = self.get_blueprint(name)
            action.handle(blueprint)

        action.quit()
Exemplo n.º 17
0
    def test_loader_unknown_class(self):

        with self.assertRaises(ImportError):
            action = PlumberyActionLoader.from_shelf('*123*')
Exemplo n.º 18
0
    def test_loader_unknown_class(self):

        with self.assertRaises(ImportError):
            PlumberyActionLoader.load('*123*')
Exemplo n.º 19
0
    def test_loader_unknown_class(self):

        with self.assertRaises(ImportError):
            PlumberyActionLoader.load('*123*')
Exemplo n.º 20
0
    def test_loader_unknown_class(self):

        with self.assertRaises(ImportError):
            action = PlumberyActionLoader.from_shelf('*123*')