Exemple #1
0
 def power_query(self, system_id, context):
     """Power query SeaMicro node."""
     # Query the state.
     # Only supported by REST v2.
     ip, username, password, server_id, power_control = (
         extract_seamicro_parameters(context))
     if power_control == 'restapi2':
         return power_query_seamicro15k_v2(ip, username, password,
                                           server_id)
     else:
         return 'unknown'
Exemple #2
0
    def test_power_query_seamicro15k_v2_power_off(self):
        ip = factory.make_ipv4_address()
        username = factory.make_string()
        password = factory.make_string()

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

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

        self.assertEqual(
            "off", power_query_seamicro15k_v2(ip, username, password, "0"))
Exemple #3
0
    def test_power_query_seamicro15k_v2_power_on(self):
        ip = factory.make_ipv4_address()
        username = factory.make_string()
        password = factory.make_string()

        fake_server = FakeServer('0/0')
        self.patch(fake_server, 'active', True)
        fake_client = FakeSeaMicroClient()
        fake_client.servers = FakeSeaMicroServerManager()
        fake_client.servers.servers.append(fake_server)

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

        self.assertEqual(
            "on", power_query_seamicro15k_v2(ip, username, password, '0'))