Virsh power driver does not seem to work at all

Bug #1357714 reported by Andres Rodriguez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Blake Rouse

Bug Description

When virsh address is, the folllowing error is shown (This means that there's no password because qemu:///system is localhost that does not require password)

qemu:///system

issue_virsh_command
' returned non-zero exit status 1:
Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
  File "/usr/lib/python2.7/dist-packages/provisioningserver/drivers/hardware/virsh.py", line 210, in power_control_virsh
    raise VirshError('Failed to login to virsh console.')
provisioningserver.drivers.hardware.virsh.VirshError: Failed to login to virsh console.
[2014-08-16 08:27:44,216: ERROR/MainProcess] Task provisioningserver.tasks.power_off[5ef02ca7-871e-4a85-bced-1f2975b0c269] raised unexpected: PowerActionFail(u'virsh failed: Command \'# -*- mode: shell-script -*-\n#\n# Control virtual system\'s "power" through virsh.\n#\n\nissue_virsh_command() {\npython - << END\nfrom provisioningserver.drivers.hardware.virsh import power_control_virsh\npower_control_virsh(\n u\'qemu:///system\',\n u\'test2\',\n u\'off\',\n u\'\',\n)\nEND\n}\n\nissue_virsh_command\n\' returned non-zero exit status 1:\nTraceback (most recent call last):\n File "<stdin>", line 6, in <module>\n File "/usr/lib/python2.7/dist-packages/provisioningserver/drivers/hardware/virsh.py", line 210, in power_control_virsh\n raise VirshError(\'Failed to login to virsh console.\')\nprovisioningserver.drivers.hardware.virsh.VirshError: Failed to login to virsh console.',)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/celery/app/trace.py", line 218, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/celery/app/trace.py", line 398, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/provisioningserver/tasks.py", line 102, in wrapper
    func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/provisioningserver/tasks.py", line 121, in wrapper
    func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/provisioningserver/tasks.py", line 202, in power_off
    pa.execute(power_change='off', **kwargs)
  File "/usr/lib/python2.7/dist-packages/provisioningserver/power/poweraction.py", line 130, in execute
    return self.run_shell(rendered)
  File "/usr/lib/python2.7/dist-packages/provisioningserver/power/poweraction.py", line 114, in run_shell
    raise PowerActionFail.from_action(self, e)
PowerActionFail: virsh failed: Command '# -*- mode: shell-script -*-
#
# Control virtual system's "power" through virsh.
#

issue_virsh_command() {
python - << END
from provisioningserver.drivers.hardware.virsh import power_control_virsh
power_control_virsh(
    u'qemu:///system',
    u'test2',
    u'off',
    u'',
)
END
}

issue_virsh_command
' returned non-zero exit status 1:
Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
  File "/usr/lib/python2.7/dist-packages/provisioningserver/drivers/hardware/virsh.py", line 210, in power_control_virsh
    raise VirshError('Failed to login to virsh console.')
provisioningserver.drivers.hardware.virsh.VirshError: Failed to login to virsh console.

=====================

IT is also affected in other escenarios:

PowerActionFail: virsh failed: Command '# -*- mode: shell-script -*-
#
# Control virtual system's "power" through virsh.
#

issue_virsh_command() {
python - << END
from provisioningserver.drivers.hardware.virsh import power_control_virsh
power_control_virsh(
    u'qemu+ssh://192.168.122.1/system',
    u'test2',
    u'on',
    u'test',
)
END
}

issue_virsh_command
' returned non-zero exit status 1:
Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
  File "/usr/lib/python2.7/dist-packages/provisioningserver/drivers/hardware/virsh.py", line 210, in power_control_virsh
    raise VirshError('Failed to login to virsh console.')
provisioningserver.drivers.hardware.virsh.VirshError: Failed to login to virsh console.

=========================

issue_virsh_command() {
python - << END
from provisioningserver.drivers.hardware.virsh import power_control_virsh
power_control_virsh(
    u'192.168.122.1',
    u'test2',
    u'on',
    u'test',
)
END
}

issue_virsh_command
' returned non-zero exit status 1:
Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
  File "/usr/lib/python2.7/dist-packages/provisioningserver/drivers/hardware/virsh.py", line 210, in power_control_virsh
    raise VirshError('Failed to login to virsh console.')
provisioningserver.drivers.hardware.virsh.VirshError: Failed to login to virsh console.

Tags: hwe

Related branches

tags: added: hwe
Changed in maas:
assignee: nobody → Blake Rouse (blake-rouse)
description: updated
Changed in maas:
status: New → Confirmed
importance: Undecided → High
Changed in maas:
status: Confirmed → Triaged
summary: - Virsh power driver does not handle cases where virsh address is
- qemu:///system
+ Virsh power driver does not seem to work at all
Revision history for this message
Julian Edwards (julian-edwards) wrote :

Let's get this fixed in the next release!

Changed in maas:
milestone: none → 1.6.1
Revision history for this message
Blake Rouse (blake-rouse) wrote :

I just tested this on my system and using qemu:///system worked correctly with no issues.

I think it might be that the user MAAS is running as does not have access to the libvirt-bin group. If you are running from packaging then this is the case, I am running from a dev enviorment as my standard user that is a member of the libvirt-bin group and its works correctly.

If you want the maas user to be a member of the libvirt-bin group by default, then you will have to fix that in packaging.

Changed in maas:
status: Triaged → Incomplete
Revision history for this message
Andres Rodriguez (andreserl) wrote : Re: [Bug 1357714] Re: Virsh power driver does not seem to work at all

Blake,

Thanks for looking at it. What in the case where I use
qemu+ssh://<ip>/system ?

On Mon, Aug 18, 2014 at 9:19 AM, Blake Rouse <email address hidden>
wrote:

> I just tested this on my system and using qemu:///system worked
> correctly with no issues.
>
> I think it might be that the user MAAS is running as does not have
> access to the libvirt-bin group. If you are running from packaging then
> this is the case, I am running from a dev enviorment as my standard user
> that is a member of the libvirt-bin group and its works correctly.
>
> If you want the maas user to be a member of the libvirt-bin group by
> default, then you will have to fix that in packaging.
>
> ** Changed in: maas
> Status: Triaged => Incomplete
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1357714
>
> Title:
> Virsh power driver does not seem to work at all
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/maas/+bug/1357714/+subscriptions
>

--
Andres Rodriguez (RoAkSoAx)
Ubuntu Server Developer
MSc. Telecom & Networking
Systems Engineer

Revision history for this message
Blake Rouse (blake-rouse) wrote :

That works as well. All is working fine on my machine. Check that the user you are logging in with has permissions to virsh. It that string you are not providing a user, so it will use your local username. If that doesn't exist or doesn't have permissions to virsh then it will fail.

This work on PowerKVM and has been certified, so it should be working fine.

The following is what I tested:

qemu:///system
qemu+ssh://localhost/system
qemu+ssh://user@localhost/system

Revision history for this message
Blake Rouse (blake-rouse) wrote :

This issue is because if the ssh key has not been accepted then it will skip waiting for password prompt.

Changed in maas:
status: Incomplete → Triaged
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.