~smoser/ubuntu/trusty/maas/lp-1172566

« back to all changes in this revision

Viewing changes to src/provisioningserver/custom_hardware/seamicro.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-04-03 13:45:02 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20140403134502-8a6wvuqwyuekufh0
Tags: upstream-1.5+bzr2227
ImportĀ upstreamĀ versionĀ 1.5+bzr2227

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import urlparse
25
25
 
26
26
import provisioningserver.custom_hardware.utils as utils
 
27
from seamicroclient.v2 import (
 
28
    client as seamicro_client,
 
29
    )
27
30
from seamicroclient import (
28
 
    client as seamicro_client,
29
31
    exceptions as seamicro_exceptions,
30
32
    )
31
33
 
212
214
            return None
213
215
        return api
214
216
    elif version == 'v2.0':
215
 
        url = 'http://%s' % ip
 
217
        url = 'http://%s/v2.0' % ip
216
218
        try:
217
219
            api = seamicro_client.Client(
218
 
                '2', auth_url=url, username=username, password=password)
 
220
                auth_url=url, username=username, password=password)
219
221
        except seamicro_exceptions.ConnectionRefused:
220
222
            # Cannot reach using v2.0, might no be supported
221
223
            return None
240
242
                if server['serverNIC'] == '0'
241
243
            )
242
244
        elif version == 'v2.0':
243
 
            return (
244
 
                (server.id, server.serverMacAddr)
245
 
                for server in
246
 
                api.servers.list()
247
 
                # There are 8 network cards attached to these boxes, we only
248
 
                # use NIC 0 for PXE booting.
249
 
                if server.serverNIC == '0'
250
 
            )
 
245
            servers = []
 
246
            for server in api.servers.list():
 
247
                id = server.id.split('/')[0]
 
248
                macs = [nic['macAddr'] for nic in server.nic.values()]
 
249
                servers.append((id, macs))
 
250
            return servers
251
251
    return None
252
252
 
253
253
 
316
316
 
317
317
def power_control_seamicro15k_v2(ip, username, password, server_id,
318
318
                                 power_change):
 
319
    server_id = '%s/0' % server_id
319
320
    api = get_seamicro15k_api('v2.0', ip, username, password)
320
321
    if api:
321
322
        server = api.servers.get(server_id)