Revision d923ef36

View differences:

src/sunstone/public/app/tabs/hosts-tab/panels/wilds.js
129 129
    var index = 0;
130 130
    var template = "";
131 131
    var rollback  = [];
132
    var duplicated_nics = {};
132 133

  
133 134
    function getNext() {
134 135

  
......
200 201
          }
201 202

  
202 203
          if (disks_and_nets[index].type === "EXISTING_DISK") {
203
            template += disks_and_nets[index].image_tmpl;
204 204
            ++index;
205 205
            getNext();
206 206
          }
......
222 222
                  var network_id = response.VNET.ID;
223 223
                  if (one_cluster_id != -1) {
224 224
                    Sunstone.runAction("Cluster.addvnet",one_cluster_id,response.VNET.ID);
225
                    // Remove vnet from cluster default 0
226
                    Sunstone.runAction("Cluster.delvnet",0,response.VNET.ID);
225 227
                  }
226 228
                  ++index;
227 229
                  var rollback_info = { type: "NETWORK", id: network_id};
......
241 243
          }
242 244

  
243 245
          if (disks_and_nets[index].type == "EXISTING_NIC") {
244
            template += disks_and_nets[index].network_tmpl;
245 246
            ++index;
246 247
            getNext();
247 248
          }
248 249

  
250
          if (disks_and_nets[index].type === "DUPLICATED_NIC") {
251
            ++index;
252
            getNext();
253
          }
249 254
      }
250 255
    }
251 256
    getNext();
src/sunstone/public/app/utils/vcenter/templates.js
245 245
    var index = 0;
246 246
    var template = "";
247 247
    var rollback  = [];
248
    var duplicated_nics = {};
248 249

  
249 250
    function getNext() {
250 251

  
......
263 264

  
264 265
      } else {
265 266

  
266
        if (disks_and_nets[index].type === "NEW_DISK") {
267
          if (disks_and_nets[index].type === "NEW_DISK") {
267 268

  
268 269
            var image_json = {
269 270
              "image": {
......
281 282
                ++index;
282 283
                template += "DISK=[\n";
283 284
                template += "IMAGE_ID=\"" + image_id + "\",\n";
284
                template += "IMAGE_UNAME=\"" + image_uname + "\",\n";
285 285
                template += "OPENNEBULA_MANAGED=\"NO\"\n";
286 286
                template += "]\n";
287 287

  
......
326 326
                  var network_id = response.VNET.ID;
327 327
                  if (one_cluster_id != -1) {
328 328
                    Sunstone.runAction("Cluster.addvnet",one_cluster_id,response.VNET.ID);
329
                    //Remove bnet from default datastore
330
                    Sunstone.runAction("Cluster.delvnet",0,response.VNET.ID);
329 331
                  }
332
                  duplicated_nics[disks_and_nets[index].network_name]=network_id;
333

  
330 334
                  ++index;
331 335
                  template += "NIC=[\n";
332 336
                  template += "NETWORK_ID=\"" + network_id + "\",\n";
333 337
                  template += "OPENNEBULA_MANAGED=\"NO\"\n";
334 338
                  template += "]\n";
339

  
335 340
                  var rollback_info = { type: "NETWORK", id: network_id};
336 341
                  rollback.push(rollback_info);
337 342
                  getNext();
......
354 359
            getNext();
355 360
          }
356 361

  
362
          if (disks_and_nets[index].type === "DUPLICATED_NIC") {
363
            var network_id = duplicated_nics[disks_and_nets[index].network_name];
364

  
365
            template += "NIC=[\n";
366
            template += "NETWORK_ID=\"" + network_id + "\",\n";
367
            template += "OPENNEBULA_MANAGED=\"NO\"\n";
368
            template += "]\n";
369
            ++index;
370
            getNext();
371
          }
372

  
373

  
357 374
      }
358 375
    }
359 376
    getNext();
......
445 462
                          message : OpenNebulaError(response).error.message
446 463
                      });
447 464
                      Notifier.onError({}, OpenNebulaError(response));
465

  
466
                      // Remove template - Rollback
467
                      var path = '/vcenter/template_rollback/' + template_id;
468
                      $.ajax({
469
                        url: path,
470
                        type: "POST",
471
                        data: {timeout: false},
472
                        dataType: "json",
473
                        success: function(response){
474
                          // Do nothing
475
                        },
476
                        error: function(response){
477
                          VCenterCommon.importFailure({
478
                              context : row_context,
479
                              message : Locale.tr("Could not delete the template " + template_id + " due to " + OpenNebulaError(response).error.message + ". Please remote it manually before importing this template again.")
480
                          });
481
                        }
482
                      });
448 483
                    }
449 484
                  });
450 485
                },
src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
295 295
                        one_i.info
296 296
                        disk_info << "DISK=[\n"
297 297
                        disk_info << "IMAGE_ID=\"#{one_i["ID"]}\",\n"
298
                        disk_info << "IMAGE_UNAME=\"#{one_i["UNAME"]}\",\n"
299 298
                        disk_info << "OPENNEBULA_MANAGED=\"NO\"\n"
300 299
                        disk_info << "]\n"
301 300
                    end
......
344 343
            # Track allocated networks for rollback
345 344
            allocated_networks = []
346 345

  
346
            # Track port groups duplicated in this VM
347
            duplicated_networks = []
348

  
347 349
            vc_nics.each do |nic|
348 350
                # Check if the network already exists
349 351
                network_found = VCenterDriver::Network.get_unmanaged_vnet_by_ref(nic[:net_ref],
......
423 425
                    one_vnet[:one] << ar_str
424 426

  
425 427
                    if sunstone
426
                        sunstone_nic = {}
427
                        sunstone_nic[:type] = "NEW_NIC"
428
                        sunstone_nic[:network_tmpl] = one_vnet[:one]
429
                        sunstone_nic[:one_cluster_id] = cluster_id.to_i
430
                        sunstone_nic_info << sunstone_nic
428
                        if !duplicated_networks.include?(nic[:net_name])
429
                            sunstone_nic = {}
430
                            sunstone_nic[:type] = "NEW_NIC"
431
                            sunstone_nic[:network_name] = nic[:net_name]
432
                            sunstone_nic[:network_tmpl] = one_vnet[:one]
433
                            sunstone_nic[:one_cluster_id] = cluster_id.to_i
434
                            sunstone_nic_info << sunstone_nic
435
                            duplicated_networks << nic[:net_name]
436
                        else
437
                            sunstone_nic = {}
438
                            sunstone_nic[:type] = "DUPLICATED_NIC"
439
                            sunstone_nic[:network_name] = nic[:net_name]
440
                            sunstone_nic_info << sunstone_nic
441
                        end
431 442
                    else
432 443
                        # Allocate the Virtual Network
433 444
                        allocated_networks << one_vn
......
444 455
                        nic_info << "NETWORK_ID=\"#{one_vn["ID"]}\",\n"
445 456
                        nic_info << "OPENNEBULA_MANAGED=\"NO\"\n"
446 457
                        nic_info << "]\n"
458

  
459
                        # Refresh npool
460
                        npool.info_all
447 461
                    end
448 462
                end
449 463
            end

Also available in: Unified diff