~ubuntu-branches/ubuntu/utopic/python-softlayer/utopic

« back to all changes in this revision

Viewing changes to SoftLayer/CLI/modules/nas.py

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2014-04-28 12:35:22 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140428123522-6fvzd0rr6ato22jx
Tags: 3.1.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
The available commands are:
7
7
  list  List NAS accounts
8
8
"""
9
 
# :copyright: (c) 2013, SoftLayer Technologies, Inc. All rights reserved.
10
9
# :license: MIT, see LICENSE for more details.
11
10
 
12
11
from SoftLayer.CLI import CLIRunnable, Table, FormattedItem
26
25
    def execute(self, args):
27
26
        account = self.client['Account']
28
27
 
29
 
        nas = account.getNasNetworkStorage(
 
28
        nas_accounts = account.getNasNetworkStorage(
30
29
            mask='eventCount,serviceResource[datacenter.name]')
31
 
        nas = [NestedDict(n) for n in nas]
32
 
 
33
 
        t = Table(['id', 'datacenter', 'size', 'username', 'password',
34
 
                   'server'])
35
 
 
36
 
        for n in nas:
37
 
            t.add_row([
38
 
                n['id'],
39
 
                n['serviceResource']['datacenter'].get('name', blank()),
 
30
        nas_accounts = [NestedDict(n) for n in nas_accounts]
 
31
 
 
32
        table = Table(['id', 'datacenter', 'size', 'username', 'password',
 
33
                       'server'])
 
34
 
 
35
        for nas_account in nas_accounts:
 
36
            table.add_row([
 
37
                nas_account['id'],
 
38
                nas_account['serviceResource']['datacenter'].get('name',
 
39
                                                                 blank()),
40
40
                FormattedItem(
41
 
                    n.get('capacityGb', blank()),
42
 
                    "%dGB" % n.get('capacityGb', 0)),
43
 
                n.get('username', blank()),
44
 
                n.get('password', blank()),
45
 
                n.get('serviceResourceBackendIpAddress', blank())])
 
41
                    nas_account.get('capacityGb', blank()),
 
42
                    "%dGB" % nas_account.get('capacityGb', 0)),
 
43
                nas_account.get('username', blank()),
 
44
                nas_account.get('password', blank()),
 
45
                nas_account.get('serviceResourceBackendIpAddress', blank())])
46
46
 
47
 
        return t
 
47
        return table