Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.1.1 impl #559

Merged
merged 39 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f4fac44
Fixes #526
IswaryaaS Feb 15, 2024
7c5ba17
Merge pull request #531 from openBackhaul/IswaryaaS/issue526
PrathibaJee Feb 26, 2024
ce56455
Merge pull request #533 from openBackhaul/develop
PrathibaJee Mar 28, 2024
1920de0
To implement /v1/bequeath-your-data-and-die
IswaryaaS Apr 1, 2024
dbfe53c
Merge pull request #534 from openBackhaul/IswaryaaS/issue527
PrathibaJee Apr 1, 2024
7b0320b
To implement /v1/regard-application and its callback
IswaryaaS Apr 10, 2024
712c26c
Tested /v1/regard-application
IswaryaaS Apr 15, 2024
7b331f0
Fixes To support /v1/add-operation-client-to-link #529
IswaryaaS Apr 16, 2024
62ed2b4
Merge branch 'v2.1.1_impl' into IswaryaaS/issue528
IswaryaaS Apr 16, 2024
1530535
Merge pull request #535 from openBackhaul/IswaryaaS/issue528
PrathibaJee Apr 16, 2024
8f25cf0
Fixes #538
IswaryaaS Apr 23, 2024
207cac6
Merge pull request #539 from openBackhaul/IswaryaaS/issue538
PrathibaJee Apr 23, 2024
65bacf3
Fixes #540
IswaryaaS May 17, 2024
a02a42e
Merge pull request #541 from openBackhaul/IswaryaaS/issue540
PrathibaJee May 26, 2024
094fc2c
Mechanism to handle 2 consecutive regard application request
IswaryaaS Jun 5, 2024
b1098d2
Merge pull request #543 from openBackhaul/IswaryaaS/issue542
PrathibaJee Jun 5, 2024
38bda30
observation : Inconsistent NoLivingConnectionsError while regarding a…
PrathibaJee Jun 22, 2024
128466f
Merge pull request #546 from openBackhaul/PrathibaJee/issue544
IswaryaaS Jun 22, 2024
9ba9293
Update trace-indicator in regard-application
PrathibaJee Jun 22, 2024
4f3417c
Merge pull request #547 from openBackhaul/PrathibaJee/issue545
IswaryaaS Jun 22, 2024
e621987
Support version 2.1.1 changes
PrathibaJee Jun 27, 2024
c694bd9
Merge pull request #548 from openBackhaul/PrathibaJee/issue530
IswaryaaS Jun 27, 2024
5cbcbe3
deleting package-lock.json
ManasaBM1 Jul 9, 2024
d20f820
Merge pull request #549 from openBackhaul/pacakage
PrathibaJee Jul 9, 2024
4ec3bec
including package-lock.json file
ManasaBM1 Jul 15, 2024
76f5368
Merge pull request #550 from openBackhaul/packagelockfile
PrathibaJee Jul 15, 2024
7491ea0
updating docker file
ManasaBM1 Jul 16, 2024
9a08d0a
Merge pull request #551 from openBackhaul/dockerfileupdate
IswaryaaS Jul 17, 2024
d844c28
Trace indicator needs to be corrected for the sequence of regard-appl…
IswaryaaS Jul 18, 2024
537d146
Merge pull request #553 from openBackhaul/IswaryaaS/issue552
PrathibaJee Jul 18, 2024
aeb5e50
Trace indicator needs to be corrected for the sequence of regard-appl…
PrathibaJee Jul 22, 2024
7df276b
Merge pull request #554 from openBackhaul/PrathibaJee/issue552
IswaryaaS Jul 22, 2024
fdf5edf
Update implementation of /v1/embed-yourself
IswaryaaS Jul 29, 2024
20cda31
Update config file
IswaryaaS Jul 29, 2024
2611c8a
Merge pull request #558 from openBackhaul/IswaryaaS/issue557
PrathibaJee Jul 29, 2024
c2a4fba
Correct eslint failures
PrathibaJee Jul 29, 2024
f3f668e
Merge pull request #561 from openBackhaul/PrathibaJee/issue560
IswaryaaS Jul 29, 2024
83ed77c
Correct eslint failures
PrathibaJee Jul 29, 2024
28b7298
Merge pull request #562 from openBackhaul/PrathibaJee/issue560
IswaryaaS Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13,980 changes: 7,310 additions & 6,670 deletions server/api/openapi.yaml

Large diffs are not rendered by default.

174 changes: 156 additions & 18 deletions server/controllers/BasicServices.js

