Beispiel #1
0
    class Serialization(Spec):
        def before_all(self):
            self.example_target = create_target()
            self.example_action = Action(targets=[self.example_target],
                                         action_type='soft-reboot')

        def can_serialize_to_a_dictionary(self):
            action_dict = self.example_action.as_dict()

            expect(action_dict['type']).to.equal('soft-reboot')
Beispiel #2
0
    class Serialization(Spec):
        def before_all(self):
            self.example_target = create_target()
            self.example_action = Action(targets=[self.example_target],
                                         action_type='soft-reboot')

        def can_serialize_to_a_dictionary(self):
            action_dict = self.example_action.as_dict()

            expect(action_dict['type']).to.equal('soft-reboot')
Beispiel #3
0
        def before_all(self):
            target = create_target()
            self.targets = [target]

            action = Action(targets=self.targets, action_type='soft-reboot')
            self.actions = [action]

            self.job = Job(tenant_id='123',
                           name='do_stuff',
                           actions=self.actions,
                           job_id='12345')
Beispiel #4
0
    def build_job_from_dict(cls, job_dict):
        actions = []
        for action in job_dict.get("actions", []):
            actions.append(Action.build_action_from_dict(action))

        kwargs = {
            'tenant_id': job_dict.get("tenant_id"),
            'job_id': job_dict.get("id", str(uuid.uuid4())),
            'name': job_dict.get("name"),
            'actions': actions
        }

        return Job(**kwargs)
Beispiel #5
0
    def build_job_from_dict(cls, job_dict):
        actions = []
        for action in job_dict.get("actions", []):
            actions.append(Action.build_action_from_dict(action))

        kwargs = {
            'tenant_id': job_dict.get("tenant_id"),
            'job_id': job_dict.get("id", str(uuid.uuid4())),
            'name': job_dict.get("name"),
            'actions': actions,
            'run_numbers': job_dict.get("run_numbers")
        }

        return Job(**kwargs)
    def can_execute_a_command(self, ssh_client):
        ssh_client.return_value = self.paramiko_stub

        action = Action(targets=['test_id'],
                        action_type='remote-command',
                        parameters={'command': 'some-command'})

        with patch('rift.data.models.target.Target.get_target') as g:
            g.return_value = self.target
            self.plugin.execute_action(self.job, action)

        expect(len(self.paramiko_stub.connect.calls)).to.equal(1)
        expect(len(self.paramiko_stub.exec_command.calls)).to.equal(1)
        expect(len(self.paramiko_stub.close.calls)).to.equal(1)
Beispiel #7
0
        def can_deserialize_from_a_dictionary(self):
            action = Action.build_action_from_dict(self.example)

            expect(action.action_type).to.equal(self.example['type'])
            expect(action.targets[0]).to.equal(self.example['targets'][0])
Beispiel #8
0
 def before_all(self):
     self.example_target = create_target()
     self.example_action = Action(targets=[self.example_target],
                                  action_type='soft-reboot')
Beispiel #9
0
 def before_all(self):
     self.example_target = create_target()
     self.example_action = Action(targets=[self.example_target],
                                  action_type='soft-reboot')
Beispiel #10
0
        def can_deserialize_from_a_dictionary(self):
            action = Action.build_action_from_dict(self.example)

            expect(action.action_type).to.equal(self.example['type'])
            expect(action.targets[0]).to.equal(self.example['targets'][0])