Пример #1
0
    def setUp(self):
        self._mock_ssh = mock.patch.object(attacker_baremetal, 'ssh')
        self.mock_ssh = self._mock_ssh.start()
        self._mock_subprocess = mock.patch.object(attacker_baremetal,
                                                  'subprocess')
        self.mock_subprocess = self._mock_subprocess.start()
        self.addCleanup(self._stop_mocks)

        self.mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')

        host = {
            "ipmi_ip": "10.20.0.5",
            "ipmi_user": "******",
            "ipmi_password": "******",
            "ip": "10.20.0.5",
            "user": "******",
            "key_filename": "/root/.ssh/id_rsa"
        }
        self.context = {"node1": host}
        self.attacker_cfg = {
            'fault_type': 'bear-metal-down',
            'host': 'node1',
        }

        self.ins = attacker_baremetal.BaremetalAttacker(
            self.attacker_cfg, self.context)
Пример #2
0
    def test__attacker_baremetal_all_successful(self, mock_ssh, mock_subprocess):
        mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
        ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
                                                   self.context)

        ins.setup()
        ins.inject_fault()
        ins.recover()
Пример #3
0
    def test__attacker_baremetal_recover_successful(self):
        self.attacker_cfg["jump_host"] = 'node1'
        self.context["node1"]["password"] = "******"
        ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
                                                   self.context)

        ins.setup()
        ins.recover()
Пример #4
0
    def test__attacker_baremetal_recover_successful(self, mock_ssh, mock_subprocess):

        self.attacker_cfg["jump_host"] = 'node1'
        self.context["node1"]["pwd"] = "123456"
        mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
        ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
                                                   self.context)

        ins.setup()
        ins.recover()
Пример #5
0
 def test__attacker_baremetal_check_failuer(self, mock_ssh, mock_subprocess):
     mock_ssh.SSH.from_node().execute.return_value = (0, "error check", '')
     ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
                                                self.context)
     ins.setup()
Пример #6
0
    def test__attacker_baremetal_check_failuer(self, mock_ssh):

        ins = attacker_baremetal.BaremetalAttacker(self.attacker_cfg,
                                                   self.context)
        mock_ssh.SSH().execute.return_value = (0, "error check", '')
        ins.setup()