Large diffs are not rendered by default.

113 changes: 89 additions & 24 deletions server/controllers/IndividualServices.js

Large diffs are not rendered by default.

3,790 changes: 3,790 additions & 0 deletions server/database/config.json

Large diffs are not rendered by default.

3,376 changes: 0 additions & 3,376 deletions server/database/load.json

This file was deleted.

4 changes: 2 additions & 2 deletions server/dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14
FROM node:18

# Create app directory
WORKDIR /home/openbackhaul/applicationLayerTopology
Expand All @@ -13,7 +13,7 @@ RUN npm ci --only=production
# Bundle app source
COPY . .

EXPOSE 3005
EXPOSE 3029

#Command to start the application
CMD [ "node", "index.js" ]
20 changes: 10 additions & 10 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ var path = require('path');
var http = require('http');
var oas3Tools = require('openbackhaul-oas3-tools');
var appCommons = require('onf-core-model-ap/applicationPattern/commons/AppCommons');
var PrepareApprovedLinks = require('./service/individualServices/PrepareApprovedLinks');
var serverPort = 3005;
//var PrepareApprovedLinks = require('./service/individualServices/PrepareApprovedLinks');
var serverPort = 3029;

const ElasticsearchPreparation = require('./service/individualServices/ElasticsearchPreparation');
const preApprovedLinks = require('./utils/preApprovedLinks.json');
//const preApprovedLinks = require('./utils/preApprovedLinks.json');

// uncomment if you do not want to validate security e.g. operation-key, basic auth, etc
// appCommons.openApiValidatorOptions.validateSecurity = false;
Expand All @@ -28,7 +28,7 @@ appCommons.setupExpressApp(app);


//setting the path to the database
global.databasePath = './database/load.json'
global.databasePath = './database/config.json'

ElasticsearchPreparation.prepareElasticsearch().catch(err => {
console.error(`Error preparing Elasticsearch : ${err}`);
Expand All @@ -39,13 +39,13 @@ ElasticsearchPreparation.prepareElasticsearch().catch(err => {
console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort);
console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort);
});
PrepareApprovedLinks.createPreApprovedLinks(preApprovedLinks).catch(
err => {
console.error(`Error entering preapproved links : ${err}`);
}
);
// PrepareApprovedLinks.createPreApprovedLinks(preApprovedLinks).catch(
// err => {
// console.error(`Error entering preapproved links : ${err}`);
// }
// );
appCommons.performApplicationRegistration();
}
}
);


2,487 changes: 341 additions & 2,146 deletions server/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "applicationlayertopology",
"version": "2.0.1",
"version": "2.1.1",
"description": "No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)",
"main": "index.js",
"scripts": {
Expand All @@ -22,8 +22,8 @@
"lodash.isequal": "^4.5.0",
"moment": "^2.29.1",
"node-statsd": "^0.1.1",
"onf-core-model-ap": "2.0.2-alpha.2",
"onf-core-model-ap-bs": "2.0.2-alpha.2",
"onf-core-model-ap": "2.1.1",
"onf-core-model-ap-bs": "2.1.1",
"openbackhaul-oas3-tools": "2.3.1-alpha.3",
"randexp": "^0.5.3",
"response-time": "^2.3.2",
Expand Down
295 changes: 295 additions & 0 deletions server/service/BasicServciesService.js

Large diffs are not rendered by default.

387 changes: 178 additions & 209 deletions server/service/IndividualServicesService.js

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions server/service/individualServices/ControlConstructService.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,46 @@ class ControlConstructService {
}
}

/**
* @description creates one LTP in control-construct.
* @param {String} controlConstructUuid
* @param {Object} ltpToBeAdded
* @returns {Promise<Object>} { took }
*/
static async createControlConstructLtp(controlConstructUuid, ltpToBeAdded) {
let esUuid = await ElasticsearchPreparation.getCorrectEsUuid(false);
let client = await elasticsearchService.getClient(false, esUuid);
let indexAlias = await getIndexAliasAsync(esUuid);
let response = await lock.acquire(controlConstructUuid, async () => {
let r = await client.updateByQuery({
index: indexAlias,
refresh: true,
body: {
script: {
source: `ctx._source['logical-termination-point'].add(params['ltpToBeAdded'])`,
params: {
"ltpToBeAdded": ltpToBeAdded
}
},
query: {
term: {
"uuid": controlConstructUuid
}
}
}
});
return r;
})
if (response.body.updated === 1) {
return { "took": response.body.took };
} else {
if (response.body.total === 0) {
throw new createHttpError.BadRequest(`CC with uuid ${controlConstructUuid} does not exist.`)
}
throw new Error("LTP was not updated")
}
}

