diff --git a/webroot/common/api/jsonDiff.helper.js b/webroot/common/api/jsonDiff.helper.js
index 8c6611d43..e82897234 100644
--- a/webroot/common/api/jsonDiff.helper.js
+++ b/webroot/common/api/jsonDiff.helper.js
@@ -58,6 +58,16 @@ var configJsonModifyObj = {
'optFields': ['virtual_machine_interface_refs'],
'mandateFields': ['fq_name', 'uuid', 'display_name']
},
+ 'global-system-config': {
+ 'isConfig': true,
+ 'optFields': ['autonomous_system', 'ibgp_auto_mesh', 'ip_fabric_subnets'],
+ 'mandateFields': ['fq_name', 'uuid', 'display_name']
+ },
+ 'global-vrouter-config': {
+ 'isConfig': true,
+ 'optFields': ['vxlan_network_identifier_mode', 'encapsulation_priorities', 'linklocal_services'],
+ 'mandateFields': ['fq_name', 'uuid', 'display_name']
+ },
'physical-topology': {
'preProcessCB': {
'applyOnOldJSON': modifyPhyTopoData,
diff --git a/webroot/config/bgp/api/admin.api.js b/webroot/config/bgp/api/admin.api.js
index f9ed42db0..264cdffd2 100644
--- a/webroot/config/bgp/api/admin.api.js
+++ b/webroot/config/bgp/api/admin.api.js
@@ -1066,18 +1066,20 @@ function updateGlobalConfigObj (error, data,
commonUtils.handleJSONResponse(error, response, null);
return;
}
-
+ var actData = commonUtils.cloneObj(data);
gASN = globalASNBody['global-system-config']['autonomous_system'] ;
data['global-system-config']['autonomous_system'] = gASN;
gscURL += data['global-system-config']['uuid'];
-
- configApiServer.apiPut(gscURL, data, appData,
- function(error, data) {
- setTimeout(function() {
+ var diffObj = jsonDiff.getConfigJSONDiff('global-system-config', actData, data);
+ if(diffObj != null) {
+ configApiServer.apiPut(gscURL, diffObj, appData,
+ function(error, data) {
commonUtils.handleJSONResponse(error, response, null);
- }, 3000);
- });
+ });
+ } else {
+ commonUtils.handleJSONResponse(error, response, null);
+ }
}
/**
@@ -1136,18 +1138,20 @@ function updateiBGPAutoMeshObj (error, data,
commonUtils.handleJSONResponse(error, response, null);
return;
}
-
+ var actData = commonUtils.cloneObj(data);
iBGPAutoMesh = globaliBGPAutoMesh['global-system-config']['ibgp_auto_mesh'] ;
data['global-system-config']['ibgp_auto_mesh'] = iBGPAutoMesh;
gscURL += data['global-system-config']['uuid'];
-
- configApiServer.apiPut(gscURL, data, appData,
- function(error, data) {
- setTimeout(function() {
+ var diffObj = jsonDiff.getConfigJSONDiff('global-system-config', actData, data);
+ if(diffObj != null) {
+ configApiServer.apiPut(gscURL, diffObj, appData,
+ function(error, data) {
commonUtils.handleJSONResponse(error, response, null);
- }, 3000);
- });
+ });
+ } else {
+ commonUtils.handleJSONResponse(error, response, null);
+ }
}
/**
@@ -1193,6 +1197,78 @@ function updateiBGPAutoMesh (request, response, appData) {
});
}
+/**
+ * @updateIPFabricSubnetsObj
+ * Update the IP Fabric Subnets
+ */
+function updateIPFabricSubnetsObj (error, data,
+ globalIPFabricSubnets, response, appData)
+{
+ var gscURL = '/global-system-config/';
+ var ipFabricSubnets = null;
+
+ if (error) {
+ commonUtils.handleJSONResponse(error, response, null);
+ return;
+ }
+ var actData = commonUtils.cloneObj(data);
+ ipFabricSubnets = globalIPFabricSubnets['global-system-config']['ip_fabric_subnets'] ;
+ data['global-system-config']['ip_fabric_subnets'] = ipFabricSubnets;
+ gscURL += data['global-system-config']['uuid'];
+ var diffObj = jsonDiff.getConfigJSONDiff('global-system-config', actData, data);
+ if(diffObj != null) {
+ configApiServer.apiPut(gscURL, diffObj, appData,
+ function(error, data) {
+ commonUtils.handleJSONResponse(error, response, null);
+ });
+ } else {
+ commonUtils.handleJSONResponse(error, response, null);
+ }
+}
+
+/**
+ * @getIPFabricSubnetsObj
+ * private function
+ * Gets the GSC Object
+ */
+function getIPFabricSubnetsObj (error, data, globalIPFabricSubnets, response, appData) {
+ var gscURL = '/global-system-config/';
+
+ if (error) {
+ commonUtils.handleJSONResponse(error, response, null);
+ return;
+ }
+
+ gscURL += data['uuid'];
+
+ configApiServer.apiGet(gscURL, appData,
+ function(error, data) {
+ updateIPFabricSubnetsObj(error, data,
+ globalIPFabricSubnets, response, appData)
+ });
+}
+
+
+/**
+ * @updateIPFabricSubnets
+ * public function
+ * 1. URL /api/tenants/admin/config/ip-fabric-subnets
+ * 2. Updates Global ASN
+ */
+function updateIPFabricSubnets (request, response, appData) {
+ var globalIPFabricSubnets = request.body;
+ var fqnameURL = '/fqname-to-id';
+ var gscReqBody = null;
+
+ gscReqBody = {'fq_name': ['default-global-system-config'],
+ 'type': 'global-system-config'};
+ configApiServer.apiPost(fqnameURL, gscReqBody, appData,
+ function(error, data) {
+ getIPFabricSubnetsObj(error, data,
+ globalIPFabricSubnets, response, appData);
+ });
+}
+
/**
* @readGlobalConfigObj
* private function
@@ -1221,7 +1297,8 @@ function readGlobalConfigObj (error, data, globalASNBody, response, appData) {
['uuid'],
'autonomous_system':data['global-system-config']
['autonomous_system'],
- 'ibgp_auto_mesh':data['global-system-config']['ibgp_auto_mesh']}
+ 'ibgp_auto_mesh':data['global-system-config']['ibgp_auto_mesh'],
+ 'ip_fabric_subnets':data['global-system-config']['ip_fabric_subnets']}
};
commonUtils.handleJSONResponse(error, response, gscObj);
return;
@@ -1784,4 +1861,5 @@ exports.deleteBGPRouter = deleteBGPRouter;
exports.getControlNodeDetailsFromConfig = getControlNodeDetailsFromConfig;
exports.getApiServerDataByPage = getApiServerDataByPage;
exports.updateiBGPAutoMesh = updateiBGPAutoMesh;
+exports.updateIPFabricSubnets = updateIPFabricSubnets;
diff --git a/webroot/config/bgp/api/parseURL.xml b/webroot/config/bgp/api/parseURL.xml
index b14bf121b..8dfad2bd4 100644
--- a/webroot/config/bgp/api/parseURL.xml
+++ b/webroot/config/bgp/api/parseURL.xml
@@ -134,5 +134,11 @@
orchestration
adminapi.getApiServerDataByPage
+ -
+ /api/tenants/admin/config/ip-fabric-subnets
+ put
+ bgp
+ adminapi.updateIPFabricSubnets
+
diff --git a/webroot/config/bgp/ui/js/bgp_config.js b/webroot/config/bgp/ui/js/bgp_config.js
index bcfc82a24..86c1cc4ce 100644
--- a/webroot/config/bgp/ui/js/bgp_config.js
+++ b/webroot/config/bgp/ui/js/bgp_config.js
@@ -171,6 +171,7 @@ function clearBgpWindow() {
$('#ddAuthType').data('contrailDropdown').value('none');
$('#ddProuter').data('contrailDropdown').value('none');
disableAuthKeyTextbox();
+ window.selectedRow = null;
}
function disableAuthKeyTextbox() {
@@ -809,9 +810,7 @@ function initComponents() {
//},
customControls: [
'',
- '',
- '',
- '
'
+ ''
]
},
columnHeader : {
diff --git a/webroot/config/forwardingoptions/ui/js/fwd_options_config.js b/webroot/config/forwardingoptions/ui/js/fwd_options_config.js
deleted file mode 100644
index 69236b5af..000000000
--- a/webroot/config/forwardingoptions/ui/js/fwd_options_config.js
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
- */
-
-fwdOptionsConfigObj = new ForwardingOptionsConfigObj();
-
-function ForwardingOptionsConfigObj() {
- this.load = load;
- this.init = init;
- this.destroy = destroy;
- this.initComponents = initComponents;
- this.createEPEntry = createEPEntry;
- this.appendEPEntry = appendEPEntry
- this.deleteEPEntry = deleteEPEntry;
- this.clearEPEntries = clearEPEntries;
- this.populateData = populateData;
- this.validate = validate;
- //Variable definitions
- //Dropdowns
- var ddVxLan;
-
- //Buttons
- var btnSaveFwdOptions, btnCnfSaveCancel, btnCnfSaveOK;
- var confirmMainSave;
-}
-
-function load() {
- var configTemplate = Handlebars.compile($("#fwdoptions-config-template").html());
- $(contentContainer).html('');
- $(contentContainer).html(configTemplate);
- currTab = 'config_infra_fwdoptions';
- init();
-}
-
-function initComponents() {
- btnSaveFwdOptions = $("#btnSaveFwdOptions");
- btnCnfSaveOK = $("#btnCnfSaveOK");
- btnCnfSaveCancel = $("#btnCnfSaveCancel");
- ddVxLan = $("#ddVxLan").contrailDropdown({
- data: [{id:"automatic", text:'Automatic'}, {id:"configured", text:'Configured'}]
- });
-
-
- confirmMainSave = $("#confirmMainSave");
- confirmMainSave.modal({backdrop:'static', keyboard: false, show:false});
-}
-
-function initActions() {
- btnSaveFwdOptions.click(function (e) {
- e.preventDefault();
- if(validate() === true)
- confirmMainSave.modal('show');
- return false;
- });
-
- btnCnfSaveCancel.click(function (a) {
- confirmMainSave.modal('hide');
- });
-
- btnCnfSaveOK.click(function (a) {
- var globalVRouterConfig = {};
- globalVRouterConfig["global-vrouter-config"] = {};
- var vxlanid = $(ddVxLan).val();
- globalVRouterConfig["global-vrouter-config"]["vxlan_network_identifier_mode"] = vxlanid;
-
- var priorities = [];
- var epTuples = $("#epTuples")[0].children;
- if (epTuples && epTuples.length > 0) {
- var encapsulationLabels = ["MPLS Over GRE","MPLS Over UDP","VxLAN"];
- var encapsulationValues = ["MPLSoGRE","MPLSoUDP","VXLAN"];
-
- for (var i = 0; i < epTuples.length; i++) {
- var epTuple = $($($(epTuples[i]).find("div")[0]).find("div")[0]);
- var priority = $($(epTuple).find("div.span12")[1]).data("contrailDropdown").text();
- if(encapsulationLabels.indexOf(priority) !== -1) {
- priorities.push(encapsulationValues[encapsulationLabels.indexOf(priority)]);
- }
- }
- }
- if(vxlanid === "configured" && priorities.indexOf("VXLAN") === -1) {
- showInfoWindow("Encapsulation type 'VxLAN' is required while setting VxLAN identifier mode.", "Input Required");
- return false;
- }
-
- if(priorities.length > 0) {
- globalVRouterConfig["global-vrouter-config"]["encapsulation_priorities"] = {};
- globalVRouterConfig["global-vrouter-config"]["encapsulation_priorities"]["encapsulation"] = [];
- for(var i=0; i 0) {
- var priorities = gvrConfig["encapsulation_priorities"]["encapsulation"];
- for(var i=0; i 0) {
- for (var i = 0; i < epTuples.length; i++) {
- var epTuple = $($(epTuples[i]).find("div")[0]).children();
- var priority = $($(epTuple).find("div.select2-offscreen")[0]).data("contrailDropdown").text();
- existing.push(priority);
- }
- var available = encapsulationLabels.diff(existing);
- if(available.length >0)
- $(selectPriorities).data("contrailDropdown").text(available[0]);
- }
- }
-
- return rootDiv;
-}
-
-function appendEPEntry(who, defaultRow) {
- var len = $("#epTuples").children().length;
- if(len >= 3) {
- return false;
- }
- var epEntry = createEPEntry(null, len);
- if (defaultRow) {
- $("#epTuples").append($(epEntry));
- } else {
- var parentEl = who.parentNode.parentNode.parentNode;
- parentEl.parentNode.insertBefore(epEntry, parentEl.nextSibling);
- }
-}
-
-function deleteEPEntry(who) {
- var epTuples = $("#epTuples")[0].children;
- if (epTuples && epTuples.length == 1) {
- showInfoWindow("Atleast one encapsulation priority is required.", "Invalid Action");
- return false;
- }
- var templateDiv = who.parentNode.parentNode.parentNode;
- $(templateDiv).remove();
- templateDiv = $();
-}
-
-function clearEPEntries() {
- var tuples = $("#epTuples")[0].children;
- if (tuples && tuples.length > 0) {
- var tupleLength = tuples.length;
- for (var i = 0; i < tupleLength; i++) {
- $(tuples[i]).empty();
- }
- $(tuples).empty();
- $("#epTuples").empty();
- }
-}
-
-function validate() {
- var vxlanid = $(ddVxLan).val();
- var priorities = [];
- var epTuples = $("#epTuples")[0].children;
- if (epTuples && epTuples.length > 0) {
- var encapsulationLabels = ["MPLS Over GRE","MPLS Over UDP","VxLAN"];
- var encapsulationValues = ["MPLSoGRE","MPLSoUDP","VXLAN"];
-
- for (var i = 0; i < epTuples.length; i++) {
- var epTuple = $($($(epTuples[i]).find("div")[0]).find("div")[0]);
- var priority = $($(epTuple).find("div.span12")[1]).data("contrailDropdown").text();
- if(encapsulationLabels.indexOf(priority) !== -1) {
- priorities.push(encapsulationValues[encapsulationLabels.indexOf(priority)]);
- }
- }
- var unique=priorities.filter(function(itm,i,a){
- return i==priorities.indexOf(itm);
- });
- if(priorities.length != unique.length){
- showInfoWindow("Two Encapsulation cannot be same.", "Input Required");
- return false;
- }
- }
- if(vxlanid === "configured" && priorities.indexOf("VXLAN") === -1) {
- showInfoWindow("Encapsulation type 'VxLAN' is required while setting VxLAN identifier mode.", "Input Required");
- return false;
- }
- return true;
-}
-
-function destroy() {
- clearEPEntries();
-
- btnSaveFwdOptions = $("#btnSaveFwdOptions");
- if(isSet(btnSaveFwdOptions)) {
- btnSaveFwdOptions.remove();
- btnSaveFwdOptions = $();
- }
-
- btnCnfSaveCancel = $("#btnCnfSaveCancel");
- if(isSet(btnCnfSaveCancel)) {
- btnCnfSaveCancel.remove();
- btnCnfSaveCancel = $();
- }
-
- btnCnfSaveOK = $("#btnCnfSaveOK");
- if(isSet(btnCnfSaveOK)) {
- btnCnfSaveOK.remove();
- btnCnfSaveOK = $();
- }
-
- ddVxLan = $("#ddVxLan").data("contrailDropdown");
- if(isSet(ddVxLan)) {
- ddVxLan.destroy();
- ddVxLan = $();
- }
-
- confirmMainSave = $("#confirmMainSave");
- if(isSet(confirmMainSave)) {
- confirmMainSave.remove();
- confirmMainSave = $();
- }
-
- var fwdOptionsTemplate = $("#fwdoptions-config-template");
- if(isSet(fwdOptionsTemplate)) {
- fwdOptionsTemplate.remove();
- fwdOptionsTemplate = $();
- }
-}
diff --git a/webroot/config/forwardingoptions/ui/js/global_options_config.js b/webroot/config/forwardingoptions/ui/js/global_options_config.js
new file mode 100644
index 000000000..926344774
--- /dev/null
+++ b/webroot/config/forwardingoptions/ui/js/global_options_config.js
@@ -0,0 +1,785 @@
+/*
+ * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
+ */
+
+fwdOptionsConfigObj = new ForwardingOptionsConfigObj();
+
+function ForwardingOptionsConfigObj() {
+ this.load = load;
+ this.init = init;
+ this.destroy = destroy;
+ this.initComponents = initComponents;
+ this.createEPEntry = createEPEntry;
+ this.appendEPEntry = appendEPEntry
+ this.deleteEPEntry = deleteEPEntry;
+ this.clearEPEntries = clearEPEntries;
+ this.populateData = populateData;
+ this.validate = validate;
+ //Variable definitions
+ //Dropdowns
+ var ddVxLan;
+
+ //Buttons
+ var btnSaveFwdOptions, btnCnfSaveCancel, btnCnfSaveOK;
+ var confirmMainSave;
+}
+
+function load() {
+ var configTemplate = Handlebars.compile($("#fwdoptions-config-template").html());
+ $(contentContainer).html('');
+ $(contentContainer).html(configTemplate);
+ currTab = 'config_infra_fwdoptions';
+ init();
+}
+
+function initComponents() {
+ dynamicID = 0;
+ $("#gridGlobalConfig").contrailGrid({
+ header : {
+ title : {
+ text : 'Global Config Options',
+ },
+ customControls: ['']
+ },
+ columnHeader : {
+ columns : [
+ {
+ id: "property",
+ field: "property",
+ name: "",
+ minWidth : 60,
+ sortable: false
+ },
+ {
+ id: "value",
+ field: "value",
+ name: "",
+ minWidth : 60,
+ sortable: false,
+ formatter: function(r, c, v, cd, dc) {
+ if(dc.property === 'Encapsulation Priority Order') {
+ var ele = '';
+ if(dc.value.length > 0) {
+ for(var i = 0; i < dc.value.length; i++) {
+ var item = dc.value[i];
+ if(ele === ''){
+ ele = '' + item + ''
+ } else {
+ ele += '
' + item + ''
+ }
+ }
+ } else {
+ ele = '-';
+ }
+ return ele;
+ } else if(dc.property === 'iBGP Auto Mesh') {
+ if(dc.value) {
+ return 'Enabled';
+ } else {
+ return "Disabled";
+ }
+ } else if(dc.property === 'IP Fabric Subnets') {
+ var ele = '';
+ if(dc.value.length > 0) {
+ for(var i = 0; i < dc.value.length ; i++) {
+ var item = dc.value[i];
+ if(ele === ''){
+ ele = '' + item.ip_prefix + '/' + item.ip_prefix_len + ''
+ } else {
+ ele += '
' + item.ip_prefix + '/' + item.ip_prefix_len + ''
+ }
+ }
+ } else {
+ ele = '-';
+ }
+ return ele;
+ } else {
+ return dc.value;
+ }
+ }
+ }]
+ },
+ body : {
+ options : {
+ forceFitColumns: true,
+ editable: false,
+ autoEdit: false
+ },
+ dataSource : {
+ data : []
+ },
+ statusMessages: {
+ loading: {
+ text: 'Loading Global Config..',
+ },
+ empty: {
+ text: 'No Global Config Found.'
+ },
+ errorGettingData: {
+ type: 'error',
+ iconClasses: 'icon-warning',
+ text: 'Error in getting Global Config.'
+ }
+ }
+ }
+ });
+
+ gridGlobalConfig = $("#gridGlobalConfig").data('contrailGrid');
+
+ ddVxLan = $("#ddVxLan").contrailDropdown({
+ data: [{id:"automatic", text:'Auto Configured'}, {id:"configured", text:'User Configured'}]
+ });
+
+ $("#ddAutoMesh").contrailDropdown({
+ data : [{id:"enabled", text:'Enabled'}, {id:"disabled", text:'Disabled'}]
+ });
+
+ confirmMainSave = $("#confirmMainSave");
+ confirmMainSave.modal({backdrop:'static', keyboard: false, show:false});
+ windowEditGblConfig = $('#windowEditGblConfig');
+ windowEditGblConfig.modal({backdrop:'static', keyboard: false, show:false});
+}
+
+function showGblConfigEditWindow() {
+ windowEditGblConfig.find('h6.modal-header-title').text('Edit Global Config');
+ setEditPopupData();
+ windowEditGblConfig.modal('show');
+}
+
+function getGasnJSON() {
+ var gasn_params = {};
+ var gasn = $("#txtgasn").val().trim();
+ ggasn = gasn;
+ gasn_params = {
+ "global-system-config":{
+ "_type":ggasnObj._type,
+ "uuid":ggasnObj.uuid,
+ "autonomous_system":parseInt(gasn)
+ }
+ };
+ return gasn_params;
+}
+
+function getiBGPAutoMeshJSON() {
+ var ibgpAutoMeshObj = {};
+ var autoMeshCkd = $('#ddAutoMesh').data('contrailDropdown').value() === 'enabled' ? true : false;
+ ibgpAutoMeshObj = {
+ "global-system-config":{
+ "_type":ggasnObj._type,
+ "uuid":ggasnObj.uuid,
+ "ibgp_auto_mesh":autoMeshCkd
+ }
+ };
+ return ibgpAutoMeshObj;
+}
+
+function isPriorityChanged(oldPriority, newPriority) {
+ if(oldPriority.length != newPriority.length) {
+ return true;
+ } else {
+ for(var i = 0; i < oldPriority.length; i++) {
+ if(oldPriority[i] != newPriority[i]) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+function isIPFabricSubnetChanged(oldSubnets, newSubnets) {
+ if(oldSubnets.length != newSubnets.length) {
+ return true;
+ } else {
+ for(var i = 0; i < oldSubnets.length; i++) {
+ if(oldSubnets[i].ip_prefix != newSubnets[i].ip_prefix
+ || oldSubnets[i].ip_prefix_len != newSubnets[i].ip_prefix_len) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+function getModifiedSubnets() {
+ var subnetList = [];
+ var subnetTuples = $("#subnetTuples")[0].children;
+ if (subnetTuples && subnetTuples.length > 0) {
+ for (var i = 0; i < subnetTuples.length; i++) {
+ var id = getID(String($("#subnetTuples").children()[i].id));
+ var cidr = $("#subnetTuples_"+id+"_txtCIDR").val().trim();
+ cidr = cidr.split('/');
+ subnetList.push({"ip_prefix" : cidr[0], "ip_prefix_len" : parseInt(cidr[1], 10)});
+ }
+ }
+ return subnetList;
+}
+
+function getipFabricSubnetsJSON() {
+ var ipFabricSubnetsObj = {};
+ var subnetObj = {};
+ var subnetList = getModifiedSubnets();;
+ subnetObj = {"subnet" : subnetList}
+ ipFabricSubnetsObj = {
+ "global-system-config":{
+ "_type":ggasnObj._type,
+ "uuid":ggasnObj.uuid,
+ "ip_fabric_subnets":subnetObj
+ }
+ };
+ return ipFabricSubnetsObj;
+}
+
+function initActions() {
+ $('#btnEditGblConfigOK').click(function (a) {
+ if(!validate()) {
+ return false;
+ }
+ gridGlobalConfig._dataView.setData([]);
+ gridGlobalConfig.showGridMessage('loading');
+ var globalVRouterConfig = {};
+ var ajaxArry = [];
+ var fwdOptnURL, fwdOptnActionType;;
+ globalVRouterConfig["global-vrouter-config"] = {};
+ var vxlanid = $(ddVxLan).val();
+ globalVRouterConfig["global-vrouter-config"]["vxlan_network_identifier_mode"] = vxlanid;
+
+ var priorities = [];
+ var epTuples = $("#epTuples")[0].children;
+ var epTuples = $("#epTuples")[0].children;
+ if (epTuples && epTuples.length > 0) {
+ var encapsulationLabels = ["MPLS Over GRE","MPLS Over UDP","VxLAN"];
+ var encapsulationValues = ["MPLSoGRE","MPLSoUDP","VXLAN"];
+
+ for (var i = 0; i < epTuples.length; i++) {
+ var epTuple = $($($(epTuples[i]).find("div")[0]).find("div")[0]);
+ var priority = $($(epTuple).find("div.span12")[1]).data("contrailDropdown").text();
+ if(encapsulationLabels.indexOf(priority) !== -1) {
+ priorities.push(encapsulationValues[encapsulationLabels.indexOf(priority)]);
+ }
+ }
+ }
+ if(vxlanid === "configured" && priorities.indexOf("VXLAN") === -1) {
+ showInfoWindow("Encapsulation type 'VxLAN' is required while setting VxLAN identifier mode.", "Input Required");
+ return false;
+ }
+ windowEditGblConfig.modal('hide');
+ if(priorities.length > 0) {
+ globalVRouterConfig["global-vrouter-config"]["encapsulation_priorities"] = {};
+ globalVRouterConfig["global-vrouter-config"]["encapsulation_priorities"]["encapsulation"] = [];
+ for(var i=0; i 1){
+ return(split[1])
+ } else {
+ return -1;
+ }
+}
+
+function handleCommitFailure(result) {
+ showInfoWindow("Error in saving configuration.", "Error", result);
+ fetchData();
+}
+
+function setEditPopupData() {
+ $("#ddVxLan").data("contrailDropdown").value(actVxlan);
+ $("#epTuples").html("");
+ for(var i=0; i 0) {
+ priorities = gvrConfig["encapsulation_priorities"]["encapsulation"];
+ for(var i=0; i 0 ? ggasnObj['ip_fabric_subnets']['subnet'] : [];
+ populateData(gblVrouterCfgData);
+ }).fail(function (msg) {
+ if(msg && msg.statusText !== "abort") {
+ //showInfoWindow("Error in getting Global ASN.", "Error");
+ gridGlobalConfig.showGridMessage('errorGettingData');
+ }
+ });
+}
+
+function init() {
+ this.initComponents();
+ this.initActions();
+ this.fetchData();
+}
+
+function createEPEntry(ep, len) {
+ var encapsulationLabels = ["MPLS Over GRE","MPLS Over UDP","VxLAN"];
+ var encapsulationValues = ["MPLSoGRE","MPLSoUDP","VXLAN"];
+
+ var selectPriorities = document.createElement("div");
+ selectPriorities.className = "span12";
+
+ var divPriorities = document.createElement("div");
+ divPriorities.className = "span5 margin-0-0-5";
+ divPriorities.setAttribute("style", "width: 44%");
+ divPriorities.appendChild(selectPriorities);
+
+ var iBtnAddRule = document.createElement("i");
+ iBtnAddRule.className = "icon-plus";
+ iBtnAddRule.setAttribute("onclick", "appendEPEntry(this);");
+ iBtnAddRule.setAttribute("title", "Add Encapsulation Priority below");
+
+ var divPullLeftMargin5Plus = document.createElement("div");
+ divPullLeftMargin5Plus.className = "pull-left margin-5";
+ divPullLeftMargin5Plus.appendChild(iBtnAddRule);
+
+ var iBtnDeleteRule = document.createElement("i");
+ iBtnDeleteRule.className = "icon-minus";
+ iBtnDeleteRule.setAttribute("onclick", "deleteEPEntry(this);");
+ iBtnDeleteRule.setAttribute("title", "Delete Encapsulation Priority");
+
+ var divPullLeftMargin5Minus = document.createElement("div");
+ divPullLeftMargin5Minus.className = "pull-left margin-5";
+ divPullLeftMargin5Minus.appendChild(iBtnDeleteRule);
+
+ var divRowFluidMargin5 = document.createElement("div");
+ divRowFluidMargin5.className = "row-fluid margin-0-0-5";
+ divRowFluidMargin5.appendChild(divPriorities);
+ divRowFluidMargin5.appendChild(divPullLeftMargin5Plus);
+ divRowFluidMargin5.appendChild(divPullLeftMargin5Minus);
+
+ var rootDiv = document.createElement("div");
+ rootDiv.appendChild(divRowFluidMargin5);
+
+ $(selectPriorities).contrailDropdown({
+ data: [
+ {
+ id: encapsulationValues[0],
+ text: encapsulationLabels[0]
+ },
+ {
+ id: encapsulationValues[1],
+ text: encapsulationLabels[1]
+ },
+ {
+ id: encapsulationValues[2],
+ text: encapsulationLabels[2]
+ }
+ ]
+ });
+
+ if (null !== ep && typeof ep !== "undefined") {
+ $(selectPriorities).data("contrailDropdown").value(ep);
+ } else {
+ var existing = [];
+ var epTuples = $("#epTuples")[0].children;
+ if (epTuples && epTuples.length > 0) {
+ for (var i = 0; i < epTuples.length; i++) {
+ var epTuple = $($(epTuples[i]).find("div")[0]).children();
+ var priority = $($(epTuple).find("div.select2-offscreen")[0]).data("contrailDropdown").text();
+ existing.push(priority);
+ }
+ var available = encapsulationLabels.diff(existing);
+ if(available.length >0)
+ $(selectPriorities).data("contrailDropdown").text(available[0]);
+ }
+ }
+
+ return rootDiv;
+}
+
+function appendEPEntry(who, defaultRow) {
+ var len = $("#epTuples").children().length;
+ if(len >= 3) {
+ return false;
+ }
+ var epEntry = createEPEntry(null, len);
+ if (defaultRow) {
+ $("#epTuples").append($(epEntry));
+ } else {
+ var parentEl = who.parentNode.parentNode.parentNode;
+ parentEl.parentNode.insertBefore(epEntry, parentEl.nextSibling);
+ }
+}
+
+function deleteEPEntry(who) {
+ var epTuples = $("#epTuples")[0].children;
+ if (epTuples && epTuples.length == 1) {
+ showInfoWindow("Atleast one encapsulation priority is required.", "Invalid Action");
+ return false;
+ }
+ var templateDiv = who.parentNode.parentNode.parentNode;
+ $(templateDiv).remove();
+ templateDiv = $();
+}
+
+function clearEPEntries() {
+ var tuples = $("#epTuples")[0].children;
+ if (tuples && tuples.length > 0) {
+ var tupleLength = tuples.length;
+ for (var i = 0; i < tupleLength; i++) {
+ $(tuples[i]).empty();
+ }
+ $(tuples).empty();
+ $("#epTuples").empty();
+ }
+}
+
+function createSubnetEntry(subnet, len) {
+ dynamicID++;
+ id = dynamicID;
+ var inputTxtPoolName = document.createElement("input");
+ inputTxtPoolName.type = "text";
+ inputTxtPoolName.className = "span12";
+ inputTxtPoolName.setAttribute("placeholder", "CIDR");
+ inputTxtPoolName.setAttribute("id","subnetTuples_"+id+"_txtCIDR");
+ var divPoolName = document.createElement("div");
+ divPoolName.className = "span3";
+ divPoolName.setAttribute("style", "width:38%");
+ divPoolName.appendChild(inputTxtPoolName);
+
+
+ var iBtnAddRule = document.createElement("i");
+ iBtnAddRule.className = "icon-plus";
+ iBtnAddRule.setAttribute("onclick", "appendSubnetEntry(this);");
+ iBtnAddRule.setAttribute("title", "Add CIDR below");
+
+ var divPullLeftMargin5Plus = document.createElement("div");
+ divPullLeftMargin5Plus.className = "pull-left margin-5";
+ divPullLeftMargin5Plus.appendChild(iBtnAddRule);
+
+ var iBtnDeleteRule = document.createElement("i");
+ iBtnDeleteRule.className = "icon-minus";
+ iBtnDeleteRule.setAttribute("onclick", "deleteSubnetEntry(this);");
+ iBtnDeleteRule.setAttribute("title", "Delete FIP Pool");
+
+ var divPullLeftMargin5Minus = document.createElement("div");
+ divPullLeftMargin5Minus.className = "pull-left margin-5";
+ divPullLeftMargin5Minus.appendChild(iBtnDeleteRule);
+
+ var divRowFluidMargin5 = document.createElement("div");
+ divRowFluidMargin5.className = "row-fluid margin-0-0-5";
+ divRowFluidMargin5.appendChild(divPoolName);
+ //divRowFluidMargin5.appendChild(divProjects);
+ divRowFluidMargin5.appendChild(divPullLeftMargin5Plus);
+ divRowFluidMargin5.appendChild(divPullLeftMargin5Minus);
+
+ var rootDiv = document.createElement("div");
+ rootDiv.id = "subnetTuples_"+id;
+ rootDiv.appendChild(divRowFluidMargin5);
+
+ if (null !== subnet && typeof subnet !== "undefined") {
+ $(inputTxtPoolName).val(subnet.ip_prefix + '/' + subnet.ip_prefix_len);
+ } else {
+ $(inputTxtPoolName).val('');
+ }
+
+ return rootDiv;
+}
+
+function validateSubnetEntry() {
+ var len = $("#subnetTuples").children().length;
+ if(len > 0) {
+ for(var i=0; i 0) {
+ var tupleLength = tuples.length;
+ for (var i = 0; i < tupleLength; i++) {
+ $(tuples[i]).empty();
+ }
+ $(tuples).empty();
+ $("#subnetTuples").empty();
+ }
+}
+
+function validate() {
+ var vxlanid = $(ddVxLan).val();
+ var priorities = [];
+ var epTuples = $("#epTuples")[0].children;
+ if (epTuples && epTuples.length > 0) {
+ var encapsulationLabels = ["MPLS Over GRE","MPLS Over UDP","VxLAN"];
+ var encapsulationValues = ["MPLSoGRE","MPLSoUDP","VXLAN"];
+
+ for (var i = 0; i < epTuples.length; i++) {
+ var epTuple = $($($(epTuples[i]).find("div")[0]).find("div")[0]);
+ var priority = $($(epTuple).find("div.span12")[1]).data("contrailDropdown").text();
+ if(encapsulationLabels.indexOf(priority) !== -1) {
+ priorities.push(encapsulationValues[encapsulationLabels.indexOf(priority)]);
+ }
+ }
+ var unique=priorities.filter(function(itm,i,a){
+ return i==priorities.indexOf(itm);
+ });
+ if(priorities.length != unique.length){
+ showInfoWindow("Encapsulation cannot be same.", "Input Required");
+ return false;
+ }
+ }
+ if(vxlanid === "configured" && priorities.indexOf("VXLAN") === -1) {
+ showInfoWindow("Encapsulation type 'VxLAN' is required while setting VxLAN identifier mode.", "Input Required");
+ return false;
+ }
+ return true;
+}
+
+function destroy() {
+ clearEPEntries();
+
+ btnSaveFwdOptions = $("#btnSaveFwdOptions");
+ if(isSet(btnSaveFwdOptions)) {
+ btnSaveFwdOptions.remove();
+ btnSaveFwdOptions = $();
+ }
+
+ btnCnfSaveCancel = $("#btnCnfSaveCancel");
+ if(isSet(btnCnfSaveCancel)) {
+ btnCnfSaveCancel.remove();
+ btnCnfSaveCancel = $();
+ }
+
+ btnCnfSaveOK = $("#btnCnfSaveOK");
+ if(isSet(btnCnfSaveOK)) {
+ btnCnfSaveOK.remove();
+ btnCnfSaveOK = $();
+ }
+
+ ddVxLan = $("#ddVxLan").data("contrailDropdown");
+ if(isSet(ddVxLan)) {
+ ddVxLan.destroy();
+ ddVxLan = $();
+ }
+
+ confirmMainSave = $("#confirmMainSave");
+ if(isSet(confirmMainSave)) {
+ confirmMainSave.remove();
+ confirmMainSave = $();
+ }
+
+ var fwdOptionsTemplate = $("#fwdoptions-config-template");
+ if(isSet(fwdOptionsTemplate)) {
+ fwdOptionsTemplate.remove();
+ fwdOptionsTemplate = $();
+ }
+}
diff --git a/webroot/config/forwardingoptions/ui/views/fwd_options_config.view b/webroot/config/forwardingoptions/ui/views/fwd_options_config.view
deleted file mode 100644
index 5e7a560be..000000000
--- a/webroot/config/forwardingoptions/ui/views/fwd_options_config.view
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
diff --git a/webroot/config/forwardingoptions/ui/views/global_options_config.view b/webroot/config/forwardingoptions/ui/views/global_options_config.view
new file mode 100644
index 000000000..140a14d46
--- /dev/null
+++ b/webroot/config/forwardingoptions/ui/views/global_options_config.view
@@ -0,0 +1,116 @@
+
\ No newline at end of file
diff --git a/webroot/config/linklocalservices/api/globalvrouterconfig.api.js b/webroot/config/linklocalservices/api/globalvrouterconfig.api.js
index bf28f91f1..30e1215fd 100644
--- a/webroot/config/linklocalservices/api/globalvrouterconfig.api.js
+++ b/webroot/config/linklocalservices/api/globalvrouterconfig.api.js
@@ -27,6 +27,8 @@ var util = require('util');
var url = require('url');
var configApiServer = require(process.mainModule.exports["corePath"] +
'/src/serverroot/common/configServer.api');
+var jsonDiff = require(process.mainModule.exports["corePath"] +
+ '/src/serverroot/common/jsondiff');
/**
* Bail out if called directly as "nodejs globalvrouterconfig.api.js"
@@ -154,26 +156,30 @@ function updateForwardingOptions (request, response, appData) {
return;
} else {
var gvrPutURL = '/global-vrouter-config/' + gvrId;
- var gvrConfigData = data;
+ var gvrConfigData = commonUtils.cloneObj(data);
gvrConfigData["global-vrouter-config"]["vxlan_network_identifier_mode"] =
gvrPutData["global-vrouter-config"]["vxlan_network_identifier_mode"];
gvrConfigData["global-vrouter-config"]["encapsulation_priorities"] = {};
gvrConfigData["global-vrouter-config"]["encapsulation_priorities"]["encapsulation"] =
gvrPutData["global-vrouter-config"]["encapsulation_priorities"]["encapsulation"];
-
- configApiServer.apiPut(gvrPutURL, gvrConfigData, appData,
- function (error, data) {
- if (error) {
- commonUtils.handleJSONResponse(error, response, null);
- return;
- } else {
- commonUtils.handleJSONResponse(error, response, data);
- }
- return;
- });
- }
- });
+ var diffObj = jsonDiff.getConfigJSONDiff('global-vrouter-config', data, gvrConfigData);
+ if(diffObj != null) {
+ configApiServer.apiPut(gvrPutURL, diffObj, appData,
+ function (error, data) {
+ if (error) {
+ commonUtils.handleJSONResponse(error, response, null);
+ return;
+ } else {
+ commonUtils.handleJSONResponse(error, response, data);
+ }
+ return;
+ });
+ } else {
+ commonUtils.handleJSONResponse(error, response, null);
+ }
+ }
+ });
}
function updateLinkLocalService (request, response, appData) {
diff --git a/webroot/menu.xml b/webroot/menu.xml
index b1208fcf8..efd939f73 100644
--- a/webroot/menu.xml
+++ b/webroot/menu.xml
@@ -392,6 +392,19 @@ and need to add the iconClass tag wherever we need to show some icons
-->
+ -
+
+ config_infra_gblconfig
+
+
+ /config/forwardingoptions/ui
+ global_options_config.view
+ global_options_config.js
+ fwdOptionsConfigObj
+
+
+ Configure Global Config
+
-
config_infra_bgp
@@ -405,19 +418,6 @@ and need to add the iconClass tag wherever we need to show some icons
Configure BGP Peers
- -
-
- config_infra_fwdoptions
-
-
- /config/forwardingoptions/ui
- fwd_options_config.view
- fwd_options_config.js
- fwdOptionsConfigObj
-
-
- Configure Fowarding Options
-
-
config_infra_lls