Esempio n. 1
0
 def test_power_state_recs_calls_get_node_power_state_off(self):
     ip, port, username, password, node_id, context = self.make_context()
     recs_power_driver = RECSPowerDriver()
     mock_get_node_power_state = self.patch(RECSAPI, "get_node_power_state",
                                            Mock(return_value="0"))
     state = recs_power_driver.power_state_recs(ip, port, username,
                                                password, node_id)
     self.assertThat(mock_get_node_power_state, MockCalledOnceWith(node_id))
     self.assertThat(state, Equals("off"))
Esempio n. 2
0
    def test_power_off_calls_power_control_recs(self):
        ip, port, username, password, node_id, context = self.make_context()
        recs_power_driver = RECSPowerDriver()
        power_control_recs_mock = self.patch(recs_power_driver,
                                             'power_control_recs')
        recs_power_driver.power_off(context['node_id'], context)

        self.assertThat(
            power_control_recs_mock,
            MockCalledOnceWith(ip, port, username, password, node_id, 'off'))
Esempio n. 3
0
    def test_power_query_calls_power_state_recs(self):
        ip, port, username, password, node_id, context = self.make_context()
        recs_power_driver = RECSPowerDriver()
        power_state_recs_mock = self.patch(recs_power_driver,
                                           "power_state_recs")
        recs_power_driver.power_query(context["node_id"], context)

        self.assertThat(
            power_state_recs_mock,
            MockCalledOnceWith(ip, port, username, password, node_id),
        )
Esempio n. 4
0
 def test_set_boot_source_recs_calls_set_boot_source(self):
     ip, port, username, password, node_id, context = self.make_context()
     recs_power_driver = RECSPowerDriver()
     mock_set_boot_source = self.patch(RECSAPI, "set_boot_source")
     boot_source = 'HDD'
     boot_persistent = 'false'
     recs_power_driver.set_boot_source_recs(ip, port, username, password,
                                            node_id, boot_source,
                                            boot_persistent)
     self.assertThat(
         mock_set_boot_source,
         MockCalledOnceWith(node_id, boot_source, boot_persistent))
Esempio n. 5
0
    def test_power_on_calls_power_control_recs(self):
        ip, port, username, password, node_id, context = self.make_context()
        recs_power_driver = RECSPowerDriver()
        power_control_recs_mock = self.patch(recs_power_driver,
                                             'power_control_recs')
        set_boot_source_recs_mock = self.patch(recs_power_driver,
                                               'set_boot_source_recs')
        recs_power_driver.power_on(context['node_id'], context)

        self.assertThat(
            power_control_recs_mock,
            MockCalledOnceWith(ip, port, username, password, node_id, 'on'))
        self.assertThat(
            set_boot_source_recs_mock,
            MockCallsMatch(
                call(ip, port, username, password, node_id, 'HDD', True),
                call(ip, port, username, password, node_id, 'PXE', False)))
Esempio n. 6
0
 def test_power_state_recs_crashes_on_url_error(self):
     ip, port, username, password, node_id, context = self.make_context()
     recs_power_driver = RECSPowerDriver()
     mock_get_node_power_state = self.patch(RECSAPI, "get_node_power_state",
                                            Mock(return_value='0'))
     mock_get_node_power_state.side_effect = urllib.error.URLError(
         "URL Error")
     self.assertRaises(RECSError, recs_power_driver.power_state_recs, ip,
                       port, username, password, node_id)
Esempio n. 7
0
    def test_power_on_calls_power_control_recs(self):
        ip, port, username, password, node_id, context = self.make_context()
        recs_power_driver = RECSPowerDriver()
        power_control_recs_mock = self.patch(recs_power_driver,
                                             "power_control_recs")
        set_boot_source_recs_mock = self.patch(recs_power_driver,
                                               "set_boot_source_recs")
        recs_power_driver.power_on(context["node_id"], context)

        self.assertThat(
            power_control_recs_mock,
            MockCalledOnceWith(ip, port, username, password, node_id, "on"),
        )
        self.assertThat(
            set_boot_source_recs_mock,
            MockCallsMatch(
                call(ip, port, username, password, node_id, "HDD", True),
                call(ip, port, username, password, node_id, "PXE", False),
            ),
        )
Esempio n. 8
0
 def test_power_control_recs_crashes_on_invalid_action(self):
     ip, port, username, password, node_id, context = self.make_context()
     recs_power_driver = RECSPowerDriver()
     self.assertRaises(
         RECSError,
         recs_power_driver.power_control_recs,
         ip,
         port,
         username,
         password,
         node_id,
         factory.make_name("action"),
     )
Esempio n. 9
0
 def test_power_control_recs_calls_set_power(self):
     ip, port, username, password, node_id, context = self.make_context()
     recs_power_driver = RECSPowerDriver()
     mock_set_power = self.patch(RECSAPI, "_set_power")
     recs_power_driver.power_control_recs(ip, port, username, password,
                                          node_id, 'on')
     recs_power_driver.power_control_recs(ip, port, username, password,
                                          node_id, 'off')
     self.assertThat(
         mock_set_power,
         MockCallsMatch(call(node_id, 'power_on'),
                        call(node_id, 'power_off')))
Esempio n. 10
0
# Register all the power drivers.
power_drivers = [
    AMTPowerDriver(),
    APCPowerDriver(),
    DLIPowerDriver(),
    HMCPowerDriver(),
    IPMIPowerDriver(),
    LXDPowerDriver(),
    ManualPowerDriver(),
    MoonshotIPMIPowerDriver(),
    MSCMPowerDriver(),
    MicrosoftOCSPowerDriver(),
    NovaPowerDriver(),
    OpenBMCPowerDriver(),
    RECSPowerDriver(),
    RedfishPowerDriver(),
    SeaMicroPowerDriver(),
    UCSMPowerDriver(),
    VirshPowerDriver(),
    VMwarePowerDriver(),
    WedgePowerDriver(),
]
for driver in power_drivers:
    PowerDriverRegistry.register_item(driver.name, driver)


# Pod drivers are also power drivers.
for driver_name, driver in PodDriverRegistry:
    PowerDriverRegistry.register_item(driver_name, driver)
Esempio n. 11
0
 def test_no_missing_packages(self):
     mock = self.patch(has_command_available)
     mock.return_value = True
     driver = RECSPowerDriver()
     missing = driver.detect_missing_packages()
     self.assertItemsEqual([], missing)