1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-25 23:21:29 +03:00

F #3440: Add forms NSX sunstone (#3620)

* F #3440: NSX add form in vnets

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>

* F #3440: add action NSX

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>

* F #3440: add form set user and password

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>

* F #3440: add form NSX-V in vnet (create)

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>

* F #3440: fix form NSX-V in vnet (create)

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>

* F #3440: clear form NSX-V in vnet (create)

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>

* F #3440: add form NSX-T in vnet (create)

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>

* F #3440: Submit action NSX (vnet create)

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>
(cherry picked from commit eb3d3cab65dde232806745e0d32a657335b080da)
This commit is contained in:
Jorge Lobo 2019-08-29 00:06:46 +02:00 committed by Tino Vazquez
parent 609ca70789
commit 81ed024186
18 changed files with 417 additions and 18 deletions

View File

@ -533,6 +533,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -534,6 +534,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -527,6 +527,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -535,6 +535,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -534,6 +534,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -527,6 +527,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -533,6 +533,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -534,6 +534,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -527,6 +527,7 @@ tabs:
host_esx_tab: true
host_pci_tab: true
host_numa_tab: true
host_nsx_tab: true
table_columns:
- 0 # Checkbox
- 1 # ID

View File

@ -98,7 +98,7 @@ define(function(require) {
}
return(false);
}
console.log("JORGE");
token = window.token;
var URL = "";
var proxy_host = window.location.hostname;

View File

@ -36,9 +36,9 @@ define(function(require) {
require('./hosts-tab/panels/zombies'),
require('./hosts-tab/panels/esx'),
require('./hosts-tab/panels/pci'),
require('./hosts-tab/panels/numa')
require('./hosts-tab/panels/numa'),
require('./hosts-tab/panels/nsx')
];
var _panelsHooks = [
require('../utils/hooks/header')
];

View File

@ -0,0 +1,140 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
/*
DEPENDENCIES
*/
var Sunstone = require('sunstone');
var TemplateUtils = require('utils/template-utils');
var Tips = require('utils/tips');
/*
TEMPLATES
*/
var TemplateNsx = require('hbs!./nsx/html');
/*
CONSTANTS
*/
var PANEL_ID = require('./nsx/panelId');
var RESOURCE = "Host";
var NSX = 'NSX';
var tabID = '#hosts-tab-panelsTabs';
var user = "NSX_USER";
var pass = "NSX_PASSWORD";
var submit = "nsx_submit";
var showForm = true;
var template = {};
/*
CONSTRUCTOR
*/
function Panel(info) {
this.title = Locale.tr("NSX");
this.icon = "fa-desktop";
this.element = info[RESOURCE.toUpperCase()];
return this;
};
Panel.PANEL_ID = PANEL_ID;
Panel.prototype.html = _html;
Panel.prototype.setup = _setup;
Panel.prototype.onShow = _onShow;
return Panel;
/*
FUNCTION DEFINITIONS
*/
function _html() {
showForm = true;
if(this && this.element && this.element.TEMPLATE && this.element.TEMPLATE.NSX_STATUS && this.element.TEMPLATE.NSX_STATUS.trim() === 'OK'){
showForm=false;
}
return TemplateNsx();
}
function _onShow(context){
var that = this;
}
function displayTab(status){
$(tabID).find('li').each(function(i, li){
var element = $(li);
if(element.text().trim() === NSX){
if(status){
element.show();
}else{
element.hide();
}
}
});
}
function _setup(context) {
var that = this;
var title = $("<h4 />").text("NSX Credentials");
var full = $("<div />",{"class": "small-12 columns"});
var middle = $("<div />",{"class": "small-6 columns"});
var label = $("<label />");
var input = $("<input />",{type: 'text'});
var form = $("#nsx-form").empty();
var button = $("<button>")
var userValue = (that && that.element && that.element.TEMPLATE && that.element.TEMPLATE.NSX_USER) || "";
var passValue = (that && that.element && that.element.TEMPLATE && that.element.TEMPLATE.NSX_PASSWORD) || "";
displayTab(showForm);
if(showForm){
form.append(
full.clone().append(title)
.add(
middle.clone().append(
label.clone().text(user).attr('for', user.toLowerCase()).add(
input.clone().val(userValue).attr('id',user.toLowerCase())
)
)
).add(
middle.clone().append(
label.clone().text(pass).attr("for", pass.toLowerCase()).add(
input.clone().text(passValue).attr({'id':pass.toLowerCase(), 'type': 'password'})
)
)
).add(
full.clone().append(
button.clone().attr({id: submit, class:'button success'}).text('Submit')
)
)
);
}
//action
$("#"+submit).off().on('click',function(){
if($('#'+user.toLowerCase()).val() && $('#'+pass.toLowerCase()).val()){
var template = that.element.TEMPLATE;
template[user] = $('#'+user.toLowerCase()).val();
template[pass] = $('#'+pass.toLowerCase()).val();
template_str = TemplateUtils.templateToString(template);
Sunstone.runAction(RESOURCE + ".update_template", that.element.ID, template_str);
}
});
}
})

