Revision c51f3a08 snf-cyclades-app/synnefo/api/management/commands/network-list.py

b/snf-cyclades-app/synnefo/api/management/commands/network-list.py
34 34
from optparse import make_option
35 35

  
36 36
from django.core.management.base import BaseCommand, CommandError
37
from synnefo.management.common import format_bool, filter_results
37
from synnefo.management.common import format_bool, filter_results, UUIDCache
38 38
from synnefo.db.models import Network
39 39
from synnefo.management.common import pprint_table
40 40

  
......
70 70
            help="Filter results. Comma seperated list of key 'cond' val pairs"
71 71
                 " that displayed entries must satisfy. e.g."
72 72
                 " --filter-by \"name=Network-1,link!=prv0\"."
73
                 " Available keys are: %s" % ", ".join(FIELDS))
74

  
73
                 " Available keys are: %s" % ", ".join(FIELDS)),
74
        make_option('--uuids',
75
            action='store_true',
76
            dest='use_uuids',
77
            default=False,
78
            help="Display UUIDs instead of user emails"),
75 79
        )
76 80

  
77 81
    def handle(self, *args, **options):
......
98 102
        else:
99 103
            headers.extend(['IPv4 Subnet', 'IPv4 Gateway'])
100 104

  
105
        if options['use_uuids'] is False:
106
            ucache = UUIDCache()
107

  
101 108
        table = []
102 109
        for network in networks.order_by("id"):
110
            user = network.userid
111
            if options['use_uuids'] is False:
112
                user = ucache.get_user(network.userid)
113

  
103 114
            fields = [str(network.id),
104 115
                      network.name,
105 116
                      network.flavor,
106
                      network.userid or '',
117
                      user or '',
107 118
                      network.mac_prefix or '',
108 119
                      str(network.dhcp),
109 120
                      network.state,

Also available in: Unified diff