Revision 9115d567 snf-cyclades-app/synnefo/logic/management/commands/backend-add.py

b/snf-cyclades-app/synnefo/logic/management/commands/backend-add.py
63 63
            choices=HYPERVISORS,
64 64
            metavar="|".join(HYPERVISORS),
65 65
            help="The hypervisor that the Ganeti backend uses"),
66
        make_option(
67
            '--no-init', action='store_false',
68
            dest='init', default=True,
69
            help="Do not perform initialization of the Backend Model")
66 70
    )
67 71

  
68 72
    def handle(self, *args, **options):
......
110 114
        pprint_table(self.stdout, table, attr)
111 115

  
112 116
        update_resources(backend, resources)
117

  
118
        if not options['init']:
119
            return
120

  
121
        networks = Network.objects.filter(deleted=False, floating_ip_pool=True)
122
        if not networks:
123
            return
124

  
125
        self.stdout.write('\nCreating the follow networks:\n')
126
        headers = ('Name', 'Subnet', 'Gateway', 'Mac Prefix', 'Public')
127
        table = []
128

  
129
        for net in networks:
130
            table.append((net.backend_id, str(net.subnet), str(net.gateway),
131
                         str(net.mac_prefix), str(net.public)))
132
        pprint_table(self.stdout, table, headers)
133

  
134
        for net in networks:
135
            net.create_backend_network(backend)
136
            result = create_network_synced(net, backend)
137
            if result[0] != "success":
138
                self.stdout.write('\nError Creating Network %s: %s\n' %
139
                                  (net.backend_id, result[1]))
140
            else:
141
                self.stdout.write('Successfully created Network: %s\n' %
142
                                  net.backend_id)
143
            result = connect_network_synced(network=net, backend=backend)
144
            if result[0] != "success":
145
                self.stdout.write('\nError Connecting Network %s: %s\n' %
146
                                  (net.backend_id, result[1]))
147
            else:
148
                self.stdout.write('Successfully connected Network: %s\n' %
149
                                  net.backend_id)

Also available in: Unified diff