Revision 442e88bf

b/snf-cyclades-app/synnefo/ui/static/snf/js/neutron.js
300 300
      get_floating_ips_network: function() {
301 301
        return this.filter(function(n) { return n.get('is_public')})[1]
302 302
      },
303
      
304
      create_subnet: function(subnet_params, complete, error) {
305
        synnefo.storage.subnets.create(subnet_params, {
306
          complete: function () { complete && complete() },
307
          error: function() { error && error() }
308
        });
309
      },
303 310

  
304 311
      create: function (name, type, cidr, dhcp, callback) {
305 312
        var quota = synnefo.storage.quotas;
......
316 323
          callback && callback();
317 324
        }
318 325
        
319
        var complete = function() {};
326
        var complete = function() {
327
          if (!create_subnet) { cb && cb() }
328
        };
320 329
        var error = function() { cb() };
321
        // on network create success, try to create the requested 
322
        // network subnet
330
        var create_subnet = !!cidr;
331
        
332
        // on network create success, try to create the requested network 
333
        // subnet.
334
        var self = this;
323 335
        var success = function(resp) {
324 336
          var network = resp.network;
325
          subnet_params.subnet.network_id = network.id;
326
          synnefo.storage.subnets.create(subnet_params, {
327
            complete: function () { cb && cb() },
328
            error: function() {
329
              var created_network = new synnefo.models.networks.Network({id: network.id});
337
          if (create_subnet) {
338
            subnet_params.subnet.network_id = network.id;
339
            self.create_subnet(subnet_params, cb, function() {
340
              // rollback network creation
341
              var created_network = new synnefo.models.networks.Network({
342
                id: network.id
343
              });
330 344
              created_network.destroy({no_skip: true});
331
            }
332
          });
345
            });
346
          }
333 347
          quota.get('cyclades.network.private').increase();
334 348
        }
335 349
        return this.api_call(this.path, "create", params, complete, error, success);

Also available in: Unified diff