Skip to content

Commit

Permalink
Merge "Related-Bug: #1528133 Implement route table in MVC. 1. Added t…
Browse files Browse the repository at this point in the history
…wo tabs (network/interface route table)"
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jan 18, 2016
2 parents 5d3da36 + 15f1b70 commit 96418d5
Show file tree
Hide file tree
Showing 18 changed files with 1,525 additions and 6 deletions.
3 changes: 3 additions & 0 deletions webroot/common/api/featureList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,7 @@
<item>
<feature>svcApplianceSet</feature>
</item>
<item>
<feature>rtTableConfig</feature>
</item>
</featureLists>
10 changes: 10 additions & 0 deletions webroot/common/api/jsonDiff.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ var configJsonModifyObj = {
'service_appliance_set_properties'],
'mandateFields': ['fq_name', 'uuid', 'display_name']
},
'route-table': {
'isConfig': true,
'optFields': ['routes'],
'mandateFields': ['fq_name', 'uuid', 'display_name']
},
'interface-route-table': {
'isConfig': true,
'optFields': ['interface_route_table_routes'],
'mandateFields': ['fq_name', 'uuid', 'display_name']
},
'physical-topology': {
'preProcessCB': {
'applyOnOldJSON': modifyPhyTopoData,
Expand Down
16 changes: 16 additions & 0 deletions webroot/common/ui/js/controller.labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,22 @@ define([
this.TITLE_CREATE_SVC_APPLIANCE_SET = 'Create Service Appliance Set';
this.SVC_APPLIANCE_SET_DETAILS = 'Service Appliance Set Details';

/* Route Table */
this.RT_TABLE_TAB_ID = 'rt-table-tab';
this.CONFIG_RT_TABLE_PAGE_ID = 'config-rttable—page';
this.CONFIG_RT_TABLE_LIST_VIEW_ID = 'config-rttable-list';
this.CONFIG_RT_TABLE_SECTION_ID = 'rtTable';
this.CONFIG_RT_TABLE_ID = 'config-rt-table';
this.NETWORK_ROUTE_TABLE_ID = 'network-rt-table';
this.INTERFACE_ROUTE_TABLE_ID = 'interface-rt-table';
this.TITLE_RT_TABLE = 'Route Tables';
this.RT_TABLE_GRID_ID = 'rt-table-grid';
this.RT_TABLE_PREFIX_ID = 'route_table';
this.TITLE_CREATE_RT_TABLE = 'Create Route Table';
this.TITLE_DEL_RT_TABLE = 'Delete Route Table';
this.TITLE_EDIT_RT_TABLE = 'Edit Route Table';
this.RT_TABLE_DETAILS = 'Route Table Details';

};
return CTLabels;
});
8 changes: 4 additions & 4 deletions webroot/config/common/api/configUtil.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ function getConfigDetailsAsync (dataObj, callback)
if (null != dataObj['fields']) {
url += '&fields=' + dataObj['fields'];
}
if (null != dataObj['parent_uuid']) {
url += '&parent_uuid=' + dataObj['parent_uuid'];
if (null != dataObj['parent_id']) {
url += '&parent_id=' + dataObj['parent_id'];
}
configApiServer.apiGet(url, appData, function(err, data) {
callback(err, data);
Expand All @@ -204,8 +204,8 @@ function getConfigDetails (req, res, appData)
if ((null != fields) && (fields.length > 0)) {
dataObjArr[i]['fields'] = fields.join(',');
}
if (null != postData[i]['parent_uuid']) {
dataObjArr[i]['parent_uuid'] = postData[i]['parent_uuid'];
if (null != postData[i]['parent_id']) {
dataObjArr[i]['parent_id'] = postData[i]['parent_id'];
}
}
async.map(dataObjArr, getConfigDetailsAsync, function(err, results) {
Expand Down
28 changes: 28 additions & 0 deletions webroot/config/networking/routetable/api/parseURL.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
-->
<urlLists>
<require>
<define>parseURLReq</define>
<path>process.mainModule.exports["corePath"] + '/src/serverroot/common/parseURLRequire'</path>
</require>
<require>
<define>rtTableApi</define>
<path>./routetable.api</path>
</require>
<!-- API / Feature definition for Security Group configuration -->
<!-- 1. List Security Group -
-->
<item>
<url>/api/tenants/config/route-table/:type</url>
<method>post</method>
<feature>rtTableConfig</feature>
<callback>rtTableApi.createRouteTable</callback>
</item>
<item>
<url>/api/tenants/config/route-table/:type/:id</url>
<method>put</method>
<feature>rtTableConfig</feature>
<callback>rtTableApi.updateRouteTable</callback>
</item>
</urlLists>
60 changes: 60 additions & 0 deletions webroot/config/networking/routetable/api/routetable.api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
*/

/**
* @routetable.api.js
* - Handlers for Route Table Configuration
* - Interfaces with config api server
*/

var logutils = require(process.mainModule.exports["corePath"] +
'/src/serverroot/utils/log.utils');
var commonUtils = require(process.mainModule.exports["corePath"] +
'/src/serverroot/utils/common.utils');
var messages = require(process.mainModule.exports["corePath"] +
'/src/serverroot/common/messages');
var util = require('util');
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 routetable.api.js"
*/
if (!module.parent)
{
logutils.logger.warn(util.format(messages.warn.invalid_mod_call,
module.filename));
process.exit(1);
}

function createRouteTable (req, res, appData)
{
var type = req.param('type');
var rtCreateURL = '/' + type + 's';
var postData = req.body;

configApiServer.apiPost(rtCreateURL, postData, appData,
function(error, data) {
commonUtils.handleJSONResponse(error, res, data);
});
}

function updateRouteTable (req, res, appData)
{
var id = req.param('id');
var type = req.param('type');
var putData = req.body;
var rtEditURL = '/' + type + '/' + id;
jsonDiff.getConfigDiffAndMakeCall(rtEditURL, appData, putData,
function(error, data) {
commonUtils.handleJSONResponse(error, res, data);
});
}

exports.createRouteTable = createRouteTable;
exports.updateRouteTable = updateRouteTable;

153 changes: 153 additions & 0 deletions webroot/config/networking/routetable/ui/js/RtTableUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
*/
define([
'underscore'
], function (_) {
var rtTableUtils = function() {
var self = this;

self.getRtsHopCollectionView = function() {
return {
columns: [{
elementId: 'prefix',
view: 'FormInputView',
class: "", width: 375,
viewConfig: {
label: 'Prefix',
templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW,
path: 'prefix',
dataBindValue: 'prefix()'
}
},
{
elementId: 'next_hop',
view: 'FormInputView',
class: "", width: 375,
viewConfig: {
label: 'Next Hop',
templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW,
path: 'next_hop',
dataBindValue: 'next_hop()'
}
},
{
elementId: 'next_hop_type',
view: 'FormInputView',
class: "", width: 375,
viewConfig: {
label: 'Next Hop Type',
templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW,
path: 'next_hop_type',
dataBindValue: 'next_hop_type()'
}
},
{
elementId: 'community_attr',
view: 'FormTextAreaView',
class: "", width: 375,
viewConfig: {
scrollHeight: 200,
height: 200,
label: 'Community Attribute',
templateId: cowc.TMPL_EDITABLE_GRID_TEXTAREA_VIEW,
path: 'community_attr',
dataBindValue: 'community_attr()'
}
}]
}
},
self.getRtsCommAttrCollectionView = function() {
return {
columns: [{
elementId: 'community-attr-collection',
view: "FormCollectionView",
viewConfig: {
colSpan: "2",
path: 'communityAttrs',
collection: 'communityAttrs()',
templateId: cowc.TMPL_GEN_COLLECTION_VIEW,
collectionActions: {
add: {onClick: "addCommunityAttr()",
iconClass: 'icon-plus',
buttonTitle: 'Add Community Attributes',
}
},
rows: [{
rowActions: [
{onClick: "deleteCommunityAttr()",
iconClass: 'icon-minus'}
],
columns: [{
elementId: 'community_attr',
view: 'FormComboboxView',
class: "", width: 385,
viewConfig: {
label: 'Community Attribute',
templateId:
cowc.TMPL_EDITABLE_GRID_COMBOBOX_VIEW,
path: 'community_attr',
dataBindValue: 'community_attr()',
elementConfig: {
placeholder: 'Select or Enter ' +
'Community Attribute ' +
'String',
dataTextField : "text",
dataValueField : "id",
dataSource: {
type: 'local',
data : [
{'text': 'no-export',
'id': 'no-export'},
{'text': 'accept-own',
'id': 'accept-own'},
{'text': 'no-advertise',
'id': 'no-advertise'},
{'text': 'no-export-subconfed',
'id': 'no-export-subconfed'},
{'text': 'no-reoriginate',
'id': 'no-reoriginate'}
]
}
}
}
}]
}]
}
}]
}
},
self.getRtTableView = function () {
return {
elementId: 'rtTypesCollection',
view: 'AccordianView',
viewConfig: [{
elementId: 'rtTypesCollectionAccordian',
title: 'Routes',
view: 'SectionView',
viewConfig: {
rows: [{
columns: [{
elementId: 'route-collection',
view: "FormEditableGridView",
viewConfig: {
path: 'routes',
collection: 'routes()',
collectionActions: {
add: {onClick: "$root.addRtTable()",
iconClass: 'icon-plus',
buttonTitle: 'Add Static Routes'
}
},
validations: 'routesValidation',
}
}]
}]
}
}]
}
}
};
return rtTableUtils;
});

46 changes: 46 additions & 0 deletions webroot/config/networking/routetable/ui/js/models/CommAttrModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
*/
define([
'underscore',
'contrail-model'
], function (_, ContrailModel) {
var CommAttrModel = ContrailModel.extend({

defaultConfig: {
community_attr: ''
},
validateAttr: function (attributePath, validation, data) {
var model = data.model().attributes.model(),
attr = cowu.getAttributeFromPath(attributePath),
errors = model.get(cowc.KEY_MODEL_ERRORS),
attrErrorObj = {}, isValid;

isValid = model.isValid(attributePath, validation);

attrErrorObj[attr + cowc.ERROR_SUFFIX_ID] = (isValid == true) ? false : isValid;
errors.set(attrErrorObj);
},
validations: {
commAttrValidation: {
}
},
deleteCommunityAttr: function(data, attr) {
var coll = this.model().collection;
var item = this.model();
coll.remove(item);
},
addCommunityAttr: function(data, obj) {
var coll = this.model().collection;
var commAttr =
this.model().attributes.model().get('next_hop');

var newCommAttr =
new CommAttrModel({'prefix': "", 'next_hop': nextHop});
coll.add([newCommAttr]);
}
});

return CommAttrModel;
});

0 comments on commit 96418d5

Please sign in to comment.