diff --git a/src/cli/one_helper/onevrouter_helper.rb b/src/cli/one_helper/onevrouter_helper.rb index b0ed03a548..5ab501ec4f 100644 --- a/src/cli/one_helper/onevrouter_helper.rb +++ b/src/cli/one_helper/onevrouter_helper.rb @@ -123,49 +123,45 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper nic_default = {"NETWORK" => "-", "IP" => "-"} - shown_ips = [] - array_id = 0 vm_nics = [obj.to_hash['VROUTER']['TEMPLATE']['NIC']].flatten.compact vm_nics.each {|nic| next if nic.has_key?("CLI_DONE") - if nic.has_key?("IP6_LINK") - shown_ips << nic["IP6_LINK"] + floating = (nic.has_key?("FLOATING_IP") && nic["FLOATING_IP"].upcase() == "YES" ) - ip6_link = {"IP" => nic.delete("IP6_LINK"), - "CLI_DONE" => true, - "DOUBLE_ENTRY" => true} - vm_nics.insert(array_id+1,ip6_link) + if floating + if nic.has_key?("IP6_LINK") + ip6_link = {"IP" => nic.delete("IP6_LINK"), + "CLI_DONE" => true, + "DOUBLE_ENTRY" => true} + vm_nics.insert(array_id+1,ip6_link) - array_id += 1 + array_id += 1 + end + + if nic.has_key?("IP6_ULA") + ip6_link = {"IP" => nic.delete("IP6_ULA"), + "CLI_DONE" => true, + "DOUBLE_ENTRY" => true} + vm_nics.insert(array_id+1,ip6_link) + + array_id += 1 + end + + if nic.has_key?("IP6_GLOBAL") + ip6_link = {"IP" => nic.delete("IP6_GLOBAL"), + "CLI_DONE" => true, + "DOUBLE_ENTRY" => true} + vm_nics.insert(array_id+1,ip6_link) + + array_id += 1 + end + else + nic.delete("IP") end - if nic.has_key?("IP6_ULA") - shown_ips << nic["IP6_ULA"] - - ip6_link = {"IP" => nic.delete("IP6_ULA"), - "CLI_DONE" => true, - "DOUBLE_ENTRY" => true} - vm_nics.insert(array_id+1,ip6_link) - - array_id += 1 - end - - if nic.has_key?("IP6_GLOBAL") - shown_ips << nic["IP6_GLOBAL"] - - ip6_link = {"IP" => nic.delete("IP6_GLOBAL"), - "CLI_DONE" => true, - "DOUBLE_ENTRY" => true} - vm_nics.insert(array_id+1,ip6_link) - - array_id += 1 - end - - shown_ips << nic["IP"] if nic.has_key?("IP") - nic.merge!(nic_default) {|k,v1,v2| v1} array_id += 1 } diff --git a/src/sunstone/public/app/tabs/vrouters-tab/dialogs/attach-nic.js b/src/sunstone/public/app/tabs/vrouters-tab/dialogs/attach-nic.js index e6ca5565a4..11c90e24d7 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/dialogs/attach-nic.js +++ b/src/sunstone/public/app/tabs/vrouters-tab/dialogs/attach-nic.js @@ -68,7 +68,7 @@ define(function(require) { NicsSection.insert({}, $(".nicsContext", context), - {floatingIP: true, management: true, + {floatingIP: true, forceIPv4:true, management: true, hide_add_button:true, click_add_button:true }); diff --git a/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create.js b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create.js index 50f7226150..c5c9caadb5 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/vrouters-tab/form-panels/create.js @@ -108,7 +108,7 @@ define(function(require) { NicsSection.insert({}, $(".nicsContext", context), - {floatingIP: true, management: true}); + {floatingIP: true, forceIPv4:true, management: true}); this.templatesTable.initialize(); diff --git a/src/sunstone/public/app/tabs/vrouters-tab/panels/info.js b/src/sunstone/public/app/tabs/vrouters-tab/panels/info.js index 476755eb72..2599e75a3e 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/vrouters-tab/panels/info.js @@ -81,6 +81,34 @@ define(function(require) { nics = [this.element.TEMPLATE.NIC]; } + $.map(nics, function(nic){ + if (nic.NETWORK == undefined){ + nic.NETWORK = "--"; + } + + if (nic.FLOATING_IP != undefined && nic.FLOATING_IP.toUpperCase() == "YES"){ + if(nic.IP == undefined){ + nic.IP = "--"; + } + + if(nic.IP6_ULA == undefined){ + nic.IP6_ULA = "--"; + } + + if(nic.IP6_GLOBAL == undefined){ + nic.IP6_GLOBAL = "--"; + } + } else { + nic.IP = "--"; + nic.IP6_ULA = "--"; + nic.IP6_GLOBAL = "--"; + } + + if(nic.VROUTER_MANAGEMENT == undefined){ + nic.VROUTER_MANAGEMENT = "--"; + } + }); + // TODO: simplify interface? var strippedTemplate = $.extend({}, this.element.TEMPLATE); delete strippedTemplate["NIC"]; diff --git a/src/sunstone/public/app/tabs/vrouters-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/vrouters-tab/panels/info/html.hbs index 1b09c2edeb..26fcb89ace 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/vrouters-tab/panels/info/html.hbs @@ -61,10 +61,10 @@ {{NIC_ID}} {{NETWORK}} - {{valOrDefault IP "--"}} - {{valOrDefault IP6_ULA "--"}} - {{valOrDefault IP6_GLOBAL "--"}} - {{valOrDefault VROUTER_MANAGEMENT "--"}} + {{IP}} + {{IP6_ULA}} + {{IP6_GLOBAL}} + {{VROUTER_MANAGEMENT}} {{#isTabActionEnabled "vrouters-tab" "VirtualRouter.detachnic"}} diff --git a/src/sunstone/public/app/utils/nics-section.js b/src/sunstone/public/app/utils/nics-section.js index 786c45639a..4223b750fc 100644 --- a/src/sunstone/public/app/utils/nics-section.js +++ b/src/sunstone/public/app/utils/nics-section.js @@ -39,6 +39,8 @@ define(function(require) { * - click_add_button {bool} * - floatingIP {bool}: true to show the * floating IP checkbox + * - forceIPv4 {bool}: true to show the + * input to select the IPv4 * - management {bool}: true to show the * management checkbox */ @@ -91,12 +93,12 @@ define(function(require) { if (nic) { if ($("input.floating_ip", $(this)).prop("checked")){ nic["FLOATING_IP"] = "YES"; + } - var ip4 = $("input.manual_ip4", $(this)).val(); + var ip4 = $("input.manual_ip4", $(this)).val(); - if (ip4 != ""){ - nic["IP"] = ip4; - } + if (ip4 != undefined && ip4 != ""){ + nic["IP"] = ip4; } if ($("input.management", $(this)).prop("checked")){ @@ -117,6 +119,8 @@ define(function(require) { * - vnet_attr {object} * - floatingIP {bool}: true to show the * floating IP checkbox + * - forceIPv4 {bool}: true to show the + * input to select the IPv4 * - management {bool}: true to show the * management checkbox */ @@ -276,13 +280,17 @@ define(function(require) { '' + '' + '' + - '' + + ''; + } + + if (options.forceIPv4){ + html += '
' + '
' + '' + '
' + @@ -312,8 +320,6 @@ define(function(require) { Tips.setup($(".selected_network", dd_context)); $('a', dd_context).first().trigger("click"); - - $("input.floating_ip", dd_context).change(); }) dd_context.on("click", ".provision_remove_nic" , function() { @@ -325,10 +331,6 @@ define(function(require) { event.stopPropagation(); }); - dd_context.on("change", "input.floating_ip" , function() { - $(".manual_ip4", dd_context).prop("disabled", !$(this).is(":checked")); - }); - if (!options.nic && !options.vnet_attr) { $('a', dd_context).trigger("click"); } @@ -343,6 +345,8 @@ define(function(require) { * - click_add_button {bool} * - floatingIP {bool}: true to show the * floating IP checkbox + * - forceIPv4 {bool}: true to show the + * input to select the IPv4 * - management {bool}: true to show the * management checkbox */