Exemplo n.º 1
0
    def test_power_control_off(self):
        mock_login = self.patch(virsh.VirshSSH, 'login')
        mock_login.return_value = True
        mock_state = self.patch(virsh.VirshSSH, 'get_state')
        mock_state.return_value = virsh.VirshVMState.ON
        mock_poweroff = self.patch(virsh.VirshSSH, 'poweroff')

        poweraddr = factory.make_name('poweraddr')
        machine = factory.make_name('machine')
        virsh.power_control_virsh(poweraddr, machine, 'off')

        self.assertThat(mock_login, MockCalledOnceWith(poweraddr, None))
        self.assertThat(mock_state, MockCalledOnceWith(machine))
        self.assertThat(mock_poweroff, MockCalledOnceWith(machine))
Exemplo n.º 2
0
    def test_power_control_off(self):
        mock_login = self.patch(virsh.VirshSSH, "login")
        mock_login.return_value = True
        mock_state = self.patch(virsh.VirshSSH, "get_state")
        mock_state.return_value = virsh.VirshVMState.ON
        mock_poweroff = self.patch(virsh.VirshSSH, "poweroff")

        poweraddr = factory.make_name("poweraddr")
        machine = factory.make_name("machine")
        virsh.power_control_virsh(poweraddr, machine, "off")

        self.assertThat(mock_login, MockCalledOnceWith(poweraddr, None))
        self.assertThat(mock_state, MockCalledOnceWith(machine))
        self.assertThat(mock_poweroff, MockCalledOnceWith(machine))
Exemplo n.º 3
0
 def power_off(self, system_id, context):
     """Power off Virsh node."""
     power_change = 'off'
     poweraddr, machine, password = extract_virsh_parameters(context)
     power_control_virsh(poweraddr, machine, power_change, password)