diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 13a4b1d180..6af20c9346 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -1258,20 +1258,34 @@ function setupCreateHostDialog(){ var trow = $('
' + '
' + - '
' + - '
').appendTo($(".content", networks_container)) - $('.type_select_'+netname).live("change",function(){ - type = $(this).val(); + $('.type_select').on("change",function(){ + var network_context = $(this).closest(".vcenter_network"); + var type = $(this).val(); - net_form_str = '' + var net_form_str = '' switch(type) { - case 'ethernet': - net_form_str = 'MAC (optional) '; + case 'ETHER': + net_form_str = + '
'+ + ''+ + '
'; break; - case 'ipv4': - net_form_str = 'MAC (optional) IP '; + case 'IP4': + net_form_str = + '
'+ + ''+ + '
'+ + '
'+ + ''+ + '
'; break; - case 'ipv6': - net_form_str = 'MAC (optional) GLOBAL PREFIX (optional) ULA_PREFIX (optional) '; + case 'IP6': + net_form_str = + '
'+ + ''+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + ''+ + '
'; break; } - $('.net_options_'+netname,$(this).parent()).html(net_form_str); + $('.net_options', network_context).html(net_form_str); }); - $(".network_name", trow).data("network_name", network.name) + $(".network_name", trow).data("network_name", netname) $(".network_name", trow).data("one_network", network.one) }); }, @@ -1315,8 +1360,6 @@ function setupCreateHostDialog(){ } else { networks_container.html(""); } - - }) }); } @@ -1431,81 +1474,57 @@ function setupCreateHostDialog(){ ''+ ''); - network_name = unescape($(network_context).find('label')[0].className); - network_size = $(".netsize", network_context).val(); - network_tmpl = $(this).data("one_network"); + var network_size = $(".netsize", network_context).val(); + var network_tmpl = $(this).data("one_network"); + var netname = $(this).data("network_name"); + var type = $('.type_select', network_context).val(); - // Let's build the AR - netname = network_name.replace(" ","_") - type = $('.type_select_'+netname, network_context).val(); - type_str = "" - - ar_str = "\nAR=[" + var ar_array = []; + ar_array.push("TYPE=" + type); + ar_array.push("SIZE=" + network_size); switch(type) { - case 'ethernet': - type_str = "ETHER"; - mac = $('.eth_mac_net_'+netname, network_context).val(); - if (mac) - { - ar_str += "MAC=" + mac; + case 'ETHER': + var mac = $('.eth_mac_net', network_context).val(); + + if (mac){ + ar_array.push("MAC=" + mac); } break; - case 'ipv4': - type_str = "IP4"; - mac = $('.four_mac_net_'+netname, network_context).val(); - ip = $('.four_ip_net_'+netname, network_context).val(); - if (mac) - { - ar_str += "MAC=" + mac; - if (ip) - { - ar_str += "," - } + case 'IP4': + var mac = $('.four_mac_net', network_context).val(); + var ip = $('.four_ip_net', network_context).val(); + + if (mac){ + ar_array.push("MAC=" + mac); } - if (ip) - { - ar_str += "IP=" + ip; - } + if (ip) { + ar_array.push("IP=" + ip); + } + break; - case 'ipv6': - type_str = "IP6"; - mac = $('.six_mac_net_'+netname, network_context).val(); - gp = $('.six_global_net_'+netname, network_context).val(); - ula = $('.six_mac_net_'+netname, network_context).val(); - if (mac) - { - ar_str += "MAC=" + mac; - if (gp || ula) - { - ar_str += "," - } + case 'IP6': + var mac = $('.six_mac_net', network_context).val(); + var gp = $('.six_global_net', network_context).val(); + var ula = $('.six_mac_net', network_context).val(); + + if (mac){ + ar_array.push("MAC=" + mac); } - if (gp) - { - ar_str += "GLOBAL_PREFIX=" + gp; - if (ula) - { - ar_str += "," - } + if (gp) { + ar_array.push("GLOBAL_PREFIX=" + gp); } - if (ula) - { - ar_str += "ULA_PREFIX=" + ula; + if (ula){ + ar_array.push("ULA_PREFIX=" + ula); } + break; } - comma_or_not = "" - if (ar_str.slice(-1) != "[") - { - comma_or_not = "," - } - - ar_str += comma_or_not + "TYPE=" + type_str - - network_tmpl = network_tmpl + ar_str + ' ,SIZE = "'+ network_size +'"]' + network_tmpl += "\nAR=[" + network_tmpl += ar_array.join(",\n") + network_tmpl += "]" var vnet_json = { "vnet": {