예제 #1
0
    def test__power_status_error(self):
        self.mox.StubOutWithMock(ipmi, '_exec_ipmitool')
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
                ["Chassis Power is badstate\n", None])
        self.mox.ReplayAll()

        state = ipmi._power_status(self.info)
        self.mox.VerifyAll()
        self.assertEqual(state, states.ERROR)
예제 #2
0
    def test__power_status_error(self):
        self.mox.StubOutWithMock(ipmi, '_exec_ipmitool')
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
            ["Chassis Power is badstate\n", None])
        self.mox.ReplayAll()

        state = ipmi._power_status(self.info)
        self.mox.VerifyAll()
        self.assertEqual(state, states.ERROR)
예제 #3
0
    def test_set_boot_device_ok(self):
        self.mox.StubOutWithMock(ipmi, '_exec_ipmitool')

        ipmi._exec_ipmitool(self.info, "chassis bootdev pxe").\
                AndReturn([None, None])
        self.mox.ReplayAll()

        with task_manager.acquire([self.node['uuid']]) as task:
            self.driver.power._set_boot_device(task, self.node, 'pxe')
        self.mox.VerifyAll()
예제 #4
0
    def test__exec_ipmitool(self):
        pw_file = '/tmp/password_file'
        file_handle = open(pw_file, "w")

        self.mox.StubOutWithMock(ipmi, '_make_password_file')
        self.mox.StubOutWithMock(utils, 'execute')
        args = [
            'ipmitool',
            '-I', 'lanplus',
            '-H', self.info['address'],
            '-U', self.info['username'],
            '-f', file_handle,
            'A', 'B', 'C',
            ]
        ipmi._make_password_file(self.info['password']).AndReturn(file_handle)
        utils.execute(*args, attempts=3).AndReturn((None, None))
        self.mox.ReplayAll()

        ipmi._exec_ipmitool(self.info, 'A B C')
        self.mox.VerifyAll()
예제 #5
0
    def test_get_power_state(self):
        self.mox.StubOutWithMock(ipmi, '_exec_ipmitool')
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
                ["Chassis Power is off\n", None])
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
                ["Chassis Power is on\n", None])
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
                ["\n", None])
        self.mox.ReplayAll()

        pstate = self.driver.power.get_power_state(None, self.node)
        self.assertEqual(pstate, states.POWER_OFF)

        pstate = self.driver.power.get_power_state(None, self.node)
        self.assertEqual(pstate, states.POWER_ON)

        pstate = self.driver.power.get_power_state(None, self.node)
        self.assertEqual(pstate, states.ERROR)

        self.mox.VerifyAll()
예제 #6
0
    def test__power_on_max_retries(self):
        self.config(ipmi_power_retry=2)
        self.mox.StubOutWithMock(ipmi, '_exec_ipmitool')

        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
                ["Chassis Power is off\n", None])
        ipmi._exec_ipmitool(self.info, "power on").AndReturn([None, None])
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
                ["Chassis Power is off\n", None])
        ipmi._exec_ipmitool(self.info, "power on").AndReturn([None, None])
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
                ["Chassis Power is off\n", None])
        ipmi._exec_ipmitool(self.info, "power on").AndReturn([None, None])
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
                ["Chassis Power is off\n", None])
        self.mox.ReplayAll()

        state = ipmi._power_on(self.info)
        self.mox.VerifyAll()
        self.assertEqual(state, states.ERROR)
예제 #7
0
    def test__power_on_max_retries(self):
        self.config(ipmi_power_retry=2)
        self.mox.StubOutWithMock(ipmi, '_exec_ipmitool')

        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
            ["Chassis Power is off\n", None])
        ipmi._exec_ipmitool(self.info, "power on").AndReturn([None, None])
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
            ["Chassis Power is off\n", None])
        ipmi._exec_ipmitool(self.info, "power on").AndReturn([None, None])
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
            ["Chassis Power is off\n", None])
        ipmi._exec_ipmitool(self.info, "power on").AndReturn([None, None])
        ipmi._exec_ipmitool(self.info, "power status").AndReturn(
            ["Chassis Power is off\n", None])
        self.mox.ReplayAll()

        state = ipmi._power_on(self.info)
        self.mox.VerifyAll()
        self.assertEqual(state, states.ERROR)