View File

@ -0,0 +1,18 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2019, OpenNebula Project, OpenNebula Systems }}
{{! }}
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
{{! not use this file except in compliance with the License. You may obtain }}
{{! a copy of the License at }}
{{! }}
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
{{! }}
{{! Unless required by applicable law or agreed to in writing, software }}
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
{{! See the License for the specific language governing permissions and }}
{{! limitations under the License. }}
{{! -------------------------------------------------------------------------- }}
<div class="row" id="nsx-form">
</div>

View File

@ -0,0 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
define(function(require) {
return 'host_nsx_tab';
})

View File

@ -30,6 +30,7 @@ define(function(require) {
var TemplateUtils = require("utils/template-utils");
var WizardFields = require("utils/wizard-fields");
var ResourceSelect = require("utils/resource-select");
var OpenNebulaAction = require('opennebula/action');
/*
TEMPLATES
@ -44,6 +45,12 @@ define(function(require) {
var FORM_PANEL_ID = require("./create/formPanelId");
var TAB_ID = require("../tabId");
var actionHost = "Host";
var idsElements = {
name: "#nsx-name",
description: "#nsx-description",
transport: "#nsx-transport"
}
/*
CONSTRUCTOR
@ -134,9 +141,7 @@ define(function(require) {
$("#network_mode", context).change(function() {
$("div.mode_param", context).hide();
$("div.mode_param [wizard_field]", context).prop("wizard_field_disabled", true);
$("input#vn_mad", context).removeAttr("required");
$("input#vn_mad", context).removeAttr("value");
$("input#vn_mad", context).removeAttr("required").removeAttr("value");
$("#vcenter_switch_name", context).removeAttr("required");
$("#vcenter_cluster_id", context).removeAttr("required");
$("#phydev", context).removeAttr("required");
@ -144,8 +149,11 @@ define(function(require) {
$("#vnetCreateSecurityTab-label").show();
$("#automatic_vlan_id option[value='NO']", context).show();
$("input[wizard_field=\"VLAN_ID\"]", context).removeAttr("required");
switch ($(this).val()) {
//NSX
$("select#nsx-transport", context).removeAttr("required").removeAttr("value");
$("select#nsx-instance-id", context).removeAttr("required").removeAttr("value");
$("select#nsx-host-id", context).removeAttr("required").removeAttr("value");
switch ($(this).find("option:selected").attr("data-form")) {
case "bridge":
$("div.mode_param.bridge", context).show();
$("div.mode_param.bridge [wizard_field]", context).prop("wizard_field_disabled", false);
@ -220,6 +228,15 @@ define(function(require) {
$("#div_vn_mad", context).hide();
break;
case "nsx":
$("div.network_mode_description").hide();
$("div.mode_param.nsx", context).show();
$("select#nsx-type", context).attr("required", "");
$("select#nsx-instance-id", context).attr({required: "", value: ""});
$("select#nsx-host-id", context).attr({required: "", value: ""});
$("select#nsx-transport", context).attr("required", "");
$("div.mode_param.nsx [wizard_field]", context).prop("wizard_field_disabled", false);
break;
case "custom":
$("div.mode_param.custom", context).show();
$("div.mode_param.custom [wizard_field]", context).prop("wizard_field_disabled", false);
@ -402,6 +419,160 @@ define(function(require) {
function _onShow(context) {
var that = this;
var hostActions = {
success: function(req,params,response){
if(response && response.HOST_POOL && response.HOST_POOL.HOST){
var hosts = response.HOST_POOL.HOST;
var nsx_type = $("select#nsx-type", context);
var nsx_transport = $("select#nsx-transport", context);
var nsx_fields = $("#nsx-fields", context);
var nsx_host_id = $("#nsx-host-id", context);
var nsx_instance_id = $("#nsx-instance-id",context);
var full = $("<div/>",{'class': 'small-12 columns'});
var label = $("<label/>");
var input = $("<input/>");
var element = $("<option/>");
nsx_type.empty().append(element.clone().text("--"));
if (!(hosts instanceof Array)) {
hosts = [hosts];
}
if(hosts && nsx_type){
hosts.map(function(host){
var name = (host && host.NAME) || "";
var type_nsx = host && host.TEMPLATE && host.TEMPLATE.NSX_TYPE || "";
var instanciate_id = host && host.TEMPLATE && host.TEMPLATE.VCENTER_INSTANCE_ID || "";
var id = (host && host.ID) || 0;
if(type_nsx && instanciate_id){
type_nsx = type_nsx.toLowerCase() === "nsx-t"? "Opaque Network" : type_nsx;
var option = element.clone();
option.val(type_nsx);
option.attr({"data-id":id, "data-instance": instanciate_id});
option.text(name);
nsx_type.append(option);
}
});
nsx_type.off().on('change', function(){
var optionSelected = $(this).find("option:selected");
var selectId = optionSelected.attr("data-id");
var instanceId = optionSelected.attr("data-instance");
nsx_host_id.val(selectId);
nsx_instance_id.val(instanceId);
var type = $(this).val();
nsx_transport.empty().append(element.clone().text("--"));
nsx_fields.empty();
if(selectId){
var template = hosts.find(function(host) {
if(host && host.ID && host.ID == selectId && host.TEMPLATE && host.TEMPLATE.NSX_TRANSPORT_ZONES){
return true;
}
});
if(template && template.TEMPLATE && template.TEMPLATE.NSX_TRANSPORT_ZONES){
var zones = template.TEMPLATE.NSX_TRANSPORT_ZONES;
var keys = Object.keys(template.TEMPLATE.NSX_TRANSPORT_ZONES);
keys.map(function(key){
var option = element.clone();
nsx_transport.append(option.val(zones[key]).text(key));
});
var idInputs = {
replication: 'nsx-replication',
universalsync: 'nsx-universalsync',
ipdiscovery: 'nsx-ipdiscovery',
maclearning: 'nsx-maclearning',
adminstatus: 'nsx-adminstatus'
};
switch (type.toLowerCase()) {
case 'nsx-v':
//NSX-V
var mode = {
unicast: 'UNICAST_MODE',
hybrid: 'HYBRID_MODE',
multicast: 'MULTICAST_MODE'
};
var inputReplication = input.clone().attr({type:'radio', name: idInputs.replication, id: idInputs.replication});
var replication = full.clone().append(
label.clone().text(Locale.tr("Replication Mode")).add(
inputReplication.clone().val(mode.unicast).attr({id: mode.unicast, checked: ""})
).add(
label.clone().text(mode.unicast).attr({for: mode.unicast})
).add(
inputReplication.clone().val(mode.hybrid).attr({id: mode.hybrid})
).add(
label.clone().text(mode.hybrid).attr({for: mode.hybrid})
).add(
inputReplication.clone().val(mode.multicast).attr({id: mode.multicast})
).add(
label.clone().text(mode.multicast).attr({for: mode.multicast})
)
);
var universalSync = full.clone().append(
input.clone().attr({type: 'checkbox', name: idInputs.universalsync, id: idInputs.universalsync}).add(
label.clone().text(Locale.tr("Universal Synchronization"))
)
);
var ipDiscover = full.clone().append(
input.clone().attr({type: 'checkbox', name: idInputs.ipdiscovery, id: idInputs.ipdiscovery, checked: ""}).add(
label.clone().text(Locale.tr("IP Discovery"))
)
);
var macLearning = full.clone().append(
input.clone().attr({type: 'checkbox', name: idInputs.maclearning, id: idInputs.maclearning}).add(
label.clone().text(Locale.tr("MAC Learning"))
)
);
nsx_fields.append(replication.add(universalSync).add(ipDiscover).add(macLearning));
break;
case 'nsx-t':
//NSX-T
var adminStatusInput = input.clone().attr({type:'radio', name: idInputs.adminstatus, id: idInputs.adminstatus});
var inputRep = input.clone().attr({type:'radio', name: idInputs.replication, id: idInputs.replication});
var adminStatusOptions = {
up: 'UP',
down: 'DOWN'
};
var replicationModeIOptions = {
mtep: 'MTEP',
source: 'SOURCE'
};
var adminStatus = full.clone().append(
label.clone().text(Locale.tr("Admin Status")).add(
adminStatusInput.clone().val(adminStatusOptions.up).attr({id: adminStatusOptions.up, checked: ""})
).add(
label.clone().text(Locale.tr(adminStatusOptions.up)).attr({for: adminStatusOptions.up})
).add(
adminStatusInput.clone().val(adminStatusOptions.down).attr({id: adminStatusOptions.down})
).add(
label.clone().text(Locale.tr(adminStatusOptions.down)).attr({for: adminStatusOptions.down})
)
);
var replicationMode = full.clone().append(
label.clone().text(Locale.tr("Replication Mode")).add(
inputRep.clone().val(replicationModeIOptions.mtep).attr({id: replicationModeIOptions.mtep, checked: ""})
).add(
label.clone().text(Locale.tr(replicationModeIOptions.mtep)).attr({for: replicationModeIOptions.mtep})
).add(
inputRep.clone().val(replicationModeIOptions.source).attr({id: replicationModeIOptions.source})
).add(
label.clone().text(Locale.tr(replicationModeIOptions.source)).attr({for: replicationModeIOptions.source})
)
);
nsx_fields.append(adminStatus.add(replicationMode));
break;
default:
//NOTHING
break;
}
}
}
});
}
}
},
error: function(){
console.log("ERRROR");
}
};
OpenNebulaAction.list(hostActions,actionHost);
this.securityGroupsTable.refreshResourceTableSelect();

View File

@ -91,17 +91,59 @@
{{tr "Network mode"}}
</label>
<select wizard_field="VN_MAD" name="network_mode" id="network_mode">
<option value="bridge">{{tr "Bridged"}}</option>
<option value="fw">{{tr "Bridged & Security Groups"}}</option>
<option value="ebtables">{{tr "Bridged & ebtables VLAN"}}</option>
<option value="802.1Q">{{tr "802.1Q"}}</option>
<option value="vxlan">{{tr "VXLAN"}}</option>
<option value="ovswitch">{{tr "Open vSwitch"}}</option>
<option value="ovswitch_vxlan">{{tr "Open vSwitch - VXLAN"}}</option>
<option value="vcenter">{{tr "vCenter"}}</option>
<option value="custom">{{tr "Custom"}}</option>
<option value="bridge" data-form="bridge">{{tr "Bridged"}}</option>
<option value="fw" data-form="fw">{{tr "Bridged & Security Groups"}}</option>
<option value="ebtables" data-form="ebtables">{{tr "Bridged & ebtables VLAN"}}</option>
<option value="802.1Q" data-form="802.1Q">{{tr "802.1Q"}}</option>
<option value="vxlan" data-form="vxlan">{{tr "VXLAN"}}</option>
<option value="ovswitch" data-form="ovswitch">{{tr "Open vSwitch"}}</option>
<option value="ovswitch_vxlan" data-form="ovswitch_vxlan">{{tr "Open vSwitch - VXLAN"}}</option>
<option value="vcenter" data-form="vcenter">{{tr "vCenter"}}</option>
<option value="vcenter" data-form="nsx">{{tr "NSX"}}</option>
<option value="custom" data-form="custom">{{tr "Custom"}}</option>
</select>
</div>
<div class="row columns">
<div class="mode_param nsx large-12 columns nsx-form">
<div class="row">
<div class="small-12 columns">
<label for="">
{{tr "Host"}}
</label>
<select wizard_field="VCENTER_PORTGROUP_TYPE" name="nsx-type" id="nsx-type"></select>
</div>
</div>
<!--hide-->
<div class="row hide">
<div class="small-12 columns">
<label for="">
{{tr "Host Instance"}}
</label>
<input type="text" wizard_field="VCENTER_INSTANCE_ID" name="nsx-instance-id" id="nsx-instance-id">
</div>
</div>
<!--hide-->
<div class="row hide">
<div class="small-12 columns">
<label for="">
{{tr "Host ID"}}
</label>
<input type="text" wizard_field="VCENTER_ONE_HOST_ID" name="nsx-host-id" id="nsx-host-id"></select>
</div>
</div>
<div class="row">
<div class="small-12 columns">
<label for="">
{{tr "Transport"}}
</label>
<select wizard_field="NSX_TZ_ID" name="nsx-transport" id="nsx-transport">
<option value="">--</option>
</select>
</div>
</div>
<div class="row" id="nsx-fields"></div>
</div>
</div>
<div class="large-3 medium-6 columns mode_param vcenter custom" id="div_vn_mad">
<label for="vn_mad">
{{tr "Network Driver (VN_MAD)"}}

View File

@ -136,7 +136,6 @@ define(function(require) {
$("#network_mode", context).change(function() {
$("div.mode_param", context).hide();
$("div.mode_param [wizard_field]", context).prop("wizard_field_disabled", true);
$("input#vn_mad", context).removeAttr("required");
$("input#vn_mad", context).removeAttr("value");
$("#vcenter_switch_name", context).removeAttr("required");

1
sshuttle.pid Normal file
View File

@ -0,0 +1 @@
26408