Revision 9621c777

b/snf-cyclades-app/synnefo/api/management/commands/cyclades-export-quota.py
40 40
class Command(NoArgsCommand):
41 41
    help = "Export account quota policies"
42 42
    option_list = NoArgsCommand.option_list + (
43
        make_option('--location',
44
                dest='location',
45
                default='exported_quota',
46
                help="Where to save the output file"),
43
        make_option(
44
            '--location',
45
            dest='location',
46
            default='exported_quota',
47
            help="Where to save the output file"),
47 48
    )
48 49

  
49 50
    def handle_noargs(self, **options):
......
65 66
            f.write('\n')
66 67
        for user, value in nets_per_user.items():
67 68
            f.write(' '.join([user, "cyclades.network.private", "%s" % value,
68
                            '0', '0', '0']))
69
                             '0', '0', '0']))
69 70
            f.write('\n')
70 71

  
71 72
        f.close()
b/snf-cyclades-app/synnefo/api/management/commands/flavor-create.py
44 44
           "<ram>[,<ram>,...] " \
45 45
           "<disk>[,<disk>,...] " \
46 46
           "<disk template>[,<disk template>,...]"
47
    help = "Create one or more flavors.\n\nThe flavors that will be created are"\
47
    help = "Create one or more flavors.\n\n"\
48
           " The flavors that will be created are"\
48 49
           " those belonging to the cartesian product of the arguments"\
49 50

  
51

  
50 52
    def handle(self, *args, **options):
51 53
        if len(args) != 4:
52 54
            raise CommandError("Invalid number of arguments")
b/snf-cyclades-app/synnefo/api/management/commands/flavor-list.py
46 46
    help = "List flavors"
