-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Changes for "Add Route Aggregate configuration page to UI""
- Loading branch information
Showing
19 changed files
with
1,325 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
146 changes: 146 additions & 0 deletions
146
webroot/config/networking/routeaggregate/api/routeAggregateConfig.api.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
93 changes: 93 additions & 0 deletions
93
webroot/config/networking/routeaggregate/test/ui/views/routeAggregateGridView.mock.data.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; | ||
}); |
66 changes: 66 additions & 0 deletions
66
webroot/config/networking/routeaggregate/test/ui/views/routeAggregateGridView.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
}); |
Oops, something went wrong.