Merge lp:~blake-rouse/maas/fix-sm15k-v2 into lp:~maas-committers/maas/trunk

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 2231
Proposed branch: lp:~blake-rouse/maas/fix-sm15k-v2
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 151 lines (+34/-26)
3 files modified
etc/maas/templates/power/sm15k.template (+3/-3)
src/provisioningserver/custom_hardware/seamicro.py (+12/-11)
src/provisioningserver/custom_hardware/tests/test_seamicro.py (+19/-12)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-sm15k-v2
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+214338@code.launchpad.net

Commit message

Fix SM15k v2.0 API enlistment issue.

Description of the change

Fixes some issues on how the python-seamicroclient returned data. This has been test on actual hardware.

Also there was weird unicode spaces in the sm15k.template, that was removed.

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

lgtm!

review: Approve
Revision history for this message
Gavin Panella (allenap) wrote :

You'll need to back-port this to lp:maas/1.5 if you want to get this into Trusty; trunk has now moved on already. See existing commits to the 1.5 branch for the commit message style.

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

Already done!
On Apr 4, 2014 6:02 PM, "Gavin Panella" <email address hidden> wrote:

> You'll need to back-port this to lp:maas/1.5 if you want to get this into
> Trusty; trunk has now moved on already. See existing commits to the 1.5
> branch for the commit message style.
> --
> https://code.launchpad.net/~blake-rouse/maas/fix-sm15k-v2/+merge/214338
> You are the owner of lp:~blake-rouse/maas/fix-sm15k-v2.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'etc/maas/templates/power/sm15k.template'
2--- etc/maas/templates/power/sm15k.template 2014-03-14 20:41:35 +0000
3+++ etc/maas/templates/power/sm15k.template 2014-04-04 21:11:12 +0000
4@@ -19,9 +19,9 @@
5 # Control power using IPMI
6 issue_ipmi_command() {
7 ${ipmitool} -I lanplus \
8-        -H ${power_address} -U ${power_user}\
9-        -P ${power_pass} raw 0x2E 1 0x00 0x7d 0xab \
10-        ${power_mode} 0 ${system_id}
11+ -H ${power_address} -U ${power_user}\
12+ -P ${power_pass} raw 0x2E 1 0x00 0x7d 0xab \
13+ ${power_mode} 0 ${system_id}
14 }
15
16 # Control power using REST v0.9
17
18=== modified file 'src/provisioningserver/custom_hardware/seamicro.py'
19--- src/provisioningserver/custom_hardware/seamicro.py 2014-03-27 04:15:45 +0000
20+++ src/provisioningserver/custom_hardware/seamicro.py 2014-04-04 21:11:12 +0000
21@@ -24,8 +24,10 @@
22 import urlparse
23
24 import provisioningserver.custom_hardware.utils as utils
25+from seamicroclient.v2 import (
26+ client as seamicro_client,
27+ )
28 from seamicroclient import (
29- client as seamicro_client,
30 exceptions as seamicro_exceptions,
31 )
32
33@@ -212,10 +214,10 @@
34 return None
35 return api
36 elif version == 'v2.0':
37- url = 'http://%s' % ip
38+ url = 'http://%s/v2.0' % ip
39 try:
40 api = seamicro_client.Client(
41- '2', auth_url=url, username=username, password=password)
42+ auth_url=url, username=username, password=password)
43 except seamicro_exceptions.ConnectionRefused:
44 # Cannot reach using v2.0, might no be supported
45 return None
46@@ -240,14 +242,12 @@
47 if server['serverNIC'] == '0'
48 )
49 elif version == 'v2.0':
50- return (
51- (server.id, server.serverMacAddr)
52- for server in
53- api.servers.list()
54- # There are 8 network cards attached to these boxes, we only
55- # use NIC 0 for PXE booting.
56- if server.serverNIC == '0'
57- )
58+ servers = []
59+ for server in api.servers.list():
60+ id = server.id.split('/')[0]
61+ macs = [nic['macAddr'] for nic in server.nic.values()]
62+ servers.append((id, macs))
63+ return servers
64 return None
65
66
67@@ -316,6 +316,7 @@
68
69 def power_control_seamicro15k_v2(ip, username, password, server_id,
70 power_change):
71+ server_id = '%s/0' % server_id
72 api = get_seamicro15k_api('v2.0', ip, username, password)
73 if api:
74 server = api.servers.get(server_id)
75
76=== modified file 'src/provisioningserver/custom_hardware/tests/test_seamicro.py'
77--- src/provisioningserver/custom_hardware/tests/test_seamicro.py 2014-03-17 14:32:20 +0000
78+++ src/provisioningserver/custom_hardware/tests/test_seamicro.py 2014-04-04 21:11:12 +0000
79@@ -60,10 +60,15 @@
80
81 class FakeServer(object):
82
83- def __init__(self, id, serverNIC='0'):
84+ def __init__(self, id):
85 self.id = id
86- self.serverNIC = serverNIC
87- self.serverMacAddr = factory.getRandomMACAddress()
88+ self.nic = {}
89+
90+ def add_fake_nic(self, id):
91+ self.nic[id] = {'macAddr': factory.getRandomMACAddress()}
92+
93+ def get_fake_macs(self):
94+ return [nic['macAddr'] for nic in self.nic.values()]
95
96
97 class FakeSeaMicroServerManager(object):
98@@ -398,14 +403,16 @@
99 username = factory.getRandomString()
100 password = factory.getRandomString()
101
102- fake_server_0 = FakeServer('0')
103- fake_server_1 = FakeServer('1')
104- fake_server_invalid_nic = FakeServer('2', serverNIC='1')
105+ fake_server_0 = FakeServer('0/0')
106+ fake_server_0.add_fake_nic('0')
107+ fake_server_0.add_fake_nic('1')
108+ fake_server_1 = FakeServer('1/0')
109+ fake_server_1.add_fake_nic('0')
110+ fake_server_1.add_fake_nic('1')
111 fake_client = FakeSeaMicroClient()
112 fake_client.servers = FakeSeaMicroServerManager()
113 fake_client.servers.servers.append(fake_server_0)
114 fake_client.servers.servers.append(fake_server_1)
115- fake_client.servers.servers.append(fake_server_invalid_nic)
116 mock_get_api = self.patch(
117 provisioningserver.custom_hardware.seamicro,
118 'get_seamicro15k_api')
119@@ -422,19 +429,19 @@
120 mock_create_node,
121 MockCallsMatch(
122 call(
123- fake_server_0.serverMacAddr, 'amd64', 'sm15k',
124+ fake_server_0.get_fake_macs(), 'amd64', 'sm15k',
125 {
126 'power_control': 'restapi2',
127- 'system_id': fake_server_0.id,
128+ 'system_id': '0',
129 'power_address': ip,
130 'power_pass': password,
131 'power_user': username
132 }),
133 call(
134- fake_server_1.serverMacAddr, 'amd64', 'sm15k',
135+ fake_server_1.get_fake_macs(), 'amd64', 'sm15k',
136 {
137 'power_control': 'restapi2',
138- 'system_id': fake_server_1.id,
139+ 'system_id': '1',
140 'power_address': ip,
141 'power_pass': password,
142 'power_user': username
143@@ -445,7 +452,7 @@
144 username = factory.getRandomString()
145 password = factory.getRandomString()
146
147- fake_server = FakeServer('0')
148+ fake_server = FakeServer('0/0')
149 fake_client = FakeSeaMicroClient()
150 fake_client.servers = FakeSeaMicroServerManager()
151 fake_client.servers.servers.append(fake_server)