Exemple #1
0
 def _power(self, power_change, context):
     """Power SeaMicro node."""
     (
         ip,
         username,
         password,
         server_id,
         power_control,
     ) = extract_seamicro_parameters(context)
     if power_control == "ipmi":
         self._power_control_seamicro15k_ipmi(ip,
                                              username,
                                              password,
                                              server_id,
                                              power_change=power_change)
     elif power_control == "restapi":
         power_control_seamicro15k_v09(ip,
                                       username,
                                       password,
                                       server_id,
                                       power_change=power_change)
     elif power_control == "restapi2":
         power_control_seamicro15k_v2(ip,
                                      username,
                                      password,
                                      server_id,
                                      power_change=power_change)
Exemple #2
0
    def test_power_control_seamicro15k_v2(self):
        ip = factory.make_ipv4_address()
        username = factory.make_string()
        password = factory.make_string()

        fake_server = FakeServer("0/0")
        fake_client = FakeSeaMicroClient()
        fake_client.servers = FakeSeaMicroServerManager()
        fake_client.servers.servers.append(fake_server)
        mock_power_on = self.patch(fake_server, "power_on")

        mock_get_api = self.patch(seamicro, "get_seamicro15k_api")
        mock_get_api.return_value = fake_client

        power_control_seamicro15k_v2(ip, username, password, "0", "on")
        self.assertThat(mock_power_on, MockCalledOnceWith(using_pxe=True))