Skip to content

Commit

Permalink
Merge "Changes for "Add Route Aggregate configuration page to UI""
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Feb 4, 2016
2 parents 7e9c31f + da90c96 commit 3ca6b25
Show file tree
Hide file tree
Showing 19 changed files with 1,325 additions and 3 deletions.
5 changes: 4 additions & 1 deletion webroot/common/api/featureList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,8 @@
</item>
<item>
<feature>bgpasaserviceconfig</feature>
</item>
</item>
<item>
<feature>routeaggregateconfig</feature>
</item>
</featureLists>
11 changes: 11 additions & 0 deletions webroot/common/ui/js/controller.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,17 @@ define([
this.URL_CFG_VN_DETAILS = '/api/tenants/config/virtual-network-details';
//Dns constants
this.ACTIVE_DNS_DATA = "/api/tenants/config/sandesh/virtual-DNS/";

/* Route Aggregate Constants */
this.CONFIG_ROUTE_AGGREGATE_LIST_ID = "config-route-aggregate-list";
this.ROUTE_AGGREGATE_GRID_ID = "route-aggregate-grid";
this.URL_GET_ROUTE_AGGREGATE_DATA = "/api/tenants/config/route-aggregates/";
this.CONFIG_ROUTE_AGGREGATE_SECTION_ID = "config-route-aggregate-section";
this.CONFIG_ROUTE_AGGREGATE_ID = "config-route-aggregate";
this.CONFIG_ROUTE_AGGREGATE_LIST_VIEW_ID = "config-route-aggregate-list-view";
this.ROUTE_AGGREGATE_PREFIX_ID = "route_aggregate";
this.URL_CREATE_ROUTE_AGGREGATE = "/api/tenants/config/route-aggregates";
this.URL_UPDATE_ROUTE_AGGREGATE = "/api/tenants/config/route-aggregate/";
};

//str will be [0-9]+(m|h|s|d)
Expand Down
7 changes: 7 additions & 0 deletions webroot/common/ui/js/controller.labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,13 @@ define([
this.CFG_VN_TITLE_MULTI_DELETE = 'Delete Network(s)';
// End VN Config labels

/* Route Aggregate Labels */
this.TITLE_ROUTE_AGGREGATE = 'Route Aggregates';
this.TITLE_EDIT_ROUTE_AGGREGATE = 'Edit Route Aggregate';
this.TITLE_ROUTE_AGGREGATE_DELETE = 'Delete Route Aggregate';
this.TITLE_ROUTE_AGGREGATE_MULTI_DELETE = 'Delete Route Aggregate(s)';
this.TITLE_ADD_ROUTE_AGGREGATE = 'Create Route Aggregate';

};
return CTLabels;
});
48 changes: 48 additions & 0 deletions webroot/config/networking/routeaggregate/api/parseURL.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
-->
<urlLists>
<require>
<define>parseURLReq</define>
<path>process.mainModule.exports["corePath"] + '/src/serverroot/common/parseURLRequire'</path>
</require>
<require>
<define>routeaggregateconfigapi</define>
<path>./routeAggregateConfig.api</path>
</require>
<!-- API / Feature definition for Ipam configuration -->
<!-- 1. Get Route Aggregates - /api/tenants/config/route-aggregates/:id,
getRouteAggregates
2. Create Route Aggregates - /api/tenants/config/route-aggregates,
createRouteAggregate
3. Update Route Aggregates - /api/tenants/config/route-aggregate/:id,
updateRouteAggregate
5. Delete Route Aggregates - /api/tenants/config/route-aggregate/:id,
deleteRouteAggregate
-->
<item>
<url>/api/tenants/config/route-aggregates/:id</url>
<method>get</method>
<feature>routeaggregateconfig</feature>
<callback>routeaggregateconfigapi.getRouteAggregates</callback>
</item>
<item>
<url>/api/tenants/config/route-aggregates</url>
<method>post</method>
<feature>routeaggregateconfig</feature>
<callback>routeaggregateconfigapi.createRouteAggregate</callback>
</item>
<item>
<url>/api/tenants/config/route-aggregate/:id</url>
<method>put</method>
<feature>routeaggregateconfig</feature>
<callback>routeaggregateconfigapi.updateRouteAggregate</callback>
</item>
<item>
<url>/api/tenants/config/route-aggregate/:id</url>
<method>delete</method>
<feature>routeaggregateconfig</feature>
<callback>routeaggregateconfigapi.deleteRouteAggregate</callback>
</item>
</urlLists>

Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
* Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
*/

