mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-28 14:50:08 +03:00
Feature #4215: Allow to force the IP also when there isn't a floating IP
This commit is contained in:
parent
4a69c1e9e2
commit
ee0c3ce351
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
});
|
||||
|
@ -108,7 +108,7 @@ define(function(require) {
|
||||
|
||||
NicsSection.insert({},
|
||||
$(".nicsContext", context),
|
||||
{floatingIP: true, management: true});
|
||||
{floatingIP: true, forceIPv4:true, management: true});
|
||||
|
||||
this.templatesTable.initialize();
|
||||
|
||||
|
@ -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"];
|
||||
|
@ -61,10 +61,10 @@
|
||||
<tr>
|
||||
<td class="nic_id" nic_id="{{NIC_ID}}">{{NIC_ID}}</td>
|
||||
<td>{{NETWORK}}</td>
|
||||
<td>{{valOrDefault IP "--"}}</td>
|
||||
<td>{{valOrDefault IP6_ULA "--"}}</td>
|
||||
<td>{{valOrDefault IP6_GLOBAL "--"}}</td>
|
||||
<td>{{valOrDefault VROUTER_MANAGEMENT "--"}}</td>
|
||||
<td>{{IP}}</td>
|
||||
<td>{{IP6_ULA}}</td>
|
||||
<td>{{IP6_GLOBAL}}</td>
|
||||
<td>{{VROUTER_MANAGEMENT}}</td>
|
||||
<td>
|
||||
{{#isTabActionEnabled "vrouters-tab" "VirtualRouter.detachnic"}}
|
||||
<a href="VirtualRouter.detachnic" class="detachnic" ><i class="fa fa-times"/>
|
||||
|
@ -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) {
|
||||
'</span>' +
|
||||
'</label>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
if (options.forceIPv4){
|
||||
html +=
|
||||
'<div class="row noclick">' +
|
||||
'<div class="small-5 columns">' +
|
||||
'<label class="right inline" style="color: #777; font-size: 16px">' +
|
||||
Locale.tr("Force IPv4:") + " " +
|
||||
'<span class="tip">' +
|
||||
Locale.tr("Optionally, you can force the IP assigned to the floating IP.") +
|
||||
Locale.tr("Optionally, you can force the IP assigned to the network interface.") +
|
||||
'</span>' +
|
||||
'</label>' +
|
||||
'</div>' +
|
||||
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user