Exemple #1
0
    def test_get_amt_command_returns_wsman(self):
        amt_power_driver = AMTPowerDriver()
        ip_address = factory.make_ipv4_address()
        power_pass = factory.make_name("power_pass")
        mock_run_command = self.patch_run_command(
            stdout=WSMAN_IDENTIFY_OUTPUT % b"10.0.47",
            stderr=b"stderr",
            decode=True,
        )
        result = amt_power_driver._get_amt_command(ip_address, power_pass)

        mock_run_command.assert_called_once_with(
            "wsman",
            "-C",
            "/etc/openwsman/openwsman_client.conf",
            "identify",
            "--port",
            "16992",
            "--hostname",
            ip_address,
            "--username",
            "admin",
            "--password",
            power_pass,
        )
        self.expectThat(result, Equals("wsman"))
Exemple #2
0
    def test__get_amt_command_returns_wsman(self):
        amt_power_driver = AMTPowerDriver()
        ip_address = factory.make_ipv4_address()
        power_pass = factory.make_name('power_pass')
        amt_environment_mock = self.patch(amt_power_driver,
                                          '_get_amt_environment')
        amt_environment_mock.return_value = None
        popen_mock = self.patch_popen(return_value=(WSMAN_IDENTIFY_OUTPUT %
                                                    b'10.0.47', b'stderr'))

        result = amt_power_driver._get_amt_command(ip_address, power_pass)

        self.expectThat(amt_environment_mock, MockCalledOnceWith(power_pass))
        self.expectThat(popen_mock.communicate, MockCalledOnceWith())
        self.expectThat(result, Equals('wsman'))
Exemple #3
0
    def test__get_amt_command_returns_amttool(self):
        amt_power_driver = AMTPowerDriver()
        ip_address = factory.make_ipv4_address()
        power_pass = factory.make_name("power_pass")
        amt_environment_mock = self.patch(amt_power_driver,
                                          "_get_amt_environment")
        amt_environment_mock.return_value = None
        popen_mock = self.patch_popen(return_value=(WSMAN_IDENTIFY_OUTPUT %
                                                    b"8.1.57", b"stderr"))

        result = amt_power_driver._get_amt_command(ip_address, power_pass)

        self.expectThat(amt_environment_mock, MockCalledOnceWith(power_pass))
        self.expectThat(popen_mock.communicate, MockCalledOnceWith())
        self.expectThat(result, Equals("amttool"))
Exemple #4
0
    def test__get_amt_command_returns_amttool(self):
        amt_power_driver = AMTPowerDriver()
        ip_address = factory.make_ipv4_address()
        power_pass = factory.make_name('power_pass')
        amt_environment_mock = self.patch(
            amt_power_driver, '_get_amt_environment')
        amt_environment_mock.return_value = None
        popen_mock = self.patch_popen(return_value=(
            AMTTOOL_OUTPUT % (b'8.1.57', b''), b'stderr'))

        result = amt_power_driver._get_amt_command(ip_address, power_pass)

        self.expectThat(
            amt_environment_mock, MockCalledOnceWith(power_pass))
        self.expectThat(popen_mock.communicate, MockCalledOnceWith())
        self.expectThat(result, Equals('amttool'))