diff --git a/server/applicationPattern/applicationPattern/commons/AppCommons.js b/server/applicationPattern/applicationPattern/commons/AppCommons.js index 14652caa..c0560ea1 100644 --- a/server/applicationPattern/applicationPattern/commons/AppCommons.js +++ b/server/applicationPattern/applicationPattern/commons/AppCommons.js @@ -90,7 +90,7 @@ async function validateBasicAuth(request, scopes, schema) { function loggingErrorHandler(err, req, res, next) { const statusCode = err.status || 500; const errorBody = { - code : statusCode, + code: statusCode, message: err.message, errors: err.errors, } @@ -102,7 +102,9 @@ function loggingErrorHandler(err, req, res, next) { const traceIndicator = req.headers['trace-indicator']; const user = req.headers.user; const originator = req.headers.originator; - executionAndTraceService.recordServiceRequest(xCorrelator, traceIndicator, user, originator, req.url, statusCode, req.body, errorBody); + if (!(originator == "ExecutionAndTraceLog" && req.url == "/v1/record-service-request")) { + executionAndTraceService.recordServiceRequest(xCorrelator, traceIndicator, user, originator, req.url, statusCode, req.body, errorBody); + } } } console.log(`loggingErrorHandler - caught error, returning response with status code "${statusCode}" and body ${JSON.stringify(errorBody)}`); diff --git a/server/applicationPattern/applicationPattern/onfModel/models/layerProtocols/OperationClientInterface.js b/server/applicationPattern/applicationPattern/onfModel/models/layerProtocols/OperationClientInterface.js index f3a1b18c..4c4f4f59 100644 --- a/server/applicationPattern/applicationPattern/onfModel/models/layerProtocols/OperationClientInterface.js +++ b/server/applicationPattern/applicationPattern/onfModel/models/layerProtocols/OperationClientInterface.js @@ -16,9 +16,7 @@ const tcpClientInterface = require('./TcpClientInterface'); const onfPaths = require('../../constants/OnfPaths'); const onfAttributes = require('../../constants/OnfAttributes'); const fileOperation = require('../../../databaseDriver/JSONDriver'); -global.operationKeyNotificationChannel = []; -global.notificationChannelSubscriber = []; -global.isNotificationChannelON = false; +const operationKeyUpdateNotificationService = require('../../services/OperationKeyUpdateNotificationService'); /** * @extends LayerProtocol */ @@ -217,7 +215,7 @@ class OperationClientInterface extends LayerProtocol { false); } if (isOperationKeySet == true || oldoperationKey == operationKey) { - this.addOperationKeyUpdateToNotificationChannel(operationClientUuid); + operationKeyUpdateNotificationService.addOperationKeyUpdateToNotificationChannel(operationClientUuid); } return isOperationKeySet; } @@ -298,93 +296,7 @@ class OperationClientInterface extends LayerProtocol { const layerProtocol = ltp[onfAttributes.LOGICAL_TERMINATION_POINT.LAYER_PROTOCOL][0]; const layerProtocolName = layerProtocol[onfAttributes.LAYER_PROTOCOL.LAYER_PROTOCOL_NAME]; return LayerProtocol.layerProtocolNameEnum.OPERATION_CLIENT === layerProtocolName; - } - - /** - * @param {HRTime} timeStampIdentifier an identifier the process that turns ON the notification channel - * @return {boolean} result whether the notificationChannel is turned ON or not - */ - static turnONNotificationChannel(timeStampIdentifier) { - try { - if (!global.notificationChannelSubscriber.includes(timeStampIdentifier)) { - global.notificationChannelSubscriber.push(timeStampIdentifier); - } - global.isNotificationChannelON = true; - console.log("******* Notification channel for Operation key is turned ON ***************"); - return global.isNotificationChannelON; - } catch (error) { - return false; - } - } - - /** - * @param {HRTime} timeStampAsIdentifier an identifier the process that turns OFF the notification channel - * @return {boolean} result whether the notificationChannel is turned OFF or not - */ - static turnOFFNotificationChannel(timeStampAsIdentifier) { - try { - if (global.notificationChannelSubscriber.includes(timeStampAsIdentifier)) { - global.notificationChannelSubscriber.forEach((element, index) => { - if (element == timeStampAsIdentifier) { - global.notificationChannelSubscriber = global.notificationChannelSubscriber.splice(index, 1); - } - }); - } - if (global.notificationChannelSubscriber.length > 0) { - global.isNotificationChannelON = false; - console.log("******* Notification channel for Operation key is turned OFF ***************"); - } - return !global.isNotificationChannelON; - } catch (error) { - return false; - } - } - - /** - * function to add notifications to the global operationKeyNotificationChannel - * @param {String} operationClientUuid of the operationKey updated instance - */ - static async addOperationKeyUpdateToNotificationChannel(operationClientUuid) { - try { - if (global.isNotificationChannelON) { - let operationKeyNotification = { - "eventTime": new Date(), - "operationClientUuid": operationClientUuid - }; - console.log("Notification pushed :" + operationKeyNotification.eventTime + "," + operationKeyNotification.operationClientUuid); - global.operationKeyNotificationChannel.push(operationKeyNotification); - } - } catch (error) { - console.log(error); - } - } - - /** - * This function waits for a desired time until an operation-key updation is received for a client - * @param {String} operationClientUuid for which the an operation-key update is monitored - * @param {Date} timestampOfCurrentRequest shall be used to monitor whether operation-key is updated after this event's occurance - * @param {Integer} waitTime will be the maximum time to wait for an operation-key update in Seconds - * @returns {promise} boolean that represents an operation-key update - */ - static async waitUntilOperationKeyIsUpdated(operationClientUuid, timestampOfCurrentRequest, waitTime) { - let startTime = process.hrtime(); - console.log("Waiting to receive operation key update for the operationClientUuid " + operationClientUuid); - return await new Promise(resolve => { - const interval = setInterval(() => { - let operationKeyUpdated = isOperationKeyUpdated(operationClientUuid, timestampOfCurrentRequest); - let waitTimeExceeded = isWaitTimeExceeded(startTime, waitTime); - if (operationKeyUpdated == true) { - console.log("Operation key update received for the operationClientUuid " + operationClientUuid); - resolve(true); - clearInterval(interval); - } else if (waitTimeExceeded == true) { - console.log("Waiting time exceeded for receiving operation key for the operationClientUuid " + operationClientUuid); - resolve(false); - clearInterval(interval); - } - }, 100); - }); - } + } } /** @@ -405,42 +317,5 @@ function getConfiguredRemoteAddress(remoteAddress) { return remoteAddress; } -/** - * - * @param {HRTime} startTime of the process - * @param {Integer} waitingTime of the process in Seconds - * @returns - */ -function isWaitTimeExceeded(startTime, waitingTime) { - let NanoSecondPerSecond = 1e9; - let executionTime = process.hrtime(startTime); - let executionTimeInseconds = (executionTime[0] * NanoSecondPerSecond + executionTime[1]) / NanoSecondPerSecond - if (executionTimeInseconds >= waitingTime) { - return true - } else { - return false; - } -} - -/** - * - * @param {String} operationClientUuid uuid of the operation client interface - * @param {HRTime} eventTime of the process - * @returns - */ -function isOperationKeyUpdated(operationClientUuid, eventTime) { - let result = false; - console.log(operationClientUuid + "," + eventTime); - let oKNotificationChannel = global.operationKeyNotificationChannel; - oKNotificationChannel.filter((notification) => { - console.log("*****************************************"); - console.log(notification.operationClientUuid); - console.log(operationClientUuid); - if (notification.operationClientUuid == operationClientUuid && notification.eventTime > eventTime) { - result = true; - } - }); - return result; -} module.exports = OperationClientInterface; \ No newline at end of file diff --git a/server/applicationPattern/applicationPattern/onfModel/models/layerProtocols/OperationServerInterface.js b/server/applicationPattern/applicationPattern/onfModel/models/layerProtocols/OperationServerInterface.js index 5933e88e..5523842c 100644 --- a/server/applicationPattern/applicationPattern/onfModel/models/layerProtocols/OperationServerInterface.js +++ b/server/applicationPattern/applicationPattern/onfModel/models/layerProtocols/OperationServerInterface.js @@ -14,6 +14,7 @@ const onfAttributes = require('../../constants/OnfAttributes'); const fileOperation = require('../../../databaseDriver/JSONDriver'); const ForwardingDomain = require('../../models/ForwardingDomain'); const FcPort = require('../FcPort'); +const operationKeyUpdateNotificationService = require('../../services/OperationKeyUpdateNotificationService'); /** * @extends LayerProtocol */ @@ -64,9 +65,9 @@ class OperationServerInterface extends LayerProtocol { */ constructor(operationName) { this.operationServerInterfaceCapability = new OperationServerInterfacePac. - OperationServerInterfaceCapability(operationName); + OperationServerInterfaceCapability(operationName); this.operationServerInterfaceConfiguration = new OperationServerInterfacePac. - OperationServerInterfaceConfiguration(); + OperationServerInterfaceConfiguration(); } } @@ -78,7 +79,7 @@ class OperationServerInterface extends LayerProtocol { super(0, OperationServerInterface.OperationServerInterfacePac.layerProtocolName); this[onfAttributes.LAYER_PROTOCOL.OPERATION_SERVER_INTERFACE_PAC] = new - OperationServerInterface.OperationServerInterfacePac(operationName); + OperationServerInterface.OperationServerInterfacePac(operationName); } /** @@ -162,12 +163,20 @@ class OperationServerInterface extends LayerProtocol { * @returns {Promise} true | false **/ static async setOperationKeyAsync(operationServerUuid, operationKey) { - let operationKeyPath = onfPaths.OPERATION_SERVER_OPERATION_KEY.replace( - "{uuid}", operationServerUuid); - return await fileOperation.writeToDatabaseAsync( - operationKeyPath, - operationKey, - false); + let isOperationKeySet = false + let oldoperationKey = await this.getOperationKeyAsync(operationServerUuid); + if (oldoperationKey != operationKey) { + let operationKeyPath = onfPaths.OPERATION_SERVER_OPERATION_KEY.replace( + "{uuid}", operationServerUuid); + isOperationKeySet = await fileOperation.writeToDatabaseAsync( + operationKeyPath, + operationKey, + false); + } + if (isOperationKeySet == true || oldoperationKey == operationKey) { + operationKeyUpdateNotificationService.addOperationKeyUpdateToNotificationChannel(operationServerUuid); + } + return isOperationKeySet; } /** @@ -196,7 +205,7 @@ class OperationServerInterface extends LayerProtocol { **/ static async getOperationServerUuidAsync(operationName) { let logicalTerminationPointList = await controlConstruct. - getLogicalTerminationPointListAsync(LayerProtocol.layerProtocolNameEnum.OPERATION_SERVER); + getLogicalTerminationPointListAsync(LayerProtocol.layerProtocolNameEnum.OPERATION_SERVER); if (logicalTerminationPointList != undefined) { for (let i = 0; i < logicalTerminationPointList.length; i++) { let logicalTerminationPoint = logicalTerminationPointList[i]; @@ -257,4 +266,4 @@ class OperationServerInterface extends LayerProtocol { return "s" === splitted[5]; } } -module.exports = OperationServerInterface; +module.exports = OperationServerInterface; \ No newline at end of file diff --git a/server/applicationPattern/applicationPattern/onfModel/services/OperationKeyUpdateNotificationService.js b/server/applicationPattern/applicationPattern/onfModel/services/OperationKeyUpdateNotificationService.js new file mode 100644 index 00000000..a3eb3d81 --- /dev/null +++ b/server/applicationPattern/applicationPattern/onfModel/services/OperationKeyUpdateNotificationService.js @@ -0,0 +1,131 @@ + +global.operationKeyNotificationChannel = []; +global.notificationChannelSubscriber = []; +global.isNotificationChannelON = false; + + +/** + * @param {HRTime} timeStampIdentifier an identifier the process that turns ON the notification channel + * @return {boolean} result whether the notificationChannel is turned ON or not + */ +exports.turnONNotificationChannel = function(timeStampIdentifier) { + try { + if (!global.notificationChannelSubscriber.includes(timeStampIdentifier)) { + global.notificationChannelSubscriber.push(timeStampIdentifier); + } + global.isNotificationChannelON = true; + console.log("******* Notification channel for Operation key is turned ON ***************"); + return global.isNotificationChannelON; + } catch (error) { + return false; + } +} + +/** + * @param {HRTime} timeStampAsIdentifier an identifier the process that turns OFF the notification channel + * @return {boolean} result whether the notificationChannel is turned OFF or not + */ +exports.turnOFFNotificationChannel = function(timeStampAsIdentifier) { + try { + if (global.notificationChannelSubscriber.includes(timeStampAsIdentifier)) { + global.notificationChannelSubscriber.forEach((element, index) => { + if (element == timeStampAsIdentifier) { + global.notificationChannelSubscriber = global.notificationChannelSubscriber.splice(index, 1); + } + }); + } + if (global.notificationChannelSubscriber.length > 0) { + global.isNotificationChannelON = false; + console.log("******* Notification channel for Operation key is turned OFF ***************"); + } + return !global.isNotificationChannelON; + } catch (error) { + return false; + } +} + +/** + * function to add notifications to the global operationKeyNotificationChannel + * @param {String} operationUuid of the operationKey updated instance + */ +exports.addOperationKeyUpdateToNotificationChannel = async function(operationUuid) { + try { + if (global.isNotificationChannelON) { + let operationKeyNotification = { + "eventTime": new Date(), + "operationUuid": operationUuid + }; + console.log("Notification pushed :" + operationKeyNotification.eventTime + "," + operationKeyNotification.operationUuid); + global.operationKeyNotificationChannel.push(operationKeyNotification); + } + } catch (error) { + console.log(error); + } +} + +/** + * This function waits for a desired time until an operation-key updation is received for a client or server + * @param {String} operationUuid for which the an operation-key update is monitored + * @param {Date} timestampOfCurrentRequest shall be used to monitor whether operation-key is updated after this event's occurance + * @param {Integer} waitTime will be the maximum time to wait for an operation-key update in milli seconds + * @returns {promise} boolean that represents an operation-key update + */ +exports.waitUntilOperationKeyIsUpdated = async function(operationUuid, timestampOfCurrentRequest, waitTime) { + let startTime = process.hrtime(); + console.log("Waiting to receive operation key update for the operationUuid " + operationUuid); + return await new Promise(resolve => { + const interval = setInterval(() => { + let operationKeyUpdated = isOperationKeyUpdated(operationUuid, timestampOfCurrentRequest); + let waitTimeExceeded = isWaitTimeExceeded(startTime, waitTime); + if (operationKeyUpdated == true) { + console.log("Operation key update received for the operationUuid " + operationUuid); + resolve(true); + clearInterval(interval); + } else if (waitTimeExceeded == true) { + console.log("Waiting time exceeded for receiving operation key for the operationUuid " + operationUuid); + resolve(false); + clearInterval(interval); + } + }, 100); + }); +} + + +/** + * + * @param {HRTime} startTime of the process + * @param {Integer} waitingTime of the process in milliSeconds + * @returns + */ +function isWaitTimeExceeded(startTime, waitingTime) { + let NanoSecondPerSecond = 1e9; + let executionTime = process.hrtime(startTime); + let waitingTimeInSeconds = waitingTime/1000; + let executionTimeInseconds = (executionTime[0] * NanoSecondPerSecond + executionTime[1]) / NanoSecondPerSecond + if (executionTimeInseconds >= waitingTimeInSeconds) { + return true + } else { + return false; + } +} + +/** + * + * @param {String} operationUuid uuid of the operation client or server interface + * @param {HRTime} eventTime of the process + * @returns + */ +function isOperationKeyUpdated(operationUuid, eventTime) { + let result = false; + console.log(operationUuid + "," + eventTime); + let oKNotificationChannel = global.operationKeyNotificationChannel; + oKNotificationChannel.filter((notification) => { + console.log("*****************************************"); + console.log(notification.operationUuid); + console.log(operationUuid); + if (notification.operationUuid == operationUuid && notification.eventTime > eventTime) { + result = true; + } + }); + return result; +} \ No newline at end of file diff --git a/server/applicationPattern/applicationPattern/onfModel/services/models/forwardingConstruct/AutomationInput.js b/server/applicationPattern/applicationPattern/onfModel/services/models/forwardingConstruct/AutomationInput.js index 4b41cdc5..1ae44e70 100644 --- a/server/applicationPattern/applicationPattern/onfModel/services/models/forwardingConstruct/AutomationInput.js +++ b/server/applicationPattern/applicationPattern/onfModel/services/models/forwardingConstruct/AutomationInput.js @@ -17,7 +17,7 @@ class AutomationInput { * constructor * @param {String} forwardingName : name of the forwarding construct. * @param {Object} attributeList : list of attributes in key value pairs. - * @param {String} context : it should be a string with the information of application name + release number + * @param {String|undefined} context : it should be a string with the information of application name + release number */ constructor(forwardingName, attributeList, context) { this.forwardingName = forwardingName; diff --git a/server/applicationPattern/package.json b/server/applicationPattern/package.json index 1f95aae7..a4c55513 100644 --- a/server/applicationPattern/package.json +++ b/server/applicationPattern/package.json @@ -1,6 +1,6 @@ { "name": "onf-core-model-ap", - "version": "2.1.1-alpha.3", + "version": "2.1.1-alpha.7", "description": "onf core model application pattern", "main": "index.js", "scripts": { diff --git a/server/basicServices/basicServices/BasicServicesService.js b/server/basicServices/basicServices/BasicServicesService.js index 422e8197..54bef601 100644 --- a/server/basicServices/basicServices/BasicServicesService.js +++ b/server/basicServices/basicServices/BasicServicesService.js @@ -2,10 +2,7 @@ 'use strict'; const LogicalTerminationPoint = require('onf-core-model-ap/applicationPattern/onfModel/models/LogicalTerminationPoint'); -const LogicalTerminationPointConfigurationInput = require('onf-core-model-ap/applicationPattern/onfModel/services/models/logicalTerminationPoint/ConfigurationInput'); -const TcpObject = require('onf-core-model-ap/applicationPattern/onfModel/services/models/TcpObject'); -const LogicalTerminationPointService = require('onf-core-model-ap/applicationPattern/onfModel/services/LogicalTerminationPointServices'); -const LogicalTerminationPointConfigurationStatus = require('onf-core-model-ap/applicationPattern/onfModel/services/models/logicalTerminationPoint/ConfigurationStatus'); +const LogicalTerminationPointService = require('onf-core-model-ap/applicationPattern/onfModel/services/LogicalTerminationPointServicesV2'); const LayerProtocol = require('onf-core-model-ap/applicationPattern/onfModel/models/LayerProtocol'); const ServiceUtils = require('./utility/LogicalTerminationPoint'); @@ -14,7 +11,6 @@ const ForwardingConfigurationService = require('onf-core-model-ap/applicationPat const ForwardingAutomationService = require('onf-core-model-ap/applicationPattern/onfModel/services/ForwardingConstructAutomationServices'); const prepareForwardingConfiguration = require('./services/PrepareForwardingConfiguration'); const prepareForwardingAutomation = require('./services/PrepareForwardingAutomation'); -const ConfigurationStatus = require('onf-core-model-ap/applicationPattern/onfModel/services/models/ConfigurationStatus'); const httpServerInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/HttpServerInterface'); const tcpServerInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/TcpServerInterface'); @@ -31,13 +27,12 @@ const onfAttributes = require('onf-core-model-ap/applicationPattern/onfModel/con const fileOperation = require('onf-core-model-ap/applicationPattern/databaseDriver/JSONDriver'); const controlConstruct = require('onf-core-model-ap/applicationPattern/onfModel/models/ControlConstruct'); -const basicServicesOperationsMapping = require('./BasicServicesOperationsMapping'); const genericRepresentation = require('./GenericRepresentation'); const createHttpError = require('http-errors'); const HttpServerInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/HttpServerInterface'); -const OperationClientInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/OperationClientInterface'); -const integerProfile = require('onf-core-model-ap/applicationPattern/onfModel/models/profile/IntegerProfile'); +const eventDispatcher = require('onf-core-model-ap/applicationPattern/rest/client/eventDispatcher'); +const FcPort = require('onf-core-model-ap/applicationPattern/onfModel/models/FcPort'); /** * Removes application from configuration and application data * @@ -75,10 +70,10 @@ exports.disposeRemaindersOfDeregisteredApplication = async function (body, user, operationClientConfigurationStatusList ); forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - unConfigureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); + unConfigureForwardingConstructAsync( + operationServerName, + forwardingConfigurationInputList + ); } /**************************************************************************************** @@ -109,141 +104,167 @@ exports.disposeRemaindersOfDeregisteredApplication = async function (body, user, * no response value expected for this operation **/ exports.embedYourself = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName) { - let applicationName = body["registry-office-application"]; - let releaseNumber = body["registry-office-application-release-number"]; - let applicationProtocol = body["registry-office-protocol"]; - let applicationAddress = body["registry-office-address"]; - let applicationPort = body["registry-office-port"]; + let registryOfficeApplicationName = body["registry-office-application"]; + let registryOfficeReleaseNumber = body["registry-office-application-release-number"]; + let registryOfficeProtocol = body["registry-office-protocol"]; + let registryOfficeAddress = body["registry-office-address"]; + let registryOfficePort = body["registry-office-port"]; let deregisterOperation = body["deregistration-operation"]; let relayOperationUpdateOperation = body["relay-operation-update-operation"]; let relayServerReplacementOperation = body["relay-server-replacement-operation"]; - - const registryOfficeApplicationName = await ServiceUtils.resolveRegistryOfficeApplicationNameFromForwardingAsync(); - if (registryOfficeApplicationName !== applicationName) { - throw new createHttpError.BadRequest(`The registry-office-application ${applicationName} was not found.`); - } /**************************************************************************************** * Prepare logicalTerminationPointConfigurationInput object to * configure logical-termination-point ****************************************************************************************/ - let operationNamesByAttributes = new Map(); - operationNamesByAttributes.set("deregistration-operation", deregisterOperation); - operationNamesByAttributes.set("relay-server-replacement-operation", relayServerReplacementOperation); - operationNamesByAttributes.set("relay-operation-update-operation", relayOperationUpdateOperation); + let ltpConfigurationList = []; + // update the registryOffice configuration + let relayServerReplacementForwarding = "PromptForBequeathingDataCausesRequestForBroadcastingInfoAboutServerReplacement"; + let relayOperationUpdate = "PromptingNewReleaseForUpdatingServerCausesRequestForBroadcastingInfoAboutBackwardCompatibleUpdateOfOperation"; + let deregisterApplication = "PromptForBequeathingDataCausesRequestForDeregisteringOfOldRelease"; + + let registryOfficeClientUuidStack = await ServiceUtils.resolveClientUuidStackFromForwardingAsync(relayServerReplacementForwarding); + let relayOperationUpdateOperationClientUuid = await ServiceUtils.resolveOperationClientUuidFromForwardingAsync(relayOperationUpdate); + let deregisterApplicationOperationClientUuid = await ServiceUtils.resolveOperationClientUuidFromForwardingAsync(deregisterApplication); + + let existingRegistryOfficeApplicationName = await httpClientInterface.getApplicationNameAsync(registryOfficeClientUuidStack.httpClientUuid); + let existingRegistryOfficeReleaseNumber = await httpClientInterface.getReleaseNumberAsync(registryOfficeClientUuidStack.httpClientUuid); + let existingRegistryOfficeAddress = await tcpClientInterface.getRemoteAddressAsync(registryOfficeClientUuidStack.tcpClientUuid); + let existingRegistryOfficePort = await tcpClientInterface.getRemotePortAsync(registryOfficeClientUuidStack.tcpClientUuid); + let existingRegistryOfficeProtocol = await tcpClientInterface.getRemoteProtocolAsync(registryOfficeClientUuidStack.tcpClientUuid); + let exsitingRegistryOfficeRelayServerReplacementOperation = await operationClientInterface.getOperationNameAsync(registryOfficeClientUuidStack.operationClientUuid); + let exsitingRegistryOfficeRelayOperationUpdateOperation = await operationClientInterface.getOperationNameAsync(relayOperationUpdateOperationClientUuid); + let exsitingRegistryOfficeDeregisterApplicationOperation = await operationClientInterface.getOperationNameAsync(deregisterApplicationOperationClientUuid); + + let isRoApplicationNameUpdated = false; + let isRoReleaseNumberUpdated = false; + let isRoAddressUpdated = false; + let isRoPortUpdated = false; + let isRoProtocolUpdated = false; + let isRoRelayServerReplacementOperationUpdated = false; + let isRoRelayOperationUpdateOperationUpdated = false; + let isRoDeregisterApplicationOperationUpdated = false; + + if (registryOfficeApplicationName != existingRegistryOfficeApplicationName) { + isRoApplicationNameUpdated = await httpClientInterface.setApplicationNameAsync( + registryOfficeClientUuidStack.httpClientUuid, + registryOfficeApplicationName); + } + if (registryOfficeReleaseNumber != existingRegistryOfficeReleaseNumber) { + isRoReleaseNumberUpdated = await httpClientInterface.setReleaseNumberAsync( + registryOfficeClientUuidStack.httpClientUuid, + registryOfficeReleaseNumber); + } + if (JSON.stringify(registryOfficeAddress) != JSON.stringify(existingRegistryOfficeAddress)) { + isRoAddressUpdated = await tcpClientInterface.setRemoteAddressAsync( + registryOfficeClientUuidStack.tcpClientUuid, + registryOfficeAddress); + } + if (registryOfficePort != existingRegistryOfficePort) { + isRoPortUpdated = await tcpClientInterface.setRemotePortAsync( + registryOfficeClientUuidStack.tcpClientUuid, + registryOfficePort); + } + if (registryOfficeProtocol != existingRegistryOfficeProtocol) { + isRoProtocolUpdated = await tcpClientInterface.setRemoteProtocolAsync( + registryOfficeClientUuidStack.tcpClientUuid, + registryOfficeProtocol); + } + if (relayServerReplacementOperation != exsitingRegistryOfficeRelayServerReplacementOperation) { + isRoRelayServerReplacementOperationUpdated = await operationClientInterface.setOperationNameAsync( + registryOfficeClientUuidStack.operationClientUuid, + relayServerReplacementOperation); + } - let isApplicationRo = await ServiceUtils.getServerApplicationDetail(); + if (relayOperationUpdateOperation != exsitingRegistryOfficeRelayOperationUpdateOperation) { + isRoRelayOperationUpdateOperationUpdated = await operationClientInterface.setOperationNameAsync( + relayOperationUpdateOperationClientUuid, + relayOperationUpdateOperation); + } - let tcpObjectList = [new TcpObject(applicationProtocol, applicationAddress, applicationPort)]; - let httpClientUuid = await httpClientInterface.getHttpClientUuidAsync( - applicationName, - releaseNumber - ); - if (!httpClientUuid) { - httpClientUuid = await httpClientInterface.getHttpClientUuidAsync(applicationName); + if (deregisterOperation != exsitingRegistryOfficeDeregisterApplicationOperation) { + isRoDeregisterApplicationOperationUpdated = await operationClientInterface.setOperationNameAsync( + deregisterApplicationOperationClientUuid, + deregisterOperation); } - let ltpConfigurationInput = new LogicalTerminationPointConfigurationInput( - httpClientUuid, - applicationName, - releaseNumber, - tcpObjectList, - operationServerName, - operationNamesByAttributes, - basicServicesOperationsMapping.basicServicesOperationsMapping - ); - let ltpConfigurationStatus; - if (httpClientUuid) { - ltpConfigurationStatus = await LogicalTerminationPointService.FindAndUpdateApplicationLtpsAsync( - ltpConfigurationInput, isApplicationRo - ); + + if (isRoApplicationNameUpdated || isRoReleaseNumberUpdated) { + ltpConfigurationList.push(registryOfficeClientUuidStack.httpClientUuid); + } + if (isRoAddressUpdated || isRoPortUpdated || isRoProtocolUpdated) { + ltpConfigurationList.push(registryOfficeClientUuidStack.tcpClientUuid); + } + if (isRoRelayServerReplacementOperationUpdated) { + ltpConfigurationList.push(registryOfficeClientUuidStack.operationClientUuid); + } + if (isRoRelayOperationUpdateOperationUpdated) { + ltpConfigurationList.push(relayOperationUpdateOperationClientUuid); + } + if (isRoDeregisterApplicationOperationUpdated) { + ltpConfigurationList.push(deregisterApplicationOperationClientUuid); } /*********************************************************************** * oldRelease information to be updated if provided in the requestBody ***********************************************************************/ - let isOldApplicationTcpClientUpdated = false; - let oldApplicationTcpClientUuid; - let oldApplicationForwardingTag = "PromptForEmbeddingCausesRequestForBequeathingData"; - let isOldReleaseExist = await isForwardingNameExist(oldApplicationForwardingTag); + let oldApplicationNameInConfiguration; - + let beaqueathYourDataAndDieForwardingName = "PromptForEmbeddingCausesRequestForBequeathingData"; + let isOldReleaseExist = await isForwardingNameExist(beaqueathYourDataAndDieForwardingName); + if (isOldReleaseExist) { - let httpUuidOfOldApplication = await httpClientInterface.getHttpClientUuidFromForwarding(oldApplicationForwardingTag); - oldApplicationNameInConfiguration = await ServiceUtils.resolveApplicationNameFromForwardingAsync(oldApplicationForwardingTag); - - if (httpUuidOfOldApplication != undefined) { - let tcpClientUuidList = await LogicalTerminationPoint.getServerLtpListAsync(httpUuidOfOldApplication); - - if (tcpClientUuidList != undefined) { - oldApplicationTcpClientUuid = tcpClientUuidList[0]; - let tcpClientProtocolOfOldApplication = await tcpClientInterface.getRemoteProtocolAsync(oldApplicationTcpClientUuid); - if ("old-release-protocol" in body) - { - let oldReleaseProtocol = body["old-release-protocol"]; - if(oldReleaseProtocol != tcpClientProtocolOfOldApplication) { - isOldApplicationTcpClientUpdated = await tcpClientInterface.setRemoteProtocolAsync(oldApplicationTcpClientUuid, oldReleaseProtocol); - } - } - if ("old-release-address" in body) - { - let oldReleaseAddress = body["old-release-address"]; - let tcpClientAddressOfOldApplication = await tcpClientInterface.getRemoteAddressAsync(oldApplicationTcpClientUuid); - if (oldReleaseAddress != tcpClientAddressOfOldApplication) { - isOldApplicationTcpClientUpdated = await tcpClientInterface.setRemoteAddressAsync(oldApplicationTcpClientUuid, oldReleaseAddress); - } - } - if ("old-release-port" in body) - { - let oldReleasePort = body["old-release-port"]; - let tcpClientPortOfOldApplication = await tcpClientInterface.getRemotePortAsync(oldApplicationTcpClientUuid); - if (oldReleasePort != tcpClientPortOfOldApplication) { - isOldApplicationTcpClientUpdated = await tcpClientInterface.setRemotePortAsync(oldApplicationTcpClientUuid, oldReleasePort); - } - } - } + let preceedingApplicationClientUuidStack = await ServiceUtils.resolveClientUuidStackFromForwardingAsync(beaqueathYourDataAndDieForwardingName); + + oldApplicationNameInConfiguration = await httpClientInterface.getApplicationNameAsync(preceedingApplicationClientUuidStack.httpClientUuid) + let existingpreceedingApplicationAddress = await tcpClientInterface.getRemoteAddressAsync(preceedingApplicationClientUuidStack.tcpClientUuid); + let existingpreceedingApplicationPort = await tcpClientInterface.getRemotePortAsync(preceedingApplicationClientUuidStack.tcpClientUuid); + let existingpreceedingApplicationProtocol = await tcpClientInterface.getRemoteProtocolAsync(preceedingApplicationClientUuidStack.tcpClientUuid); + + let isORAddressUpdated = false; + let isORPortUpdated = false; + let isORProtocolUpdated = false; + + let oldReleaseAddress = body["old-release-address"]; + let oldReleaseProtocol = body["old-release-protocol"]; + let oldReleasePort = body["old-release-port"]; + if (JSON.stringify(oldReleaseAddress) != JSON.stringify(existingpreceedingApplicationAddress)) { + isORAddressUpdated = await tcpClientInterface.setRemoteAddressAsync( + preceedingApplicationClientUuidStack.tcpClientUuid, + oldReleaseAddress); } - if (isOldApplicationTcpClientUpdated) { - let configurationStatus = new ConfigurationStatus(oldApplicationTcpClientUuid, '', isOldApplicationTcpClientUpdated); - if (ltpConfigurationStatus) { - let tcpClientConfigurationStatusList = ltpConfigurationStatus.tcpClientConfigurationStatusList; - tcpClientConfigurationStatusList.push(configurationStatus); - } + if (oldReleasePort != existingpreceedingApplicationPort) { + isORPortUpdated = await tcpClientInterface.setRemotePortAsync( + preceedingApplicationClientUuidStack.tcpClientUuid, + oldReleasePort); } + if (oldReleaseProtocol != existingpreceedingApplicationProtocol) { + isORProtocolUpdated = await tcpClientInterface.setRemoteProtocolAsync( + preceedingApplicationClientUuidStack.tcpClientUuid, + oldReleaseProtocol); + } + + if (isORAddressUpdated || isORPortUpdated || isORProtocolUpdated) { + ltpConfigurationList.push(preceedingApplicationClientUuidStack.tcpClientUuid); + } + } /**************************************************************************************** * Prepare attributes to configure forwarding-construct + * Since the following forwarding-constructs are invariant , no configuration required in the forwarding-construct + * PromptForBequeathingDataCausesRequestForBroadcastingInfoAboutServerReplacement, + * PromptingNewReleaseForUpdatingServerCausesRequestForBroadcastingInfoAboutBackwardCompatibleUpdateOfOperation + * PromptForBequeathingDataCausesRequestForDeregisteringOfOldRelease ****************************************************************************************/ - let forwardingConfigurationInputList = []; - let forwardingConstructConfigurationStatus; - let operationClientConfigurationStatusList - if (ltpConfigurationStatus) { - operationClientConfigurationStatusList = ltpConfigurationStatus.operationClientConfigurationStatusList; - } - if (operationClientConfigurationStatusList && isOldReleaseExist) { - forwardingConfigurationInputList = await prepareForwardingConfiguration.embedYourself( - operationClientConfigurationStatusList, - deregisterOperation, - relayServerReplacementOperation, - relayOperationUpdateOperation - ); - forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - configureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); - } /**************************************************************************************** * Prepare attributes to automate forwarding-construct ****************************************************************************************/ let forwardingAutomationInputList = await prepareForwardingAutomation.embedYourself( - ltpConfigurationStatus, - forwardingConstructConfigurationStatus, - oldApplicationNameInConfiguration + ltpConfigurationList, oldApplicationNameInConfiguration ); ForwardingAutomationService.automateForwardingConstructAsync( operationServerName, @@ -275,10 +296,10 @@ exports.endSubscription = async function (body, user, xCorrelator, traceIndicato subscriptionOperation ); let forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - unConfigureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); + unConfigureForwardingConstructAsync( + operationServerName, + forwardingConfigurationInputList + ); let forwardingAutomationInputList = prepareForwardingAutomation.endSubscription( forwardingConstructConfigurationStatus ); @@ -388,82 +409,21 @@ exports.informAboutReleaseHistoryInGenericRepresentation = async function (opera * no response value expected for this operation **/ exports.inquireBasicAuthRequestApprovals = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName, newReleaseFwName) { - let applicationName = body["application-name"]; - let releaseNumber = body["release-number"]; - let applicationProtocol = body["protocol"]; - let applicationAddress = body["address"]; - let applicationPort = body["port"]; - let basicAuthApprovalOperation = body["operation-name"]; - - - let httpClientUuid = await httpClientInterface.getHttpClientUuidFromForwarding("BasicAuthRequestCausesInquiryForAuthentication"); - - let operationNamesByAttributes = new Map(); - operationNamesByAttributes.set("basic-auth-approval-operation", basicAuthApprovalOperation); - - let tcpObjectList = [new TcpObject(applicationProtocol, applicationAddress, applicationPort)]; - - if (!httpClientUuid) { - httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - undefined, - newReleaseFwName - ); - } - let ltpConfigurationInput = new LogicalTerminationPointConfigurationInput( - httpClientUuid, - applicationName, - releaseNumber, - tcpObjectList, - operationServerName, - operationNamesByAttributes, - basicServicesOperationsMapping.basicServicesOperationsMapping - ); - let ltpConfigurationStatus; - if (httpClientUuid) { - ltpConfigurationStatus = await LogicalTerminationPointService.createOrUpdateApplicationLtpsAsync( - ltpConfigurationInput, false - ); - } - - /**************************************************************************************** - * Prepare attributes to configure forwarding-construct - ****************************************************************************************/ + let subscribingApplicationName = body["application-name"]; + let subscribingApplicationReleaseNumber = body["release-number"]; + let subscribingApplicationProtocol = body["protocol"]; + let subscribingApplicationIPAddress = body["address"]; + let subscribingApplicationPort = body["port"]; - let forwardingConfigurationInputList = []; - let forwardingConstructConfigurationStatus; - let operationClientConfigurationStatusList; - if (ltpConfigurationStatus) { - operationClientConfigurationStatusList = ltpConfigurationStatus.operationClientConfigurationStatusList; - } + let basicAuthApprovalOperation = body["operation-name"]; + let inquireBasicAuthFCName = "BasicAuthRequestCausesInquiryForAuthentication"; - if (operationClientConfigurationStatusList) { - forwardingConfigurationInputList = await prepareForwardingConfiguration.inquireBasicAuthRequestApprovals( - operationClientConfigurationStatusList, - basicAuthApprovalOperation - ); - forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - configureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); - } + let subscribingServiceAndCallbackUrlMap = new Map(); + subscribingServiceAndCallbackUrlMap.set(inquireBasicAuthFCName, basicAuthApprovalOperation); - /**************************************************************************************** - * Prepare attributes to automate forwarding-construct - ****************************************************************************************/ - let forwardingAutomationInputList = await prepareForwardingAutomation.inquireBasicAuthRequestApprovals( - ltpConfigurationStatus, - forwardingConstructConfigurationStatus - ); - ForwardingAutomationService.automateForwardingConstructAsync( - operationServerName, - forwardingAutomationInputList, - user, - xCorrelator, - traceIndicator, - customerJourney - ); + await processInvariantSubscription(subscribingApplicationName, subscribingApplicationReleaseNumber, subscribingApplicationProtocol, + subscribingApplicationIPAddress, subscribingApplicationPort, subscribingServiceAndCallbackUrlMap, + operationServerName, user, xCorrelator, traceIndicator, customerJourney); } /** @@ -477,88 +437,20 @@ exports.inquireBasicAuthRequestApprovals = async function (body, user, xCorrelat * no response value expected for this operation **/ exports.inquireOamRequestApprovals = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName, newReleaseFwName) { - let applicationName = body["oam-approval-application"]; - let releaseNumber = body["oam-approval-application-release-number"]; - let applicationProtocol = body["oam-approval-protocol"]; - let applicationAddress = body["oam-approval-address"]; - let applicationPort = body["oam-approval-port"]; - let oamApprovalOperation = body["oam-approval-operation"]; + let subscribingApplicationName = body["oam-approval-application"]; + let subscribingApplicationReleaseNumber = body["oam-approval-application-release-number"]; + let subscribingApplicationProtocol = body["oam-approval-protocol"]; + let subscribingApplicationIPAddress = body["oam-approval-address"]; + let subscribingApplicationPort = body["oam-approval-port"]; - const oamApplicationName = await ServiceUtils.resolveApplicationNameFromForwardingAsync("OamRequestCausesInquiryForAuthentication"); - if (oamApplicationName !== applicationName) { - throw new createHttpError.BadRequest(`The oam-approval-application ${applicationName} was not found.`); - } - let operationNamesByAttributes = new Map(); - operationNamesByAttributes.set("oam-approval-operation", oamApprovalOperation); - let isApplicationRo = await ServiceUtils.getServerApplicationDetail(); - - let tcpObjectList = [new TcpObject(applicationProtocol, applicationAddress, applicationPort)]; - let httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - releaseNumber, - newReleaseFwName - ); - if (!httpClientUuid) { - httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - undefined, - newReleaseFwName - ); - } - let ltpConfigurationInput = new LogicalTerminationPointConfigurationInput( - httpClientUuid, - applicationName, - releaseNumber, - tcpObjectList, - operationServerName, - operationNamesByAttributes, - basicServicesOperationsMapping.basicServicesOperationsMapping - ); - let ltpConfigurationStatus; - if (httpClientUuid) { - ltpConfigurationStatus = await LogicalTerminationPointService.FindAndUpdateApplicationLtpsAsync( - ltpConfigurationInput, isApplicationRo - ); - } - - /**************************************************************************************** - * Prepare attributes to configure forwarding-construct - ****************************************************************************************/ - - let forwardingConfigurationInputList = []; - let forwardingConstructConfigurationStatus; - let operationClientConfigurationStatusList; - if (ltpConfigurationStatus) { - operationClientConfigurationStatusList = ltpConfigurationStatus.operationClientConfigurationStatusList; - } - - if (operationClientConfigurationStatusList) { - forwardingConfigurationInputList = await prepareForwardingConfiguration.inquireOamRequestApprovals( - operationClientConfigurationStatusList, - oamApprovalOperation - ); - forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - configureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); - } + let oamApprovalOperation = body["oam-approval-operation"]; + let inquireBasicAuthFCName = "BasicAuthRequestCausesInquiryForAuthentication"; + let subscribingServiceAndCallbackUrlMap = new Map(); + subscribingServiceAndCallbackUrlMap.set(inquireBasicAuthFCName, oamApprovalOperation); - /**************************************************************************************** - * Prepare attributes to automate forwarding-construct - ****************************************************************************************/ - let forwardingAutomationInputList = await prepareForwardingAutomation.inquireOamRequestApprovals( - ltpConfigurationStatus, - forwardingConstructConfigurationStatus - ); - ForwardingAutomationService.automateForwardingConstructAsync( - operationServerName, - forwardingAutomationInputList, - user, - xCorrelator, - traceIndicator, - customerJourney - ); + await processInvariantSubscription(subscribingApplicationName, subscribingApplicationReleaseNumber, subscribingApplicationProtocol, + subscribingApplicationIPAddress, subscribingApplicationPort, subscribingServiceAndCallbackUrlMap, + operationServerName, user, xCorrelator, traceIndicator, customerJourney); } /** @@ -631,91 +523,21 @@ exports.listLtpsAndFcs = async function () { * customerJourney String Holds information supporting customer’s journey to which the execution applies * no response value expected for this operation **/ -exports.redirectOamRequestInformation = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName, newReleaseFwName) { - let applicationName = body["oam-log-application"]; - let releaseNumber = body["oam-log-application-release-number"]; - let applicationProtocol = body["oam-log-protocol"]; - let applicationAddress = body["oam-log-address"]; - let applicationPort = body["oam-log-port"]; - let oamLogOperation = body["oam-log-operation"]; - - const oamApplicationName = await ServiceUtils.resolveApplicationNameFromForwardingAsync("OamRequestCausesLoggingRequest"); - if (oamApplicationName !== applicationName) { - throw new createHttpError.BadRequest(`The oam-log-application ${applicationName} was not found.`); - } - - let operationNamesByAttributes = new Map(); - operationNamesByAttributes.set("oam-log-operation", oamLogOperation); - - let isApplicationRo = await ServiceUtils.getServerApplicationDetail(); - - let tcpObjectList = [new TcpObject(applicationProtocol, applicationAddress, applicationPort)]; - let httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - releaseNumber, - newReleaseFwName - ); - if (!httpClientUuid) { - httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - undefined, - newReleaseFwName - ); - } - let ltpConfigurationInput = new LogicalTerminationPointConfigurationInput( - httpClientUuid, - applicationName, - releaseNumber, - tcpObjectList, - operationServerName, - operationNamesByAttributes, - basicServicesOperationsMapping.basicServicesOperationsMapping - ); - let ltpConfigurationStatus; - if (httpClientUuid) { - ltpConfigurationStatus = await LogicalTerminationPointService.FindAndUpdateApplicationLtpsAsync( - ltpConfigurationInput, isApplicationRo - ); - } - - /**************************************************************************************** - * Prepare attributes to configure forwarding-construct - ****************************************************************************************/ +exports.redirectOamRequestInformation = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName) { + let subscribingApplicationName = body["oam-log-application"]; + let subscribingApplicationReleaseNumber = body["oam-log-application-release-number"]; + let subscribingApplicationProtocol = body["oam-log-protocol"]; + let subscribingApplicationIPAddress = body["oam-log-address"]; + let subscribingApplicationPort = body["oam-log-port"]; - let forwardingConfigurationInputList = []; - let forwardingConstructConfigurationStatus; - let operationClientConfigurationStatusList; - if (ltpConfigurationStatus) { - operationClientConfigurationStatusList = ltpConfigurationStatus.operationClientConfigurationStatusList; - } - - if (operationClientConfigurationStatusList) { - forwardingConfigurationInputList = await prepareForwardingConfiguration.redirectOamRequestInformation( - operationClientConfigurationStatusList, - oamLogOperation - ); - forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - configureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); - } + let oamLogOperation = body["oam-log-operation"]; + let oamRequestLoggingFCName = "OamRequestCausesLoggingRequest"; + let subscribingServiceAndCallbackUrlMap = new Map(); + subscribingServiceAndCallbackUrlMap.set(oamRequestLoggingFCName, oamLogOperation); - /**************************************************************************************** - * Prepare attributes to automate forwarding-construct - ****************************************************************************************/ - let forwardingAutomationInputList = await prepareForwardingAutomation.redirectOamRequestInformation( - ltpConfigurationStatus, - forwardingConstructConfigurationStatus - ); - ForwardingAutomationService.automateForwardingConstructAsync( - operationServerName, - forwardingAutomationInputList, - user, - xCorrelator, - traceIndicator, - customerJourney - ); + await processInvariantSubscription(subscribingApplicationName, subscribingApplicationReleaseNumber, subscribingApplicationProtocol, + subscribingApplicationIPAddress, subscribingApplicationPort, subscribingServiceAndCallbackUrlMap, + operationServerName, user, xCorrelator, traceIndicator, customerJourney); } /** @@ -728,90 +550,21 @@ exports.redirectOamRequestInformation = async function (body, user, xCorrelator, * customerJourney String Holds information supporting customer’s journey to which the execution applies * no response value expected for this operation **/ -exports.redirectServiceRequestInformation = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName, newReleaseFwName) { - let applicationName = body["service-log-application"]; - let releaseNumber = body["service-log-application-release-number"]; - let applicationProtocol = body["service-log-protocol"]; - let applicationAddress = body["service-log-address"]; - let applicationPort = body["service-log-port"]; - let serviceLogOperation = body["service-log-operation"]; - - const eatlApplicationName = await ServiceUtils.resolveApplicationNameFromForwardingAsync("ServiceRequestCausesLoggingRequest"); - if (eatlApplicationName !== applicationName) { - throw new createHttpError.BadRequest(`The service-log-application ${applicationName} was not found.`); - } - - let operationNamesByAttributes = new Map(); - operationNamesByAttributes.set("service-log-operation", serviceLogOperation); - let isApplicationRo = await ServiceUtils.getServerApplicationDetail(); - - let tcpObjectList = [new TcpObject(applicationProtocol, applicationAddress, applicationPort)]; - let httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - releaseNumber, - newReleaseFwName - ); - if (!httpClientUuid) { - httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - undefined, - newReleaseFwName - ); - } - let ltpConfigurationInput = new LogicalTerminationPointConfigurationInput( - httpClientUuid, - applicationName, - releaseNumber, - tcpObjectList, - operationServerName, - operationNamesByAttributes, - basicServicesOperationsMapping.basicServicesOperationsMapping - ); - let ltpConfigurationStatus; - if (httpClientUuid) { - ltpConfigurationStatus = await LogicalTerminationPointService.FindAndUpdateApplicationLtpsAsync( - ltpConfigurationInput, isApplicationRo - ); - } - - /**************************************************************************************** - * Prepare attributes to configure forwarding-construct - ****************************************************************************************/ - - let forwardingConfigurationInputList = []; - let forwardingConstructConfigurationStatus; - let operationClientConfigurationStatusList; - if (ltpConfigurationStatus) { - operationClientConfigurationStatusList = ltpConfigurationStatus.operationClientConfigurationStatusList; - } +exports.redirectServiceRequestInformation = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName) { + let subscribingApplicationName = body["service-log-application"]; + let subscribingApplicationReleaseNumber = body["service-log-application-release-number"]; + let subscribingApplicationProtocol = body["service-log-protocol"]; + let subscribingApplicationIPAddress = body["service-log-address"]; + let subscribingApplicationPort = body["service-log-port"]; - if (operationClientConfigurationStatusList) { - forwardingConfigurationInputList = await prepareForwardingConfiguration.redirectServiceRequestInformation( - operationClientConfigurationStatusList, - serviceLogOperation - ); - forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - configureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); - } + let serviceLogOperation = body["service-log-operation"]; + let ServiceRequestCausesLoggingRequestFCName = "ServiceRequestCausesLoggingRequest"; + let subscribingServiceAndCallbackUrlMap = new Map(); + subscribingServiceAndCallbackUrlMap.set(ServiceRequestCausesLoggingRequestFCName, serviceLogOperation); - /**************************************************************************************** - * Prepare attributes to automate forwarding-construct - ****************************************************************************************/ - let forwardingAutomationInputList = await prepareForwardingAutomation.redirectServiceRequestInformation( - ltpConfigurationStatus, - forwardingConstructConfigurationStatus - ); - ForwardingAutomationService.automateForwardingConstructAsync( - operationServerName, - forwardingAutomationInputList, - user, - xCorrelator, - traceIndicator, - customerJourney - ); + await processInvariantSubscription(subscribingApplicationName, subscribingApplicationReleaseNumber, subscribingApplicationProtocol, + subscribingApplicationIPAddress, subscribingApplicationPort, subscribingServiceAndCallbackUrlMap, + operationServerName, user, xCorrelator, traceIndicator, customerJourney); } /** @@ -824,162 +577,42 @@ exports.redirectServiceRequestInformation = async function (body, user, xCorrela * customerJourney String Holds information supporting customer’s journey to which the execution applies * no response value expected for this operation **/ -exports.redirectTopologyChangeInformation = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName, newReleaseFwName) { - let applicationName = body["topology-application"]; - let releaseNumber = body["topology-application-release-number"]; - let applicationAddress = body["topology-application-address"]; - let applicationPort = body["topology-application-port"]; - let applicationProtocol = body["topology-application-protocol"]; +exports.redirectTopologyChangeInformation = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName) { + let subscribingApplicationName = body["topology-application"]; + let subscribingApplicationReleaseNumber = body["topology-application-release-number"]; + let subscribingApplicationIPAddress = body["topology-application-address"]; + let subscribingApplicationPort = body["topology-application-port"]; + let subscribingApplicationProtocol = body["topology-application-protocol"]; + let ltpUpdateTopologyOperation = body["topology-operation-ltp-update"]; + let updateLtpFCName = "ServiceRequestCausesLtpUpdateRequest"; + let ltpDeletionTopologyOperation = body["topology-operation-ltp-deletion"]; + let deleteLtpFCName = "ServiceRequestCausesLtpDeletionRequest"; + let fcUpdateTopologyOperation = body["topology-operation-fc-update"]; + let updateForwardingFCName = "ServiceRequestCausesFcUpdateRequest"; + let fcPortUpdateTopologyOperation = body["topology-operation-fc-port-update"]; - let fcPortDeletionTopologyOperation = body["topology-operation-fc-port-deletion"]; + let updateFCPortFCName = "ServiceRequestCausesFcPortUpdateRequest"; - const altApplicationName = await ServiceUtils.resolveApplicationNameFromForwardingAsync("OamRequestCausesLtpUpdateRequest"); - if (altApplicationName !== applicationName) { - throw new createHttpError.BadRequest(`The topology-application ${applicationName} was not found.`); - } + let fcPortDeletionTopologyOperation = body["topology-operation-fc-port-deletion"]; + let deleteFCPortFCName = "ServiceRequestCausesFcPortDeletionRequest"; - let operationNamesByAttributes = new Map(); - operationNamesByAttributes.set("topology-operation-ltp-update", ltpUpdateTopologyOperation); - operationNamesByAttributes.set("topology-operation-ltp-deletion", ltpDeletionTopologyOperation); - operationNamesByAttributes.set("topology-operation-fc-update", fcUpdateTopologyOperation); - operationNamesByAttributes.set("topology-operation-fc-port-update", fcPortUpdateTopologyOperation); - operationNamesByAttributes.set("topology-operation-fc-port-deletion", fcPortDeletionTopologyOperation); - let isApplicationRo = await ServiceUtils.getServerApplicationDetail(); - let tcpObjectList = [new TcpObject(applicationProtocol, applicationAddress, applicationPort)]; - let httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - releaseNumber, - newReleaseFwName - ); - if (!httpClientUuid) { - httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - applicationName, - undefined, - newReleaseFwName - ); - } - let ltpConfigurationInput = new LogicalTerminationPointConfigurationInput( - httpClientUuid, - applicationName, - releaseNumber, - tcpObjectList, - operationServerName, - operationNamesByAttributes, - basicServicesOperationsMapping.basicServicesOperationsMapping - ); - let ltpConfigurationStatus; - if (httpClientUuid) { - ltpConfigurationStatus = await LogicalTerminationPointService.FindAndUpdateApplicationLtpsAsync( - ltpConfigurationInput, isApplicationRo - ); - } + let subscribingServiceAndCallbackUrlMap = new Map(); + subscribingServiceAndCallbackUrlMap.set(updateLtpFCName, ltpUpdateTopologyOperation); + subscribingServiceAndCallbackUrlMap.set(deleteLtpFCName, ltpDeletionTopologyOperation); + subscribingServiceAndCallbackUrlMap.set(updateForwardingFCName, fcUpdateTopologyOperation); + subscribingServiceAndCallbackUrlMap.set(updateFCPortFCName, fcPortUpdateTopologyOperation); + subscribingServiceAndCallbackUrlMap.set(deleteFCPortFCName, fcPortDeletionTopologyOperation); - /**************************************************************************************** - * Prepare attributes to configure forwarding-construct - ****************************************************************************************/ + await processInvariantSubscription(subscribingApplicationName, subscribingApplicationReleaseNumber, subscribingApplicationProtocol, + subscribingApplicationIPAddress, subscribingApplicationPort, subscribingServiceAndCallbackUrlMap, + operationServerName, user, xCorrelator, traceIndicator, customerJourney); - let forwardingConfigurationInputList = []; - let forwardingConstructConfigurationStatus; - let operationClientConfigurationStatusList; - if (ltpConfigurationStatus) { - operationClientConfigurationStatusList = ltpConfigurationStatus.operationClientConfigurationStatusList; - } - - if (operationClientConfigurationStatusList) { - forwardingConfigurationInputList = await prepareForwardingConfiguration.redirectTopologyChangeInformation( - operationClientConfigurationStatusList, - ltpUpdateTopologyOperation, - ltpDeletionTopologyOperation, - fcUpdateTopologyOperation, - fcPortUpdateTopologyOperation, - fcPortDeletionTopologyOperation - ); - forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - configureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); - } - - /**************************************************************************************** - * Prepare attributes to automate forwarding-construct - ****************************************************************************************/ - let forwardingAutomationInputList = await prepareForwardingAutomation.redirectTopologyChangeInformation( - ltpConfigurationStatus, - forwardingConstructConfigurationStatus - ); - ForwardingAutomationService.automateForwardingConstructAsync( - operationServerName, - forwardingAutomationInputList, - user, - xCorrelator, - traceIndicator, - customerJourney - ); - - let forwrdingContructResponse = await controlConstruct.getForwardingDomainListAsync() - let serverclientinterfacepac; - let controlConstructUrl = onfPaths.CONTROL_CONSTRUCT; - let controlConstructcompleteResponse = await fileOperation.readFromDatabaseAsync(controlConstructUrl); - let controluuid = controlConstructcompleteResponse['uuid'] - let logicalterminationpoint = await fileOperation.readFromDatabaseAsync( - onfPaths.LOGICAL_TERMINATION_POINT - ); - for (let i = 0; i < logicalterminationpoint.length; i++) { - let layerprotocol = logicalterminationpoint[i][onfAttributes.LOGICAL_TERMINATION_POINT.LAYER_PROTOCOL] - for (let j = 0; j < layerprotocol.length; j++) { - let layerProtocalName = layerprotocol[j]['layer-protocol-name'] - if (layerProtocalName == 'operation-client-interface-1-0:LAYER_PROTOCOL_NAME_TYPE_OPERATION_LAYER') { - let operationclientinterfacepac = layerprotocol[j][onfAttributes.LAYER_PROTOCOL.OPERATION_CLIENT_INTERFACE_PAC] - let clientconfiguration = operationclientinterfacepac[onfAttributes.OPERATION_CLIENT.CONFIGURATION] - if (clientconfiguration !== undefined) { - delete clientconfiguration['operation-key']; - if (clientconfiguration['detailed-logging-is-on'] != undefined) { - delete clientconfiguration['detailed-logging-is-on']; - } - } - } else if (layerProtocalName == 'operation-server-interface-1-0:LAYER_PROTOCOL_NAME_TYPE_OPERATION_LAYER') { - serverclientinterfacepac = layerprotocol[j][onfAttributes.LAYER_PROTOCOL.OPERATION_SERVER_INTERFACE_PAC] - let serverconfiguration = serverclientinterfacepac[onfAttributes.OPERATION_SERVER.CONFIGURATION] - if (serverconfiguration !== undefined) { - delete serverconfiguration['operation-key']; - } - } else if (layerProtocalName == LayerProtocol.layerProtocolNameEnum.ES_CLIENT) { - let elsticSearchClientInterface = layerprotocol[j][onfAttributes.LAYER_PROTOCOL.ES_CLIENT_INTERFACE_PAC]; - if (elsticSearchClientInterface !== undefined) { - let elasticSearchConfiguration = elsticSearchClientInterface[onfAttributes.ES_CLIENT.CONFIGURATION] - if (elasticSearchConfiguration !== undefined) { - delete elasticSearchConfiguration["auth"] - } - } - } else if (layerProtocalName == LayerProtocol.layerProtocolNameEnum.HTTP_SERVER) { - let httpServerInterface = layerprotocol[j][onfAttributes.LAYER_PROTOCOL.HTTP_SERVER_INTERFACE_PAC]; - if (httpServerInterface !== undefined) { - let httpServerCapability = httpServerInterface[onfAttributes.HTTP_SERVER.CAPABILITY] - if (httpServerCapability !== undefined) { - delete httpServerCapability['application-purpose'] - delete httpServerCapability['owner-name'] - delete httpServerCapability['owner-email-address'] - delete httpServerCapability[onfAttributes.HTTP_SERVER.RELEASE_LIST] - } - } - } - - } - } - - let controlConstructResponse = { - "core-model-1-4:control-construct": { - "uuid": controluuid, - "logical-termination-point": logicalterminationpoint, - "forwarding-domain": forwrdingContructResponse - } - }; - return controlConstructResponse; -} + let response = await prepareResponseForRedirectTopologyChangeInformation(); + return response; +} /** * Initiates registering at the currently active RegistryOffice @@ -994,10 +627,11 @@ exports.redirectTopologyChangeInformation = async function (body, user, xCorrela * no response value expected for this operation **/ exports.registerYourself = async function (body, user, xCorrelator, traceIndicator, customerJourney, operationServerName) { - let ltpConfigurationStatus; + let ltpConfigurationList = []; let forwardingConstructConfigurationStatus; - let oldApplicationName; - let oldReleaseNumber; + let preceedingApplicationName; + let preceedingApplicationRelease; + if (Object.keys(body).length != 0) { /**************************************************************************************** * Setting up required local variables from the request body @@ -1014,125 +648,138 @@ exports.registerYourself = async function (body, user, xCorrelator, traceIndicat let httpAddress = body["http-address"]; let httpPort = body["http-port"]; - oldApplicationName = body["preceding-application-name"]; - oldReleaseNumber = body["preceding-release-number"]; + preceedingApplicationName = body["preceding-application-name"]; + preceedingApplicationRelease = body["preceding-release-number"]; /**************************************************************************************** * Prepare logicalTerminationPointConfigurationInput object to * configure logical-termination-point ****************************************************************************************/ // update the registryOffice configuration - const roApplicationName = await ServiceUtils.resolveRegistryOfficeApplicationNameFromForwardingAsync(); - if (roApplicationName !== registryOfficeApplicationName) { - throw new createHttpError.BadRequest(`The registry-office-application ${registryOfficeApplicationName} was not found.`); + let registrationForwardingName = "PromptForRegisteringCausesRegistrationRequest"; + let registryOfficeClientUuidStack = await ServiceUtils.resolveClientUuidStackFromForwardingAsync(registrationForwardingName); + + let existingRegistryOfficeApplicationName = await httpClientInterface.getApplicationNameAsync(registryOfficeClientUuidStack.httpClientUuid); + let existingRegistryOfficeReleaseNumber = await httpClientInterface.getReleaseNumberAsync(registryOfficeClientUuidStack.httpClientUuid); + let existingRegistryOfficeAddress = await tcpClientInterface.getRemoteAddressAsync(registryOfficeClientUuidStack.tcpClientUuid); + let existingRegistryOfficePort = await tcpClientInterface.getRemotePortAsync(registryOfficeClientUuidStack.tcpClientUuid); + let existingRegistryOfficeProtocol = await tcpClientInterface.getRemoteProtocolAsync(registryOfficeClientUuidStack.tcpClientUuid); + let exsitingRegistryOfficeRegisterOperation = await operationClientInterface.getOperationNameAsync(registryOfficeClientUuidStack.operationClientUuid); + + let isRoApplicationNameUpdated = false; + let isRoReleaseNumberUpdated = false; + let isRoAddressUpdated = false; + let isRoPortUpdated = false; + let isRoProtocolUpdated = false; + let isRoRegisterOperationUpdated = false; + + if (registryOfficeApplicationName != existingRegistryOfficeApplicationName) { + isRoApplicationNameUpdated = await httpClientInterface.setApplicationNameAsync( + registryOfficeClientUuidStack.httpClientUuid, + registryOfficeApplicationName); + } + if (registryOfficeReleaseNumber != existingRegistryOfficeReleaseNumber) { + isRoReleaseNumberUpdated = await httpClientInterface.setReleaseNumberAsync( + registryOfficeClientUuidStack.httpClientUuid, + registryOfficeReleaseNumber); + } + if (JSON.stringify(registryOfficeAddress) != JSON.stringify(existingRegistryOfficeAddress)) { + isRoAddressUpdated = await tcpClientInterface.setRemoteAddressAsync( + registryOfficeClientUuidStack.tcpClientUuid, + registryOfficeAddress); + } + if (registryOfficePort != existingRegistryOfficePort) { + isRoPortUpdated = await tcpClientInterface.setRemotePortAsync( + registryOfficeClientUuidStack.tcpClientUuid, + registryOfficePort); + } + if (registryOfficeProtocol != existingRegistryOfficeProtocol) { + isRoProtocolUpdated = await tcpClientInterface.setRemoteProtocolAsync( + registryOfficeClientUuidStack.tcpClientUuid, + registryOfficeProtocol); + } + if (registryOfficeRegisterOperation != exsitingRegistryOfficeRegisterOperation) { + isRoRegisterOperationUpdated = await operationClientInterface.setOperationNameAsync( + registryOfficeClientUuidStack.operationClientUuid, + registryOfficeRegisterOperation); } - let operationNamesByAttributes = new Map(); - operationNamesByAttributes.set("registration-operation", registryOfficeRegisterOperation); - - let isApplicationRo = await ServiceUtils.getServerApplicationDetail(); - let tcpObjectList = [new TcpObject(registryOfficeProtocol, registryOfficeAddress, registryOfficePort)]; - let httpClientUuid = await httpClientInterface.getHttpClientUuidAsync( - registryOfficeApplicationName, - registryOfficeReleaseNumber - ); - if (!httpClientUuid) { - httpClientUuid = await httpClientInterface.getHttpClientUuidAsync( - registryOfficeApplicationName - ); + if (isRoApplicationNameUpdated || isRoReleaseNumberUpdated) { + ltpConfigurationList.push(registryOfficeClientUuidStack.httpClientUuid); } - let ltpConfigurationInput = new LogicalTerminationPointConfigurationInput( - httpClientUuid, - registryOfficeApplicationName, - registryOfficeReleaseNumber, - tcpObjectList, - operationServerName, - operationNamesByAttributes, - basicServicesOperationsMapping.basicServicesOperationsMapping - ); - if (httpClientUuid) { - ltpConfigurationStatus = await LogicalTerminationPointService.FindAndUpdateApplicationLtpsAsync( - ltpConfigurationInput, isApplicationRo - ); + if (isRoAddressUpdated || isRoPortUpdated || isRoProtocolUpdated) { + ltpConfigurationList.push(registryOfficeClientUuidStack.tcpClientUuid); + } + if (isRoRegisterOperationUpdated) { + ltpConfigurationList.push(registryOfficeClientUuidStack.operationClientUuid); } // update tcp-server configuration if required let tcpServerWithHttpUpdated = await updateTcpServerDetails("HTTP", httpAddress, httpPort); if (tcpServerWithHttpUpdated.istcpServerUpdated) { - let configurationStatus = new ConfigurationStatus(tcpServerWithHttpUpdated.tcpServerUuid, '', tcpServerWithHttpUpdated.istcpServerUpdated); - if (ltpConfigurationStatus) { - let tcpClientConfigurationStatusList = ltpConfigurationStatus.tcpClientConfigurationStatusList; - tcpClientConfigurationStatusList.push(configurationStatus); - } - } + ltpConfigurationList.push(tcpServerWithHttpUpdated.tcpServerUuid); + } // update old release configuration - let isOldApplicationIsUpdated = false; - let httpUuidOfOldApplication; - //whether oldRelease of the application name exists - let oldApplicationForwardingTag = "PromptForEmbeddingCausesRequestForBequeathingData"; - let isOldReleaseExist = await isForwardingNameExist(oldApplicationForwardingTag); - if ((oldApplicationName != undefined || oldReleaseNumber != undefined) && isOldReleaseExist) { - httpUuidOfOldApplication = await httpClientInterface.getHttpClientUuidFromForwarding(oldApplicationForwardingTag); - - if (httpUuidOfOldApplication != undefined) { - if (oldApplicationName != undefined) { - let configuredOldApplicationName = await httpClientInterface.getApplicationNameAsync(httpUuidOfOldApplication); - if (configuredOldApplicationName != oldApplicationName) { - isOldApplicationIsUpdated = await httpClientInterface.setApplicationNameAsync(httpUuidOfOldApplication, oldApplicationName); - } - } - if (oldReleaseNumber != undefined) { - let configuredOldApplicationReleaseNumber = await httpClientInterface.getReleaseNumberAsync(httpUuidOfOldApplication); - if (configuredOldApplicationReleaseNumber != oldReleaseNumber) { - isOldApplicationIsUpdated = await httpClientInterface.setReleaseNumberAsync(httpUuidOfOldApplication, oldReleaseNumber); - } + let beaqueathYourDataAndDieForwardingName = "PromptForEmbeddingCausesRequestForBequeathingData"; + let preceedingApplicationClientUuidStack = await ServiceUtils.resolveClientUuidStackFromForwardingAsync(beaqueathYourDataAndDieForwardingName); + + if (preceedingApplicationClientUuidStack.httpClientUuid) { + let isPreceedingApplicationNameUpdated = false; + let isPreceedingReleaseNumberUpdated = false; + if (preceedingApplicationName != undefined) { + let existingPreceedingApplicationName = await httpClientInterface.getApplicationNameAsync( + preceedingApplicationClientUuidStack.httpClientUuid); + if (existingPreceedingApplicationName != preceedingApplicationName) { + isPreceedingApplicationNameUpdated = await httpClientInterface.setApplicationNameAsync( + preceedingApplicationClientUuidStack.httpClientUuid, + preceedingApplicationName); } - if (isOldApplicationIsUpdated) { - let configurationStatus = new ConfigurationStatus(httpUuidOfOldApplication, '', isOldApplicationIsUpdated); - if (ltpConfigurationStatus) { - let tcpClientConfigurationStatusList = ltpConfigurationStatus.tcpClientConfigurationStatusList; - tcpClientConfigurationStatusList.push(configurationStatus); - } + } + if (preceedingApplicationRelease != undefined) { + let existingPreceedingApplicationReleaseNumber = await httpClientInterface.getReleaseNumberAsync( + preceedingApplicationClientUuidStack.httpClientUuid); + if (existingPreceedingApplicationReleaseNumber != preceedingApplicationRelease) { + isPreceedingReleaseNumberUpdated = await httpClientInterface.setReleaseNumberAsync( + preceedingApplicationClientUuidStack.httpClientUuid, + preceedingApplicationRelease); } } + if (isPreceedingApplicationNameUpdated || isPreceedingReleaseNumberUpdated) { + ltpConfigurationList.push(preceedingApplicationClientUuidStack.httpClientUuid) + } } /**************************************************************************************** * Prepare attributes to configure forwarding-construct + * Since PromptForRegisteringCausesRegistrationRequest is invariant process snippet , + * no fc-port updation is required ****************************************************************************************/ - let forwardingConfigurationInputList = []; - let operationClientConfigurationStatusList; - if (ltpConfigurationStatus) { - operationClientConfigurationStatusList = ltpConfigurationStatus.operationClientConfigurationStatusList; - } - if (operationClientConfigurationStatusList) { - forwardingConfigurationInputList = await prepareForwardingConfiguration.registerYourself( - operationClientConfigurationStatusList, - registryOfficeRegisterOperation - ); - forwardingConstructConfigurationStatus = await ForwardingConfigurationService. - configureForwardingConstructAsync( - operationServerName, - forwardingConfigurationInputList - ); - } } /**************************************************************************************** * Prepare attributes to automate forwarding-construct ****************************************************************************************/ - let forwardingAutomationInputList = await prepareForwardingAutomation.registerYourself( - ltpConfigurationStatus, - forwardingConstructConfigurationStatus, - oldApplicationName, - oldReleaseNumber + let forwardingAutomationToALTInputList = await prepareForwardingAutomation.updateLtpToALT( + ltpConfigurationList ); ForwardingAutomationService.automateForwardingConstructAsync( operationServerName, + forwardingAutomationToALTInputList, + user, + xCorrelator, + traceIndicator, + customerJourney + ); + + let forwardingAutomationInputList = await prepareForwardingAutomation.registerYourself( + preceedingApplicationName, + preceedingApplicationRelease + ); + automateRegisterApplicationAsync( forwardingAutomationInputList, user, xCorrelator, @@ -1141,6 +788,42 @@ exports.registerYourself = async function (body, user, xCorrelator, traceIndicat ); } +async function automateRegisterApplicationAsync(forwardingAutomationInputList, user, + xCorrelator, traceIndicator, customerJourney) { + let response; + let traceIndicatorIncrementor = 1; + for (let forwardingAutomationInput of forwardingAutomationInputList) { + let newTraceIndicator = traceIndicator + "." + traceIndicatorIncrementor++; + if (!(response && response.status == 204)) { + try { + let forwardingName = forwardingAutomationInput.forwardingName; + let attributeList = forwardingAutomationInput.attributeList; + let forwardingConstruct = await ForwardingDomain.getForwardingConstructForTheForwardingNameAsync( + forwardingName); + let fcPortList = forwardingConstruct["fc-port"]; + for (let fcPort of fcPortList) { + let fcPortDirection = fcPort["port-direction"]; + if (fcPortDirection == FcPort.portDirectionEnum.OUTPUT) { + let fcPortLogicalTerminationPoint = fcPort["logical-termination-point"]; + response = await eventDispatcher.dispatchEvent( + fcPortLogicalTerminationPoint, + attributeList, + user, + xCorrelator, + newTraceIndicator, + customerJourney, + undefined, + undefined, + true + ); + } + } + } catch (error) { + console.log(error); + } + } + } +} /** * Starts application in generic representation * @@ -1178,81 +861,99 @@ exports.updateClient = async function (body, user, xCorrelator, traceIndicator, * Prepare logicalTerminationPointConfigurationInput object to * configure logical-termination-point ****************************************************************************************/ - let operationNamesByAttributes = new Map(); - - let tcpObjectList = [new TcpObject(futureProtocol, futureAddress, futurePort)]; + let ltpConfigurationList = []; - let httpClientUuidOfnewApplication = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease(futureApplicationName, futureReleaseNumber, newReleaseFwName); - let httpClientUuid; - if (!httpClientUuidOfnewApplication) { - httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - currentApplicationName, - currentReleaseNumber, - newReleaseFwName - ); - } else { - httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( - futureApplicationName, - futureReleaseNumber, - newReleaseFwName - ); - } - let ltpConfigurationInput = new LogicalTerminationPointConfigurationInput( - httpClientUuid, + let httpClientUuidOfFutureApplication = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( futureApplicationName, futureReleaseNumber, - tcpObjectList, - operationServerName, - operationNamesByAttributes, - basicServicesOperationsMapping.basicServicesOperationsMapping - ); - - let isApplicationRo = await ServiceUtils.getServerApplicationDetail(); + newReleaseFwName); + let httpClientUuidOfCurrentApplication = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease( + currentApplicationName, + currentReleaseNumber, + newReleaseFwName); + + if (httpClientUuidOfFutureApplication) { + let tcpClientUuidOfFutureApplication = await LogicalTerminationPoint.getServerLtpListAsync(httpClientUuidOfFutureApplication); + let existingIpAddressOfFutureApplication = await tcpClientInterface.getRemoteAddressAsync(tcpClientUuidOfFutureApplication); + let existingProtocolOfFutureApplication = await tcpClientInterface.getRemoteProtocolAsync(tcpClientUuidOfFutureApplication); + let existingPortOfFutureApplication = await tcpClientInterface.getRemotePortAsync(tcpClientUuidOfFutureApplication); + + let isIpAddressOfFutureApplicationUpdated = false; + let isProtocolOfFutureApplicationUpdated = false; + let isPortOfFutureApplicationUpdated = false; + + if (JSON.stringify(futureAddress) != JSON.stringify(existingIpAddressOfFutureApplication)) { + isIpAddressOfFutureApplicationUpdated = await tcpClientInterface.setRemoteAddressAsync( + tcpClientUuidOfFutureApplication, + futureAddress); + } + if (futureProtocol != existingProtocolOfFutureApplication) { + isProtocolOfFutureApplicationUpdated = await tcpClientInterface.setRemoteProtocolAsync( + tcpClientUuidOfFutureApplication, + futureProtocol); + } + if (futurePort != existingPortOfFutureApplication) { + isPortOfFutureApplicationUpdated = await tcpClientInterface.setRemotePortAsync( + tcpClientUuidOfFutureApplication, + futurePort); + } - let ltpConfigurationStatus; - if (httpClientUuid) { - ltpConfigurationStatus = await LogicalTerminationPointService.FindAndUpdateApplicationLtpsAsync( - ltpConfigurationInput, - isApplicationRo - ); - } - if(currentApplicationName != futureApplicationName){ - await httpClientInterface.setApplicationNameAsync(httpClientUuid, futureApplicationName) - ltpConfigurationStatus.httpClientConfigurationStatus.updated = true - } - /******************************************************************************************************* - * bussiness logic to transfer the operation-client instances from current-release to future-release - *******************************************************************************************************/ - - let httpClientUuidOfOldApplication = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease(currentApplicationName, currentReleaseNumber, newReleaseFwName); - if (httpClientUuidOfOldApplication) { - let clientLtpsOfOldApplication = await LogicalTerminationPoint.getClientLtpListAsync(httpClientUuidOfOldApplication); - if (clientLtpsOfOldApplication != undefined && clientLtpsOfOldApplication.length > 0) { - await LogicalTerminationPoint.setClientLtpListAsync( - httpClientUuidOfOldApplication, - [] - ); - if (httpClientUuidOfnewApplication) { - let existingLtpsOfNewRelease = await LogicalTerminationPoint.getClientLtpListAsync(httpClientUuidOfnewApplication); + if (isIpAddressOfFutureApplicationUpdated || isProtocolOfFutureApplicationUpdated || isPortOfFutureApplicationUpdated) { + ltpConfigurationList.push(tcpClientUuidOfFutureApplication); + } - for (let i = 0; i < clientLtpsOfOldApplication.length; i++) { - let operationClientLtpOfOldApplication = clientLtpsOfOldApplication[i]; - existingLtpsOfNewRelease.push(operationClientLtpOfOldApplication); - } - await LogicalTerminationPoint.setClientLtpListAsync( - httpClientUuidOfnewApplication, - existingLtpsOfNewRelease - ); - } + if (httpClientUuidOfCurrentApplication) { + let updateUuidList = await transferOperationClientFromOldToNewRelease(httpClientUuidOfCurrentApplication, httpClientUuidOfFutureApplication) + ltpConfigurationList = ltpConfigurationList.concat(updateUuidList); + } + } else if (httpClientUuidOfCurrentApplication) { + let tcpClientUuidOfCurrentApplication = await LogicalTerminationPoint.getServerLtpListAsync(httpClientUuidOfCurrentApplication); + let existingIpAddressOfCurrentApplication = await tcpClientInterface.getRemoteAddressAsync(tcpClientUuidOfCurrentApplication); + let existingProtocolOfCurrentApplication = await tcpClientInterface.getRemoteProtocolAsync(tcpClientUuidOfCurrentApplication); + let existingPortOfCurrentApplication = await tcpClientInterface.getRemotePortAsync(tcpClientUuidOfCurrentApplication); + + let isIpAddressOfCurrentApplicationUpdated = false; + let isProtocolOfCurrentApplicationUpdated = false; + let isPortOfCurrentApplicationUpdated = false; + + if (JSON.stringify(futureAddress) != JSON.stringify(existingIpAddressOfCurrentApplication)) { + isIpAddressOfCurrentApplicationUpdated = await tcpClientInterface.setRemoteAddressAsync( + tcpClientUuidOfCurrentApplication, + futureAddress); + } + if (futureProtocol != existingProtocolOfCurrentApplication) { + isProtocolOfCurrentApplicationUpdated = await tcpClientInterface.setRemoteProtocolAsync( + tcpClientUuidOfCurrentApplication, + futureProtocol); + } + if (futurePort != existingPortOfCurrentApplication) { + isPortOfCurrentApplicationUpdated = await tcpClientInterface.setRemotePortAsync( + tcpClientUuidOfCurrentApplication, + futurePort); + } + + let isApplicationNameUpdated = await httpClientInterface.setApplicationNameAsync( + httpClientUuidOfCurrentApplication, + futureApplicationName); + + let isReleaseNumberUpdated = await httpClientInterface.setReleaseNumberAsync( + httpClientUuidOfCurrentApplication, + futureReleaseNumber); + + if (isIpAddressOfCurrentApplicationUpdated || isProtocolOfCurrentApplicationUpdated || isPortOfCurrentApplicationUpdated) { + ltpConfigurationList.push(tcpClientUuidOfCurrentApplication); + } + + if (isApplicationNameUpdated || isReleaseNumberUpdated) { + ltpConfigurationList.push(httpClientUuidOfCurrentApplication); } } /**************************************************************************************** * Prepare attributes to automate forwarding-construct ****************************************************************************************/ - let forwardingAutomationInputList = await prepareForwardingAutomation.updateClient( - ltpConfigurationStatus, undefined, - futureApplicationName + let forwardingAutomationInputList = await prepareForwardingAutomation.updateLtpToALT( + ltpConfigurationList ); ForwardingAutomationService.automateForwardingConstructAsync( operationServerName, @@ -1290,42 +991,65 @@ exports.updateClientOfSubsequentRelease = async function (body, user, xCorrelato * configure logical-termination-point ****************************************************************************************/ - let ltpConfigurationStatus = {}; + let ltpConfigurationList = []; + let newReleaseHttpClientLtpUuid = await httpClientInterface.getHttpClientUuidFromForwarding(newReleaseForwardingName); if (newReleaseHttpClientLtpUuid != undefined) { - let isReleaseUpdated = await httpClientInterface.setReleaseNumberAsync(newReleaseHttpClientLtpUuid, futureReleaseNumber); - let isApplicationNameUpdated = await httpClientInterface.setApplicationNameAsync(newReleaseHttpClientLtpUuid, futureApplicationName); - - if (isReleaseUpdated || isApplicationNameUpdated) { - let configurationStatus = new ConfigurationStatus( - newReleaseHttpClientLtpUuid, - '', - true); - ltpConfigurationStatus.httpClientConfigurationStatus = configurationStatus; - } - let newReleaseTcpClientUuidList = await LogicalTerminationPoint.getServerLtpListAsync(newReleaseHttpClientLtpUuid); let newReleaseTcpClientUuid = newReleaseTcpClientUuidList[0]; - let isProtocolUpdated = await tcpClientInterface.setRemoteProtocolAsync(newReleaseTcpClientUuid, futureProtocol); - let isAddressUpdated = await tcpClientInterface.setRemoteAddressAsync(newReleaseTcpClientUuid, futureAddress); - let isPortUpdated = await tcpClientInterface.setRemotePortAsync(newReleaseTcpClientUuid, futurePort); + let existingNewReleaseApplicationName = await httpClientInterface.getApplicationNameAsync(newReleaseHttpClientLtpUuid); + let existingNewReleaseNumber = await httpClientInterface.getReleaseNumberAsync(newReleaseHttpClientLtpUuid); + let existingNewReleaseAddress = await tcpClientInterface.getRemoteAddressAsync(newReleaseTcpClientUuid); + let existingNewReleasePort = await tcpClientInterface.getRemotePortAsync(newReleaseTcpClientUuid); + let existingNewReleaseProtocol = await tcpClientInterface.getRemoteProtocolAsync(newReleaseTcpClientUuid); + + let isNewReleaseApplicationNameIsUpdated = false; + let isNewReleaseNumberIsUpdated = false; + let isNewReleaseAddressUpdated = false; + let isNewReleasePortUpdated = false; + let isNewReleaseProtocolUpdated = false; - if (isProtocolUpdated || isAddressUpdated || isPortUpdated) { - let configurationStatus = new ConfigurationStatus( + if (futureApplicationName != existingNewReleaseApplicationName) { + isNewReleaseApplicationNameIsUpdated = await httpClientInterface.setApplicationNameAsync( + newReleaseHttpClientLtpUuid, + futureApplicationName); + } + if (futureReleaseNumber != existingNewReleaseNumber) { + isNewReleaseNumberIsUpdated = await httpClientInterface.setReleaseNumberAsync( + newReleaseHttpClientLtpUuid, + futureReleaseNumber); + } + if (JSON.stringify(futureAddress) != JSON.stringify(existingNewReleaseAddress)) { + isNewReleaseAddressUpdated = await tcpClientInterface.setRemoteAddressAsync( newReleaseTcpClientUuid, - '', - true); - ltpConfigurationStatus.tcpClientConfigurationStatusList = [configurationStatus]; + futureAddress); } - let forwardingAutomationInputList; - if (ltpConfigurationStatus != undefined) { + if (futurePort != existingNewReleasePort) { + isNewReleasePortUpdated = await tcpClientInterface.setRemotePortAsync( + newReleaseTcpClientUuid, + futurePort); + } + if (futureProtocol != existingNewReleaseProtocol) { + isNewReleaseProtocolUpdated = await tcpClientInterface.setRemoteProtocolAsync( + newReleaseTcpClientUuid, + futureProtocol); + } + + if (isNewReleaseApplicationNameIsUpdated || isNewReleaseNumberIsUpdated) { + ltpConfigurationList.push(newReleaseHttpClientLtpUuid); + } + if (isNewReleaseAddressUpdated || isNewReleasePortUpdated || isNewReleaseProtocolUpdated) { + ltpConfigurationList.push(newReleaseTcpClientUuid); + } + + if (ltpConfigurationList.length != 0) { /**************************************************************************************** * Prepare attributes to automate forwarding-construct ****************************************************************************************/ - forwardingAutomationInputList = await prepareForwardingAutomation.updateClientOfSubsequentRelease( - ltpConfigurationStatus + let forwardingAutomationInputList = await prepareForwardingAutomation.updateLtpToALT( + ltpConfigurationList ); ForwardingAutomationService.automateForwardingConstructAsync( operationServerName, @@ -1335,25 +1059,30 @@ exports.updateClientOfSubsequentRelease = async function (body, user, xCorrelato traceIndicator, customerJourney ); - } + } } - bequeathYourDataAndDieOperation = await operationServerInterface.getInputOperationServerNameFromForwarding(newReleaseForwardingName); - let dataTransferOperationClientUuidList = await LogicalTerminationPoint.getClientLtpListAsync(newReleaseHttpClientLtpUuid); - for (let i = 0; i < dataTransferOperationClientUuidList.length; i++) { - let operationClientUuid = dataTransferOperationClientUuidList[i]; - let operationClientName = await OperationClientInterface.getOperationNameAsync(operationClientUuid); - dataTransferOperationsList.push(operationClientName); + bequeathYourDataAndDieOperation = await operationServerInterface.getInputOperationServerNameFromForwarding(newReleaseForwardingName); + + if (newReleaseHttpClientLtpUuid) { + let dataTransferOperationClientUuidList = await LogicalTerminationPoint.getClientLtpListAsync(newReleaseHttpClientLtpUuid); + for (let i = 0; i < dataTransferOperationClientUuidList.length; i++) { + let operationClientUuid = dataTransferOperationClientUuidList[i]; + let operationClientName = await operationClientInterface.getOperationNameAsync(operationClientUuid); + dataTransferOperationsList.push(operationClientName); + } } /**************************************************************************************** - * Prepare attributes for the response body - ****************************************************************************************/ - var handOverAndDatatransferInformation = {}; - handOverAndDatatransferInformation.bequeathYourDataAndDieOperation = bequeathYourDataAndDieOperation; - handOverAndDatatransferInformation.dataTransferOperationsList = dataTransferOperationsList; + * Prepare attributes for the response body + ****************************************************************************************/ + let handOverAndDatatransferInformation = { + "bequeathYourDataAndDieOperation": bequeathYourDataAndDieOperation, + "dataTransferOperationsList": dataTransferOperationsList + }; + return onfAttributeFormatter.modifyJsonObjectKeysToKebabCase(handOverAndDatatransferInformation); -} +} /** * Allows updating operation clients to redirect to backward compatible services @@ -1371,41 +1100,34 @@ exports.updateOperationClient = async function (body, user, xCorrelator, traceIn let oldOperationName = body["old-operation-name"]; let newOperationName = body["new-operation-name"]; - let isUpdated; - let operationClientUuid + let ltpConfigurationList = []; let httpClientUuid = await httpClientInterface.getHttpClientUuidExcludingOldReleaseAndNewRelease(applicationName, releaseNumber, newReleaseFwName); if (httpClientUuid) { - operationClientUuid = await operationClientInterface.getOperationClientUuidAsync(httpClientUuid, oldOperationName); + let operationClientUuid = await operationClientInterface.getOperationClientUuidAsync(httpClientUuid, oldOperationName); if (operationClientUuid) { if (oldOperationName != newOperationName) { - isUpdated = await operationClientInterface.setOperationNameAsync(operationClientUuid, newOperationName); + let isOperationClientUpdated = await operationClientInterface.setOperationNameAsync(operationClientUuid, newOperationName); + if (isOperationClientUpdated) { + ltpConfigurationList.push(operationClientUuid); + } } } } - if (isUpdated) { - let configurationStatus = new ConfigurationStatus(operationClientUuid, undefined, isUpdated); - - let logicalTerminationPointConfigurationStatus = new LogicalTerminationPointConfigurationStatus( - [configurationStatus], - undefined, - [] - ); - /**************************************************************************************** - * Prepare attributes to automate forwarding-construct - ****************************************************************************************/ - let forwardingAutomationInputList = await prepareForwardingAutomation.updateOperationClient( - logicalTerminationPointConfigurationStatus - ); - ForwardingAutomationService.automateForwardingConstructAsync( - operationServerName, - forwardingAutomationInputList, - user, - xCorrelator, - traceIndicator, - customerJourney - ); - } + /**************************************************************************************** + * Prepare attributes to automate forwarding-construct + ****************************************************************************************/ + let forwardingAutomationInputList = await prepareForwardingAutomation.updateLtpToALT( + ltpConfigurationList + ); + ForwardingAutomationService.automateForwardingConstructAsync( + operationServerName, + forwardingAutomationInputList, + user, + xCorrelator, + traceIndicator, + customerJourney + ); } /** @@ -1423,11 +1145,17 @@ exports.updateOperationKey = async function (body) { operationServerInterface.setOperationKeyAsync(operationUuid, newOperationKey); } else if (isOperationClientUuid) { operationClientInterface.setOperationKeyAsync(operationUuid, newOperationKey); - }else { + } else { throw new createHttpError.BadRequest("OperationClientUuid/OperationServerUuid is not present"); } } + + +/*********************************************************************************************** + * FUNCTIONS + ***********************************************************************************************/ + async function isForwardingNameExist(forwardingName) { const forwardingConstruct = await ForwardingDomain.getForwardingConstructForTheForwardingNameAsync(forwardingName); return forwardingConstruct !== undefined; @@ -1466,3 +1194,223 @@ async function updateTcpServerDetails(protocol, address, port) { updatedDetails.istcpServerUpdated = istcpServerUpdated; return updatedDetails; } + +/** + * Prepares response for the redirect topology change information + * @returns controlConstructResponse + */ +async function prepareResponseForRedirectTopologyChangeInformation() { + let controlConstructResponse; + let forwrdingContructResponse = await controlConstruct.getForwardingDomainListAsync() + let serverclientinterfacepac; + let controlConstructUrl = onfPaths.CONTROL_CONSTRUCT; + let controlConstructcompleteResponse = await fileOperation.readFromDatabaseAsync(controlConstructUrl); + let controluuid = controlConstructcompleteResponse['uuid'] + let logicalterminationpoint = await fileOperation.readFromDatabaseAsync( + onfPaths.LOGICAL_TERMINATION_POINT + ); + for (let i = 0; i < logicalterminationpoint.length; i++) { + let layerprotocol = logicalterminationpoint[i][onfAttributes.LOGICAL_TERMINATION_POINT.LAYER_PROTOCOL] + for (let j = 0; j < layerprotocol.length; j++) { + let layerProtocalName = layerprotocol[j]['layer-protocol-name'] + if (layerProtocalName == 'operation-client-interface-1-0:LAYER_PROTOCOL_NAME_TYPE_OPERATION_LAYER') { + let operationclientinterfacepac = layerprotocol[j][onfAttributes.LAYER_PROTOCOL.OPERATION_CLIENT_INTERFACE_PAC] + let clientconfiguration = operationclientinterfacepac[onfAttributes.OPERATION_CLIENT.CONFIGURATION] + if (clientconfiguration !== undefined) { + delete clientconfiguration['operation-key']; + if (clientconfiguration['detailed-logging-is-on'] != undefined) { + delete clientconfiguration['detailed-logging-is-on']; + } + } + } else if (layerProtocalName == 'operation-server-interface-1-0:LAYER_PROTOCOL_NAME_TYPE_OPERATION_LAYER') { + serverclientinterfacepac = layerprotocol[j][onfAttributes.LAYER_PROTOCOL.OPERATION_SERVER_INTERFACE_PAC] + let serverconfiguration = serverclientinterfacepac[onfAttributes.OPERATION_SERVER.CONFIGURATION] + if (serverconfiguration !== undefined) { + delete serverconfiguration['operation-key']; + } + } else if (layerProtocalName == LayerProtocol.layerProtocolNameEnum.ES_CLIENT) { + let elsticSearchClientInterface = layerprotocol[j][onfAttributes.LAYER_PROTOCOL.ES_CLIENT_INTERFACE_PAC]; + if (elsticSearchClientInterface !== undefined) { + let elasticSearchConfiguration = elsticSearchClientInterface[onfAttributes.ES_CLIENT.CONFIGURATION] + if (elasticSearchConfiguration !== undefined) { + delete elasticSearchConfiguration["auth"] + } + } + } else if (layerProtocalName == LayerProtocol.layerProtocolNameEnum.HTTP_SERVER) { + let httpServerInterface = layerprotocol[j][onfAttributes.LAYER_PROTOCOL.HTTP_SERVER_INTERFACE_PAC]; + if (httpServerInterface !== undefined) { + let httpServerCapability = httpServerInterface[onfAttributes.HTTP_SERVER.CAPABILITY] + if (httpServerCapability !== undefined) { + delete httpServerCapability['application-purpose'] + delete httpServerCapability['owner-name'] + delete httpServerCapability['owner-email-address'] + delete httpServerCapability[onfAttributes.HTTP_SERVER.RELEASE_LIST] + } + } + } + + } + } + + controlConstructResponse = { + "core-model-1-4:control-construct": { + "uuid": controluuid, + "logical-termination-point": logicalterminationpoint, + "forwarding-domain": forwrdingContructResponse + } + }; + + return controlConstructResponse; +} + +/** + * To transfer the operation-client instances from current-release to future-release + * @param {String} httpClientUuidOfOldApplication + * @param {String} httpClientUuidOfNewApplication + * @returns {Promise} updatedLtpUuids + */ +async function transferOperationClientFromOldToNewRelease(httpClientUuidOfOldApplication, httpClientUuidOfNewApplication) { + let updatedLtpUuids = []; + let clientLtpsOfOldApplication = await LogicalTerminationPoint.getClientLtpListAsync(httpClientUuidOfOldApplication); + if (clientLtpsOfOldApplication != undefined && clientLtpsOfOldApplication.length > 0) { + let existingClientLtpsOfNewRelease = await LogicalTerminationPoint.getClientLtpListAsync(httpClientUuidOfNewApplication); + for (let i = 0; i < clientLtpsOfOldApplication.length; i++) { + let operationClientLtpOfOldApplication = clientLtpsOfOldApplication[i]; + let isOperationClientUpdated = await LogicalTerminationPoint.setServerLtpListAsync( + operationClientLtpOfOldApplication, + [httpClientUuidOfNewApplication] + ); + if (isOperationClientUpdated) { + updatedLtpUuids.push(operationClientLtpOfOldApplication); + } + existingClientLtpsOfNewRelease.push(operationClientLtpOfOldApplication); + } + + let isHttpClientOfNewReleaseUpdated = await LogicalTerminationPoint.setClientLtpListAsync( + httpClientUuidOfNewApplication, + existingClientLtpsOfNewRelease + ); + + let isHttpClientOfOldReleaseUpdated = await LogicalTerminationPoint.setClientLtpListAsync( + httpClientUuidOfOldApplication, + [] + ); + + if (isHttpClientOfNewReleaseUpdated) { + updatedLtpUuids.push(httpClientUuidOfNewApplication); + } + + if (isHttpClientOfOldReleaseUpdated) { + updatedLtpUuids.push(httpClientUuidOfNewApplication); + } + } + return updatedLtpUuids; +} + +/** + * Update invariant subscription and initiate callbacks about topology change information + * @param {String} subscribingApplicationName + * @param {String} subscribingApplicationReleaseNumber + * @param {String} subscribingApplicationProtocol + * @param {String} subscribingApplicationIPAddress + * @param {String} subscribingApplicationPort + * @param {Map} subscribingServiceAndCallbackUrlMap + * @param {String} operationServerName + * @param {String} user + * @param {String} xCorrelator + * @param {String} traceIndicator + * @param {String} customerJourney + */ +async function processInvariantSubscription(subscribingApplicationName, subscribingApplicationReleaseNumber, subscribingApplicationProtocol, + subscribingApplicationIPAddress, subscribingApplicationPort, subscribingServiceAndCallbackUrlMap, + operationServerName, user, xCorrelator, traceIndicator, customerJourney) { + /**************************************************************************************** + * configure logical-termination-point + ****************************************************************************************/ + let ltpConfigurationList = []; + let operationClientUuid; + + for (let [key, value] of subscribingServiceAndCallbackUrlMap) { + let subscribingServiceFcName = key; + let proposedCallbackOperationName = value; + operationClientUuid = await ServiceUtils.resolveOperationClientUuidFromForwardingAsync(subscribingServiceFcName); + let exsitingSubscriberCallbackOperationName = await operationClientInterface.getOperationNameAsync(operationClientUuid); + if (proposedCallbackOperationName != exsitingSubscriberCallbackOperationName) { + let isOperationClientUpdated = await operationClientInterface.setOperationNameAsync( + operationClientUuid, + proposedCallbackOperationName); + if (isOperationClientUpdated) { + ltpConfigurationList.push(operationClientUuid); + } + } + } + + let subscriberClientUuidStack = await ServiceUtils.resolveClientUuidStackForOperationClientAsync(operationClientUuid); + + let existingSubscriberApplicationName = await httpClientInterface.getApplicationNameAsync(subscriberClientUuidStack.httpClientUuid); + let existingSubscriberReleaseNumber = await httpClientInterface.getReleaseNumberAsync(subscriberClientUuidStack.httpClientUuid); + let existingSubscriberAddress = await tcpClientInterface.getRemoteAddressAsync(subscriberClientUuidStack.tcpClientUuid); + let existingSubscriberPort = await tcpClientInterface.getRemotePortAsync(subscriberClientUuidStack.tcpClientUuid); + let existingSubscriberProtocol = await tcpClientInterface.getRemoteProtocolAsync(subscriberClientUuidStack.tcpClientUuid); + + let isSubscriberApplicationNameUpdated = false; + let isSubscriberReleaseNumberUpdated = false; + let isSubscriberAddressUpdated = false; + let isSubscriberPortUpdated = false; + let isSubscriberProtocolUpdated = false; + + if (subscribingApplicationName != existingSubscriberApplicationName) { + isSubscriberApplicationNameUpdated = await httpClientInterface.setApplicationNameAsync( + subscriberClientUuidStack.httpClientUuid, + subscribingApplicationName); + } + if (subscribingApplicationReleaseNumber != existingSubscriberReleaseNumber) { + isSubscriberReleaseNumberUpdated = await httpClientInterface.setReleaseNumberAsync( + subscriberClientUuidStack.httpClientUuid, + subscribingApplicationReleaseNumber); + } + if (JSON.stringify(subscribingApplicationIPAddress) != JSON.stringify(existingSubscriberAddress)) { + isSubscriberAddressUpdated = await tcpClientInterface.setRemoteAddressAsync( + subscriberClientUuidStack.tcpClientUuid, + subscribingApplicationIPAddress); + } + if (subscribingApplicationPort != existingSubscriberPort) { + isSubscriberPortUpdated = await tcpClientInterface.setRemotePortAsync( + subscriberClientUuidStack.tcpClientUuid, + subscribingApplicationPort); + } + if (subscribingApplicationProtocol != existingSubscriberProtocol) { + isSubscriberProtocolUpdated = await tcpClientInterface.setRemoteProtocolAsync( + subscriberClientUuidStack.tcpClientUuid, + subscribingApplicationProtocol); + } + + if (isSubscriberApplicationNameUpdated || isSubscriberReleaseNumberUpdated) { + ltpConfigurationList.push(subscriberClientUuidStack.httpClientUuid); + } + if (isSubscriberAddressUpdated || isSubscriberPortUpdated || isSubscriberProtocolUpdated) { + ltpConfigurationList.push(subscriberClientUuidStack.tcpClientUuid); + } + + /**************************************************************************************** + * Prepare attributes to configure forwarding-construct + * no configuration required in forwarding-constructs for invariant forwardings + ****************************************************************************************/ + + /**************************************************************************************** + * Prepare attributes to automate forwarding-construct + ****************************************************************************************/ + + let forwardingAutomationInputList = await prepareForwardingAutomation.updateLtpToALT( + ltpConfigurationList + ); + ForwardingAutomationService.automateForwardingConstructAsync( + operationServerName, + forwardingAutomationInputList, + user, + xCorrelator, + traceIndicator, + customerJourney + ); + return true; +} \ No newline at end of file diff --git a/server/basicServices/basicServices/services/PrepareALTForwardingAutomationV2.js b/server/basicServices/basicServices/services/PrepareALTForwardingAutomationV2.js new file mode 100644 index 00000000..c8e6c2af --- /dev/null +++ b/server/basicServices/basicServices/services/PrepareALTForwardingAutomationV2.js @@ -0,0 +1,195 @@ +// @ts-check +const ForwardingConstructAutomationInput = require('onf-core-model-ap/applicationPattern/onfModel/services/models/forwardingConstruct/AutomationInput'); +const onfFormatter = require('onf-core-model-ap/applicationPattern/onfModel/utility/OnfAttributeFormatter'); +const ControlConstruct = require('onf-core-model-ap/applicationPattern/onfModel/models/ControlConstruct'); +const ForwardingDomain = require('onf-core-model-ap/applicationPattern/onfModel/models/ForwardingDomain'); +const ForwardingConstruct = require('onf-core-model-ap/applicationPattern/onfModel/models/ForwardingConstruct'); +const LayerProtocol = require('onf-core-model-ap/applicationPattern/onfModel/models/LayerProtocol'); +// eslint-disable-next-line no-unused-vars +const LogicalTerminationPointConfigurationStatus = require('onf-core-model-ap/applicationPattern/onfModel/services/models/logicalTerminationPoint/ConfigurationStatus'); +// eslint-disable-next-line no-unused-vars +const ForwardingConstructConfigurationStatus = require('onf-core-model-ap/applicationPattern/onfModel/services/models/forwardingConstruct/ConfigurationStatus') + +/** + * @param {LogicalTerminationPointConfigurationStatus} ltpUuidList + * @param {ForwardingConstructConfigurationStatus} fcConfigurationStatus + * @returns {Promise>} + */ +exports.getALTForwardingAutomationInputAsync = async function (ltpUuidList, fcConfigurationStatus) { + let forwardingConstructAutomationList = []; + let ltpforwardingConstructAutomationInputList = await getLTPForwardingAutomationInputListAsync( + ltpUuidList + ); + forwardingConstructAutomationList.push(ltpforwardingConstructAutomationInputList); + let fdforwardingConstructAutomationInputList = await getFDForwardingAutomationInputListAsync( + fcConfigurationStatus + ); + forwardingConstructAutomationList.push(fdforwardingConstructAutomationInputList); + return forwardingConstructAutomationList.flat(); +} + +/** + * This function should be used for creating delete-ltp-and-dependents forwardings when an application is + * removed. Since delete-ltp-and-dependents will remove all traces of an LTP (including fc-ports), + * there is no need to send each LTP individually, only tcp-clients are necessary. + * + * @param {LogicalTerminationPointConfigurationStatus} ltpConfigurationStatus + * @returns {Array} list of forwardings + */ +exports.getALTUnConfigureForwardingAutomationInputAsync = function (ltpConfigurationStatus) { + if (ltpConfigurationStatus === undefined || + ltpConfigurationStatus.tcpClientConfigurationStatusList === undefined) { + return []; + } + let tcpClientConfigurationStatusList = ltpConfigurationStatus.tcpClientConfigurationStatusList; + let tcpClientForwardingAutomationList = getUnconfigurableTcpClientForwardingAutomationInput(tcpClientConfigurationStatusList); + return tcpClientForwardingAutomationList; +} + +/** + * @param {String} uuid + * @returns {Promise>} + */ +exports.getALTForwardingAutomationInputForOamRequestAsync = async function (uuid) { + let forwardingConstructAutomationList = []; + let fwName = "OamRequestCausesLtpUpdateRequest"; + if (uuid) { + let body = await ControlConstruct.getLogicalTerminationPointAsync(uuid); + let layerProtocolName = body["layer-protocol"][0]["layer-protocol-name"]; + if (layerProtocolName == LayerProtocol.layerProtocolNameEnum.OPERATION_CLIENT || + layerProtocolName == LayerProtocol.layerProtocolNameEnum.OPERATION_SERVER) { + body = removeAttribute(body, "operation-key"); + } + let ltpforwardingConstructAutomationInput = new ForwardingConstructAutomationInput(fwName, body, undefined); + forwardingConstructAutomationList.push(ltpforwardingConstructAutomationInput); + } + return forwardingConstructAutomationList; +} + +async function getLTPForwardingAutomationInputListAsync(ltpUuidList) { + let forwardingConstructAutomationList = []; + for (let index = 0; index < ltpUuidList.length; index++) { + let ltpUuid = ltpUuidList[index]; + let LTPUpdateRequestFCName = "ServiceRequestCausesLtpUpdateRequest"; + let body = await ControlConstruct.getLogicalTerminationPointAsync( + ltpUuid); + body = removeAttribute(body, "operation-key") + let forwardingAutomation = new ForwardingConstructAutomationInput(LTPUpdateRequestFCName, + body, undefined); + forwardingConstructAutomationList.push(forwardingAutomation); + } + return forwardingConstructAutomationList.flat(); +} + + +async function getFDForwardingAutomationInputListAsync(fcConfigurationStatus) { + let forwardingConstructAutomationList = []; + if (fcConfigurationStatus === undefined || + fcConfigurationStatus.forwardingConstructConfigurationStatusList === undefined) { + return []; + } + let fcConfigurationStatusList = fcConfigurationStatus.forwardingConstructConfigurationStatusList; + let fcforwardingConstructAutomationInputList = await getFCForwardingAutomationInputList(fcConfigurationStatusList); + forwardingConstructAutomationList.push(fcforwardingConstructAutomationInputList); + + let fcPortConfigurationStatusList = fcConfigurationStatus.fcPortConfigurationStatusList; + let fcPortforwardingConstructAutomationInputList = await getFCPortForwardingAutomationInputList(fcPortConfigurationStatusList); + forwardingConstructAutomationList.push(fcPortforwardingConstructAutomationInputList); + + return forwardingConstructAutomationList.flat(); +} + +/** + * Creates forwardings for delete-fc-port. + * @param {ForwardingConstructConfigurationStatus} fcConfigurationStatus + * @returns {Array} list of forwardings + */ +exports.getFDUnconfigureForwardingAutomationInputList = function (fcConfigurationStatus) { + if (fcConfigurationStatus === undefined || + fcConfigurationStatus.forwardingConstructConfigurationStatusList === undefined) { + return []; + } + let fcPortConfigurationStatusList = fcConfigurationStatus.fcPortConfigurationStatusList; + return getFCPortDeleteForwardingAutomationInputList(fcPortConfigurationStatusList); +} + +function getUnconfigurableTcpClientForwardingAutomationInput(tcpClientConfigurationStatusList) { + let fwName = "ServiceRequestCausesLtpDeletionRequest"; + let forwardingAutomationList = []; + + for (let tcpClientConfigurationStatus of tcpClientConfigurationStatusList) { + if (tcpClientConfigurationStatus.updated) { + let body = { + uuid: tcpClientConfigurationStatus.uuid + }; + body = onfFormatter.modifyJsonObjectKeysToKebabCase(body); + let forwardingAutomation = new ForwardingConstructAutomationInput(fwName, body, undefined); + forwardingAutomationList.push(forwardingAutomation); + } + } + return forwardingAutomationList; +} + +async function getFCForwardingAutomationInputList(fcConfigurationStatusList) { + let fwName = "ServiceRequestCausesFcUpdateRequest"; + let forwardingConstructAutomationList = []; + for (let fcConfigurationStatus of fcConfigurationStatusList) { + if (fcConfigurationStatus.updated) { + let body = await ForwardingDomain.getForwardingConstructAsync( + fcConfigurationStatus.uuid); + let forwardingAutomation = new ForwardingConstructAutomationInput(fwName, body, undefined); + forwardingConstructAutomationList.push(forwardingAutomation); + } + } + return forwardingConstructAutomationList +} + +async function getFCPortForwardingAutomationInputList(fcPortConfigurationStatusList) { + let fwName = "ServiceRequestCausesFcPortUpdateRequest"; + let forwardingConstructAutomationList = []; + + for (let fcPortConfigurationStatus of fcPortConfigurationStatusList) { + if (fcPortConfigurationStatus.updated) { + let body = { + fcUuid: fcPortConfigurationStatus.uuid + }; + body.fcPort = await ForwardingConstruct.getFcPortAsync( + fcPortConfigurationStatus.uuid, + fcPortConfigurationStatus.localId + ); + body = onfFormatter.modifyJsonObjectKeysToKebabCase(body); + let forwardingAutomation = new ForwardingConstructAutomationInput(fwName, body, undefined); + forwardingConstructAutomationList.push(forwardingAutomation); + } + } + return forwardingConstructAutomationList; +} + +function getFCPortDeleteForwardingAutomationInputList(fcPortConfigurationStatusList) { + let fwName = "ServiceRequestCausesFcPortDeletionRequest"; + let forwardingConstructAutomationList = []; + + for (let fcPortConfigurationStatus of fcPortConfigurationStatusList) { + if (fcPortConfigurationStatus.updated) { + let body = { + fcUuid: fcPortConfigurationStatus.uuid + }; + body.fcPortLocalId = fcPortConfigurationStatus.localId; + body = onfFormatter.modifyJsonObjectKeysToKebabCase(body); + let forwardingAutomation = new ForwardingConstructAutomationInput(fwName, body, undefined); + forwardingConstructAutomationList.push(forwardingAutomation); + } + } + return forwardingConstructAutomationList; +} + +function removeAttribute(jsonObject, attributeName) { + for (var element in jsonObject) { + if (element == attributeName) { + delete jsonObject[element]; + } else if (typeof jsonObject[element] == 'object') { + removeAttribute(jsonObject[element], attributeName); + } + } + return jsonObject; +} \ No newline at end of file diff --git a/server/basicServices/basicServices/services/PrepareForwardingAutomation.js b/server/basicServices/basicServices/services/PrepareForwardingAutomation.js index 51562934..69f61335 100644 --- a/server/basicServices/basicServices/services/PrepareForwardingAutomation.js +++ b/server/basicServices/basicServices/services/PrepareForwardingAutomation.js @@ -11,7 +11,7 @@ const operationServerInterface = require('onf-core-model-ap/applicationPattern/o const ControlConstruct = require('onf-core-model-ap/applicationPattern/onfModel/models/ControlConstruct'); const httpClientInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/HttpClientInterface'); const forwardingConstructAutomationInput = require('onf-core-model-ap/applicationPattern/onfModel/services/models/forwardingConstruct/AutomationInput'); -const prepareALTForwardingAutomation = require('./PrepareALTForwardingAutomation'); +const prepareALTForwardingAutomation = require('./PrepareALTForwardingAutomationV2'); const TcpClientInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/TcpClientInterface'); exports.disposeRemaindersOfDeregisteredApplication = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus) { @@ -41,7 +41,7 @@ exports.disposeRemaindersOfDeregisteredApplication = function (logicalTerminatio }); } -exports.embedYourself = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus, oldApplicationName = '') { +exports.embedYourself = function (ltpConfigurationList, oldApplicationName = '') { return new Promise(async function (resolve, reject) { let forwardingConstructAutomationList = []; try { @@ -80,8 +80,7 @@ exports.embedYourself = function (logicalTerminationPointconfigurationStatus, fo * forwardings for application layer topology ************************************************************************************/ let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus + ltpConfigurationList ); if (applicationLayerTopologyForwardingInputList) { @@ -98,56 +97,12 @@ exports.embedYourself = function (logicalTerminationPointconfigurationStatus, fo }); } -exports.registerYourself = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus, oldApplicationName, oldReleaseNumber) { +exports.registerYourself = function (oldApplicationName, oldReleaseNumber) { return new Promise(async function (resolve, reject) { let forwardingConstructAutomationList = []; try { let forwardingAutomation; - let controlConstructUuid = await fileOperation.readFromDatabaseAsync(onfPaths.CONTROL_CONSTRUCT_UUID); - /*********************************************************************************** - * PromptForRegisteringCausesRegistrationRequest /v1/register-application - ************************************************************************************/ - let registrationApplicationForwardingName = "PromptForRegisteringCausesRegistrationRequest"; - let registrationApplicationContext; - let registrationApplicationRequestBody = {}; - let tcpServerList = []; - registrationApplicationRequestBody.applicationName = await httpServerInterface.getApplicationNameAsync(); - registrationApplicationRequestBody.releaseNumber = await httpServerInterface.getReleaseNumberAsync(); - registrationApplicationRequestBody.embeddingOperation = await operationServerInterface.getOperationNameAsync(controlConstructUuid + "-op-s-bm-001"); - registrationApplicationRequestBody.clientUpdateOperation = await operationServerInterface.getOperationNameAsync(controlConstructUuid + "-op-s-bm-007"); - registrationApplicationRequestBody.operationClientUpdateOperation = await operationServerInterface.getOperationNameAsync(controlConstructUuid + "-op-s-bm-011"); - - // formulate the tcp-server-list - let tcpHttpAddress = await tcpServerInterface.getLocalAddressOfTheProtocol("HTTP"); - let tcpHttpPort = await tcpServerInterface.getLocalPortOfTheProtocol("HTTP"); - if (tcpHttpAddress != undefined && tcpHttpPort != undefined) { - if ("ipv-4-address" in tcpHttpAddress) { - tcpHttpAddress = { - "ip-address": tcpHttpAddress - } - } - let tcpServer = { - protocol: "HTTP", - port: tcpHttpPort, - address: tcpHttpAddress - } - tcpServerList.push(tcpServer); - } - - registrationApplicationRequestBody.tcpServerList = tcpServerList; - if (oldApplicationName) { - registrationApplicationRequestBody.precedingApplicationName = oldApplicationName; - } - if (oldReleaseNumber) { - registrationApplicationRequestBody.precedingReleaseNumber = oldReleaseNumber; - } - registrationApplicationRequestBody = onfFormatter.modifyJsonObjectKeysToKebabCase(registrationApplicationRequestBody); - forwardingAutomation = new forwardingConstructAutomationInput( - registrationApplicationForwardingName, - registrationApplicationRequestBody, - registrationApplicationContext - ); - forwardingConstructAutomationList.push(forwardingAutomation); + let controlConstructUuid = await fileOperation.readFromDatabaseAsync(onfPaths.CONTROL_CONSTRUCT_UUID); /*********************************************************************************** * PromptForRegisteringCausesRegistrationRequest2 /v2/register-application @@ -155,7 +110,7 @@ exports.registerYourself = function (logicalTerminationPointconfigurationStatus, let registrationRequest2ForwardingName = "PromptForRegisteringCausesRegistrationRequest2"; let registrationRequest2Context; let registrationRequest2RequestBody = {}; - let registrationRequest2TcpServerList = []; + let registrationRequest2TcpServer; registrationRequest2RequestBody.applicationName = await httpServerInterface.getApplicationNameAsync(); registrationRequest2RequestBody.releaseNumber = await httpServerInterface.getReleaseNumberAsync(); registrationRequest2RequestBody.embeddingOperation = await operationServerInterface.getOperationNameAsync(controlConstructUuid + "-op-s-bm-001"); @@ -174,15 +129,14 @@ exports.registerYourself = function (logicalTerminationPointconfigurationStatus, "ip-address": registrationRequest2TcpHttpAddress } } - let registrationRequest2tcpServer = { + registrationRequest2TcpServer = { protocol: "HTTP", port: registrationRequest2TcpHttpPort, address: registrationRequest2TcpHttpAddress } - registrationRequest2TcpServerList.push(registrationRequest2tcpServer); } - registrationRequest2RequestBody.tcpServerList = registrationRequest2TcpServerList; + registrationRequest2RequestBody.tcpServer = registrationRequest2TcpServer; if (oldApplicationName) { registrationRequest2RequestBody.precedingApplicationName = oldApplicationName; } @@ -198,159 +152,49 @@ exports.registerYourself = function (logicalTerminationPointconfigurationStatus, forwardingConstructAutomationList.push(registrationRequest2forwardingAutomation); /*********************************************************************************** - * forwardings for application layer topology - ************************************************************************************/ - let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus - ); - - if (applicationLayerTopologyForwardingInputList) { - for (let i = 0; i < applicationLayerTopologyForwardingInputList.length; i++) { - let applicationLayerTopologyForwardingInput = applicationLayerTopologyForwardingInputList[i]; - forwardingConstructAutomationList.push(applicationLayerTopologyForwardingInput); - } - } - - resolve(forwardingConstructAutomationList); - } catch (error) { - reject(error); - } - }); -} - -exports.endSubscription = function (forwardingConstructConfigurationStatus) { - return prepareALTForwardingAutomation.getFDUnconfigureForwardingAutomationInputList( - forwardingConstructConfigurationStatus - ); -} - -exports.inquireBasicAuthRequestApprovals = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus) { - return new Promise(async function (resolve, reject) { - let forwardingConstructAutomationList = []; - try { - - /*********************************************************************************** - * forwardings for application layer topology + * PromptForRegisteringCausesRegistrationRequest /v1/register-application ************************************************************************************/ - let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus - ); + let registrationApplicationForwardingName = "PromptForRegisteringCausesRegistrationRequest"; + let registrationApplicationContext; + let registrationApplicationRequestBody = {}; + let tcpServerList = []; + registrationApplicationRequestBody.applicationName = await httpServerInterface.getApplicationNameAsync(); + registrationApplicationRequestBody.releaseNumber = await httpServerInterface.getReleaseNumberAsync(); + registrationApplicationRequestBody.embeddingOperation = await operationServerInterface.getOperationNameAsync(controlConstructUuid + "-op-s-bm-001"); + registrationApplicationRequestBody.clientUpdateOperation = await operationServerInterface.getOperationNameAsync(controlConstructUuid + "-op-s-bm-007"); + registrationApplicationRequestBody.operationClientUpdateOperation = await operationServerInterface.getOperationNameAsync(controlConstructUuid + "-op-s-bm-011"); - if (applicationLayerTopologyForwardingInputList) { - for (let i = 0; i < applicationLayerTopologyForwardingInputList.length; i++) { - let applicationLayerTopologyForwardingInput = applicationLayerTopologyForwardingInputList[i]; - forwardingConstructAutomationList.push(applicationLayerTopologyForwardingInput); + // formulate the tcp-server-list + let tcpHttpAddress = await tcpServerInterface.getLocalAddressOfTheProtocol("HTTP"); + let tcpHttpPort = await tcpServerInterface.getLocalPortOfTheProtocol("HTTP"); + if (tcpHttpAddress != undefined && tcpHttpPort != undefined) { + if ("ipv-4-address" in tcpHttpAddress) { + tcpHttpAddress = { + "ip-address": tcpHttpAddress + } } - } - - resolve(forwardingConstructAutomationList); - } catch (error) { - reject(error); - } - }); -} - -exports.inquireOamRequestApprovals = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus) { - return new Promise(async function (resolve, reject) { - let forwardingConstructAutomationList = []; - try { - - /*********************************************************************************** - * forwardings for application layer topology - ************************************************************************************/ - let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus - ); - - if (applicationLayerTopologyForwardingInputList) { - for (let i = 0; i < applicationLayerTopologyForwardingInputList.length; i++) { - let applicationLayerTopologyForwardingInput = applicationLayerTopologyForwardingInputList[i]; - forwardingConstructAutomationList.push(applicationLayerTopologyForwardingInput); + let tcpServer = { + protocol: "HTTP", + port: tcpHttpPort, + address: tcpHttpAddress } + tcpServerList.push(tcpServer); } - resolve(forwardingConstructAutomationList); - } catch (error) { - reject(error); - } - }); -} - -exports.redirectOamRequestInformation = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus) { - return new Promise(async function (resolve, reject) { - let forwardingConstructAutomationList = []; - try { - - /*********************************************************************************** - * forwardings for application layer topology - ************************************************************************************/ - let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus - ); - - if (applicationLayerTopologyForwardingInputList) { - for (let i = 0; i < applicationLayerTopologyForwardingInputList.length; i++) { - let applicationLayerTopologyForwardingInput = applicationLayerTopologyForwardingInputList[i]; - forwardingConstructAutomationList.push(applicationLayerTopologyForwardingInput); - } + registrationApplicationRequestBody.tcpServerList = tcpServerList; + if (oldApplicationName) { + registrationApplicationRequestBody.precedingApplicationName = oldApplicationName; } - - resolve(forwardingConstructAutomationList); - } catch (error) { - reject(error); - } - }); -} - -exports.redirectServiceRequestInformation = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus) { - return new Promise(async function (resolve, reject) { - let forwardingConstructAutomationList = []; - try { - - /*********************************************************************************** - * forwardings for application layer topology - ************************************************************************************/ - let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus - ); - - if (applicationLayerTopologyForwardingInputList) { - for (let i = 0; i < applicationLayerTopologyForwardingInputList.length; i++) { - let applicationLayerTopologyForwardingInput = applicationLayerTopologyForwardingInputList[i]; - forwardingConstructAutomationList.push(applicationLayerTopologyForwardingInput); - } + if (oldReleaseNumber) { + registrationApplicationRequestBody.precedingReleaseNumber = oldReleaseNumber; } - - resolve(forwardingConstructAutomationList); - } catch (error) { - reject(error); - } - }); -} - -exports.redirectTopologyChangeInformation = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus) { - return new Promise(async function (resolve, reject) { - let forwardingConstructAutomationList = []; - try { - /*********************************************************************************** - * forwardings for application layer topology - ************************************************************************************/ - let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus + registrationApplicationRequestBody = onfFormatter.modifyJsonObjectKeysToKebabCase(registrationApplicationRequestBody); + forwardingAutomation = new forwardingConstructAutomationInput( + registrationApplicationForwardingName, + registrationApplicationRequestBody, + registrationApplicationContext ); - - if (applicationLayerTopologyForwardingInputList) { - for (let i = 0; i < applicationLayerTopologyForwardingInputList.length; i++) { - let applicationLayerTopologyForwardingInput = applicationLayerTopologyForwardingInputList[i]; - forwardingConstructAutomationList.push(applicationLayerTopologyForwardingInput); - } - } + forwardingConstructAutomationList.push(forwardingAutomation); resolve(forwardingConstructAutomationList); } catch (error) { @@ -359,34 +203,12 @@ exports.redirectTopologyChangeInformation = function (logicalTerminationPointcon }); } -exports.updateOperationClient = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus) { - return new Promise(async function (resolve, reject) { - let forwardingConstructAutomationList = []; - try { - - /*********************************************************************************** - * forwardings for application layer topology - ************************************************************************************/ - let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus - ); - - if (applicationLayerTopologyForwardingInputList) { - for (let i = 0; i < applicationLayerTopologyForwardingInputList.length; i++) { - let applicationLayerTopologyForwardingInput = applicationLayerTopologyForwardingInputList[i]; - forwardingConstructAutomationList.push(applicationLayerTopologyForwardingInput); - } - } - - resolve(forwardingConstructAutomationList); - } catch (error) { - reject(error); - } - }); +exports.endSubscription = function (forwardingConstructConfigurationStatus) { + return prepareALTForwardingAutomation.getFDUnconfigureForwardingAutomationInputList( + forwardingConstructConfigurationStatus + ); } - exports.updateClient = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus, applicationName) { return new Promise(async function (resolve, reject) { let forwardingConstructAutomationList = []; @@ -448,7 +270,7 @@ exports.updateClient = function (logicalTerminationPointconfigurationStatus, for }); } -exports.updateClientOfSubsequentRelease = function (logicalTerminationPointconfigurationStatus, forwardingConstructConfigurationStatus) { +exports.updateLtpToALT = function (ltpConfigurationList) { return new Promise(async function (resolve, reject) { let forwardingConstructAutomationList = []; try { @@ -457,8 +279,7 @@ exports.updateClientOfSubsequentRelease = function (logicalTerminationPointconfi * forwardings for application layer topology ************************************************************************************/ let applicationLayerTopologyForwardingInputList = await prepareALTForwardingAutomation.getALTForwardingAutomationInputAsync( - logicalTerminationPointconfigurationStatus, - forwardingConstructConfigurationStatus + ltpConfigurationList ); if (applicationLayerTopologyForwardingInputList) { diff --git a/server/basicServices/basicServices/utility/LogicalTerminationPoint.js b/server/basicServices/basicServices/utility/LogicalTerminationPoint.js index ba24dec3..ceeda3e5 100644 --- a/server/basicServices/basicServices/utility/LogicalTerminationPoint.js +++ b/server/basicServices/basicServices/utility/LogicalTerminationPoint.js @@ -9,6 +9,7 @@ const LogicalTerminationPoint = require('onf-core-model-ap/applicationPattern/on const tcpClientInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/TcpClientInterface'); const httpClientInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/HttpClientInterface'); const httpServerInterface = require('onf-core-model-ap/applicationPattern/onfModel/models/layerProtocols/HttpServerInterface'); +const ControlConstruct = require('onf-core-model-ap/applicationPattern/onfModel/models/ControlConstruct'); exports.resolveHttpTcpAndOperationClientUuidOfNewRelease = function () { return new Promise(async function (resolve, reject) { @@ -24,7 +25,10 @@ exports.resolveHttpTcpAndOperationClientUuidOfNewRelease = function () { let operationClientUuid = fcPortOutput[onfAttributes.FC_PORT.LOGICAL_TERMINATION_POINT]; let httpClientUuid = (await LogicalTerminationPoint.getServerLtpListAsync(operationClientUuid))[0]; let tcpClientUuid = (await LogicalTerminationPoint.getServerLtpListAsync(httpClientUuid))[0]; - uuidOfHttpandTcpClient = { httpClientUuid, tcpClientUuid } + uuidOfHttpandTcpClient = { + httpClientUuid, + tcpClientUuid + } resolve(uuidOfHttpandTcpClient) } catch (error) { reject(error) @@ -33,17 +37,17 @@ exports.resolveHttpTcpAndOperationClientUuidOfNewRelease = function () { } /** -* @description This function returns list of registered application information application-name, release-number, -* address, protocol and port. -* @return {Promise} return the list of application information -* Procedure :
-* step 1 : Get forwarding-construct based on ForwardingName -* step 2 : Get forwarding-construct UUID -* step 3 : Get fc-port list using forwarding-construct UUID -* step 4 : Fetch http-client-list using logical-termination-point uuid from fc-port -* step 5 : get the application name, release number and server-ltp
-* step 6 : get the ipaddress, port and protocol name of each associated tcp-client
-**/ + * @description This function returns list of registered application information application-name, release-number, + * address, protocol and port. + * @return {Promise} return the list of application information + * Procedure :
+ * step 1 : Get forwarding-construct based on ForwardingName + * step 2 : Get forwarding-construct UUID + * step 3 : Get fc-port list using forwarding-construct UUID + * step 4 : Fetch http-client-list using logical-termination-point uuid from fc-port + * step 5 : get the application name, release number and server-ltp
+ * step 6 : get the ipaddress, port and protocol name of each associated tcp-client
+ **/ exports.getAllApplicationList = async function (forwardingName) { let clientApplicationList = []; @@ -78,6 +82,77 @@ exports.getAllApplicationList = async function (forwardingName) { return clientApplicationList; } +/** + * Resolves undelying client stack from forwarding name. + * @param {String} forwardingName + * @returns {Promise} clientStack + */ +exports.resolveClientUuidStackFromForwardingAsync = async function (forwardingName) { + let clientStack = {}; + let forwardingConstruct = await ForwardingDomain.getForwardingConstructForTheForwardingNameAsync(forwardingName); + if (forwardingConstruct === undefined) { + return undefined; + } + let fcPortList = forwardingConstruct[onfAttributes.FORWARDING_CONSTRUCT.FC_PORT]; + let outputFcPort = fcPortList.find(fcPort => + FcPort.portDirectionEnum.OUTPUT === fcPort[onfAttributes.FC_PORT.PORT_DIRECTION] + ); + let operationClientUuid = outputFcPort[onfAttributes.FC_PORT.LOGICAL_TERMINATION_POINT]; + let operationClient = await ControlConstruct.getLogicalTerminationPointAsync(operationClientUuid); + clientStack.operationClientUuid = operationClient[onfAttributes.GLOBAL_CLASS.UUID]; + if (operationClient) { + let httpClientUuid = operationClient[onfAttributes.LOGICAL_TERMINATION_POINT.SERVER_LTP][0]; + let httpClient = await ControlConstruct.getLogicalTerminationPointAsync(httpClientUuid); + clientStack.httpClientUuid = httpClient[onfAttributes.GLOBAL_CLASS.UUID]; + if (httpClient) { + let tcpClientUuid = httpClient[onfAttributes.LOGICAL_TERMINATION_POINT.SERVER_LTP][0]; + let tcpClient = await ControlConstruct.getLogicalTerminationPointAsync(tcpClientUuid); + clientStack.tcpClientUuid = tcpClient[onfAttributes.GLOBAL_CLASS.UUID]; + } + } + return clientStack; +} + +/** + * Resolves undelying client stack from operation client. + * @param {String} operationClientUuid + * @returns {Promise} clientStack + */ +exports.resolveClientUuidStackForOperationClientAsync = async function (operationClientUuid) { + let clientStack = {}; + let operationClient = await ControlConstruct.getLogicalTerminationPointAsync(operationClientUuid); + clientStack.operationClientUuid = operationClient[onfAttributes.GLOBAL_CLASS.UUID]; + if (operationClient) { + let httpClientUuid = operationClient[onfAttributes.LOGICAL_TERMINATION_POINT.SERVER_LTP][0]; + let httpClient = await ControlConstruct.getLogicalTerminationPointAsync(httpClientUuid); + clientStack.httpClientUuid = httpClient[onfAttributes.GLOBAL_CLASS.UUID]; + if (httpClient) { + let tcpClientUuid = httpClient[onfAttributes.LOGICAL_TERMINATION_POINT.SERVER_LTP][0]; + let tcpClient = await ControlConstruct.getLogicalTerminationPointAsync(tcpClientUuid); + clientStack.tcpClientUuid = tcpClient[onfAttributes.GLOBAL_CLASS.UUID]; + } + } + return clientStack; +} + +/** + * Resolves operationClientUuid of Invariant forwardingConstruct. + * @param {String} forwardingName + * @returns {Promise} application name + */ +exports.resolveOperationClientUuidFromForwardingAsync = async function (forwardingName) { + let operationClientUuid; + let forwardingConstruct = await ForwardingDomain.getForwardingConstructForTheForwardingNameAsync(forwardingName); + if (forwardingConstruct != undefined) { + let fcPortList = forwardingConstruct[onfAttributes.FORWARDING_CONSTRUCT.FC_PORT]; + let outputFcPort = fcPortList.find(fcPort => + FcPort.portDirectionEnum.OUTPUT === fcPort[onfAttributes.FC_PORT.PORT_DIRECTION] + ); + operationClientUuid = outputFcPort[onfAttributes.FC_PORT.LOGICAL_TERMINATION_POINT]; + } + return operationClientUuid; +} + /** * Resolves application name from forwarding name. * @param {String} forwardingName @@ -114,8 +189,8 @@ exports.resolveApplicationNameAndReleaseNumberFromForwardingAsync = async functi let applicationName = await httpClientInterface.getApplicationNameAsync(httpLtpUuidList[0]); let releaseNumber = await httpClientInterface.getReleaseNumberAsync(httpLtpUuidList[0]); let result = { - "applicationName" : applicationName, - "releaseNumber" : releaseNumber + "applicationName": applicationName, + "releaseNumber": releaseNumber }; return result; } diff --git a/server/basicServices/package.json b/server/basicServices/package.json index 756a739a..da33e5dd 100644 --- a/server/basicServices/package.json +++ b/server/basicServices/package.json @@ -1,6 +1,6 @@ { "name": "onf-core-model-ap-bs", - "version": "2.1.1-alpha.3", + "version": "2.1.1-alpha.7", "description": "onf core model application pattern", "main": "index.js", "scripts": { @@ -14,7 +14,7 @@ "js-yaml": "^3.3.0", "moment": "^2.29.1", "node-statsd": "^0.1.1", - "onf-core-model-ap": "2.1.1-alpha.3", + "onf-core-model-ap": "2.1.1-alpha.7", "openbackhaul-oas3-tools": "2.3.1-alpha.3", "randexp": "^0.5.3", "response-time": "^2.3.2"