/**
* @routeaggregateconfig.api.js
* - Handlers for Route Aggregate 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 appErrors = require(process.mainModule.exports["corePath"] +
'/src/serverroot/errors/app.errors');
var util = require('util');
var url = require('url');
var configApiServer = require(process.mainModule.exports["corePath"] +
'/src/serverroot/common/configServer.api');


/**
* Bail out if called directly as "nodejs routeraggregateconfig.api.js"
*/
if (!module.parent)
{
logutils.logger.warn(util.format(messages.warn.invalid_mod_call,
module.filename));
process.exit(1);
}

/**
* @getRouteAggregates
* public function
* 1. URL /api/tenants/config/route-aggregates/:id
* 2. Gets list of route aggregates from config api server
* 3. Needs tenant / project id
*/
function getRouteAggregates (request, response, appData)
{
var tenantId = null;
var requestParams = url.parse(request.url,true);
var routeAggregateListURL = '/route-aggregates?detail=true';

if (tenantId = request.param('id').toString()) {
routeAggregateListURL += '&parent_id=' + tenantId.toString();
} else {
error = new appErrors.RESTServerError('Provide Tenant Id');
commonUtils.handleJSONResponse(error, response, null);
return;
}

configApiServer.apiGet(routeAggregateListURL, appData,
function(error, routeAggregates) {
commonUtils.handleJSONResponse(error, response, routeAggregates)
}
);
}

/**
* @createRouteAggregate
* public function
* 1. URL /api/tenants/config/route-aggregates - Post
* 2. Sets Post Data and sends back the Route Aggregate config to client
*/
function createRouteAggregate (request, response, appData)
{
var routeAggregateCreateURL = '/route-aggregates';
var routeAggregatePostData = request.body;
if (typeof(routeAggregatePostData) != 'object') {
error = new appErrors.RESTServerError('Invalid Post Data');
commonUtils.handleJSONResponse(error, response, null);
return;
}
configApiServer.apiPost(routeAggregateCreateURL, routeAggregatePostData, appData,
function(error, routeAggregate) {
commonUtils.handleJSONResponse(error, response, routeAggregate);
}
);
}

/**
* @updateRouteAggregate
* public function
* 1. URL /api/tenants/config/route-aggregate/:id - Put
* 2. updates Route Aggregate config data
*/
function updateRouteAggregate (request, response, appData)
{
var routeAggregateId = null;
var routeAggregateUpdateURL = '/route-aggregate/';
var routeAggregateData = request.body;

if (typeof(routeAggregateData) != 'object') {
error = new appErrors.RESTServerError('Invalid Post Data');
commonUtils.handleJSONResponse(error, response, null);
return;
}

if (routeAggregateId = request.param('id').toString()) {
routeAggregateUpdateURL += routeAggregateId;
} else {
error = new appErrors.RESTServerError('Provide Route Aggregate UUID');
commonUtils.handleJSONResponse(error, response, null);
return;
}
configApiServer.apiPut(routeAggregateUpdateURL, routeAggregateData, appData,
function(error, routeAggregate) {
commonUtils.handleJSONResponse(error, response, routeAggregate);
}
);
}

/**
* @deleteRouteAggregate
* public function
* 1. URL /api/tenants/config/route-aggregate/:id - Delete
* 2. Deletes the Route Aggregate from config api server
*/
function deleteRouteAggregate (request, response, appData)
{
var routeAggregateId = null;
var routeAggregateDelURL = '/route-aggregate/';
var requestParams = url.parse(request.url, true);

if (routeAggregateId = request.param('id').toString()) {
routeAggregateDelURL += routeAggregateId;
} else {
error = new appErrors.RESTServerError('Provide Route Aggregate UUID');
commonUtils.handleJSONResponse(error, response, null);
return;
}
configApiServer.apiDelete(routeAggregateDelURL, appData,
function(error, deleteRouteAggregate) {
commonUtils.handleJSONResponse(error, response, deleteRouteAggregate);
}
);
}

exports.getRouteAggregates = getRouteAggregates;
exports.createRouteAggregate = createRouteAggregate;
exports.updateRouteAggregate = updateRouteAggregate;
exports.deleteRouteAggregate = deleteRouteAggregate;
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
*/