/**
* @description Replaces forwarding-construct in control-construct
* @param {String} controlConstructUuid
Expand Down Expand Up @@ -438,6 +478,8 @@ class ControlConstructService {
let intermitent = (backendTime[0] * 1000 + backendTime[1] / 1000000);
if (res.body.result === 'created' || res.body.result === 'updated') {
return { "took": took + intermitent };
} else {
return { "took": -1 };
}
}

Expand Down
16 changes: 11 additions & 5 deletions server/service/individualServices/ElasticsearchPreparation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { elasticsearchService, getIndexAliasAsync, operationalStateEnum } = require('onf-core-model-ap/applicationPattern/services/ElasticsearchService');
const logicalTerminationPoint = require('onf-core-model-ap/applicationPattern/onfModel/models/LogicalTerminationPoint');
const LayerProtocol = require('onf-core-model-ap/applicationPattern/onfModel/models/LayerProtocol');
const controlConstruct = require('onf-core-model-ap/applicationPattern/onfModel/models/ControlConstruct');
const onfAttributes = require('onf-core-model-ap/applicationPattern/onfModel/constants/OnfAttributes');

module.exports = {
prepareElasticsearch,
Expand All @@ -13,8 +14,12 @@ module.exports = {
* @returns {Promise<String>} LINKS ES UUID or CC ES UUID
*/
async function getCorrectEsUuid(links) {
let uuids = await logicalTerminationPoint.getUuidListForTheProtocolAsync(LayerProtocol.layerProtocolNameEnum.ES_CLIENT);
return links ? uuids.find(uuid => uuid.endsWith('001')) : uuids.find(uuid => uuid.endsWith('000'));
let ltpList = await controlConstruct.getLogicalTerminationPointListAsync(LayerProtocol.layerProtocolNameEnum.ES_CLIENT);
if(links) {
return ltpList.find(ltp => ltp[onfAttributes.GLOBAL_CLASS.UUID].endsWith('001'))[onfAttributes.GLOBAL_CLASS.UUID];
} else {
return ltpList.find(ltp => ltp[onfAttributes.GLOBAL_CLASS.UUID].endsWith('000'))[onfAttributes.GLOBAL_CLASS.UUID];
}
}

