Пример #1
0
    def test_finish_action(self, spe_terminate_instance, spe_stop_instance):
        ssh = SSHCrossCloud(**self.command_arg)
        ssh.init_provider_specifics()
        ssh.ssh_params.final_state = 'stop'
        ssh.finish_action()
        spe_stop_instance.assert_called()

        ssh.ssh_params.final_state = 'terminate'
        ssh.finish_action()
        spe_terminate_instance.assert_called()
Пример #2
0
    def test_manage_instance(self, spe_start_instance, ssh_init_instance):
        ssh = SSHCrossCloud(**self.command_arg)
        ssh.init_provider_specifics()
        ssh.manage_instance()
        ssh.ssh_params.sshcrosscloud_instance_id = None
        ssh_init_instance.assert_called_with(with_instance=False)

        ssh.ssh_params.instance_state = "stopped"
        ssh.manage_instance()
        ssh_init_instance.assert_called_with(with_instance=True)

        ssh.ssh_params.instance_state = "unknown"
        with self.assertRaises(Exception):
            ssh.manage_instance()