47 47

  
48 48
    option_list = BaseCommand.option_list + (
49
        make_option('-c',
49
        make_option(
50
            '-c',
50 51
            action='store_true',
51 52
            dest='csv',
52 53
            default=False,
53 54
            help="Use pipes to separate values"),
54
        make_option('--deleted',
55
        make_option(
56
            '--deleted',
55 57
            action='store_true',
56 58
            dest='deleted',
57 59
            default=False,
58 60
            help="Include deleted flavors"),
59
         make_option('--filter-by',
61
        make_option(
62
            '--filter-by',
60 63
            dest='filter_by',
61 64
            help="Filter results. Comma seperated list of key=val pairs"
62 65
                 " that displayed entries must satisfy. e.g."
63 66
                 " --filter-by \"cpu=1,ram!=1024\"."
64 67
                 "Available keys are: %s" % ", ".join(FIELDS))
65
        )
68
    )
66 69

  
67 70
    def handle(self, *args, **options):
68 71
        if args:
b/snf-cyclades-app/synnefo/api/management/commands/flavor-modify.py
37 37
from synnefo.management.common import get_flavor
38 38

  
39 39

  
40

  
41 40
class Command(BaseCommand):
42 41
    args = "<flavor id>"
43 42
    help = "Modify a flavor"
44 43

  
45 44
    option_list = BaseCommand.option_list + (
46
        make_option('--set-deleted',
45
        make_option(
46
            '--set-deleted',
47 47
            action='store_true',
48 48
            dest='deleted',
49 49
            help="Mark a server as deleted"),
50
        make_option('--set-undeleted',
50
        make_option(
51
            '--set-undeleted',
51 52
            action='store_true',
52 53
            dest='undeleted',
53 54
            help="Mark a server as not deleted"),
54
        )
55
    )
55 56

  
56 57
    def handle(self, *args, **options):
57 58
        if len(args) != 1:
58 59
            raise CommandError("Please provide a flavor ID")
59 60

  
60

  
61 61
        flavor = get_flavor(args[0])
62 62

  
63 63
        if options.get('deleted'):
b/snf-cyclades-app/synnefo/api/management/commands/network-create.py
50 50
    help = "Create a new network"
51 51

  
52 52
    option_list = BaseCommand.option_list + (
53
        make_option('--name',
53
        make_option(
54
            '--name',
54 55
            dest='name',
55 56
            help="Name of network"),
56
        make_option('--owner',
57
        make_option(
58
            '--owner',
57 59
            dest='owner',
58 60
            help="The owner of the network"),
59
        make_option('--subnet',
61
        make_option(
62
            '--subnet',
60 63
            dest='subnet',
61 64
            default=None,
62 65
            # required=True,
63 66
            help='Subnet of the network'),
64
        make_option('--gateway',
67
        make_option(
68
            '--gateway',
65 69
            dest='gateway',
66 70
            default=None,
67 71
            help='Gateway of the network'),
68
        make_option('--subnet6',
72
        make_option(
73
            '--subnet6',
69 74
            dest='subnet6',
70 75
            default=None,
71 76
            help='IPv6 subnet of the network'),
72
        make_option('--gateway6',
77
        make_option(
78
            '--gateway6',
73 79
            dest='gateway6',
74 80
            default=None,
75 81
            help='IPv6 gateway of the network'),
76
        make_option('--dhcp',
82
        make_option(
83
            '--dhcp',
77 84
            dest='dhcp',
78 85
            action='store_true',
79 86
            default=False,
80 87
            help='Automatically assign IPs'),
81
        make_option('--public',
88
        make_option(
89
            '--public',
82 90
            dest='public',
83 91
            action='store_true',
84 92
            default=False,
85 93
            help='Network is public'),
86
        make_option('--flavor',
94
        make_option(
95
            '--flavor',
87 96
            dest='flavor',
88 97
            default=None,
89 98
            choices=NETWORK_FLAVORS,
90 99
            help='Network flavor. Choices: ' + ', '.join(NETWORK_FLAVORS)),
91
        make_option('--mode',
100
        make_option(
101
            '--mode',
92 102
            dest='mode',
93 103
            default=None,
94 104
            help="Overwrite flavor connectivity mode."),
95
        make_option('--link',
105
        make_option(
106
            '--link',
96 107
            dest='link',
97 108
            default=None,
98 109
            help="Overwrite flavor connectivity link."),
99
        make_option('--mac-prefix',
110
        make_option(
111
            '--mac-prefix',
100 112
            dest='mac_prefix',
101 113
            default=None,
102 114
            help="Overwrite flavor connectivity MAC prefix"),
103
        make_option('--tags',
115
        make_option(
116
            '--tags',
104 117
            dest='tags',
105 118
            default=None,
106 119
            help='The tags of the Network (comma separated strings)'),
107
        make_option('--backend-id',
120
        make_option(
121
            '--backend-id',
108 122
            dest='backend_id',
109 123
            default=None,
110 124
            help='ID of the backend that the network will be created. Only for'
111 125
                 ' public networks'),
112
        )
126
    )
113 127

  
114 128
    def handle(self, *args, **options):
115 129
        if args:
......
154 168
        subnet, gateway, subnet6, gateway6 = validate_network_info(options)
155 169

  
156 170
        if not link or not mode:
157
            raise CommandError("Can not create network. No connectivity link or mode")
158

  
159
        network = Network.objects.create(
160
                name=name,
161
                userid=options['owner'],
162
                subnet=subnet,
163
                gateway=gateway,
164
                gateway6=gateway6,
165
                subnet6=subnet6,
166
                dhcp=options['dhcp'],
167
                flavor=flavor,
168
                public=public,
169
                mode=mode,
170
                link=link,
171
                mac_prefix=mac_prefix,
172
                tags=tags,
173
                state='PENDING')
171
            raise CommandError("Can not create network."
172
                               " No connectivity link or mode")
173

  
174
        network = Network.objects.create(name=name,
175
                                         userid=options['owner'],
176
                                         subnet=subnet,
177
                                         gateway=gateway,
178
                                         gateway6=gateway6,
179
                                         subnet6=subnet6,
180
                                         dhcp=options['dhcp'],
181
                                         flavor=flavor,
182
                                         public=public,
183
                                         mode=mode,
184
                                         link=link,
185
                                         mac_prefix=mac_prefix,
186
                                         tags=tags,
187
                                         state='PENDING')
174 188

  
175 189
        if public:
176 190
            # Create BackendNetwork only to the specified Backend
b/snf-cyclades-app/synnefo/api/management/commands/network-list.py
45 45
    help = "List networks"
46 46

  
47 47
    option_list = BaseCommand.option_list + (
48
        make_option('-c',
48
        make_option(
49
            '-c',
49 50
            action='store_true',
50 51
            dest='csv',
51 52
            default=False,
52 53
            help="Use pipes to separate values"),
53
        make_option('--deleted',
54
        make_option(
55
            '--deleted',
54 56
            action='store_true',
55 57
            dest='deleted',
56 58
            default=False,
57 59
            help="Include deleted networks"),
58
        make_option('--public',
60
        make_option(
61
            '--public',
59 62
            action='store_true',
60 63
            dest='public',
61 64
            default=False,
62 65
            help="List only public networks"),
63
        make_option('--ipv6',
66
        make_option(
67
            '--ipv6',
64 68
            action='store_true',
65 69
            dest='ipv6',
66 70
            default=False,
67 71
            help="Show IPv6 information of the network"),
68
        make_option('--filter-by',
72
        make_option(
73
            '--filter-by',
69 74
            dest='filter_by',
70 75
            help="Filter results. Comma seperated list of key 'cond' val pairs"
71 76
                 " that displayed entries must satisfy. e.g."
......
77 82
            dest='use_uuids',
78 83
            default=False,
79 84
            help="Display UUIDs instead of user emails"),
80
        )
85
    )
81 86

  
82 87
    def handle(self, *args, **options):
83 88
        if args:
......
97 102
            networks = filter_results(networks, filter_by)
98 103

  
99 104
        headers = ['id', 'name', 'flavor', 'owner',
100
                  'mac_prefix', 'dhcp', 'state', 'link', 'vms', 'public']
105
                   'mac_prefix', 'dhcp', 'state', 'link', 'vms', 'public']
101 106

  
102 107
        if options['ipv6']:
103 108
            headers.extend(['IPv6 Subnet', 'IPv6 Gateway'])
b/snf-cyclades-app/synnefo/api/management/commands/network-modify.py
38 38
from synnefo.db.models import Network, pooled_rapi_client
39 39
from synnefo.management.common import validate_network_info, get_network
40 40

  
41
HELP_MSG = \
42
"""Modify a network.
41
HELP_MSG = """Modify a network.
43 42

  
44 43
This management command will only modify the state of the network in Cyclades
45 44
DB. The state of the network in the Ganeti backends will remain unchanged. You
......
57 56
    output_transaction = True
58 57

  
59 58
    option_list = BaseCommand.option_list + (
60
        make_option('--name',
59
        make_option(
60
            '--name',
61 61
            dest='name',
62 62
            metavar='NAME',
63 63
            help="Set network's name"),
64
        make_option('--userid',
64
        make_option(
65
            '--userid',
65 66
            dest='userid',
66 67
            help="Set the userid of the network owner"),
67
        make_option('--subnet',
68
        make_option(
69
            '--subnet',
68 70
            dest='subnet',
69 71
            help="Set network's subnet"),
70
        make_option('--gateway',
72
        make_option(
73
            '--gateway',
71 74
            dest='gateway',
72 75
            help="Set network's gateway"),
73
        make_option('--subnet6',
76
        make_option(
77
            '--subnet6',
74 78
            dest='subnet6',
75 79
            help="Set network's IPv6 subnet"),
76
        make_option('--gateway6',
80
        make_option(
81
            '--gateway6',
77 82
            dest='gateway6',
78 83
            help="Set network's IPv6 gateway"),
79
        make_option('--dhcp',
84
        make_option(
85
            '--dhcp',
80 86
            dest='dhcp',
81 87
            help="Set if network will use nfdhcp"),
82
        make_option('--state',
88
        make_option(
89
            '--state',
83 90
            dest='state',
84 91
            metavar='STATE',
85 92
            help="Set network's state"),
86
        make_option('--link',
93
        make_option(
94
            '--link',
87 95
            dest='link',
88 96
            help="Set the connectivity link"),
89
        make_option('--mac-prefix',
97
        make_option(
98
            '--mac-prefix',
90 99
            dest="mac_prefix",
91 100
            help="Set the MAC prefix"),
92
        make_option('--add-reserved-ips',
101
        make_option(
102
            '--add-reserved-ips',
93 103
            dest="add_reserved_ips",
94 104
            help="Comma seperated list of IPs to externally reserve."),
95
        make_option('--remove-reserved-ips',
105
        make_option(
106
            '--remove-reserved-ips',
96 107
            dest="remove_reserved_ips",
97 108
            help="Comma seperated list of IPs to externally release."),
98 109

  
b/snf-cyclades-app/synnefo/api/management/commands/server-create.py
56 56
    help = "Create a new VM." + HELP_MSG
57 57

  
58 58
    option_list = BaseCommand.option_list + (
59
            make_option("--backend-id", dest="backend_id",
60
                        help="Unique identifier of the Ganeti backend."
61
                             " Use snf-manage backend-list to find out"
62
                             " available backends."),
63
            make_option("--name", dest="name",
64
                        help="An arbitrary string for naming the server"),
65
            make_option("--user-id", dest="user_id",
66
                        help="Unique identifier of the owner of the server"),
67
            make_option("--image-id", dest="image_id",
68
                        help="Unique identifier of the image."
69
                             " Use snf-manage image-list to find out"
70
                             " available images."),
71
            make_option("--flavor-id", dest="flavor_id",
72
                        help="Unique identifier of the flavor"
73
                             " Use snf-manage flavor-list to find out"
74
                             " available flavors."),
75
            make_option("--password", dest="password",
76
                        help="Password for the new server")
77
        )
59
        make_option("--backend-id", dest="backend_id",
60
                    help="Unique identifier of the Ganeti backend."
61
                         " Use snf-manage backend-list to find out"
62
                         " available backends."),
63
        make_option("--name", dest="name",
64
                    help="An arbitrary string for naming the server"),
65
        make_option("--user-id", dest="user_id",
66
                    help="Unique identifier of the owner of the server"),
67
        make_option("--image-id", dest="image_id",
68
                    help="Unique identifier of the image."
69
                         " Use snf-manage image-list to find out"
70
                         " available images."),
71
        make_option("--flavor-id", dest="flavor_id",
72
                    help="Unique identifier of the flavor"
73
                         " Use snf-manage flavor-list to find out"
74
                         " available flavors."),
75
        make_option("--password", dest="password",
76
                    help="Password for the new server")
77
    )
78 78

  
79 79
    @transaction.commit_manually
80 80
    def handle(self, *args, **options):
......
106 106
            image = {}
107 107
            image['backend_id'] = img['location']
108 108
            image['format'] = img['disk_format']
109
            image['metadata'] = dict((key.upper(), val) \
109
            image['metadata'] = dict((key.upper(), val)
110 110
                                     for key, val in properties.items())
111 111
        else:
112 112
            raise CommandError("image-id is mandatory")
......
136 136
            # Get Public address
137 137
            (network, address) = util.allocate_public_address(backend)
138 138
            if address is None:
139
                raise CommandError("Can not allocate a public address."\
139
                raise CommandError("Can not allocate a public address."
140 140
                                   " No available public network.")
141 141
            nic = {'ip': address, 'network': network.backend_id}
142 142

  
b/snf-cyclades-app/synnefo/api/management/commands/server-import.py
65 65
    output_transaction = True
66 66

  
67 67
    option_list = BaseCommand.option_list + (
68
            make_option("--backend-id", dest="backend_id",
69
                        help="Unique identifier of the Ganeti backend that"
70
                             " hosts the VM. Use snf-manage backend-list to"
71
                             " find out available backends."),
72
            make_option("--user-id", dest="user_id",
73
                        help="Unique identifier of the owner of the server"),
74
            make_option("--image-id", dest="image_id",
75
                        default=None,
76
                        help="Unique identifier of the image."
77
                             " Use snf-manage image-list to find out"
78
                             " available images."),
79
            make_option("--flavor-id", dest="flavor_id",
80
                        help="Unique identifier of the flavor"
81
                             " Use snf-manage flavor-list to find out"
82
                             " available flavors."),
83
            make_option("--new-nics", dest='new_nics',
84
                        default=False,
85
                        action="store_true",
86
                        help="Remove old NICs of instance, and create"
87
                             " a new NIC connected to a public network of"
88
                             " Synnefo.")
89
        )
68
        make_option(
69
            "--backend-id",
70
            dest="backend_id",
71
            help="Unique identifier of the Ganeti backend that"
72
                 " hosts the VM. Use snf-manage backend-list to"
73
                 " find out available backends."),
74
        make_option(
75
            "--user-id",
76
            dest="user_id",
77
            help="Unique identifier of the owner of the server"),
78
        make_option(
79
            "--image-id",
80
            dest="image_id",
81
            default=None,
82
            help="Unique identifier of the image."
83
                 " Use snf-manage image-list to find out"
84
                 " available images."),
85
        make_option(
86
            "--flavor-id",
87
            dest="flavor_id",
88
            help="Unique identifier of the flavor"
89
                 " Use snf-manage flavor-list to find out"
90
                 " available flavors."),
91
        make_option(
92
            "--new-nics",
93
            dest='new_nics',
94
            default=False,
95
            action="store_true",
96
            help="Remove old NICs of instance, and create"
97
                 " a new NIC connected to a public network of"
98
                 " Synnefo.")
99
    )
90 100

  
91 101
    REQUIRED = ("user-id", "backend-id", "image-id", "flavor-id")
92 102

  
......
127 137
        instance = backend_client.GetInstance(instance_name)
128 138
    except GanetiApiError as e:
129 139
        if e.code == 404:
130
            raise CommandError("Instance %s does not exist in backend %s"\
131
                              % (instance_name, backend))
140
            raise CommandError("Instance %s does not exist in backend %s"
141
                               % (instance_name, backend))
132 142
        else:
133 143
            raise CommandError("Unexpected error" + str(e))
134 144

  
......
137 147
                             stream=stream)
138 148
        (network, address) = allocate_public_address(backend)
139 149
        if address is None:
140
            raise CommandError("Can not allocate a public address."\
150
            raise CommandError("Can not allocate a public address."
141 151
                               " No available public network.")
142 152
        nic = {'ip': address, 'network': network.backend_id}
143 153
        add_public_nic(instance_name, nic, backend_client,
......
187 197
        networks = map(id_from_network_name, networks)
188 198
    except Network.InvalidBackendIdError:
189 199
        raise CommandError("Instance %s has NICs that do not belong to a"
190
                          " network belonging to synnefo. Either manually"
191
                          " modify the instance NICs or specify --new-nics"
192
                          " to clear the old NICs and create a new NIC to"
193
                          " a public network of synnefo." % instance_name)
200
                           " network belonging to synnefo. Either manually"
201
                           " modify the instance NICs or specify --new-nics"
202
                           " to clear the old NICs and create a new NIC to"
203
                           " a public network of synnefo." % instance_name)
194 204

  
195 205

  
196 206
def remove_instance_nics(instance, backend_client, stream=sys.stdout):
......
218 228
    instance_name = instance['name']
219 229
    if instance['status'] != 'ADMIN_down':
220 230
        stream.write("Instance is not down. Shutting down"
221
                          " instance\n")
231
                     " instance\n")
222 232
        jobid = backend_client.ShutdownInstance(instance_name)
223 233
        (status, error) = wait_for_job(backend_client, jobid)
224 234
        if status != 'success':
......
229 239
    stream.write("Renaming instance to %s\n" % new_name)
230 240

  
231 241
    jobid = backend_client.RenameInstance(old_name, new_name,
232
                                         ip_check=False, name_check=False)
242
                                          ip_check=False, name_check=False)
233 243
    (status, error) = wait_for_job(backend_client, jobid)
234 244
    if status != 'success':
235 245
        raise CommandError("Can not rename instance: %s" % error)
b/snf-cyclades-app/synnefo/api/management/commands/server-inspect.py
56 56
    args = "<server ID>"
57 57

  
58 58
    option_list = BaseCommand.option_list + (
59
        make_option('--jobs',
59
        make_option(
60
            '--jobs',
60 61
            action='store_true',
61 62
            dest='jobs',
62 63
            default=False,
63 64
            help="Show non-archived jobs concerning server."),
64
        make_option('--uuids',
65
        make_option(
66
            '--uuids',
65 67
            action='store_true',
66 68
            dest='use_uuids',
67 69
            default=False,
......
102 104
            self.stdout.write(l.ljust(18) + ': ' + f.ljust(20) + '\n')
103 105
        self.stdout.write('\n')
104 106
        for nic in vm.nics.all():
105
            self.stdout.write("nic/%d: IPv4: %s, MAC: %s, IPv6:%s,  Network: %s\n"\
106
                              % (nic.index, nic.ipv4, nic.mac, nic.ipv6,  nic.network))
107
            msg = "nic/%d: IPv4: %s, MAC: %s, IPv6:%s,  Network: %s\n"\
108
                  % (nic.index, nic.ipv4, nic.mac, nic.ipv6,  nic.network)
109
            self.stdout.write(msg)
107 110

  
108 111
        client = vm.get_client()
109 112
        try:
......
138 141
        for j in jobs:
139 142
            info = client.GetJobStatus(j)
140 143
            summary = ' '.join(info['summary'])
141
            if summary.startswith("INSTANCE") and \
142
               summary.find(vm.backend_vm_id) != -1:
144
            job_is_relevant = summary.startswith("INSTANCE") and\
145
                (summary.find(vm.backend_vm_id) != -1)
146
            if job_is_relevant:
143 147
                for i in GANETI_JOB_FIELDS:
144 148
                    value = info[i]
145 149
                    if i.find('_ts') != -1:
146 150
                        value = merge_time(value)
147 151
                    try:
148
                        self.stdout.write(i.ljust(14) + ': ' + str(value) +\
152
                        self.stdout.write(i.ljust(14) + ': ' + str(value) +
149 153
                                          '\n')
150 154
                    except KeyError:
151 155
                        pass
b/snf-cyclades-app/synnefo/api/management/commands/server-list.py
47 47
    help = "List servers"
48 48

  
49 49
    option_list = BaseCommand.option_list + (
50
        make_option('-c',
50
        make_option(
51
            '-c',
51 52
            action='store_true',
52 53
            dest='csv',
53 54
            default=False,
54 55
            help="Use pipes to separate values"),
55
        make_option('--suspended',
56
        make_option(
57
            '--suspended',
56 58
            action='store_true',
57 59
            dest='suspended',
58 60
            default=False,
59 61
            help="List only suspended servers"),
60
        make_option('--build',
62
        make_option(
63
            '--build',
61 64
            action='store_true',
62 65
            dest='build',
63 66
            default=False,
64 67
            help="List only servers in the building state"),
65
        make_option('--deleted',
68
        make_option(
69
            '--deleted',
66 70
            action='store_true',
67 71
            dest='deleted',
68 72
            default=False,
69 73
            help="Include deleted servers"),
70
        make_option('--backend-id',
74
        make_option(
75
            '--backend-id',
71 76
            dest='backend_id',
72 77
            help="List only servers of the specified backend"),
73
        make_option('--filter-by',
78
        make_option(
79
            '--filter-by',
74 80
            dest='filter_by',
75 81
            help="Filter results. Comma seperated list of key `cond` val pairs"
76 82
                 " that displayed entries must satisfy. e.g."
b/snf-cyclades-app/synnefo/api/management/commands/server-modify.py
44 44
    help = "Modify a server"
45 45

  
46 46
    option_list = BaseCommand.option_list + (
47
        make_option('--name',
47
        make_option(
48
            '--name',
48 49
            dest='name',
49 50
            metavar='NAME',
50 51
            help="Set server's name"),
51
        make_option('--owner',
52
        make_option(
53
            '--owner',
52 54
            dest='owner',
53 55
            metavar='USER_ID',
54 56
            help="Set server's owner"),
55
        make_option('--state',
57
        make_option(
58
            '--state',
56 59
            dest='state',
57 60
            metavar='STATE',
58 61
            help="Set server's state"),
59
        make_option('--set-deleted',
62
        make_option(
63
            '--set-deleted',
60 64
            action='store_true',
61 65
            dest='deleted',
62 66
            help="Mark a server as deleted"),
63
        make_option('--set-undeleted',
67
        make_option(
68
            '--set-undeleted',
64 69
            action='store_true',
65 70
            dest='undeleted',
66 71
            help="Mark a server as not deleted"),
67
        make_option('--set-suspended',
72
        make_option(
73
            '--set-suspended',
68 74
            action='store_true',
69 75
            dest='suspended',
70 76
            help="Mark a server as suspended"),
71
        make_option('--set-unsuspended',
77
        make_option(
78
            '--set-unsuspended',
72 79
            action='store_true',
73 80
            dest='unsuspended',
74 81
            help="Mark a server as not suspended")
75
        )
82
    )
76 83

  
77 84
    def handle(self, *args, **options):
78 85
        if len(args) != 1:
b/snf-cyclades-app/synnefo/logic/management/commands/network-inspect.py
48 48
    help = "Inspect a network on DB and Ganeti."
49 49

  
50 50
    option_list = BaseCommand.option_list + (
51
        make_option('--uuids',
51
        make_option(
52
            '--uuids',
52 53
            action='store_true',
53 54
            dest='use_uuids',
54 55
            default=False,
55 56
            help="Display UUIDs instead of user emails"),
56
        )
57
    )
57 58

  
58 59
    def handle(self, *args, **options):
59 60
        write = self.stdout.write
b/snf-cyclades-app/synnefo/logic/management/commands/reconcile-pools.py
56 56
            return
57 57
        bridges = []
58 58
        for i in xrange(0, bridge_pool.size()):
59
            if not bridge_pool.is_available(i, index=True) and \
60
                not bridge_pool.is_reserved(i, index=True):
59
            used_bridge = not (bridge_pool.is_available(i, index=True) or
60
                               bridge_pool.is_reserved(i, index=True))
61
            if used_bridge:
61 62
                    bridges.append(bridge_pool.index_to_value(i))
62 63

  
63 64
        write("Used bridges from Pool: %d\n" % len(bridges))
......
95 96

  
96 97
        macs = []
97 98
        for i in xrange(1, macp_pool.size()):
98
            if not macp_pool.is_available(i, index=True) and \
99
               not macp_pool.is_reserved(i, index=True):
99
            used_macp = not (macp_pool.is_available(i, index=True) or
100
                             macp_pool.is_reserved(i, index=True))
101
            if used_macp:
100 102
                value = macp_pool.index_to_value(i)
101 103
                macs.append(value)
102 104

  

Also available in: Unified diff