/**
Expand All @@ -32,8 +37,9 @@ async function getCorrectEsUuid(links) {
*/
async function prepareElasticsearch() {
console.log("Configuring Elasticsearch...");
let uuids = await logicalTerminationPoint.getUuidListForTheProtocolAsync(LayerProtocol.layerProtocolNameEnum.ES_CLIENT);
for (let uuid of uuids) {
let ltpList = await controlConstruct.getLogicalTerminationPointListAsync(LayerProtocol.layerProtocolNameEnum.ES_CLIENT);
for (let ltp of ltpList) {
let uuid = ltp[onfAttributes.GLOBAL_CLASS.UUID];
let ping = await elasticsearchService.getElasticsearchClientOperationalStateAsync(uuid);
if (ping === operationalStateEnum.UNAVAILABLE) {
let err = new Error(`Elasticsearch unavailable. Skipping Elasticsearch configuration.`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const RequestHeader = require('onf-core-model-ap/applicationPattern/rest/client/
const RestRequestBuilder = require('onf-core-model-ap/applicationPattern/rest/client/RequestBuilder');
const ExecutionAndTraceService = require('onf-core-model-ap/applicationPattern/services/ExecutionAndTraceService');
const onfAttributes = require('onf-core-model-ap/applicationPattern/onfModel/constants/OnfAttributes');
const createHttpError = require('http-errors');

var traceIndicatorIncrementer = 1;

Expand All @@ -30,7 +31,7 @@ exports.automateForwardingConstructAsync = async function (forwardingAutomationI
fcp[onfAttributes.FC_PORT.PORT_DIRECTION] === FcPort.portDirectionEnum.OUTPUT
);
let found = await findOutputMatchesContextAsync(fcOutputPortList, forwardingAutomationInput.context);
return await dispatchEvent(
return await exports.dispatchEvent(
found[onfAttributes.FC_PORT.LOGICAL_TERMINATION_POINT],
forwardingAutomationInput.attributeList,
headers.user,
Expand Down Expand Up @@ -70,7 +71,7 @@ async function findOutputMatchesContextAsync(fcPortList, context) {
* @param {String} traceIndicator Sequence number of the request.
* @param {String} customerJourney Holds information supporting customer’s journey to which the execution applies.
*/
async function dispatchEvent(operationClientUuid, httpRequestBody, user, xCorrelator, traceIndicator, customerJourney) {
exports.dispatchEvent = async function (operationClientUuid, httpRequestBody, user, xCorrelator, traceIndicator, customerJourney) {
let operationKey = await OperationClientInterface.getOperationKeyAsync(
operationClientUuid);
let operationName = await OperationClientInterface.getOperationNameAsync(
Expand All @@ -82,20 +83,20 @@ async function dispatchEvent(operationClientUuid, httpRequestBody, user, xCorrel
let serverApplicationReleaseNumber = await HttpClientInterface.getReleaseNumberAsync(httpClientUuid[0]);
let originator = await HttpServerInterface.getApplicationNameAsync();
let httpRequestHeader = new RequestHeader(
user,
user,
originator,
xCorrelator,
traceIndicator,
customerJourney,
xCorrelator,
traceIndicator,
customerJourney,
operationKey
);
);
httpRequestHeader = OnfAttributeFormatter.modifyJsonObjectKeysToKebabCase(httpRequestHeader);
let response = await RestRequestBuilder.BuildAndTriggerRestRequest(
operationClientUuid,
"POST",
httpRequestHeader,
"POST",
httpRequestHeader,
httpRequestBody
);
);
let responseCode = response.status;
if (responseCode == 408) {
ExecutionAndTraceService.recordServiceRequestFromClient(serverApplicationName, serverApplicationReleaseNumber, xCorrelator, traceIndicator, user, originator, operationName, responseCode, httpRequestBody, response.data)
Expand All @@ -114,3 +115,64 @@ async function dispatchEvent(operationClientUuid, httpRequestBody, user, xCorrel
}
return response;
}

/**
* This funtion formulates the request body based on the operation name and application
* @param {String} operationClientUuid uuid of the client operation that needs to be addressed
* @param {object} httpRequestBody request body for the operation
* @param {String} user username of the request initiator.
* @param {String} xCorrelator UUID for the service execution flow that allows to correlate requests and responses.
* @param {String} traceIndicator Sequence number of the request.
* @param {String} customerJourney Holds information supporting customer’s journey to which the execution applies.
* @param {String} httpMethod method of the request if undefined defaults to POST
* @param {Object} params path and query params
*/
exports.dispatchEventWithDefaultOperationKey = async function (operationClientUuid, httpRequestBody, user, xCorrelator, traceIndicator, customerJourney, httpMethod = "POST", params) {
try {
let operationKey = "Operation key not yet provided.";
let operationName = await OperationClientInterface.getOperationNameAsync(
operationClientUuid);
// we need information from the database at this stage, because the database might change
// before the response is received, see https://github.com/openBackhaul/ExecutionAndTraceLog/issues/227
let httpClientUuid = await LogicalTerminationPoint.getServerLtpListAsync(operationClientUuid);
let serverApplicationName = await HttpClientInterface.getApplicationNameAsync(httpClientUuid[0]);
let serverApplicationReleaseNumber = await HttpClientInterface.getReleaseNumberAsync(httpClientUuid[0]);
let originator = await HttpServerInterface.getApplicationNameAsync();
let httpRequestHeader = new RequestHeader(
user,
originator,
xCorrelator,
traceIndicator,
customerJourney,
operationKey
);
httpRequestHeader = OnfAttributeFormatter.modifyJsonObjectKeysToKebabCase(httpRequestHeader);
let response = await RestRequestBuilder.BuildAndTriggerRestRequest(
operationClientUuid,
httpMethod,
httpRequestHeader,
httpRequestBody,
params
);
let responseCode = response.status;
if (responseCode == 408) {
ExecutionAndTraceService.recordServiceRequestFromClient(serverApplicationName, serverApplicationReleaseNumber, xCorrelator, traceIndicator, user, originator, operationName, responseCode, httpRequestBody, response.data)
.catch((error) => console.log(`record service request ${JSON.stringify({
xCorrelator,
traceIndicator,
user,
originator,
serverApplicationName,
serverApplicationReleaseNumber,
operationName,
responseCode,
reqBody: httpRequestBody,
resBody: response.data
})} failed with error: ${error.message}`));
}
return response;
} catch (error) {
console.log(error)
return createHttpError.InternalServerError(`${error}`);
}
}
Loading
Loading