summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/factories
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/factories')
-rw-r--r--vid-webpack-master/src/app/factories/models/requestDetails.model.ts126
-rw-r--r--vid-webpack-master/src/app/factories/mso.factory.spec.ts319
-rw-r--r--vid-webpack-master/src/app/factories/mso.factory.ts92
3 files changed, 537 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/factories/models/requestDetails.model.ts b/vid-webpack-master/src/app/factories/models/requestDetails.model.ts
new file mode 100644
index 000000000..4ccc4781b
--- /dev/null
+++ b/vid-webpack-master/src/app/factories/models/requestDetails.model.ts
@@ -0,0 +1,126 @@
+export class RequestInfo {
+ instanceName: string;
+ source: string;
+ suppressRollback: boolean;
+ requestorId: string;
+ productFamilyId: string;
+}
+
+export class ModelInfo {
+ modelType: string;
+ modelInvariantId: string;
+ modelVersionId: string;
+ modelName: string;
+ modelVersion: string;
+ modelCustomizationId: string;
+ modelCustomizationName: string;
+}
+
+export class RequestParameters {
+ userParams: any[];
+ testApi: string;
+}
+
+export class CloudConfiguration {
+ lcpCloudRegionId: string;
+ tenantId: string;
+}
+
+export class LineOfBusiness {
+ lineOfBusinessName: string;
+}
+
+export class Platform {
+ platformName: string;
+}
+
+export class VfcModel {
+ uuid: string;
+ invariantUuid: string;
+ name: string;
+ version: string;
+ vfcInstanceGroupProperties : any;
+}
+
+export class RelatedInstance {
+ instanceId: string;
+ modelInfo: ModelInfo;
+}
+
+export class RelatedInstanceList {
+ relatedInstance: RelatedInstance;
+}
+
+export class RequestDetails {
+ requestInfo: RequestInfo;
+ modelInfo: ModelInfo;
+ requestParameters: RequestParameters;
+ cloudConfiguration: CloudConfiguration;
+ lineOfBusiness: LineOfBusiness;
+ platform: Platform;
+ relatedInstanceList: RelatedInstanceList[];
+}
+
+export class RootObject {
+ requestDetails: RequestDetails;
+}
+// {
+// "requestDetails": {
+// "modelInfo": {
+// “modelType”: “vnf”,
+// “modelInvariantId”: “ff5256d1-5a33-55df-13ab-12abad84e7ff”,
+// “modelVersionId”: “fe042c22-ba82-43c6-b2f6-8f1fc4164091”,
+// “modelName”: “vSAMP12”,
+// "modelVersion": "1.0",
+// “modelCustomizationName”: “vSAMP12 1”,
+// “modelCustomizationId”: “a7f1d08e-b02d-11e6-80f5-76304dec7eb7”
+// },
+// “cloudConfiguration”: {
+// “lcpCloudRegionId”: “mdt1”,
+// “tenantId”: “88a6ca3ee0394ade9403f075db23167e”
+// },
+// "requestInfo": {
+// “instanceName”: “MSOTEST103a”,
+// “productFamilyId”: “a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb”,
+// “source”: “VID”,
+// “suppressRollback”: false,
+// “requestorId”: “az2016”
+// },
+// "platform": {
+// "platformName": "{some platformName}"
+// },
+// "lineOfBusiness": {
+// "lineOfBusinessName": "{some string}"
+// },
+// "relatedInstanceList": [
+// {
+// “relatedInstance”: {
+// “instanceId”: “{serviceInstanceId}”,
+// “modelInfo”: {
+// “modelType”: “service”,
+// “modelInvariantId”: “ff3514e3-5a33-55df-13ab-12abad84e7ff”,
+// “modelVersionId”: “fe6985cd-ea33-3346-ac12-ab121484a3fe”,
+// “modelName”: “{parent service model name}”,
+// "modelVersion": "1.0"
+// }
+// }
+// },
+// {
+// “relatedInstance”: {
+// “instanceId”: “{instanceGroupId}”,
+// “modelInfo”: {
+// “modelType”: “networkCollection”,
+// “modelInvariantId”: “9ea660dc-155f-44d3-b45c-cc7648b4f31c”,
+// “modelVersionId”: “bb07aad1-ce2d-40c1-85cb-5392f76bb1ef”,
+// “modelName”: “{network collection model name}”,
+// "modelVersion": "1.0"
+// }
+// }
+// }
+
+// ],
+// “requestParameters”: {
+// “userParams”: []
+// }
+// }
+// }
diff --git a/vid-webpack-master/src/app/factories/mso.factory.spec.ts b/vid-webpack-master/src/app/factories/mso.factory.spec.ts
new file mode 100644
index 000000000..16efd2970
--- /dev/null
+++ b/vid-webpack-master/src/app/factories/mso.factory.spec.ts
@@ -0,0 +1,319 @@
+import {createRequest} from './mso.factory';
+
+sessionStorage.setItem("msoRequestParametersTestApiValue","GR_API");
+describe('Vlantagging', () => {
+ it('should create a correct request', (done: DoneFn) => {
+ let userInputs_withEcompGeneratedNaming = {
+ "productFamily": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpRegion": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "aicZone": "YYY1",
+ "platformName": "plat1",
+ "lineOfBusiness": "ecomp"
+ };
+ let userInputs_withoutEcompGeneratedNaming = {
+ "instanceName": "New Name",
+ "productFamily": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "lcpRegion": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
+ "aicZone": "YYY1",
+ "platformName": "plat1",
+ "lineOfBusiness": "ecomp"
+ };
+ let service = {
+ "service": {
+ "uuid": "6bce7302-70bd-4057-b48e-8d5b99e686ca",
+ "invariantUuid": "9aa04749-c02c-432d-a90c-18caa361c833",
+ "name": "vDBE_srv",
+ "version": "1.0",
+ "toscaModelURL": null,
+ "category": "Network L4+",
+ "serviceType": "",
+ "serviceRole": "",
+ "description": "vDBE_srv",
+ "serviceEcompNaming": "true",
+ "instantiationType": "A-La-Carte",
+ "inputs": {}
+ },
+ "vnfs": {
+ "vDBE 0": {
+ "uuid": "61535073-2e50-4141-9000-f66fea69b433",
+ "invariantUuid": "fcdf49ce-6f0b-4ca2-b676-a484e650e734",
+ "description": "vDBE",
+ "name": "vDBE",
+ "version": "0.2",
+ "customizationUuid": "1",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "nf_naming": "{ecomp_generated_naming=true}",
+ "multi_stage_design": "false",
+ "oam_vfc_instance_group_function": "oambbb",
+ "availability_zone_max_count": "1",
+ "oam_network_collection_function": "oamaaa",
+ "ecomp_generated_naming": "true",
+ "untr_vfc_instance_group_function": "untrbbb",
+ "untr_network_collection_function": "untraaa"
+ },
+ "type": "VF",
+ "modelCustomizationName": "vDBE 0",
+ "vfModules": {
+ "vdbe0..Vdbe..main..module-0": {
+ "uuid": "25a4d009-2f5a-44b4-b02a-62c584c15912",
+ "invariantUuid": "614afb1a-3e7e-44e9-90ab-424d0070c781",
+ "customizationUuid": "3443b341-7b0b-498c-a84a-a7ee736cba7e",
+ "description": null,
+ "name": "Vdbe..main..module-0",
+ "version": "1",
+ "modelCustomizationName": "Vdbe..main..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": "main"
+ },
+ "inputs": {},
+ "volumeGroupAllowed": false
+ }
+ },
+ "volumeGroups": {},
+ "vfcInstanceGroups": {
+ "untr_group": {
+ "uuid": "5fca04e2-a889-4579-8338-f60f1bf285fa",
+ "invariantUuid": "fb1e384b-117a-46ae-9ad1-bf2f1ee1e49f",
+ "name": "untr_group",
+ "version": "1",
+ "vfcInstanceGroupProperties": {
+ "vfcParentPortRole": "untr",
+ "networkCollectionFunction": "untraaa",
+ "vfcInstanceGroupFunction": null,
+ "subinterfaceRole": "untr"
+ }
+ },
+ "oam_group": {
+ "uuid": "a0efd5fc-f7be-4502-936a-a6c6392b958f",
+ "invariantUuid": "9384abf9-1231-4da4-bd8d-89e4d2f8a749",
+ "name": "oam_group",
+ "version": "1",
+ "vfcInstanceGroupProperties": {
+ "vfcParentPortRole": "untr",
+ "networkCollectionFunction": "untraaa",
+ "vfcInstanceGroupFunction": null,
+ "subinterfaceRole": "untr"
+ }
+ }
+ }
+ }
+ },
+ "networks": {},
+ "collectionResource": {},
+ "configurations": {},
+ "serviceProxies": {},
+ "vfModules": {
+ "vdbe0..Vdbe..main..module-0": {
+ "uuid": "25a4d009-2f5a-44b4-b02a-62c584c15912",
+ "invariantUuid": "614afb1a-3e7e-44e9-90ab-424d0070c781",
+ "customizationUuid": "3443b341-7b0b-498c-a84a-a7ee736cba7e",
+ "description": null,
+ "name": "Vdbe..main..module-0",
+ "version": "1",
+ "modelCustomizationName": "Vdbe..main..module-0",
+ "properties": {
+ "minCountInstances": 1,
+ "maxCountInstances": 1,
+ "initialCount": 1,
+ "vfModuleLabel": "main"
+ },
+ "inputs": {},
+ "volumeGroupAllowed": false
+ }
+ },
+ "volumeGroups": {},
+ "pnfs": {}
+ };
+ let serviceInstanceId: string = "6bce7302-70bd-4057-b48e-8d5b99e686ca";
+ let networkInstanceGroups = {
+ "untr_group": {
+ "instance-group": {
+ "instance-group-role": "JZmha7QSS4tJ",
+ "model-invariant-id": "model-id3",
+ "model-version-id": "a0efd5fc-f7be-4502-936a-a6c6392b958f",
+ "id": "AAI-12002-test3-vm230w",
+ "description": "a9DEa0kpY",
+ "instance-group-type": "type",
+ "resource-version": "1520888659539",
+ "instance-group-name": "wKmBXiO1xm8bK",
+ "instance-group-function": "testfunction2",
+ "relationship-list": {
+ "relationship": [
+ {
+ "relationDataList": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "AAI-12002-vm230w"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "AAI-region-vm230w"
+ }
+ ],
+ "relatedToPropertyList": [
+ {
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": null
+ }
+ ],
+ "related-to": "cloud-region",
+ "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "AAI-12002-vm230w"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "AAI-region-vm230w"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": null
+ }
+ ]
+ }
+ ]
+ }
+ }
+ },
+ "oam_group": {
+ "instance-group": {
+ "instance-group-role": "JZmha7QSS4tJ",
+ "model-invariant-id": "model-id3",
+ "model-version-id": "a0efd5fc-f7be-4502-936a-a6c6392b958f",
+ "id": "AAI-12002-test3-vm230w",
+ "description": "a9DEa0kpY",
+ "instance-group-type": "type",
+ "resource-version": "1520888659539",
+ "instance-group-name": "wKmBXiO1xm8bK",
+ "instance-group-function": "testfunction2",
+ "relationship-list": {
+ "relationship": [
+ {
+ "relationDataList": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "AAI-12002-vm230w"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "AAI-region-vm230w"
+ }
+ ],
+ "relatedToPropertyList": [
+ {
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": null
+ }
+ ],
+ "related-to": "cloud-region",
+ "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/AAI-12002-vm230w/AAI-region-vm230w",
+ "relationship-label": "org.onap.relationships.inventory.Uses",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "AAI-12002-vm230w"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "AAI-region-vm230w"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "cloud-region.owner-defined-type",
+ "property-value": null
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ };
+ let expectedResult = {
+ "requestInfo": {
+ "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
+ "source": "VID",
+ "requestorId": "az2016",
+ "suppressRollback": false
+ },
+ "lineOfBusiness": Object({ lineOfBusinessName: "ecomp" }),
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "AAIAIC25",
+ "tenantId": "092eb9e8e4b7412e8787dd091bc58e86"
+ },
+ "platform": Object({ platformName: "plat1" }),
+ "modelInfo": {
+ modelCustomizationId :'1',
+ "modelVersionId": "61535073-2e50-4141-9000-f66fea69b433",
+ "modelCustomizationName": "vDBE 0",
+ "modelName": "vDBE",
+ "modelInvariantId": "fcdf49ce-6f0b-4ca2-b676-a484e650e734",
+ "modelType": "vnf",
+ "modelVersion": "0.2"
+ },
+ "requestParameters": {
+ "userParams": [],
+ "testApi": "GR_API"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "6bce7302-70bd-4057-b48e-8d5b99e686ca",
+ "modelInfo": {
+ "modelVersionId": "6bce7302-70bd-4057-b48e-8d5b99e686ca",
+ "modelName": "vDBE_srv",
+ "modelInvariantId": "9aa04749-c02c-432d-a90c-18caa361c833",
+ "modelType": "service",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "AAI-12002-test3-vm230w",
+ "modelInfo": {
+ "modelName": "oam_group",
+ "modelType": "networkCollection",
+ "modelVersion": "1",
+ "modelVersionId": "a0efd5fc-f7be-4502-936a-a6c6392b958f",
+ "modelInvariantId": "9384abf9-1231-4da4-bd8d-89e4d2f8a749"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "AAI-12002-test3-vm230w",
+ "modelInfo": {
+ "modelName": "oam_group",
+ "modelType": "networkCollection",
+ "modelVersion": "1",
+ "modelVersionId": "a0efd5fc-f7be-4502-936a-a6c6392b958f",
+ "modelInvariantId": "9384abf9-1231-4da4-bd8d-89e4d2f8a749"
+ }
+ }
+ }
+ ]
+ };
+
+
+ let actualResult_withEcompGeneratedNaming = <any>createRequest("az2016",userInputs_withEcompGeneratedNaming, service, serviceInstanceId, networkInstanceGroups,'vDBE 0','1');
+ expect(actualResult_withEcompGeneratedNaming).toEqual(expectedResult);
+ expectedResult["requestInfo"]["instanceName"] = "New Name";
+ let actualResult_withoutEcompGeneratedNaming = <any>createRequest("az2016",userInputs_withoutEcompGeneratedNaming, service, serviceInstanceId, networkInstanceGroups,'vDBE 0','1');
+ expect(actualResult_withoutEcompGeneratedNaming).toEqual(expectedResult);
+ done();
+ });
+});
diff --git a/vid-webpack-master/src/app/factories/mso.factory.ts b/vid-webpack-master/src/app/factories/mso.factory.ts
new file mode 100644
index 000000000..c26296edf
--- /dev/null
+++ b/vid-webpack-master/src/app/factories/mso.factory.ts
@@ -0,0 +1,92 @@
+import { RequestInfo, RequestDetails, ModelInfo, CloudConfiguration, LineOfBusiness, Platform, RelatedInstanceList, VfcModel } from "./models/requestDetails.model";
+import * as _ from "lodash";
+
+function extractModelInfoFromNodeTemplate(node: any, type: string) {
+ let modelInfo: ModelInfo = <ModelInfo>{};
+ if (node["customizationUuid"] !== undefined) {
+ modelInfo.modelCustomizationId = node["customizationUuid"];
+ }
+ if (node["modelCustomizationName"] !== undefined) {
+ modelInfo.modelCustomizationName = node["modelCustomizationName"];
+ }
+ modelInfo.modelVersionId = node["uuid"];
+ modelInfo.modelName = node["name"];
+ modelInfo.modelInvariantId = node["invariantUuid"];
+ modelInfo.modelType = type;
+ modelInfo.modelVersion = node["version"];
+ return modelInfo;
+}
+
+function extractRequestInfo(userInputs: any, userId: string): RequestInfo {
+ let requestInfo: RequestInfo = <RequestInfo>{};
+ if (userInputs["instanceName"] !== undefined) requestInfo.instanceName = userInputs["instanceName"];
+ requestInfo.productFamilyId = userInputs["productFamily"];
+ requestInfo.source = "VID";
+ requestInfo.suppressRollback = userInputs["rollback"] === "false";
+ requestInfo.requestorId = userId;
+ return requestInfo;
+}
+
+function extractPlatform(userInputs: any): Platform {
+ let platform: Platform = <Platform>{};
+ platform.platformName = userInputs["platformName"];
+ return platform;
+}
+
+function extractVfcGroupModelAccordingToUuid(vnfModel: any, vfcUuid: string) {
+ return _.find(vnfModel.vfcInstanceGroups, { uuid: vfcUuid });
+}
+
+function extractLineOfBusiness(userInputs: any) {
+ let lob: LineOfBusiness = <LineOfBusiness>{};
+ lob.lineOfBusinessName = userInputs["lineOfBusiness"];
+ return lob;
+}
+
+function extractCloudConfiguration(userInputs: any) {
+ let cloudConfig: CloudConfiguration = <CloudConfiguration>{};
+ cloudConfig.lcpCloudRegionId = userInputs["lcpRegion"];
+ cloudConfig.tenantId = userInputs["tenantId"];
+ return cloudConfig;
+}
+
+function extractModelInfoFromVfcNode(vfcModel: VfcModel): ModelInfo {
+ let modelinfo: ModelInfo = <ModelInfo>{};
+ modelinfo.modelName = vfcModel.name;
+ modelinfo.modelType = "networkCollection";
+ modelinfo.modelVersion = vfcModel.version;
+ modelinfo.modelVersionId = vfcModel.uuid;
+ modelinfo.modelInvariantId = vfcModel.invariantUuid;
+ return modelinfo;
+}
+
+export function createRequest(userId: string, userInputs: any, service: any, serviceInstanceId: string, networkInstanceGroups: any, vnfCustomizationName: string, vnfCustomizationId: string) {
+ let request: RequestDetails = <RequestDetails>{};
+ request.requestInfo = extractRequestInfo(userInputs, userId);
+ request.lineOfBusiness = extractLineOfBusiness(userInputs);
+ request.cloudConfiguration = extractCloudConfiguration(userInputs);
+ request.platform = extractPlatform(userInputs);
+ request.modelInfo = extractModelInfoFromNodeTemplate(service.vnfs[vnfCustomizationName], "vnf");
+ request.requestParameters = { userParams: [], testApi: sessionStorage.getItem("msoRequestParametersTestApiValue")};
+ request.relatedInstanceList = [];
+ let serviceRelatedInstance: RelatedInstanceList = {
+ relatedInstance: {
+ instanceId: serviceInstanceId,
+ modelInfo: extractModelInfoFromNodeTemplate(service.service, "service")
+ }
+ };
+ request.relatedInstanceList.push(serviceRelatedInstance);
+ _.forOwn(networkInstanceGroups, function(group) {
+ let modelUuid = group["instance-group"]["model-version-id"];
+ let vfcModel = extractVfcGroupModelAccordingToUuid(service.vnfs[vnfCustomizationName], modelUuid);
+ let networkInstanceGroup: RelatedInstanceList = {
+ relatedInstance: {
+ instanceId: group["instance-group"].id,
+ modelInfo: extractModelInfoFromVfcNode(vfcModel)
+ }
+ };
+ request.relatedInstanceList.push(networkInstanceGroup);
+ });
+
+ return request;
+}