Merge lp:~julian-edwards/maas/virsh-power-cleanup into lp:~maas-committers/maas/trunk

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 1728
Proposed branch: lp:~julian-edwards/maas/virsh-power-cleanup
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 96 lines (+48/-7)
4 files modified
docs/nodes.rst (+46/-0)
etc/maas/templates/power/virsh.template (+0/-2)
src/maasserver/power_parameters.py (+0/-3)
src/provisioningserver/power/tests/test_poweraction.py (+2/-2)
To merge this branch: bzr merge lp:~julian-edwards/maas/virsh-power-cleanup
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+194441@code.launchpad.net

Commit message

Two bugs for the price of one: Fix the virsh power parameters input boxes, plus document how to set up virsh.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'docs/media/virsh-config.png'
2Binary files docs/media/virsh-config.png 1970-01-01 00:00:00 +0000 and docs/media/virsh-config.png 2013-11-08 04:07:46 +0000 differ
3=== modified file 'docs/nodes.rst'
4--- docs/nodes.rst 2013-06-07 16:26:25 +0000
5+++ docs/nodes.rst 2013-11-08 04:07:46 +0000
6@@ -46,3 +46,49 @@
7
8 If you know the MAC address of a node, you can manually enter details
9 about the node through the web interface.
10+
11+
12+Virtual machine nodes
13+---------------------
14+
15+If you're setting up virtual machines to use as nodes with MAAS, you need
16+to configure the power type as ``virsh``. For MAAS to be able to use
17+virsh, make sure you have the ``libvirt-bin`` package installed.
18+
19+The virsh power type takes two parameters:
20+
21+Power ID
22+ The Power ID is the name of the virtual machine shown by
23+ ``sudo virsh list --all``
24+
25+Address
26+ This is a libvirt connection string, such as
27+ ``qemu+ssh://ubuntu@10.0.0.2/system`` or ``qemu:///system``
28+
29+.. image:: media/virsh-config.png
30+
31+If you want to use ssh you'll need to generate a ssh key pair for the maas
32+user. By default there is no home directory created for the maas user::
33+
34+ $ sudo mkdir /home/maas
35+ $ sudo chown maas:maas /home/maas
36+
37+Add a login shell for the maas user::
38+
39+ $ sudo chsh maas
40+ $ /bin/bash
41+
42+Become the maas user and generate a SSH keypair::
43+
44+ # sudo su - maas
45+ $ ssh-keygen
46+
47+Then add the public key to ``/ubuntu/.ssh/authorized_keys`` on the vm server
48+so virsh can use ssh without a password::
49+
50+ $ ssh-copy-id -i ~/.ssh/id_rsa ubuntu@10.0.0.2
51+
52+As the maas user, test virsh commands against libvirt at 10.0.0.2::
53+
54+ $ virsh -c qemu+ssh://ubuntu@10.0.0.2/system list --all
55+
56
57=== modified file 'etc/maas/templates/power/virsh.template'
58--- etc/maas/templates/power/virsh.template 2012-06-14 05:52:58 +0000
59+++ etc/maas/templates/power/virsh.template 2013-11-08 04:07:46 +0000
60@@ -7,8 +7,6 @@
61 power_change={{power_change}}
62 power_address={{power_address}}
63 power_id={{power_id}}
64-username={{username}}
65-system_id={{system_id}}
66 virsh={{virsh}}
67
68
69
70=== modified file 'src/maasserver/power_parameters.py'
71--- src/maasserver/power_parameters.py 2013-10-18 09:54:17 +0000
72+++ src/maasserver/power_parameters.py 2013-11-08 04:07:46 +0000
73@@ -54,9 +54,6 @@
74 skip_check=True),
75 POWER_TYPE.VIRSH: DictCharField(
76 [
77- ('driver', forms.CharField(label="Driver", required=False)),
78- ('username',
79- forms.CharField(label="Username", required=False)),
80 ('power_address',
81 forms.CharField(label="Address", required=False)),
82 ('power_id',
83
84=== modified file 'src/provisioningserver/power/tests/test_poweraction.py'
85--- src/provisioningserver/power/tests/test_poweraction.py 2013-10-15 11:35:10 +0000
86+++ src/provisioningserver/power/tests/test_poweraction.py 2013-11-08 04:07:46 +0000
87@@ -168,8 +168,8 @@
88 action = PowerAction(POWER_TYPE.VIRSH)
89 script = action.render_template(
90 action.get_template(), power_change='on',
91- power_address='qemu://example.com/', system_id='mysystem',
92- power_id='mysystem', username='me', virsh='echo')
93+ power_address='qemu://example.com/',
94+ power_id='mysystem', virsh='echo')
95 output = action.run_shell(script)
96 self.assertIn("Got unknown power state from virsh", output)
97