define(['underscore'], function(_){
this.routeAggregateDomainsData = {
"domains": [
{
"href": "http://10.204.216.12:9100/domain/efa3feca-769d-4583-b38f-86614cde1810",
"fq_name": [
"default-domain"
],
"uuid": "efa3feca-769d-4583-b38f-86614cde1810"
}
]
};
this.routeAggregatePojectsData = {
"projects": [
{
"uuid": "ee14bbf4-a3fc-4f98-a7b3-f1fe1d8b29bb",
"fq_name": [
"default-domain",
"admin"
]
},
{
"uuid": "fc176b78-28ff-4e0e-88f7-cc1e0224d237",
"fq_name": [
"default-domain",
"demo"
]
}
]
};
this.routeAggregateMockData = {
"route-aggregates": [
{
"route-aggregate": {
"fq_name": [
"default-domain",
"admin",
"test_route_aggregate"
],
"name": "test_route_aggregate",
"aggregate_route_nexthop": "12.12.12.1",
"parent_uuid": "ee14bbf4-a3fc-4f98-a7b3-f1fe1d8b29bb",
"parent_href": "http://10.204.216.12:9100/project/ee14bbf4-a3fc-4f98-a7b3-f1fe1d8b29bb",
"parent_type": "project",
"perms2": {
"owner": null,
"owner_access": 7,
"global_access": 0,
"share": []
},
"href": "http://10.204.216.12:9100/route-aggregate/1b2bf39a-85ea-4dbb-bf72-072e1950970e",
"id_perms": {
"enable": true,
"uuid": {
"uuid_mslong": 1957926308019850800,
"uuid_lslong": 13795096503163853000
},
"created": "2016-02-03T10:30:13.813523",
"description": null,
"creator": null,
"user_visible": true,
"last_modified": "2016-02-03T10:30:13.813523",
"permissions": {
"owner": "cloud-admin",
"owner_access": 7,
"other_access": 7,
"group": "cloud-admin-group",
"group_access": 7
}
},
"aggregate_route_entries": {
"route": [
"route1",
"route2",
"route3"
]
},
"display_name": "test_route_aggregate",
"uuid": "1b2bf39a-85ea-4dbb-bf72-072e1950970e"
}
}
]
};
return {
routeAggregateDomainsData : routeAggregateDomainsData,
routeAggregatePojectsData : routeAggregatePojectsData,
routeAggregateMockData : routeAggregateMockData
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
*/
define([
'co-test-runner',
'ct-test-utils',
'ct-test-messages',
'config/networking/routeaggregate/test/ui/views/routeAggregateGridView.mock.data',
'co-grid-contrail-list-model-test-suite',
'co-grid-view-test-suite'
], function (cotr, cttu, cttm, TestMockdata, GridListModelTestSuite, GridViewTestSuite) {

var moduleId = cttm.ROUTE_AGGREGATE_GRID_VIEW_COMMON_TEST_MODULE;

var testType = cotc.VIEW_TEST;

var fakeServerConfig = cotr.getDefaultFakeServerConfig();

var fakeServerResponsesConfig = function() {
var responses = [];
responses.push(cotr.createFakeServerResponse( {
url: /\/api\/tenants\/config\/domains.*$/,
body: JSON.stringify(TestMockdata.routeAggregateDomainsData)
}));
responses.push(cotr.createFakeServerResponse( {
url: /\/api\/tenants\/config\/projects\/default-domain.*$/,
body: JSON.stringify(TestMockdata.routeAggregatePojectsData)
}));
responses.push(cotr.createFakeServerResponse( {
url: /\/api\/tenants\/config\/route-aggregates\/ee14bbf4-a3fc-4f98-a7b3-f1fe1d8b29bb.*$/,
body: JSON.stringify(TestMockdata.routeAggregateMockData)
}));

return responses;
};
fakeServerConfig.getResponsesConfig = fakeServerResponsesConfig;

var pageConfig = cotr.getDefaultPageConfig();
pageConfig.hashParams = {
p: 'config_net_rtaggregate'
};
pageConfig.loadTimeout = cotc.PAGE_LOAD_TIMEOUT * 2;

var getTestConfig = function() {
return {
rootView: configRouteAggregatePageLoader.routeAggregateView,
tests: [
{
viewId: ctwc.ROUTE_AGGREGATE_GRID_ID,
suites: [
{
class: GridViewTestSuite,
groups: ['all']
}
]
}
]
} ;

};

var pageTestConfig = cotr.createPageTestConfig(moduleId, testType, fakeServerConfig, pageConfig, getTestConfig);

cotr.startTestRunner(pageTestConfig);

});

0 comments on commit 3ca6b25

Please sign in to comment.