diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/services')
19 files changed, 2830 insertions, 52 deletions
diff --git a/vid-webpack-master/src/app/shared/services/aaiService/aai.actions.ts b/vid-webpack-master/src/app/shared/services/aaiService/aai.actions.ts new file mode 100644 index 000000000..dc234bd61 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/aai.actions.ts @@ -0,0 +1,77 @@ +import {Action, ActionCreator} from "redux"; + +export const LOAD_PRODUCT_FAMILIES = '[PRODUCT_FAMILIES] Load'; + +export const LOAD_LCP_TENANT = '[LCP_TENANT] Load'; + +export const LOAD_AIC_ZONES = '[AIC_ZONES] Load'; + +export const LOAD_CATEGORY_PARAMETERS = '[LOAD_CATEGORY_PARAMETERS] Load'; + +export const LOAD_SERVICE_MDOEL_BY_UUID = '[LOAD_SERVICE_MDOEL_BY_UUID] Load'; + +export const LOAD_NETWORK_ACCORDING_TO_NF = '[LOAD_NETWORK_ACCORDING_TO_NF] Load' + +export const LOAD_USER_ID = '[LOAD_USER_ID] Load' + + +export interface LoadProductFamiliesAction extends Action {} + +interface LoadLcpTenant extends Action {} + +interface LoadAicZones extends Action {} + +interface LoadCategoryParameters extends Action {} + +interface LoadServiceModelByUuid extends Action {} + +interface LoadNetworkAccordingToNetworkCF extends Action{} + +interface LoadUserId extends Action{} + + +export const loadServiceAccordingToUuid : ActionCreator<LoadServiceModelByUuid> = + (uuid : string) =>({ + type : LOAD_SERVICE_MDOEL_BY_UUID, + modelId : uuid + }) + + +export const loadProductFamiliesAction: ActionCreator<LoadProductFamiliesAction> = + () => ({ + type: LOAD_PRODUCT_FAMILIES, + }); + + +export const loadUserId: ActionCreator<LoadUserId> = +() => ({ + type: LOAD_USER_ID, +}); + + + export const loadLcpTenant: ActionCreator<LoadLcpTenant> = + (subscriberId : string, serviceType : string) => ({ + type: LOAD_LCP_TENANT, + subscriberId : subscriberId, + serviceType : serviceType + }); + + +export const loadAicZones: ActionCreator<LoadAicZones> = + () => ({ + type: LOAD_AIC_ZONES, + }); + +export const loadCategoryParameters: ActionCreator<LoadCategoryParameters> = + () => ({ + type: LOAD_CATEGORY_PARAMETERS, + }); + + +export const loadAaiNetworkAccordingToNetworkCF: ActionCreator<LoadNetworkAccordingToNetworkCF> = + (networkFunction,cloudOwner,cloudRegionId) => ({ + type: LOAD_NETWORK_ACCORDING_TO_NF, + networkFunctions: networkFunction, + cloudOwner: cloudOwner, + cloudRegionId: cloudRegionId + }); diff --git a/vid-webpack-master/src/app/shared/services/aaiService/aai.epics.ts b/vid-webpack-master/src/app/shared/services/aaiService/aai.epics.ts new file mode 100644 index 000000000..a850d55da --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/aai.epics.ts @@ -0,0 +1,81 @@ +import {Injectable} from '@angular/core'; +import {combineEpics, createEpicMiddleware, ofType} from 'redux-observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/startWith'; +import { + LOAD_PRODUCT_FAMILIES, + LOAD_LCP_TENANT, + LOAD_AIC_ZONES, + LOAD_CATEGORY_PARAMETERS, + LOAD_SERVICE_MDOEL_BY_UUID, + LOAD_NETWORK_ACCORDING_TO_NF, + LOAD_USER_ID +} from "./aai.actions"; +import {AaiService} from "./aai.service"; +import {AppState} from "../../store/reducers"; +import { + updateAicZones, updateCategoryParameters, + updateLcpRegionsAndTenants, + updateNetworkCollectionFunction, + updateProductFamilies, updateUserId +} from "../../storeUtil/utils/general/general.actions"; +import {createServiceInstance} from "../../storeUtil/utils/service/service.actions"; +import {delay, mapTo} from "rxjs/operators"; + +const notFetchedAlready = (state: AppState): boolean => state.service.productFamilies !== null; + +@Injectable() +export class AAIEpics { + constructor(private aaiService: AaiService) { + } + + public createEpic() { + return combineEpics( + this.loadProductFamiliesEpic + , this.loadLcpTenants + , this.loadAicZones + , this.loadCategoryParameters + , this.loadServiceAccordingToUuid + , this.loadNetworkAccordingToNetworkFunction + , this.loadUserId) + } + + private loadLcpTenants = (action$, store) => + action$.ofType(LOAD_LCP_TENANT) + .switchMap((action) => this.aaiService.getLcpRegionsAndTenants(action.subscriberId, action.serviceType) + .map(data => updateLcpRegionsAndTenants(data))); + + private loadProductFamiliesEpic = (action$, store) => action$ + .ofType(LOAD_PRODUCT_FAMILIES) + .switchMap(() => this.aaiService.getProductFamilies().map(data => updateProductFamilies(data))); + + private loadCategoryParameters = (action$, store) => action$ + .ofType(LOAD_CATEGORY_PARAMETERS) + .switchMap(() => this.aaiService.getCategoryParameters(null).map(data => updateCategoryParameters(data))); + + + private loadNetworkAccordingToNetworkFunction = (action$, store) => action$ + .ofType(LOAD_NETWORK_ACCORDING_TO_NF) + .flatMap((action) => this.aaiService.getCRAccordingToNetworkFunctionId(action.networkFunctions, action.cloudOwner, action.cloudRegionId).map((res) => + updateNetworkCollectionFunction(action.networkFunctions, res))); + + private loadServiceAccordingToUuid = (action$, store) => action$ + .ofType(LOAD_SERVICE_MDOEL_BY_UUID) + .switchMap((action) => this.aaiService.getServiceModelById(action.modelId) + .map(data => createServiceInstance(action.uuid, data))); + + private loadUserId = (action$, store) => action$ + .ofType(LOAD_USER_ID) + .switchMap(() => this.aaiService.getUserId() + .map(res => updateUserId(res))); + + + private loadAicZones = (action$, store) => action$ + .ofType(LOAD_AIC_ZONES) + .switchMap(() => this.aaiService.getAicZones().map(data => updateAicZones(data))); + // .catch(response => of(this.actions.loadFailed(status))) + // .startWith(this.actions.loadStarted())); + +} diff --git a/vid-webpack-master/src/app/shared/services/aaiService/aai.service.spec.ts b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.spec.ts new file mode 100644 index 000000000..9f19f6259 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.spec.ts @@ -0,0 +1,497 @@ +import {ServiceInstance} from "../../models/serviceInstance"; +import {RootObject} from "./model/crawledAaiService"; +import {AaiService} from "./aai.service"; +import {instance, mock, when} from "ts-mockito"; +import {FeatureFlagsService, Features} from "../featureFlag/feature-flags.service"; +import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing"; +import {getTestBed, TestBed} from "@angular/core/testing"; +import {NgRedux} from "@angular-redux/store"; +import {Constants} from "../../utils/constants"; +import {AppState} from "../../store/reducers"; +import {setOptionalMembersVnfGroupInstance} from "../../storeUtil/utils/vnfGroup/vnfGroup.actions"; +import each from 'jest-each'; + +class MockAppStore<T> { + dispatch(){} + getState(){} +} + +describe("AaiService", () => { + + let injector; + let httpMock: HttpTestingController; + let aaiService: AaiService; + let mockFeatureFlagsService: FeatureFlagsService = mock(FeatureFlagsService); + let store : NgRedux<AppState>; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + AaiService, + {provide: NgRedux, useClass: MockAppStore}, + {provide: FeatureFlagsService, useValue: instance(mockFeatureFlagsService)} + ] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + httpMock = injector.get(HttpTestingController); + aaiService = injector.get(AaiService); + store = injector.get(NgRedux); + + })().then(done).catch(done.fail)); + + + + describe('#resolve tests', () => { + test('aai service resolve should return the right object', () => { + let serviceInstance = new ServiceInstance(); + aaiService.resolve(aaiServiceInstnace.root, serviceInstance); + + expectedResult.vnfs['DROR_vsp'].trackById = serviceInstance.vnfs['DROR_vsp'].trackById; + expect(JSON.parse(JSON.stringify(serviceInstance.vnfs))).toEqual(expectedResult.vnfs); + expect(JSON.parse(JSON.stringify(serviceInstance.networks))).toEqual(expectedResult.networks); + }); + }); + + describe('#serviceInstanceTopology tests', () => { + test('aai service get serviceInstanceTopolgetServiceInstanceTopologyResult.jsonogy from backend, and return ServiceInstance', () => { + + const mockedResult = getTopology(); + const serviceInstanceId: string = "id"; + const subscriberId: string = "fakeSunId"; + const serviceType: string = "justServiceType"; + aaiService.retrieveServiceInstanceTopology(serviceInstanceId, subscriberId, serviceType).subscribe((result: ServiceInstance) => { + expect(result.instanceName).toEqual("mCaNkinstancename"); + expect(result.modelInavariantId).toEqual("6b528779-44a3-4472-bdff-9cd15ec93450"); + expect(result.vnfs["2017-388_ADIOD-vPE 0"].instanceName).toEqual("2017388_ADIODvPEmCaNkinstanceName"); + expect(result.vnfs["2017-488_ADIOD-vPE 0"]. + vfModules["2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0"] + ["2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot"].instanceName + ).toEqual("VFinstancenameZERO"); + }); + + const req = httpMock.expectOne(`${Constants.Path.AAI_GET_SERVICE_INSTANCE_TOPOLOGY_PATH}${subscriberId}/${serviceType}/${serviceInstanceId}`); + expect(req.request.method).toEqual('GET'); + req.flush(mockedResult); + }); + }); + + + describe('#retrieveAndStoreServiceInstanceRetryTopology tests', () => { + test('aai service get retrieveAndStoreServiceInstanceRetryTopology.jsonogy from backend, and return ServiceInstance', () => { + + let mockedResult = getTopology(); + + const jobId: string = "jobId"; + aaiService.retrieveServiceInstanceRetryTopology(jobId).subscribe((result: ServiceInstance) => { + expect(result.instanceName).toEqual("mCaNkinstancename"); + expect(result.modelInavariantId).toEqual("6b528779-44a3-4472-bdff-9cd15ec93450"); + expect(result.vnfs["2017-388_ADIOD-vPE 0"].instanceName).toEqual("2017388_ADIODvPEmCaNkinstanceName"); + expect(result.vnfs["2017-488_ADIOD-vPE 0"]. + vfModules["2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0"] + ["2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot"].instanceName + ).toEqual("VFinstancenameZERO"); + }); + + const req = httpMock.expectOne(`${Constants.Path.SERVICES_RETRY_TOPOLOGY}/${jobId}`); + expect(req.request.method).toEqual('GET'); + req.flush(mockedResult); + }); + }); + + describe('# get optional group members tests', () =>{ + test('aai service get getOptionalGroupMembers and return list of VnfMember', () => { + jest.spyOn(store, 'dispatch'); + jest.spyOn(store, 'getState').mockReturnValue({ + service :{ + serviceInstance : { + "serviceModelId" : { + optionalGroupMembersMap : {} + } + } + } + }); + const mockedResult = getMockMembers(); + const serviceInvariantId: string = "serviceInvariantId"; + const subscriberId: string = "subscriberId"; + const serviceType: string = "serviceType"; + const groupType: string = "groupType"; + const groupRole: string = "groupRole"; + const serviceModelId: string = "serviceModelId"; + aaiService.getOptionalGroupMembers(serviceModelId, subscriberId, serviceType, serviceInvariantId, groupType, groupRole).subscribe((res)=>{ + const path = `${Constants.Path.AAI_GET_SERVICE_GROUP_MEMBERS_PATH}${subscriberId}/${serviceType}/${serviceInvariantId}/${groupType}/${groupRole}`; + expect(store.dispatch).toHaveBeenCalledWith(setOptionalMembersVnfGroupInstance(serviceModelId, path, res)); + expect(res.length).toEqual(2); + }); + + + const req = httpMock.expectOne(`${Constants.Path.AAI_GET_SERVICE_GROUP_MEMBERS_PATH}${subscriberId}/${serviceType}/${serviceInvariantId}/${groupType}/${groupRole}`); + expect(req.request.method).toEqual('GET'); + req.flush(mockedResult); + }); + }); + describe('#cloud owner tests', () => { + let featureFlagToLcpRegionName = [ + ['aai service extract lcpRegion, flag is true=> lcp region include cloud owner', true, 'id (OWNER)' ], + ['aai service extract lcpRegion, flag is false=> lcp region doesnt include cloud owner', false, 'id'] + ]; + + each(featureFlagToLcpRegionName).test("%s", (desc: string, flag: boolean, expectedName: string ) => { + when(mockFeatureFlagsService.getFlagState(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).thenReturn(flag); + let name: string = aaiService.extractLcpRegionName("id", "att-owner"); + expect(name).toEqual(expectedName); + }); + + let cloudOwnerFormattingDataProvider = [ + ['classic cloud owner', 'irma-aic', ' (AIC)'], + ['upper case cloud owner', 'IRMA-AIC', ' (AIC)'], + ['no att cloud owner', 'nc', ' (NC)'], + ]; + + each(cloudOwnerFormattingDataProvider).test('test cloudOwner trailer formatting %s', (desc: string, cloudOwner: string, expectedTrailer: string) => { + expect(AaiService.formatCloudOwnerTrailer(cloudOwner)).toEqual(expectedTrailer); + }); + }); + + function getTopology() { + return { + "vnfs": { + "2017-388_ADIOD-vPE 0": { + "vfModules": {}, + "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "JANET25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168", + "modelName": "2017-388_ADIOD-vPE", + "modelVersion": "4.0", + "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c", + "modelCustomizationName": "2017-388_ADIOD-vPE 0", + "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168" + }, + "instanceName": "2017388_ADIODvPEmCaNkinstanceName", + "legacyRegion": "some legacy region" + }, + "2017-488_ADIOD-vPE 0": { + "vfModules": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": { + "instanceName": "VFinstancenameZERO", + "modelInfo": { + "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", + "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "modelVersion": "5", + "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + }, + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "provStatus": "Prov Status", + "orchStatus": "Active", + "inMaint": true + } + }, + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": { + "instanceName": "VFinstancename", + "volumeGroupName": "VFinstancename_vol_abc", + "orchStatus": "Create", + "provStatus": "Prov Status", + "inMaint": false, + "modelInfo": { + "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", + "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5", + "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "modelVersion": "6", + "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + }, + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + } + } + }, + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "JANET25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "5.0", + "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", + "modelCustomizationName": "2017-488_ADIOD-vPE 0", + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" + }, + "orchStatus": "Created", + "inMaint": false, + "instanceName": "2017488_ADIODvPEVNFinstancename", + "legacyRegion": "some legacy region" + }, + "2017-488_ADIOD-vPE 0:0001": { + "vfModules": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": { + "instanceName": "VFinstancenameZERO_001", + "provStatus": "Prov Status", + "inMaint": true, + "modelInfo": { + "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", + "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "modelVersion": "5", + "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + }, + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + } + }, + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": { + "instanceName": "VFinstancename_001", + "volumeGroupName": "VFinstancename_vol_abc_001", + "modelInfo": { + "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", + "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5", + "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "modelVersion": "6", + "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + }, + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + } + } + }, + + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "JANET25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "5.0", + "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", + "modelCustomizationName": "2017-488_ADIOD-vPE 0", + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" + }, + "instanceName": "2017488_ADIODvPEVNFinstancename_001", + "legacyRegion": "some legacy region" + }, + "2017-488_ADIOD-vPE 0:0002": { + "vfModules": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": { + "instanceName": "VFinstancenameZERO_002", + "modelInfo": { + "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", + "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "modelVersion": "5", + "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + }, + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + } + }, + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": { + "instanceName": "VFinstancename_002", + "volumeGroupName": "VFinstancename_vol_abc_002", + "modelInfo": { + "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", + "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5", + "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "modelVersion": "6", + "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + }, + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + } + } + }, + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "JANET25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "5.0", + "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", + "modelCustomizationName": "2017-488_ADIOD-vPE 0", + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" + }, + "instanceName": "2017488_ADIODvPEVNFinstancename_002", + "legacyRegion": "some legacy region" + } + }, + "vnfGroups": {}, + "existingVnfGroupCounterMap": {}, + "validationCounter": 0, + "existingVNFCounterMap": { + "afacccf6-397d-45d6-b5ae-94c39734b168": 1, + "69e09f68-8b63-4cc9-b9ff-860960b5db09": 3 + }, + "existingNetworksCounterMap": {}, + "instanceName": "mCaNkinstancename", + "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89", + "subscriptionServiceType": "TYLER SILVIA", + "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "hvf6", + "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054", + "aicZoneId": "NFT1", + "projectName": "WATKINS", + "rollbackOnFailure": "true", + "aicZoneName": "NFTJSSSS-NFT1", + "owningEntityName": "WayneHolland", + "tenantName": "AIN Web Tool-15-D-testalexandria", + "modelInfo": { + "modelInvariantId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "modelVersionId": "6b528779-44a3-4472-bdff-9cd15ec93450", + "modelName": "action-data", + "modelVersion": "1.0", + "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450" + }, + "isALaCarte": false, + "orchStatus": "Active", + "modelInavariantId": "6b528779-44a3-4472-bdff-9cd15ec93450" + } + } + + const getMockMembers = (): any[] => { + return [ + { + "action":"None", + "instanceName":"VNF1_INSTANCE_NAME", + "instanceId":"VNF1_INSTANCE_ID", + "orchStatus":null, + "productFamilyId":null, + "lcpCloudRegionId":null, + "tenantId":null, + "modelInfo":{ + "modelInvariantId":"vnf-instance-model-invariant-id", + "modelVersionId":"7a6ee536-f052-46fa-aa7e-2fca9d674c44", + "modelVersion":"2.0", + "modelName":"vf_vEPDG", + "modelType":"vnf" + }, + "instanceType":"VNF1_INSTANCE_TYPE", + "provStatus":null, + "inMaint":false, + "uuid":"7a6ee536-f052-46fa-aa7e-2fca9d674c44", + "originalName":null, + "legacyRegion":null, + "lineOfBusiness":null, + "platformName":null, + "trackById":"7a6ee536-f052-46fa-aa7e-2fca9d674c44:002", + "serviceInstanceId":"service-instance-id1", + "serviceInstanceName":"service-instance-name" + }, + { + "action":"None", + "instanceName":"VNF2_INSTANCE_NAME", + "instanceId":"VNF2_INSTANCE_ID", + "orchStatus":null, + "productFamilyId":null, + "lcpCloudRegionId":null, + "tenantId":null, + "modelInfo":{ + "modelInvariantId":"vnf-instance-model-invariant-id", + "modelVersionId":"eb5f56bf-5855-4e61-bd00-3e19a953bf02", + "modelVersion":"1.0", + "modelName":"vf_vEPDG", + "modelType":"vnf" + }, + "instanceType":"VNF2_INSTANCE_TYPE", + "provStatus":null, + "inMaint":true, + "uuid":"eb5f56bf-5855-4e61-bd00-3e19a953bf02", + "originalName":null, + "legacyRegion":null, + "lineOfBusiness":null, + "platformName":null, + "trackById":"eb5f56bf-5855-4e61-bd00-3e19a953bf02:003", + "serviceInstanceId":"service-instance-id2", + "serviceInstanceName":"service-instance-name" + }]; + }; +}); + + +var expectedResult = + { + 'vnfs': { + 'DROR_vsp': { + 'rollbackOnFailure': 'true', + 'vfModules': {}, + 'isMissingData': false, + 'originalName': 'DROR_vsp', + 'orchStatus': 'Created', + 'inMaint': false, + 'vnfStoreKey' : null, + 'trackById' : 'abc', + 'action': 'Create' + } + }, + "vnfGroups" :{}, + "existingVNFCounterMap" : {}, + "existingVnfGroupCounterMap" : {}, + "existingNetworksCounterMap" : {}, + 'instanceParams': {}, + 'validationCounter': 0, + 'existingNames': {}, + 'networks': {}, + 'instanceName': 'Dror123', + 'orchStatus': 'Active', + 'modelInavariantId': '35340388-0b82-4d3a-823d-cbddf842be52', + 'action': 'Create' + }; + + +var aaiServiceInstnace: RootObject = { + "root": { + "type": "service-instance", + "orchestrationStatus": "Active", + "modelVersionId": "4e799efd-fd78-444d-bc25-4a3cde2f8cb0", + "modelCustomizationId": "4e799efd-fd78-444d-bc25-4a3cde2f8cb0", + "modelInvariantId": "35340388-0b82-4d3a-823d-cbddf842be52", + "id": "62888f15-6d24-4f7b-92a7-c3f35beeb215", + "name": "Dror123", + "children": [ + { + "type": "generic-vnf", + "orchestrationStatus": "Created", + "provStatus": "PREPROV", + "inMaint": true, + "modelVersionId": "11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", + "modelCustomizationId": "11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", + "modelInvariantId": "55628ce3-ed56-40bd-9b27-072698ce02a9", + "id": "59bde732-9b84-46bd-a59a-3c45fee0538b", + "name": "DROR_vsp", + "children": [] + } + ] + } +}; diff --git a/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts new file mode 100644 index 000000000..1b102e623 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts @@ -0,0 +1,619 @@ +import {NgRedux} from "@angular-redux/store"; +import {HttpClient} from '@angular/common/http'; +import {Injectable} from '@angular/core'; +import * as _ from 'lodash'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/operator/do'; +import {of} from "rxjs"; + +import {AicZone} from "../../models/aicZone"; +import {CategoryParams} from "../../models/categoryParams"; +import {LcpRegion} from "../../models/lcpRegion"; +import {LcpRegionsAndTenants} from "../../models/lcpRegionsAndTenants"; +import {OwningEntity} from "../../models/owningEntity"; +import {ProductFamily} from "../../models/productFamily"; +import {Project} from "../../models/project"; +import {SelectOption} from '../../models/selectOption'; +import {ServiceType} from "../../models/serviceType"; +import {Subscriber} from "../../models/subscriber"; +import {Tenant} from "../../models/tenant"; +import {Constants} from '../../utils/constants'; +import {AppState} from "../../store/reducers"; +import {GetAicZonesResponse} from "./responseInterfaces/getAicZonesResponseInterface"; +import {GetCategoryParamsResponseInterface} from "./responseInterfaces/getCategoryParamsResponseInterface"; +import {GetServicesResponseInterface} from "./responseInterfaces/getServicesResponseInterface"; +import {GetSubDetailsResponse} from "./responseInterfaces/getSubDetailsResponseInterface"; +import {GetSubscribersResponse} from "./responseInterfaces/getSubscribersResponseInterface"; +import {Root} from "./model/crawledAaiService"; +import {VnfInstance} from "../../models/vnfInstance"; +import {VfModuleInstance} from "../../models/vfModuleInstance"; +import {ServiceInstance} from "../../models/serviceInstance"; +import {VfModuleMap} from "../../models/vfModulesMap"; +import { + updateAicZones, + updateCategoryParameters, + updateLcpRegionsAndTenants, + updateServiceTypes, + updateSubscribers, + updateUserId +} from "../../storeUtil/utils/general/general.actions"; +import {updateModel, createServiceInstance} from "../../storeUtil/utils/service/service.actions"; +import {FeatureFlagsService, Features} from "../featureFlag/feature-flags.service"; +import {VnfMember} from "../../models/VnfMember"; +import {setOptionalMembersVnfGroupInstance} from "../../storeUtil/utils/vnfGroup/vnfGroup.actions"; +import {Observable} from "rxjs"; + +@Injectable() +export class AaiService { + constructor(private http: HttpClient, private store: NgRedux<AppState>, private featureFlagsService:FeatureFlagsService) { + + } + + getServiceModelById = (serviceModelId: string): Observable<any> => { + if (_.has(this.store.getState().service.serviceHierarchy, serviceModelId)) { + return of(<any> JSON.parse(JSON.stringify(this.store.getState().service.serviceHierarchy[serviceModelId]))); + } + let pathQuery: string = Constants.Path.SERVICES_PATH + serviceModelId; + return this.http.get(pathQuery).map(res => res) + .do((res) => { + this.store.dispatch(updateModel(res)); + }); + }; + + getUserId = (): Observable<any> => { + return this.http.get("../../getuserID", {responseType: 'text'}).do((res) => this.store.dispatch(updateUserId(res))); + }; + + + resolve = (root: Root, serviceInstance: ServiceInstance) => { + if (root.type === 'service-instance') { + serviceInstance.instanceName = root.name; + serviceInstance.orchStatus = root.orchestrationStatus; + serviceInstance.modelInavariantId = root.modelInvariantId; + for (let i = 0; i < root.children.length; i++) { + let child = root.children[i]; + if (child.type === 'generic-vnf') { + let vnf = new VnfInstance(); + vnf.originalName = child.name; + vnf.orchStatus = child.orchestrationStatus + if (child.children.length > 0) { + let vfModuleMap = new VfModuleMap(); + for (let j = 0; j < child.children.length; j++) { + let child = root.children[i]; + if (child.type === 'vf-module') { + let vfModule = new VfModuleInstance(); + vfModule.instanceName = child.name; + vfModule.orchStatus = child.orchestrationStatus; + vfModuleMap.vfModules[child.name] = vfModule; + } + } + vnf.vfModules = {"a": vfModuleMap}; + } + serviceInstance.vnfs[child.name] = vnf; + + } + } + + } + }; + + + getCRAccordingToNetworkFunctionId = (networkCollectionFunction, cloudOwner, cloudRegionId) => { + return this.http.get('../../aai_get_instance_groups_by_cloudregion/' + cloudOwner + '/' + cloudRegionId + '/' + networkCollectionFunction) + .map(res => res).do((res) => console.log(res)); + }; + + getCategoryParameters = (familyName): Observable<CategoryParams> => { + familyName = familyName || Constants.Path.PARAMETER_STANDARDIZATION_FAMILY; + let pathQuery: string = Constants.Path.GET_CATEGORY_PARAMETERS + "?familyName=" + familyName + "&r=" + Math.random(); + + return this.http.get<GetCategoryParamsResponseInterface>(pathQuery) + .map(this.categoryParametersResponseToProductAndOwningEntity) + .do(res => { + this.store.dispatch(updateCategoryParameters(res)) + }); + }; + + + categoryParametersResponseToProductAndOwningEntity = (res: GetCategoryParamsResponseInterface): CategoryParams => { + if (res && res.categoryParameters) { + const owningEntityList = res.categoryParameters.owningEntity.map(owningEntity => new OwningEntity(owningEntity)); + const projectList = res.categoryParameters.project.map(project => new Project(project)); + const lineOfBusinessList = res.categoryParameters.lineOfBusiness.map(owningEntity => new SelectOption(owningEntity)); + const platformList = res.categoryParameters.platform.map(platform => new SelectOption(platform)); + + return new CategoryParams(owningEntityList, projectList, lineOfBusinessList, platformList); + } else { + return new CategoryParams(); + } + }; + + getProductFamilies = (): Observable<ProductFamily[]> => { + + let pathQuery: string = Constants.Path.AAI_GET_SERVICES + Constants.Path.ASSIGN + Math.random(); + + return this.http.get<GetServicesResponseInterface>(pathQuery).map(res => res.service.map(service => new ProductFamily(service))); + }; + + getServices = (): Observable<GetServicesResponseInterface> => { + let pathQuery: string = Constants.Path.AAI_GET_SERVICES + Constants.Path.ASSIGN + Math.random(); + + return this.http.get<GetServicesResponseInterface>(pathQuery); + }; + + getSubscribers = (): Observable<Subscriber[]> => { + + if (this.store.getState().service.subscribers) { + return of(<any> JSON.parse(JSON.stringify(this.store.getState().service.subscribers))); + } + + let pathQuery: string = Constants.Path.AAI_GET_SUBSCRIBERS + Constants.Path.ASSIGN + Math.random(); + + return this.http.get<GetSubscribersResponse>(pathQuery).map(res => + res.customer.map(subscriber => new Subscriber(subscriber))).do((res) => { + this.store.dispatch(updateSubscribers(res)); + }); + }; + + getAicZones = (): Observable<AicZone[]> => { + if (this.store.getState().service.aicZones) { + return of(<any> JSON.parse(JSON.stringify(this.store.getState().service.aicZones))); + } + + let pathQuery: string = Constants.Path.AAI_GET_AIC_ZONES + Constants.Path.ASSIGN + Math.random(); + + return this.http.get<GetAicZonesResponse>(pathQuery).map(res => + res.zone.map(aicZone => new AicZone(aicZone))).do((res) => { + this.store.dispatch(updateAicZones(res)); + }); + }; + + getLcpRegionsAndTenants = (globalCustomerId, serviceType): Observable<LcpRegionsAndTenants> => { + + let pathQuery: string = Constants.Path.AAI_GET_TENANTS + + globalCustomerId + Constants.Path.FORWARD_SLASH + serviceType + Constants.Path.ASSIGN + Math.random(); + + console.log("AaiService:getSubscriptionServiceTypeList: globalCustomerId: " + + globalCustomerId); + if (globalCustomerId != null) { + return this.http.get(pathQuery) + .map(this.tenantResponseToLcpRegionsAndTenants).do((res) => { + this.store.dispatch(updateLcpRegionsAndTenants(res)); + }); + } + }; + + tenantResponseToLcpRegionsAndTenants = (cloudRegionTenantList): LcpRegionsAndTenants => { + + const lcpRegionsTenantsMap = {}; + + const lcpRegionList = _.uniqBy(cloudRegionTenantList, 'cloudRegionID').map((cloudRegionTenant) => { + const cloudOwner:string = cloudRegionTenant["cloudOwner"]; + const cloudRegionId:string = cloudRegionTenant["cloudRegionID"]; + const name:string = this.extractLcpRegionName(cloudRegionId, cloudOwner); + const isPermitted:boolean = cloudRegionTenant["is-permitted"]; + return new LcpRegion(cloudRegionId, name, isPermitted, cloudOwner); + }); + + lcpRegionList.forEach(region => { + lcpRegionsTenantsMap[region.id] = _.filter(cloudRegionTenantList, {'cloudRegionID': region.id}) + .map((cloudRegionTenant) => { + return new Tenant(cloudRegionTenant) + }); + const reducer = (accumulator, currentValue) => { + accumulator.isPermitted = accumulator.isPermitted || currentValue.isPermitted; + + return accumulator; + }; + region.isPermitted = lcpRegionsTenantsMap[region.id].reduce(reducer).isPermitted; + }); + + return new LcpRegionsAndTenants(lcpRegionList, lcpRegionsTenantsMap); + }; + + public extractLcpRegionName(cloudRegionId: string, cloudOwner: string):string { + return this.featureFlagsService.getFlagState(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) ? + cloudRegionId+AaiService.formatCloudOwnerTrailer(cloudOwner) : cloudRegionId; + }; + + public static formatCloudOwnerTrailer(cloudOwner: string):string { + return " ("+ cloudOwner.trim().toLowerCase().replace(/^att-/, "").toUpperCase() + ")"; + } + + getServiceTypes = (subscriberId): Observable<ServiceType[]> => { + + console.log("AaiService:getSubscriptionServiceTypeList: globalCustomerId: " + subscriberId); + if (_.has(this.store.getState().service.serviceTypes, subscriberId)) { + return of(<ServiceType[]> JSON.parse(JSON.stringify(this.store.getState().service.serviceTypes[subscriberId]))); + } + + return this.getSubscriberDetails(subscriberId) + .map(this.subDetailsResponseToServiceTypes) + .do((res) => { + this.store.dispatch(updateServiceTypes(res, subscriberId)); + }); + }; + + getSubscriberDetails = (subscriberId): Observable<GetSubDetailsResponse> => { + let pathQuery: string = Constants.Path.AAI_SUB_DETAILS_PATH + subscriberId + Constants.Path.ASSIGN + Math.random(); + + if (subscriberId != null) { + return this.http.get<GetSubDetailsResponse>(pathQuery); + } + }; + + subDetailsResponseToServiceTypes = (res: GetSubDetailsResponse): ServiceType[] => { + if (res && res['service-subscriptions']) { + const serviceSubscriptions = res['service-subscriptions']['service-subscription']; + return serviceSubscriptions.map((subscription, index) => new ServiceType(String(index), subscription)) + } else { + return []; + } + }; + + + public retrieveServiceInstanceTopology(serviceInstanceId : string, subscriberId: string, serviceType: string):Observable<ServiceInstance> { + let pathQuery: string = `${Constants.Path.AAI_GET_SERVICE_INSTANCE_TOPOLOGY_PATH}${subscriberId}/${serviceType}/${serviceInstanceId}`; + return this.http.get<ServiceInstance>(pathQuery); + } + + public retrieveAndStoreServiceInstanceTopology(serviceInstanceId: string, subscriberId: string, serviceType: string, serviceModeId: string):Observable<ServiceInstance> { + return this.retrieveServiceInstanceTopology(serviceInstanceId, subscriberId, serviceType).do((service:ServiceInstance) => { + this.store.dispatch(createServiceInstance(service, serviceModeId)); + }); + }; + + + public retrieveServiceInstanceRetryTopology(jobId : string) :Observable<ServiceInstance> { + let pathQuery: string = `${Constants.Path.SERVICES_RETRY_TOPOLOGY}/${jobId}`; + return this.http.get<ServiceInstance>(pathQuery); + + // return of( + // <any>{ + // "action": "None", + // "instanceName": "LXzQMx9clZl7D6ckJ", + // "instanceId": "service-instance-id", + // "orchStatus": "GARBAGE DATA", + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelInvariantId": "d27e42cf-087e-4d31-88ac-6c4b7585f800", + // "modelVersionId": "6e59c5de-f052-46fa-aa7e-2fca9d674c44", + // "modelName": "vf_vEPDG", + // "modelType": "service", + // "modelVersion": "5.0" + // }, + // "globalSubscriberId": "global-customer-id", + // "subscriptionServiceType": "service-instance-type", + // "owningEntityId": null, + // "owningEntityName": null, + // "tenantName": null, + // "aicZoneId": null, + // "aicZoneName": null, + // "projectName": null, + // "rollbackOnFailure": null, + // "isALaCarte": false, + // "vnfs": { + // "1e918ade-3dc6-4cec-b952-3ff94ed82d1c": { + // "action": "None", + // "instanceName": "DgZuxjJy5LMIc3755", + // "instanceId": "1e918ade-3dc6-4cec-b952-3ff94ed82d1c", + // "orchStatus": null, + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelInvariantId": "vnf-instance-model-invariant-id", + // "modelVersionId": "vnf-instance-model-version-id", + // "modelType": "vnf" + // }, + // "instanceType": "SXDBMhwdR9iO0g1Uv", + // "provStatus": null, + // "inMaint": false, + // "uuid": "vnf-instance-model-version-id", + // "originalName": null, + // "legacyRegion": null, + // "lineOfBusiness": null, + // "platformName": null, + // "trackById": "1e918ade-3dc6-4cec-b952-3ff94ed82d1c", + // "vfModules": {}, + // "networks": { + // "ff464c97-ea9c-4165-996a-fe400499af3e": { + // "action": "None", + // "instanceName": "ZI0quzIpu8TNXS7nl", + // "instanceId": "ff464c97-ea9c-4165-996a-fe400499af3e", + // "orchStatus": "Assigned", + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelInvariantId": "network-instance-model-invariant-id", + // "modelVersionId": "network-instance-model-version-id", + // "modelType": "network" + // }, + // "instanceType": "CONTRAIL30_BASIC", + // "provStatus": "prov", + // "inMaint": false, + // "uuid": "network-instance-model-version-id", + // "originalName": null, + // "legacyRegion": null, + // "lineOfBusiness": null, + // "platformName": null, + // "trackById": "ff464c97-ea9c-4165-996a-fe400499af3e", + // "isFailed": true + // }, + // "3e41d57c-8bb4-443e-af02-9f86487ba938": { + // "action": "None", + // "instanceName": "0i9asscqSLm7Poeb8", + // "instanceId": "3e41d57c-8bb4-443e-af02-9f86487ba938", + // "orchStatus": "Created", + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelInvariantId": "network-instance-model-invariant-id", + // "modelVersionId": "network-instance-model-version-id", + // "modelType": "network" + // }, + // "instanceType": "CONTRAIL30_BASIC", + // "provStatus": "prov", + // "inMaint": false, + // "uuid": "network-instance-model-version-id", + // "originalName": null, + // "legacyRegion": null, + // "lineOfBusiness": null, + // "platformName": null, + // "trackById": "3e41d57c-8bb4-443e-af02-9f86487ba938", + // "isFailed": true + // } + // }, + // "isFailed": true + // }, + // "9a9b2705-c569-4f1b-9a67-13e9f86e6c55": { + // "isFailed": true, + // "action": "None", + // "instanceName": "TFn0SYhrCUs7L3qWS", + // "instanceId": "9a9b2705-c569-4f1b-9a67-13e9f86e6c55", + // "orchStatus": null, + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelCustomizationName": "VF_vMee 0", + // "modelInvariantId": "vnf-instance-model-invariant-id", + // "modelVersionId": "d6557200-ecf2-4641-8094-5393ae3aae60", + // "modelType": "vnf" + // }, + // "instanceType": "WIT68GUnH34VaGZgp", + // "provStatus": null, + // "inMaint": true, + // "uuid": "d6557200-ecf2-4641-8094-5393ae3aae60", + // "originalName": "VF_vMee 0", + // "legacyRegion": null, + // "lineOfBusiness": null, + // "platformName": null, + // "trackById": "9a9b2705-c569-4f1b-9a67-13e9f86e6c55", + // "vfModules": { + // "vf_vmee0..VfVmee..vmme_vlc..module-1": { + // "2c1ca484-cbc2-408b-ab86-25a2c15ce280": { + // "action": "None", + // "instanceName": "ss820f_0918_db", + // "instanceId": "2c1ca484-cbc2-408b-ab86-25a2c15ce280", + // "orchStatus": "deleted", + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelCustomizationName": "VfVmee..vmme_vlc..module-1", + // "modelCustomizationId": "b200727a-1bf9-4e7c-bd06-b5f4c9d920b9", + // "modelInvariantId": "09edc9ef-85d0-4b26-80de-1f569d49e750", + // "modelVersionId": "522159d5-d6e0-4c2a-aa44-5a542a12a830", + // "modelType": "vfModule" + // }, + // "instanceType": null, + // "provStatus": null, + // "inMaint": true, + // "uuid": "522159d5-d6e0-4c2a-aa44-5a542a12a830", + // "originalName": "VfVmee..vmme_vlc..module-1", + // "legacyRegion": null, + // "lineOfBusiness": null, + // "platformName": null, + // "trackById": "2c1ca484-cbc2-408b-ab86-25a2c15ce280", + // "isBase": false, + // "volumeGroupName": null, + // "isFailed": true + // } + // }, + // "dc229cd8-c132-4455-8517-5c1787c18b14": { + // "3ef042c4-259f-45e0-9aba-0989bd8d1cc5": { + // "action": "None", + // "instanceName": "ss820f_0918_base", + // "instanceId": "3ef042c4-259f-45e0-9aba-0989bd8d1cc5", + // "orchStatus": "Assigned", + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelCustomizationId": "8ad8670b-0541-4499-8101-275bbd0e8b6a", + // "modelInvariantId": "1e463c9c-404d-4056-ba56-28fd102608de", + // "modelVersionId": "dc229cd8-c132-4455-8517-5c1787c18b14", + // "modelType": "vfModule" + // }, + // "instanceType": null, + // "provStatus": null, + // "inMaint": false, + // "uuid": "dc229cd8-c132-4455-8517-5c1787c18b14", + // "originalName": null, + // "legacyRegion": null, + // "lineOfBusiness": null, + // "platformName": null, + // "trackById": "3ef042c4-259f-45e0-9aba-0989bd8d1cc5", + // "isBase": true, + // "volumeGroupName": null + // } + // } + // }, + // "networks": {} + // } + // }, + // "networks": { + // "e1edb09e-e68b-4ebf-adb8-e2587be56257": { + // "action": "None", + // "instanceName": "cNpGlYQDsmrUDK5iG", + // "instanceId": "e1edb09e-e68b-4ebf-adb8-e2587be56257", + // "orchStatus": "Created", + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelInvariantId": "network-instance-model-invariant-id", + // "modelVersionId": "ddc3f20c-08b5-40fd-af72-c6d14636b986", + // "modelType": "network" + // }, + // "instanceType": "CONTRAIL30_HIMELGUARD", + // "provStatus": "preprov", + // "inMaint": false, + // "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986", + // "originalName": null, + // "legacyRegion": null, + // "lineOfBusiness": null, + // "platformName": null, + // "trackById": "e1edb09e-e68b-4ebf-adb8-e2587be56257" + // }, + // "de4b5203-ad1c-4f2b-8843-5236fb8dc9ba": { + // "action": "None", + // "instanceName": "EI9QlSRVK0lon54Cb", + // "instanceId": "de4b5203-ad1c-4f2b-8843-5236fb8dc9ba", + // "orchStatus": "Assigned", + // "productFamilyId": null, + // "lcpCloudRegionId": null, + // "tenantId": null, + // "modelInfo": { + // "modelInvariantId": "network-instance-model-invariant-id", + // "modelVersionId": "ddc3f20c-08b5-40fd-af72-c6d14636b986", + // "modelType": "network" + // }, + // "instanceType": "CONTRAIL30_BASIC", + // "provStatus": "nvtprov", + // "inMaint": false, + // "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986", + // "originalName": null, + // "legacyRegion": null, + // "lineOfBusiness": null, + // "platformName": null, + // "trackById": "de4b5203-ad1c-4f2b-8843-5236fb8dc9ba", + // "isFailed": true + // } + // }, + // "vnfGroups": {}, + // "validationCounter": 0, + // "existingVNFCounterMap": { + // "vnf-instance-model-version-id": 1, + // "d6557200-ecf2-4641-8094-5393ae3aae60": 1 + // }, + // "existingNetworksCounterMap": { + // "ddc3f20c-08b5-40fd-af72-c6d14636b986": 2 + // }, + // "existingVnfGroupCounterMap": {} + // } + // ); + + } + + public retrieveAndStoreServiceInstanceRetryTopology(jobId: string, serviceModeId : string):Observable<ServiceInstance> { + return this.retrieveServiceInstanceRetryTopology(jobId).do((service:ServiceInstance) => { + this.store.dispatch(createServiceInstance(service, serviceModeId)); + }); + }; + + public getOptionalGroupMembers(serviceModelId: string, subscriberId: string, serviceType: string, serviceInvariantId: string, groupType: string, groupRole: string): Observable<VnfMember[]> { + let pathQuery: string = `${Constants.Path.AAI_GET_SERVICE_GROUP_MEMBERS_PATH}${subscriberId}/${serviceType}/${serviceInvariantId}/${groupType}/${groupRole}`; + if(_.has(this.store.getState().service.serviceInstance[serviceModelId].optionalGroupMembersMap,pathQuery)){ + return of(<VnfMember[]> JSON.parse(JSON.stringify(this.store.getState().service.serviceInstance[serviceModelId].optionalGroupMembersMap[pathQuery]))); + } + return this.http.get<VnfMember[]>(pathQuery) + .do((res) => { + this.store.dispatch(setOptionalMembersVnfGroupInstance(serviceModelId, pathQuery, res)) + }); + // let res = Observable.of((JSON.parse(JSON.stringify(this.loadMockMembers())))); + // return res; + + } + + //TODO: make other places use this function + extractSubscriberNameBySubscriberId(subscriberId: string) { + let result: string = null; + let filteredArray: any = _.filter(this.store.getState().service.subscribers, function (o: Subscriber) { + return o.id === subscriberId + }); + if (filteredArray.length > 0) { + result = filteredArray[0].name; + } + return result; + } + + loadMockMembers(): any { + return [ + { + "action":"None", + "instanceName":"VNF1_INSTANCE_NAME", + "instanceId":"VNF1_INSTANCE_ID", + "orchStatus":null, + "productFamilyId":null, + "lcpCloudRegionId":"mtn23b", + "tenantId":"3e9a20a3e89e45f884e09df0cc2d2d2a", + "tenantName":"APPC-24595-T-IST-02C", + "modelInfo":{ + "modelInvariantId":"vnf-instance-model-invariant-id", + "modelVersionId":"7a6ee536-f052-46fa-aa7e-2fca9d674c44", + "modelVersion":"2.0", + "modelName":"vf_vEPDG", + "modelType":"vnf" + }, + "instanceType":"VNF1_INSTANCE_TYPE", + "provStatus":null, + "inMaint":false, + "uuid":"7a6ee536-f052-46fa-aa7e-2fca9d674c44", + "originalName":null, + "legacyRegion":null, + "lineOfBusiness":null, + "platformName":null, + "trackById":"7a6ee536-f052-46fa-aa7e-2fca9d674c44:002", + "serviceInstanceId":"service-instance-id1", + "serviceInstanceName":"service-instance-name" + }, + { + "action":"None", + "instanceName":"VNF2_INSTANCE_NAME", + "instanceId":"VNF2_INSTANCE_ID", + "orchStatus":null, + "productFamilyId":null, + "lcpCloudRegionId":"mtn23b", + "tenantId":"3e9a20a3e89e45f884e09df0cc2d2d2a", + "tenantName":"APPC-24595-T-IST-02C", + "modelInfo":{ + "modelInvariantId":"vnf-instance-model-invariant-id", + "modelVersionId":"eb5f56bf-5855-4e61-bd00-3e19a953bf02", + "modelVersion":"1.0", + "modelName":"vf_vEPDG", + "modelType":"vnf" + }, + "instanceType":"VNF2_INSTANCE_TYPE", + "provStatus":null, + "inMaint":true, + "uuid":"eb5f56bf-5855-4e61-bd00-3e19a953bf02", + "originalName":null, + "legacyRegion":null, + "lineOfBusiness":null, + "platformName":null, + "trackById":"eb5f56bf-5855-4e61-bd00-3e19a953bf02:003", + "serviceInstanceId":"service-instance-id2", + "serviceInstanceName":"service-instance-name" + } + ] + + } + + +} diff --git a/vid-webpack-master/src/app/shared/services/aaiService/model/crawledAaiService.ts b/vid-webpack-master/src/app/shared/services/aaiService/model/crawledAaiService.ts new file mode 100644 index 000000000..8c27d43f7 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/model/crawledAaiService.ts @@ -0,0 +1,30 @@ + + export interface Child { + type: string; + orchestrationStatus: string; + provStatus: string; + inMaint: boolean; + modelVersionId: string; + modelCustomizationId: string; + modelInvariantId: string; + id: string; + name: string; + children: any[]; + } + + export interface Root { + type: string; + orchestrationStatus: string; + modelVersionId: string; + modelCustomizationId: string; + modelInvariantId: string; + id: string; + name: string; + children: Child[]; + } + + export interface RootObject { + root: Root; + } + + diff --git a/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getAicZonesResponseInterface.ts b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getAicZonesResponseInterface.ts new file mode 100644 index 000000000..62581c9e2 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getAicZonesResponseInterface.ts @@ -0,0 +1,3 @@ +export interface GetAicZonesResponse { + zone: any[]; +} diff --git a/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getCategoryParamsResponseInterface.ts b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getCategoryParamsResponseInterface.ts new file mode 100644 index 000000000..06398904c --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getCategoryParamsResponseInterface.ts @@ -0,0 +1,10 @@ +interface CategoryParametersResponse { + owningEntity: any[], + project: any[] + lineOfBusiness: any[] + platform: any[] +} + +export interface GetCategoryParamsResponseInterface { + categoryParameters: CategoryParametersResponse; +} diff --git a/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getServiceModelResponseInterface.ts b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getServiceModelResponseInterface.ts new file mode 100644 index 000000000..016bb0a85 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getServiceModelResponseInterface.ts @@ -0,0 +1,5 @@ +import {ServiceModelResponseInterface} from "../../../models/serviceModel"; + +export interface GetServiceModelResponseInterface { + service: ServiceModelResponseInterface +} diff --git a/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getServicesResponseInterface.ts b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getServicesResponseInterface.ts new file mode 100644 index 000000000..ae04055e4 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getServicesResponseInterface.ts @@ -0,0 +1,9 @@ +export interface ServiceResponseInterface { + 'service-id': string, + 'service-description': string + 'is-permitted': boolean +} + +export interface GetServicesResponseInterface { + service: ServiceResponseInterface[]; +} diff --git a/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getSubDetailsResponseInterface.ts b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getSubDetailsResponseInterface.ts new file mode 100644 index 000000000..dbfb695d0 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getSubDetailsResponseInterface.ts @@ -0,0 +1,12 @@ +export interface Subscription { + 'service-type': string; + 'is-permitted': boolean; +} + +interface ServiceSubscriptions { + 'service-subscription': Subscription[]; +} + +export interface GetSubDetailsResponse { + 'service-subscriptions': ServiceSubscriptions; +} diff --git a/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getSubscribersResponseInterface.ts b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getSubscribersResponseInterface.ts new file mode 100644 index 000000000..1399709a5 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/aaiService/responseInterfaces/getSubscribersResponseInterface.ts @@ -0,0 +1,5 @@ +import {Subscriber} from "../../../models/subscriber"; + +export interface GetSubscribersResponse { + customer: Subscriber[]; +} diff --git a/vid-webpack-master/src/app/shared/services/configuration.service.ts b/vid-webpack-master/src/app/shared/services/configuration.service.ts new file mode 100644 index 000000000..6c618b5b4 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/configuration.service.ts @@ -0,0 +1,35 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from "@angular/common/http"; +import {Constants} from "../utils/constants"; +import {Observable} from 'rxjs'; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../store/reducers"; +import {updateFlags} from "../storeUtil/utils/global/global.actions"; +import {of} from "rxjs"; + +@Injectable() +export class ConfigurationService { + store : NgRedux<AppState>; + + constructor(private _http: HttpClient, _store : NgRedux<AppState>) { + this.store = _store; + } + + getConfiguration(key : string): Observable<any> { + let pathQuery = Constants.Path.CONFIGURATION_PATH; + pathQuery = pathQuery.replace("{name}",key); + return this._http.get(pathQuery).map(response => response); + } + + getFlags(): Observable<{[key: string] : boolean}> { + let flags = this.store.getState().global.flags; + if (flags) { + return of(flags); + } + let pathQuery = Constants.Path.FEATURES_FLAG_PATH; + return this._http.get<{[key: string] : boolean}>(pathQuery).map(response => { + this.store.dispatch(updateFlags(response)); + return response; + }); + } +} diff --git a/vid-webpack-master/src/app/shared/services/data.service.ts b/vid-webpack-master/src/app/shared/services/data.service.ts new file mode 100644 index 000000000..4f8bf3623 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/data.service.ts @@ -0,0 +1,528 @@ +import { Injectable } from '@angular/core'; + +@Injectable() +export class DataService { + + private static _availableVolumeGroupList; + private static _cloudRegionTenantList; + private static _globalCustomerId; + private static _customizationUUID; + private static _rescustomizationUUID; + private static _inventoryItem; + private static _modelId; + private static _modelInstanceName; + private static _modelInfo; + private static _networkInstanceId; + private static _serviceIdList; + private static _aicZones; + private static _aicZone; + private static _serviceInstanceId; + private static _serviceInstanceName; + private static _serviceName; + private static _serviceType; + private static _serviceUuid; + private static _serviceTypeName; + private static _createSubscriberName; + private static _uploadSupplementoryDataFile; + private static _supplementoryDataFile; + private static _subscriberId; + private static _loggedInUserId; + private static _subscriberName; + private static _subscribers; + private static _subscriptionServiceTypeList; + private static _userParams; + private static _userServiceInstanceName; + private static _vfModuleInstanceId; + private static _vnfInstanceId; + private static _vfModuleInstanceName; + private static _volumeGroupInstanceId; + private static _lcpRegion; + private static _tenant; + private static _treeHandle; + private static _serviceInstanceToCustomer; + private static _aLaCarte: boolean; + private static _macro: boolean; + private static _resources; + private static _syspropProvStatusList; + private static _updatedvnfProvStatus; + private static _arbitraryParameters; + private static _hideServiceFields; + private static _serviceProxies; + private static _sourceServiceProxies; + private static _collectorServiceProxies; + private static _configurationByPolicy; + private static _suppressRollback; + private static _portMirroningConfigFields; + private static _configurationInstanceId: string; + private static _configurationStatus: string; + private static _portStatus: string; + private static _portId: string; + private static _pnf; + private static _owningEntityProperties; + + static get availableVolumeGroupList() { + return this._availableVolumeGroupList; + } + + static set availableVolumeGroupList(value) { + this._availableVolumeGroupList = value; + } + + static get cloudRegionTenantList() { + return this._cloudRegionTenantList; + } + + static set cloudRegionTenantList(value) { + this._cloudRegionTenantList = value; + } + + static get globalCustomerId() { + return this._globalCustomerId; + } + + static set globalCustomerId(value) { + this._globalCustomerId = value; + } + + static get customizationUUID() { + return this._customizationUUID; + } + + static set customizationUUID(value) { + this._customizationUUID = value; + } + + static get rescustomizationUUID() { + return this._rescustomizationUUID; + } + + static set rescustomizationUUID(value) { + this._rescustomizationUUID = value; + } + + static get inventoryItem() { + return this._inventoryItem; + } + + static set inventoryItem(value) { + this._inventoryItem = value; + } + + static get modelId() { + return this._modelId; + } + + static set modelId(value) { + this._modelId = value; + } + + static get modelInstanceName() { + return this._modelInstanceName; + } + + static set modelInstanceName(value) { + this._modelInstanceName = value; + } + + static get modelInfo() { + return this._modelInfo; + } + + static set modelInfo(value) { + this._modelInfo = value; + } + + static getModelInfo(componentId) { + return this._modelInfo[componentId]; + } + + static setModelInfo(componentId, modelInfo) { + if (!this._modelInfo) { + this._modelInfo = {}; + } + this._modelInfo[componentId] = modelInfo; + } + + static get networkInstanceId() { + return this._networkInstanceId; + } + + static set networkInstanceId(value) { + this._networkInstanceId = value; + } + + static get serviceIdList() { + return this._serviceIdList; + } + + static set serviceIdList(value) { + this._serviceIdList = value; + } + + static get aicZones() { + return this._aicZones; + } + + static set aicZones(value) { + this._aicZones = value; + } + + static get aicZone() { + return this._aicZone; + } + + static set aicZone(value) { + this._aicZone = value; + } + + static get serviceInstanceId() { + return this._serviceInstanceId; + } + + static set serviceInstanceId(value) { + this._serviceInstanceId = value; + } + + static get serviceInstanceName() { + return this._serviceInstanceName; + } + + static set serviceInstanceName(value) { + this._serviceInstanceName = value; + } + + static get serviceName() { + return this._serviceName; + } + + static set serviceName(value) { + this._serviceName = value; + } + + static get serviceType() { + return this._serviceType; + } + + static set serviceType(value) { + this._serviceType = value; + } + + static get serviceUuid() { + return this._serviceUuid; + } + + static set serviceUuid(value) { + this._serviceUuid = value; + } + + static get serviceTypeName() { + return this._serviceTypeName; + } + + static set serviceTypeName(value) { + this._serviceTypeName = value; + } + + static get createSubscriberName() { + return this._createSubscriberName; + } + + static set createSubscriberName(value) { + this._createSubscriberName = value; + } + + static get uploadSupplementoryDataFile() { + return this._uploadSupplementoryDataFile; + } + + static set uploadSupplementoryDataFile(value) { + this._uploadSupplementoryDataFile = value; + } + + static get supplementoryDataFile() { + return this._supplementoryDataFile; + } + + static set supplementoryDataFile(value) { + this._supplementoryDataFile = value; + } + + static get subscriberId() { + return this._subscriberId; + } + + static set subscriberId(value) { + this._subscriberId = value; + } + + static get loggedInUserId() { + return this._loggedInUserId; + } + + static set loggedInUserId(value) { + this._loggedInUserId = value; + } + + static get subscriberName() { + return this._subscriberName; + } + + static set subscriberName(value) { + this._subscriberName = value; + } + + static get subscribers() { + return this._subscribers; + } + + static set subscribers(value) { + this._subscribers = value; + } + + static get subscriptionServiceTypeList() { + return this._subscriptionServiceTypeList; + } + + static set subscriptionServiceTypeList(value) { + this._subscriptionServiceTypeList = value; + } + + static get userParams() { + return this._userParams; + } + + static set userParams(value) { + this._userParams = value; + } + + static get userServiceInstanceName() { + return this._userServiceInstanceName; + } + + static set userServiceInstanceName(value) { + this._userServiceInstanceName = value; + } + + static get vfModuleInstanceId() { + return this._vfModuleInstanceId; + } + + static set vfModuleInstanceId(value) { + this._vfModuleInstanceId = value; + } + + static get vnfInstanceId() { + return this._vnfInstanceId; + } + + static set vnfInstanceId(value) { + this._vnfInstanceId = value; + } + + static get vfModuleInstanceName() { + return this._vfModuleInstanceName; + } + + static set vfModuleInstanceName(value) { + this._vfModuleInstanceName = value; + } + + static get volumeGroupInstanceId() { + return this._volumeGroupInstanceId; + } + + static set volumeGroupInstanceId(value) { + this._volumeGroupInstanceId = value; + } + + static get lcpRegion() { + return this._lcpRegion; + } + + static set lcpRegion(value) { + this._lcpRegion = value; + } + + static get tenant() { + return this._tenant; + } + + static set tenant(value) { + this._tenant = value; + } + + static get treeHandle() { + return this._treeHandle; + } + + static set treeHandle(value) { + this._treeHandle = value; + } + + static get serviceInstanceToCustomer() { + return this._serviceInstanceToCustomer; + } + + static set serviceInstanceToCustomer(value) { + this._serviceInstanceToCustomer = value; + } + + static get aLaCarte() { + if (!this._aLaCarte) { + return true; + } + return this._aLaCarte; + } + + static set aLaCarte(value: boolean) { + this._aLaCarte = value; + } + + static get macro() { + if (!this._macro) { + return false; + } + return this._macro; + } + + static set macro(value: boolean) { + this._macro = value; + } + + static get resources() { + return this._resources; + } + + static set resources(value) { + this._resources = value; + } + + static get syspropProvStatusList() { + return this._syspropProvStatusList; + } + + static set syspropProvStatusList(value) { + this._syspropProvStatusList = value; + } + + static get updatedvnfProvStatus() { + return this._updatedvnfProvStatus; + } + + static set updatedvnfProvStatus(value) { + this._updatedvnfProvStatus = value; + } + + static get arbitraryParameters() { + return this._arbitraryParameters; + } + + static set arbitraryParameters(value) { + this._arbitraryParameters = value; + } + + static get hideServiceFields() { + return this._hideServiceFields; + } + + static set hideServiceFields(value) { + this._hideServiceFields = value; + } + + static get serviceProxies() { + return this._serviceProxies; + } + + static set serviceProxies(value) { + this._serviceProxies = value; + } + + static get sourceServiceProxies() { + return this._sourceServiceProxies; + } + + static set sourceServiceProxies(value) { + this._sourceServiceProxies = value; + } + + static get collectorServiceProxies() { + return this._collectorServiceProxies; + } + + static set collectorServiceProxies(value) { + this._collectorServiceProxies = value; + } + + static get configurationByPolicy() { + return this._configurationByPolicy; + } + + static set configurationByPolicy(value) { + this._configurationByPolicy = value; + } + + static get suppressRollback() { + return this._suppressRollback; + } + + static set suppressRollback(value) { + this._suppressRollback = value; + } + + static get portMirroningConfigFields() { + return this._portMirroningConfigFields; + } + + static set portMirroningConfigFields(value) { + this._portMirroningConfigFields = value; + } + + static get configurationInstanceId(): string { + return this._configurationInstanceId; + } + + static set configurationInstanceId(value: string) { + this._configurationInstanceId = value; + } + + static get configurationStatus(): string { + return this._configurationStatus; + } + + static set configurationStatus(value: string) { + this._configurationStatus = value; + } + + static get portStatus(): string { + return this._portStatus; + } + + static set portStatus(value: string) { + this._portStatus = value; + } + + static get portId(): string { + return this._portId; + } + + static set portId(value: string) { + this._portId = value; + } + + static get pnf() { + return this._pnf; + } + + static set pnf(value) { + this._pnf = value; + } + + static get owningEntityProperties() { + return this._owningEntityProperties; + } + + static set owningEntityProperties(value) { + this._owningEntityProperties = value; + } + +} diff --git a/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.spec.ts b/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.spec.ts index 617dbd3da..c4ef881f0 100644 --- a/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.spec.ts +++ b/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.spec.ts @@ -1,33 +1,44 @@ -import { getTestBed, TestBed } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { NgRedux } from '@angular-redux/store'; -import { DefaultDataGeneratorService } from './default.data.generator.service'; - -export class MockAppStore<T> {} +import {getTestBed, TestBed} from '@angular/core/testing'; +import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; +import {NgRedux} from '@angular-redux/store'; +import {DefaultDataGeneratorService} from './default.data.generator.service'; +import {ServiceNodeTypes} from "../../models/ServiceNodeTypes"; +import {VNFModel} from "../../models/vnfModel"; +class MockAppStore<T> {} describe('Default Data Generator Service', () => { let injector; let service: DefaultDataGeneratorService; let httpMock: HttpTestingController; - beforeEach(() => { + beforeAll(done => (async () => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], - providers: [DefaultDataGeneratorService, - {provide: NgRedux, useClass: MockAppStore}] + providers: [DefaultDataGeneratorService, + {provide: NgRedux, useClass: MockAppStore}] }); + await TestBed.compileComponents(); injector = getTestBed(); service = injector.get(DefaultDataGeneratorService); httpMock = injector.get(HttpTestingController); + })().then(done).catch(done.fail)); + + test('generateVFModule aLaCarte vf module object should missed data', () => { + const serviceHierarchy = generateServiceHierarchy(); + const vnfUUID: string = 'VF_vMee 0'; + const vnfModuleUUID: string = 'vf_vmee0..VfVmee..base_vmme..module-0'; + + let result = service.generateVFModule(serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID], [], false, true); + expect(result.isMissingData).toBeTruthy(); }); - it('generateVFModule should create vf module object', () => { + test('generateVFModule should create vf module object', () => { const serviceHierarchy = generateServiceHierarchy(); const vnfUUID: string = 'VF_vMee 0'; const vnfModuleUUID: string = 'vf_vmee0..VfVmee..base_vmme..module-0'; - let result = service.generateVFModule(serviceHierarchy, vnfUUID, vnfModuleUUID); + let result = service.generateVFModule(serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID], [], false, false); expect(result.modelInfo.modelType).toEqual('VFmodule'); expect(result.modelInfo.modelInvariantId).toEqual(serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].invariantUuid); @@ -37,15 +48,16 @@ describe('Default Data Generator Service', () => { expect(result.modelInfo.modelCustomizationId).toEqual(serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].customizationUuid); expect(result.modelInfo.modelCustomizationName).toEqual(serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].modelCustomizationName); expect(result.sdncPreReload).toBeNull(); + expect(result.isMissingData).toBeTruthy(); + expect(result.instanceParams).toEqual([{}]); }); - it('generateVNFData should create vnf object', () => { + test('generateVNFData should create vnf object', () => { const serviceHierarchy = generateServiceHierarchy(); const vnfName: string = 'VF_vMee 0'; const formValues = generateVNFFormValues(); - const vfUUID: string = 'vf_vmee0..VfVmee..base_vmme..module-0'; - let result = service.generateVNFData(serviceHierarchy, vnfName, vfUUID, formValues); + let result = service.generateVNFData(serviceHierarchy, vnfName, formValues, false); expect(result.productFamilyId).toEqual(formValues.productFamilyId); expect(result.lcpCloudRegionId).toBeNull(); @@ -57,17 +69,343 @@ describe('Default Data Generator Service', () => { expect(result.modelInfo.modelVersionId).toEqual(formValues.modelInfo.modelVersionId); expect(result.modelInfo.modelName).toEqual(serviceHierarchy.vnfs[vnfName].name); expect(result.modelInfo.modelVersion).toEqual(serviceHierarchy.vnfs[vnfName].version); - expect(result.modelInfo.modelCustomizationId).toEqual(serviceHierarchy.vnfs[vnfName].modelCustomizationId); + expect(result.modelInfo.modelCustomizationId).toEqual(serviceHierarchy.vnfs[vnfName].customizationUuid); + expect(result.modelInfo.modelUniqueId).toEqual(serviceHierarchy.vnfs[vnfName].customizationUuid); expect(result.modelInfo.modelCustomizationName).toEqual(serviceHierarchy.vnfs[vnfName].modelCustomizationName); + expect(result.isMissingData).toBeTruthy(); + }); + + describe('#updateDynamicInputsVnfDataFromModel', () => { + test('get vfModule instance params', () => { + let dynamicInputs = service.updateDynamicInputsVnfDataFromModel(ServiceNodeTypes.VFmodule, generateVFModule()); + expect(dynamicInputs).toEqual([{ + id: '2017488_adiodvpe0_vnf_config_template_version', + type: 'string', + name: '2017488_adiodvpe0_vnf_config_template_version', + value: '17.2', + isRequired: true, + description: 'VPE Software Version' + }, { + id: '2017488_adiodvpe0_AIC_CLLI', + type: 'string', + name: '2017488_adiodvpe0_AIC_CLLI', + value: 'ATLMY8GA', + isRequired: true, + description: 'AIC Site CLLI' + }]); + + /*get vfModule with no instance params should return empty array*/ + dynamicInputs = service.updateDynamicInputsVnfDataFromModel(ServiceNodeTypes.VFmodule, generateVFModule2); + expect(dynamicInputs).toEqual([]); + + /*get vf instance params should be undefined*/ + dynamicInputs = service.updateDynamicInputsVnfDataFromModel(ServiceNodeTypes.VF, generateVNF()); + expect(dynamicInputs).toEqual([]); + }); + }); + + describe('#createNewVfModuleTreeNode', () => { + test('createNewVfModuleTreeNode with isEcompGeneratedNaming instance name not fill - missing data true', () => { + const vnfModuleUUID: string = 'vf_vmee0..VfVmee..base_vmme..module-0'; + const vfModuleModel = generateServiceHierarchy().vnfs['VF_vMee 0'].vfModules['vf_vmee0..VfVmee..base_vmme..module-0']; + const newVfModule = service.createNewVfModuleTreeNode(<any>{ + instanceName: "", + instanceParams: {}, + volumeGroupName: "", + isMissingData : false, + trackById: Math.random().toString() + }, vfModuleModel, vnfModuleUUID, false, [], ""); + expect(newVfModule.name).toEqual('<Automatically Assigned>'); + expect(newVfModule.missingData).toEqual(true); + }); + + test('createNewVfModuleTreeNode without isEcompGeneratedNaming missing data false', () => { + const vnfModuleUUID: string = 'vf_vmee0..VfVmee..base_vmme..module-0'; + const vfModuleModel = generateServiceHierarchy().vnfs['VF_vMee 0'].vfModules['vf_vmee0..VfVmee..base_vmme..module-0']; + const newVfModule = service.createNewVfModuleTreeNode(<any>{ + instanceName: "", + instanceParams: {}, + volumeGroupName: "", + isMissingData : false, + trackById: Math.random().toString() + }, vfModuleModel, vnfModuleUUID, true, [], ""); + expect(newVfModule.name).toEqual('<Automatically Assigned>'); + expect(newVfModule.missingData).toEqual(false); + }); + }); + + describe('#createNewVnfTreeNode', () => { + test('createNewVnfTreeNode with isEcompGeneratedNaming instance name not filled - missing data true', () => { + const vnfModel = generateServiceHierarchy().vnfs['VF_vMee 0']; + const newVnf = service.createNewTreeNode({ + uuid : '', + instanceName: "", + productFamilyId: "productFamilyId", + lcpCloudRegionId: "lcpCloudRegionId", + legacyRegion: "legacyRegion", + tenantId: "tenantId", + platformName: "platformName", + lineOfBusiness: "lineOfBusiness", + rollbackOnFailure: "rollbackOnFailure", + originalName : null, + vfModules: {}, + isMissingData: false, + trackById: Math.random().toString(), + vnfStoreKey: "abc" + }, new VNFModel(vnfModel),'VF_vMee 0', 'vnfs'); + expect(newVnf.name).toEqual('VF_vMee 0'); + expect(newVnf.missingData).toEqual(true); + }); + + test('createNewVnfTreeNode with isEcompGeneratedNaming instance name filled - missing data false', () => { + const vnfModel = generateServiceHierarchy().vnfs['VF_vMee 0']; + const newVnf = service.createNewTreeNode({ + uuid : '', + instanceName: "instanceName", + productFamilyId: "productFamilyId", + lcpCloudRegionId: "lcpCloudRegionId", + legacyRegion: "legacyRegion", + tenantId: "tenantId", + platformName: "platformName", + lineOfBusiness: "lineOfBusiness", + rollbackOnFailure: "rollbackOnFailure", + originalName : null, + vfModules: {}, + isMissingData: false, + trackById: Math.random().toString(), + vnfStoreKey: "abc" + }, vnfModel,'VF_vMee 0', 'vnfs'); + expect(newVnf.name).toEqual("instanceName"); + expect(newVnf.missingData).toEqual(false); + }); }); + }); function generateServiceHierarchy() { - return JSON.parse('{"service":{"uuid":"6e59c5de-f052-46fa-aa7e-2fca9d674c44","invariantUuid":"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0","name":"ComplexService","version":"1.0","toscaModelURL":null,"category":"Mobility","serviceType":"","serviceRole":"","description":"ComplexService","serviceEcompNaming":"true","instantiationType":"Macro","inputs":{}},"vnfs":{"VF_vMee 0":{"uuid":"d6557200-ecf2-4641-8094-5393ae3aae60","invariantUuid":"4160458e-f648-4b30-a176-43881ffffe9e","description":"VSP_vMee","name":"VF_vMee","version":"2.0","customizationUuid":"91415b44-753d-494c-926a-456a9172bbb9","inputs":{},"commands":{},"properties":{"gpb2_Internal2_mac":"00:80:37:0E:02:22","sctp-b-ipv6-egress_src_start_port":"0","sctp-a-ipv6-egress_rule_application":"any","Internal2_allow_transit":"true","sctp-b-IPv6_ethertype":"IPv6","sctp-a-egress_rule_application":"any","sctp-b-ingress_action":"pass","sctp-b-ingress_rule_protocol":"icmp","ncb2_Internal1_mac":"00:80:37:0E:0F:12","sctp-b-ipv6-ingress-src_start_port":"0.0","ncb1_Internal2_mac":"00:80:37:0E:09:12","fsb_volume_size_0":"320.0","sctp-b-egress_src_addresses":"local","sctp-a-ipv6-ingress_ethertype":"IPv4","sctp-a-ipv6-ingress-dst_start_port":"0","sctp-b-ipv6-ingress_rule_application":"any","domain_name":"default-domain","sctp-a-ingress_rule_protocol":"icmp","sctp-b-egress-src_start_port":"0.0","sctp-a-egress_src_addresses":"local","sctp-b-display_name":"epc-sctp-b-ipv4v6-sec-group","sctp-a-egress-src_start_port":"0.0","sctp-a-ingress_ethertype":"IPv4","sctp-b-ipv6-ingress-dst_end_port":"65535","sctp-b-dst_subnet_prefix_v6":"::","nf_naming":"{ecomp_generated_naming=true}","sctp-a-ipv6-ingress_src_subnet_prefix":"0.0.0.0","sctp-b-egress-dst_start_port":"0.0","ncb_flavor_name":"nv.c20r64d1","gpb1_Internal1_mac":"00:80:37:0E:01:22","sctp-b-egress_dst_subnet_prefix_len":"0.0","Internal2_net_cidr":"169.255.0.0","sctp-a-ingress-dst_start_port":"0.0","sctp-a-egress-dst_start_port":"0.0","fsb1_Internal2_mac":"00:80:37:0E:0B:12","sctp-a-egress_ethertype":"IPv4","vlc_st_service_mode":"in-network-nat","sctp-a-ipv6-egress_ethertype":"IPv4","sctp-a-egress-src_end_port":"65535.0","sctp-b-ipv6-egress_rule_application":"any","sctp-b-egress_action":"pass","sctp-a-ingress-src_subnet_prefix_len":"0.0","sctp-b-ipv6-ingress-src_end_port":"65535.0","sctp-b-name":"epc-sctp-b-ipv4v6-sec-group","fsb2_Internal1_mac":"00:80:37:0E:0D:12","sctp-a-ipv6-ingress-src_start_port":"0.0","sctp-b-ipv6-egress_ethertype":"IPv4","Internal1_net_cidr":"169.253.0.0","sctp-a-egress_dst_subnet_prefix":"0.0.0.0","fsb_flavor_name":"nv.c20r64d1","sctp_rule_protocol":"132","sctp-b-ipv6-ingress_src_subnet_prefix_len":"0","sctp-a-ipv6-ingress_rule_application":"any","ecomp_generated_naming":"true","sctp-a-IPv6_ethertype":"IPv6","vlc2_Internal1_mac":"00:80:37:0E:02:12","vlc_st_virtualization_type":"virtual-machine","sctp-b-ingress-dst_start_port":"0.0","sctp-b-ingress-dst_end_port":"65535.0","sctp-a-ipv6-ingress-src_end_port":"65535.0","sctp-a-display_name":"epc-sctp-a-ipv4v6-sec-group","sctp-b-ingress_rule_application":"any","int2_sec_group_name":"int2-sec-group","vlc_flavor_name":"nd.c16r64d1","sctp-b-ipv6-egress_src_addresses":"local","vlc_st_interface_type_int1":"other1","sctp-b-egress-src_end_port":"65535.0","sctp-a-ipv6-egress-dst_start_port":"0","vlc_st_interface_type_int2":"other2","sctp-a-ipv6-egress_rule_protocol":"any","Internal2_shared":"false","sctp-a-ipv6-egress_dst_subnet_prefix_len":"0","Internal2_rpf":"disable","vlc1_Internal1_mac":"00:80:37:0E:01:12","sctp-b-ipv6-egress_src_end_port":"65535","sctp-a-ipv6-egress_src_addresses":"local","sctp-a-ingress-dst_end_port":"65535.0","sctp-a-ipv6-egress_src_end_port":"65535","Internal1_forwarding_mode":"l2","Internal2_dhcp":"false","sctp-a-dst_subnet_prefix_v6":"::","pxe_image_name":"MME_PXE-Boot_16ACP04_GA.qcow2","vlc_st_interface_type_gtp":"other0","ncb1_Internal1_mac":"00:80:37:0E:09:12","sctp-b-src_subnet_prefix_v6":"::","sctp-a-egress_dst_subnet_prefix_len":"0.0","int1_sec_group_name":"int1-sec-group","Internal1_dhcp":"false","sctp-a-ipv6-egress_dst_end_port":"65535","Internal2_forwarding_mode":"l2","fsb2_Internal2_mac":"00:80:37:0E:0D:12","sctp-b-egress_dst_subnet_prefix":"0.0.0.0","Internal1_net_cidr_len":"17","gpb2_Internal1_mac":"00:80:37:0E:02:22","sctp-b-ingress-src_subnet_prefix_len":"0.0","sctp-a-ingress_dst_addresses":"local","sctp-a-egress_action":"pass","fsb_volume_type_0":"SF-Default-SSD","ncb2_Internal2_mac":"00:80:37:0E:0F:12","vlc_st_interface_type_sctp_a":"left","vlc_st_interface_type_sctp_b":"right","sctp-a-src_subnet_prefix_v6":"::","vlc_st_version":"2","sctp-b-egress_ethertype":"IPv4","sctp-a-ingress_rule_application":"any","gpb1_Internal2_mac":"00:80:37:0E:01:22","instance_ip_family_v6":"v6","sctp-a-ipv6-egress_src_start_port":"0","sctp-b-ingress-src_start_port":"0.0","sctp-b-ingress_dst_addresses":"local","fsb1_Internal1_mac":"00:80:37:0E:0B:12","vlc_st_interface_type_oam":"management","multi_stage_design":"false","oam_sec_group_name":"oam-sec-group","Internal2_net_gateway":"169.255.0.3","sctp-a-ipv6-ingress-dst_end_port":"65535","sctp-b-ipv6-egress-dst_start_port":"0","Internal1_net_gateway":"169.253.0.3","sctp-b-ipv6-egress_rule_protocol":"any","gtp_sec_group_name":"gtp-sec-group","sctp-a-ipv6-egress_dst_subnet_prefix":"0.0.0.0","sctp-b-ipv6-egress_dst_subnet_prefix_len":"0","sctp-a-ipv6-ingress_dst_addresses":"local","sctp-a-egress_rule_protocol":"icmp","sctp-b-ipv6-egress_action":"pass","sctp-a-ipv6-egress_action":"pass","Internal1_shared":"false","sctp-b-ipv6-ingress_rule_protocol":"any","Internal2_net_cidr_len":"17","sctp-a-name":"epc-sctp-a-ipv4v6-sec-group","sctp-a-ingress-src_end_port":"65535.0","sctp-b-ipv6-ingress_src_subnet_prefix":"0.0.0.0","sctp-a-egress-dst_end_port":"65535.0","sctp-a-ingress_action":"pass","sctp-b-egress_rule_protocol":"icmp","sctp-b-ipv6-ingress_action":"pass","vlc_st_service_type":"firewall","sctp-b-ipv6-egress_dst_end_port":"65535","sctp-b-ipv6-ingress-dst_start_port":"0","vlc2_Internal2_mac":"00:80:37:0E:02:12","vlc_st_availability_zone":"true","fsb_volume_image_name_1":"MME_FSB2_16ACP04_GA.qcow2","sctp-b-ingress-src_subnet_prefix":"0.0.0.0","sctp-a-ipv6-ingress_src_subnet_prefix_len":"0","Internal1_allow_transit":"true","gpb_flavor_name":"nv.c20r64d1","availability_zone_max_count":"1","fsb_volume_image_name_0":"MME_FSB1_16ACP04_GA.qcow2","sctp-b-ipv6-ingress_dst_addresses":"local","sctp-b-ipv6-egress_dst_subnet_prefix":"0.0.0.0","sctp-b-ipv6-ingress_ethertype":"IPv4","vlc1_Internal2_mac":"00:80:37:0E:01:12","sctp-a-ingress-src_subnet_prefix":"0.0.0.0","sctp-a-ipv6-ingress_action":"pass","Internal1_rpf":"disable","sctp-b-ingress_ethertype":"IPv4","sctp-b-egress_rule_application":"any","sctp-b-ingress-src_end_port":"65535.0","sctp-a-ipv6-ingress_rule_protocol":"any","sctp-a-ingress-src_start_port":"0.0","sctp-b-egress-dst_end_port":"65535.0"},"type":"VF","modelCustomizationName":"VF_vMee 0","vfModules":{"vf_vmee0..VfVmee..vmme_vlc..module-1":{"uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830","invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b","customizationUuid":"55b1be94-671a-403e-a26c-667e9c47d091","description":null,"name":"VfVmee..vmme_vlc..module-1","version":"2","modelCustomizationName":"VfVmee..vmme_vlc..module-1","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_vlc"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..vmme_gpb..module-2":{"uuid":"41708296-e443-4c71-953f-d9a010f059e1","invariantUuid":"1cca90b8-3490-495e-87da-3f3e4c57d5b9","customizationUuid":"6add59e0-7fe1-4bc4-af48-f8812422ae7c","description":null,"name":"VfVmee..vmme_gpb..module-2","version":"2","modelCustomizationName":"VfVmee..vmme_gpb..module-2","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_gpb"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{},"volumeGroupAllowed":true}},"volumeGroups":{"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{}}},"vfcInstanceGroups":{}}},"networks":{"ExtVL 0":{"uuid":"ddc3f20c-08b5-40fd-af72-c6d14636b986","invariantUuid":"379f816b-a7aa-422f-be30-17114ff50b7c","description":"ECOMP generic virtual link (network) base type for all other service-level and global networks","name":"ExtVL","version":"37.0","customizationUuid":"94fdd893-4a36-4d70-b16a-ec29c54c184f","inputs":{},"commands":{},"properties":{"network_assignments":"{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}","exVL_naming":"{ecomp_generated_naming=true}","network_flows":"{is_network_policy=false, is_bound_to_vpn=false}","network_homing":"{ecomp_selected_instance_node_target=false}"},"type":"VL","modelCustomizationName":"ExtVL 0"}},"collectionResource":{},"configurations":{"Port Mirroring Configuration By Policy 0":{"uuid":"b4398538-e89d-4f13-b33d-ca323434ba50","invariantUuid":"6ef0ca40-f366-4897-951f-abd65d25f6f7","description":"A port mirroring configuration by policy object","name":"Port Mirroring Configuration By Policy","version":"27.0","customizationUuid":"3c3b7b8d-8669-4b3b-8664-61970041fad2","inputs":{},"commands":{},"properties":{},"type":"Configuration","modelCustomizationName":"Port Mirroring Configuration By Policy 0","sourceNodes":[],"collectorNodes":null,"configurationByPolicy":false}},"serviceProxies":{},"vfModules":{"vf_vmee0..VfVmee..vmme_vlc..module-1":{"uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830","invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b","customizationUuid":"55b1be94-671a-403e-a26c-667e9c47d091","description":null,"name":"VfVmee..vmme_vlc..module-1","version":"2","modelCustomizationName":"VfVmee..vmme_vlc..module-1","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_vlc"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..vmme_gpb..module-2":{"uuid":"41708296-e443-4c71-953f-d9a010f059e1","invariantUuid":"1cca90b8-3490-495e-87da-3f3e4c57d5b9","customizationUuid":"6add59e0-7fe1-4bc4-af48-f8812422ae7c","description":null,"name":"VfVmee..vmme_gpb..module-2","version":"2","modelCustomizationName":"VfVmee..vmme_gpb..module-2","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_gpb"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{},"volumeGroupAllowed":true}},"volumeGroups":{"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{}}},"pnfs":{}}'); + return JSON.parse('{"service":{"uuid":"6e59c5de-f052-46fa-aa7e-2fca9d674c44","invariantUuid":"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0","name":"ComplexService","version":"1.0","toscaModelURL":null,"category":"Emanuel","serviceType":"","serviceRole":"","description":"ComplexService","serviceEcompNaming":"true","instantiationType":"Macro","inputs":{}},"vnfs":{"VF_vMee 0":{"uuid":"d6557200-ecf2-4641-8094-5393ae3aae60","invariantUuid":"4160458e-f648-4b30-a176-43881ffffe9e","description":"VSP_vMee","name":"VF_vMee","version":"2.0","customizationUuid":"91415b44-753d-494c-926a-456a9172bbb9","inputs":{},"commands":{},"properties":{"gpb2_Internal2_mac":"00:11:22:EF:AC:DF","sctp-b-ipv6-egress_src_start_port":"0","sctp-a-ipv6-egress_rule_application":"any","Internal2_allow_transit":"true","sctp-b-IPv6_ethertype":"IPv6","sctp-a-egress_rule_application":"any","sctp-b-ingress_action":"pass","sctp-b-ingress_rule_protocol":"icmp","ncb2_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-ipv6-ingress-src_start_port":"0.0","ncb1_Internal2_mac":"00:11:22:EF:AC:DF","fsb_volume_size_0":"320.0","sctp-b-egress_src_addresses":"local","sctp-a-ipv6-ingress_ethertype":"IPv4","sctp-a-ipv6-ingress-dst_start_port":"0","sctp-b-ipv6-ingress_rule_application":"any","domain_name":"default-domain","sctp-a-ingress_rule_protocol":"icmp","sctp-b-egress-src_start_port":"0.0","sctp-a-egress_src_addresses":"local","sctp-b-display_name":"epc-sctp-b-ipv4v6-sec-group","sctp-a-egress-src_start_port":"0.0","sctp-a-ingress_ethertype":"IPv4","sctp-b-ipv6-ingress-dst_end_port":"65535","sctp-b-dst_subnet_prefix_v6":"::","nf_naming":"{ecomp_generated_naming=true}","sctp-a-ipv6-ingress_src_subnet_prefix":"0.0.0.0","sctp-b-egress-dst_start_port":"0.0","ncb_flavor_name":"nv.c20r64d1","gpb1_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-egress_dst_subnet_prefix_len":"0.0","Internal2_net_cidr":"10.0.0.10","sctp-a-ingress-dst_start_port":"0.0","sctp-a-egress-dst_start_port":"0.0","fsb1_Internal2_mac":"00:11:22:EF:AC:DF","sctp-a-egress_ethertype":"IPv4","vlc_st_service_mode":"in-network-nat","sctp-a-ipv6-egress_ethertype":"IPv4","sctp-a-egress-src_end_port":"65535.0","sctp-b-ipv6-egress_rule_application":"any","sctp-b-egress_action":"pass","sctp-a-ingress-src_subnet_prefix_len":"0.0","sctp-b-ipv6-ingress-src_end_port":"65535.0","sctp-b-name":"epc-sctp-b-ipv4v6-sec-group","fsb2_Internal1_mac":"00:11:22:EF:AC:DF","sctp-a-ipv6-ingress-src_start_port":"0.0","sctp-b-ipv6-egress_ethertype":"IPv4","Internal1_net_cidr":"10.0.0.10","sctp-a-egress_dst_subnet_prefix":"0.0.0.0","fsb_flavor_name":"nv.c20r64d1","sctp_rule_protocol":"132","sctp-b-ipv6-ingress_src_subnet_prefix_len":"0","sctp-a-ipv6-ingress_rule_application":"any","ecomp_generated_naming":"false","sctp-a-IPv6_ethertype":"IPv6","vlc2_Internal1_mac":"00:11:22:EF:AC:DF","vlc_st_virtualization_type":"virtual-machine","sctp-b-ingress-dst_start_port":"0.0","sctp-b-ingress-dst_end_port":"65535.0","sctp-a-ipv6-ingress-src_end_port":"65535.0","sctp-a-display_name":"epc-sctp-a-ipv4v6-sec-group","sctp-b-ingress_rule_application":"any","int2_sec_group_name":"int2-sec-group","vlc_flavor_name":"nd.c16r64d1","sctp-b-ipv6-egress_src_addresses":"local","vlc_st_interface_type_int1":"other1","sctp-b-egress-src_end_port":"65535.0","sctp-a-ipv6-egress-dst_start_port":"0","vlc_st_interface_type_int2":"other2","sctp-a-ipv6-egress_rule_protocol":"any","Internal2_shared":"false","sctp-a-ipv6-egress_dst_subnet_prefix_len":"0","Internal2_rpf":"disable","vlc1_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-ipv6-egress_src_end_port":"65535","sctp-a-ipv6-egress_src_addresses":"local","sctp-a-ingress-dst_end_port":"65535.0","sctp-a-ipv6-egress_src_end_port":"65535","Internal1_forwarding_mode":"l2","Internal2_dhcp":"false","sctp-a-dst_subnet_prefix_v6":"::","pxe_image_name":"MME_PXE-Boot_16ACP04_GA.qcow2","vlc_st_interface_type_gtp":"other0","ncb1_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-src_subnet_prefix_v6":"::","sctp-a-egress_dst_subnet_prefix_len":"0.0","int1_sec_group_name":"int1-sec-group","Internal1_dhcp":"false","sctp-a-ipv6-egress_dst_end_port":"65535","Internal2_forwarding_mode":"l2","fsb2_Internal2_mac":"00:11:22:EF:AC:DF","sctp-b-egress_dst_subnet_prefix":"0.0.0.0","Internal1_net_cidr_len":"17","gpb2_Internal1_mac":"00:11:22:EF:AC:DF","sctp-b-ingress-src_subnet_prefix_len":"0.0","sctp-a-ingress_dst_addresses":"local","sctp-a-egress_action":"pass","fsb_volume_type_0":"SF-Default-SSD","ncb2_Internal2_mac":"00:11:22:EF:AC:DF","vlc_st_interface_type_sctp_a":"left","vlc_st_interface_type_sctp_b":"right","sctp-a-src_subnet_prefix_v6":"::","vlc_st_version":"2","sctp-b-egress_ethertype":"IPv4","sctp-a-ingress_rule_application":"any","gpb1_Internal2_mac":"00:11:22:EF:AC:DF","instance_ip_family_v6":"v6","sctp-a-ipv6-egress_src_start_port":"0","sctp-b-ingress-src_start_port":"0.0","sctp-b-ingress_dst_addresses":"local","fsb1_Internal1_mac":"00:11:22:EF:AC:DF","vlc_st_interface_type_oam":"management","multi_stage_design":"false","oam_sec_group_name":"oam-sec-group","Internal2_net_gateway":"10.0.0.10","sctp-a-ipv6-ingress-dst_end_port":"65535","sctp-b-ipv6-egress-dst_start_port":"0","Internal1_net_gateway":"10.0.0.10","sctp-b-ipv6-egress_rule_protocol":"any","gtp_sec_group_name":"gtp-sec-group","sctp-a-ipv6-egress_dst_subnet_prefix":"0.0.0.0","sctp-b-ipv6-egress_dst_subnet_prefix_len":"0","sctp-a-ipv6-ingress_dst_addresses":"local","sctp-a-egress_rule_protocol":"icmp","sctp-b-ipv6-egress_action":"pass","sctp-a-ipv6-egress_action":"pass","Internal1_shared":"false","sctp-b-ipv6-ingress_rule_protocol":"any","Internal2_net_cidr_len":"17","sctp-a-name":"epc-sctp-a-ipv4v6-sec-group","sctp-a-ingress-src_end_port":"65535.0","sctp-b-ipv6-ingress_src_subnet_prefix":"0.0.0.0","sctp-a-egress-dst_end_port":"65535.0","sctp-a-ingress_action":"pass","sctp-b-egress_rule_protocol":"icmp","sctp-b-ipv6-ingress_action":"pass","vlc_st_service_type":"firewall","sctp-b-ipv6-egress_dst_end_port":"65535","sctp-b-ipv6-ingress-dst_start_port":"0","vlc2_Internal2_mac":"00:11:22:EF:AC:DF","vlc_st_availability_zone":"true","fsb_volume_image_name_1":"MME_FSB2_16ACP04_GA.qcow2","sctp-b-ingress-src_subnet_prefix":"0.0.0.0","sctp-a-ipv6-ingress_src_subnet_prefix_len":"0","Internal1_allow_transit":"true","gpb_flavor_name":"nv.c20r64d1","availability_zone_max_count":"1","fsb_volume_image_name_0":"MME_FSB1_16ACP04_GA.qcow2","sctp-b-ipv6-ingress_dst_addresses":"local","sctp-b-ipv6-egress_dst_subnet_prefix":"0.0.0.0","sctp-b-ipv6-ingress_ethertype":"IPv4","vlc1_Internal2_mac":"00:11:22:EF:AC:DF","sctp-a-ingress-src_subnet_prefix":"0.0.0.0","sctp-a-ipv6-ingress_action":"pass","Internal1_rpf":"disable","sctp-b-ingress_ethertype":"IPv4","sctp-b-egress_rule_application":"any","sctp-b-ingress-src_end_port":"65535.0","sctp-a-ipv6-ingress_rule_protocol":"any","sctp-a-ingress-src_start_port":"0.0","sctp-b-egress-dst_end_port":"65535.0"},"type":"VF","modelCustomizationName":"VF_vMee 0","vfModules":{"vf_vmee0..VfVmee..vmme_vlc..module-1":{"uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830","invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b","customizationUuid":"55b1be94-671a-403e-a26c-667e9c47d091","description":null,"name":"VfVmee..vmme_vlc..module-1","version":"2","modelCustomizationName":"VfVmee..vmme_vlc..module-1","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_vlc"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..vmme_gpb..module-2":{"uuid":"41708296-e443-4c71-953f-d9a010f059e1","invariantUuid":"1cca90b8-3490-495e-87da-3f3e4c57d5b9","customizationUuid":"6add59e0-7fe1-4bc4-af48-f8812422ae7c","description":null,"name":"VfVmee..vmme_gpb..module-2","version":"2","modelCustomizationName":"VfVmee..vmme_gpb..module-2","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_gpb"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{},"volumeGroupAllowed":true}},"volumeGroups":{"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{}}},"vfcInstanceGroups":{}}},"networks":{"ExtVL 0":{"uuid":"ddc3f20c-08b5-40fd-af72-c6d14636b986","invariantUuid":"379f816b-a7aa-422f-be30-17114ff50b7c","description":"ECOMP generic virtual link (network) base type for all other service-level and global networks","name":"ExtVL","version":"37.0","customizationUuid":"94fdd893-4a36-4d70-b16a-ec29c54c184f","inputs":{},"commands":{},"properties":{"network_assignments":"{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}","exVL_naming":"{ecomp_generated_naming=true}","network_flows":"{is_network_policy=false, is_bound_to_vpn=false}","network_homing":"{ecomp_selected_instance_node_target=false}"},"type":"VL","modelCustomizationName":"ExtVL 0"}},"collectionResource":{},"configurations":{"Port Mirroring Configuration By Policy 0":{"uuid":"b4398538-e89d-4f13-b33d-ca323434ba50","invariantUuid":"6ef0ca40-f366-4897-951f-abd65d25f6f7","description":"A port mirroring configuration by policy object","name":"Port Mirroring Configuration By Policy","version":"27.0","customizationUuid":"3c3b7b8d-8669-4b3b-8664-61970041fad2","inputs":{},"commands":{},"properties":{},"type":"Configuration","modelCustomizationName":"Port Mirroring Configuration By Policy 0","sourceNodes":[],"collectorNodes":null,"configurationByPolicy":false}},"serviceProxies":{},"vfModules":{"vf_vmee0..VfVmee..vmme_vlc..module-1":{"uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830","invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b","customizationUuid":"55b1be94-671a-403e-a26c-667e9c47d091","description":null,"name":"VfVmee..vmme_vlc..module-1","version":"2","modelCustomizationName":"VfVmee..vmme_vlc..module-1","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_vlc"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..vmme_gpb..module-2":{"uuid":"41708296-e443-4c71-953f-d9a010f059e1","invariantUuid":"1cca90b8-3490-495e-87da-3f3e4c57d5b9","customizationUuid":"6add59e0-7fe1-4bc4-af48-f8812422ae7c","description":null,"name":"VfVmee..vmme_gpb..module-2","version":"2","modelCustomizationName":"VfVmee..vmme_gpb..module-2","properties":{"minCountInstances":0,"maxCountInstances":null,"initialCount":0,"vfModuleLabel":"vmme_gpb"},"inputs":{},"volumeGroupAllowed":false},"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{},"volumeGroupAllowed":true}},"volumeGroups":{"vf_vmee0..VfVmee..base_vmme..module-0":{"uuid":"a27f5cfc-7f12-4f99-af08-0af9c3885c87","invariantUuid":"a6f9e51a-2b35-416a-ae15-15e58d61f36d","customizationUuid":"f8c040f1-7e51-4a11-aca8-acf256cfd861","description":null,"name":"VfVmee..base_vmme..module-0","version":"2","modelCustomizationName":"VfVmee..base_vmme..module-0","properties":{"minCountInstances":1,"maxCountInstances":1,"initialCount":1,"vfModuleLabel":"base_vmme"},"inputs":{}}},"pnfs":{}}'); } function generateVNFFormValues() { - return JSON.parse('{"globalSubscriberId":"e433710f-9217-458d-a79d-1c7aff376d89","productFamilyId":"vRRaaS","subscriptionServiceType":"VIRTUAL USP","lcpCloudRegionId":"mtn6","tenantId":"1178612d2b394be4834ad77f567c0af2","aicZoneId":"JAG1","projectName":"DFW","owningEntityId":"d61e6f2d-12fa-4cc2-91df-7c244011d6fc","rollbackOnFailure":"true","bulkSize":1,"instanceParams":[{}],"modelInfo":{"modelInvariantId":"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0","modelVersionId":"6e59c5de-f052-46fa-aa7e-2fca9d674c44","modelName":"ComplexService","modelVersion":"1.0"},"isUserProvidedNaming":false,"tenantName":"AIN Web Tool-15-D-SSPtestcustome","aicZoneName":"YUDFJULP-JAG1"}'); + return JSON.parse('{"globalSubscriberId":"e433710f-9217-458d-a79d-1c7aff376d89","productFamilyId":"vTerrance","subscriptionServiceType":"TYLER SILVIA","lcpCloudRegionId":"hvf6","tenantId":"1178612d2b394be4834ad77f567c0af2","aicZoneId":"JAG1","projectName":"WATKINS","owningEntityId":"d61e6f2d-12fa-4cc2-91df-7c244011d6fc","rollbackOnFailure":"true","bulkSize":1,"instanceParams":[{}],"modelInfo":{"modelInvariantId":"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0","modelVersionId":"6e59c5de-f052-46fa-aa7e-2fca9d674c44","modelName":"ComplexService","modelVersion":"1.0"},"tenantName":"AIN Web Tool-15-D-SSPtestcustome","aicZoneName":"YUDFJULP-JAG1"}'); +} + +function generateVFModule() { + return { + 'uuid': '25284168-24bb-4698-8cb4-3f509146eca5', + 'invariantUuid': '7253ff5c-97f0-4b8b-937c-77aeb4d79aa1', + 'customizationUuid': 'f7e7c365-60cf-49a9-9ebf-a1aa11b9d401', + 'description': null, + 'name': '2017488AdiodVpe..ADIOD_vRE_BV..module-1', + 'version': '6', + 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vRE_BV..module-1', + 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0}, + 'commands': {}, + 'volumeGroupAllowed': true, + 'inputs': { + '2017488_adiodvpe0_vnf_config_template_version': { + 'type': 'string', + 'description': 'VPE Software Version', + 'entry_schema': null, + 'constraints': [], + 'required': true, + 'default': '17.2' + }, + '2017488_adiodvpe0_AIC_CLLI': { + 'type': 'string', + 'description': 'AIC Site CLLI', + 'entry_schema': null, + 'constraints': [], + 'required': true, + 'default': 'ATLMY8GA' + } + } + }; +} + +function generateVFModule2() { + return { + 'uuid': '0a0dd9d4-31d3-4c3a-ae89-a02f383e6a9a', + 'invariantUuid': 'eff8cc59-53a1-4101-aed7-8cf24ecf8339', + 'customizationUuid': '3cd946bb-50e0-40d8-96d3-c9023520b557', + 'description': null, + 'name': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2', + 'version': '6', + 'modelCustomizationName': '2017488AdiodVpe..ADIOD_vPFE_BV..module-2', + 'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0}, + 'commands': {}, + 'volumeGroupAllowed': true, + 'inputs': {} + }; +} + +function generateVNF() { + return { + 'uuid': '0903e1c0-8e03-4936-b5c2-260653b96413', + 'invariantUuid': '00beb8f9-6d39-452f-816d-c709b9cbb87d', + 'description': 'Name ADIOD vPE Description The provider edge function for the ADIOD service supported by the Junipers VMX product Category Router Vendor Juniper Vendor Release Code 17.2 Owners Mary Fragale. Updated 9-25 to use v8.0 of the Juniper Valid 2 VLM', + 'name': '2017-388_ADIOD-vPE', + 'version': '1.0', + 'customizationUuid': '280dec31-f16d-488b-9668-4aae55d6648a', + 'inputs': { + 'vnf_config_template_version': { + 'type': 'string', + 'description': 'VPE Software Version', + 'entry_schema': null, + 'constraints': [], + 'required': true, + 'default': '17.2' + }, + 'bandwidth_units': { + 'type': 'string', + 'description': 'Units of bandwidth', + 'entry_schema': null, + 'constraints': [], + 'required': true, + 'default': 'Gbps' + }, + 'bandwidth': { + 'type': 'string', + 'description': 'Requested VPE bandwidth', + 'entry_schema': null, + 'constraints': [], + 'required': true, + 'default': '10' + }, + 'AIC_CLLI': { + 'type': 'string', + 'description': 'AIC Site CLLI', + 'entry_schema': null, + 'constraints': [], + 'required': true, + 'default': 'ATLMY8GA' + }, + 'ASN': { + 'type': 'string', + 'description': 'AV/PE', + 'entry_schema': null, + 'constraints': [], + 'required': true, + 'default': 'AV_vPE' + }, + 'vnf_instance_name': { + 'type': 'string', + 'description': 'The hostname assigned to the vpe.', + 'entry_schema': null, + 'constraints': [], + 'required': true, + 'default': 'mtnj309me6' + } + }, + 'commands': { + 'vnf_config_template_version': { + 'displayName': 'vnf_config_template_version', + 'command': 'get_input', + 'inputName': '2017488_adiodvpe0_vnf_config_template_version' + }, + 'bandwidth_units': { + 'displayName': 'bandwidth_units', + 'command': 'get_input', + 'inputName': 'adiodvpe0_bandwidth_units' + }, + 'bandwidth': {'displayName': 'bandwidth', 'command': 'get_input', 'inputName': 'adiodvpe0_bandwidth'}, + 'AIC_CLLI': {'displayName': 'AIC_CLLI', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_AIC_CLLI'}, + 'ASN': {'displayName': 'ASN', 'command': 'get_input', 'inputName': '2017488_adiodvpe0_ASN'}, + 'vnf_instance_name': { + 'displayName': 'vnf_instance_name', + 'command': 'get_input', + 'inputName': '2017488_adiodvpe0_vnf_instance_name' + } + }, + 'properties': { + 'vmxvre_retype': 'RE-VMX', + 'vnf_config_template_version': 'get_input:2017488_adiodvpe0_vnf_config_template_version', + 'sriov44_net_id': '48d399b3-11ee-48a8-94d2-f0ea94d6be8d', + 'int_ctl_net_id': '2f323477-6936-4d01-ac53-d849430281d9', + 'vmxvpfe_sriov41_0_port_mac': '00:11:22:EF:AC:DF', + 'int_ctl_net_name': 'VMX-INTXI', + 'vmx_int_ctl_prefix': '10.0.0.10', + 'sriov43_net_id': 'da349ca1-6de9-4548-be88-2d88e99bfef5', + 'sriov42_net_id': '760669ba-013d-4d9b-b0e7-4151fe2e6279', + 'sriov41_net_id': '25ad52d5-c165-40f8-b3b0-ddfc2373280a', + 'nf_type': 'vPE', + 'vmxvpfe_int_ctl_ip_1': '10.0.0.10', + 'is_AVPN_service': 'false', + 'vmx_RSG_name': 'vREXI-affinity', + 'vmx_int_ctl_forwarding': 'l2', + 'vmxvre_oam_ip_0': '10.0.0.10', + 'vmxvpfe_sriov44_0_port_mac': '00:11:22:EF:AC:DF', + 'vmxvpfe_sriov41_0_port_vlanstrip': 'false', + 'vmxvpfe_sriov42_0_port_vlanfilter': '4001', + 'vmxvpfe_sriov44_0_port_unknownunicastallow': 'true', + 'vmxvre_image_name_0': 'VRE-ENGINE_17.2-S2.1.qcow2', + 'vmxvre_instance': '0', + 'vmxvpfe_sriov43_0_port_mac': '00:11:22:EF:AC:DF', + 'vmxvre_flavor_name': 'ns.c1r16d32.v5', + 'vmxvpfe_volume_size_0': '40.0', + 'vmxvpfe_sriov43_0_port_vlanfilter': '4001', + 'nf_naming': '{ecomp_generated_naming=true}', + 'nf_naming_code': 'Navneet', + 'vmxvre_name_0': 'vREXI', + 'vmxvpfe_sriov42_0_port_vlanstrip': 'false', + 'vmxvpfe_volume_name_0': 'vPFEXI_FBVolume', + 'vmx_RSG_id': 'bd89a33c-13c3-4a04-8fde-1a57eb123141', + 'vmxvpfe_image_name_0': 'VPE_ROUTING-ENGINE_17.2R1-S2.1.qcow2', + 'vmxvpfe_sriov43_0_port_unknownunicastallow': 'true', + 'vmxvpfe_sriov44_0_port_unknownmulticastallow': 'true', + 'vmxvre_console': 'vidconsole', + 'vmxvpfe_sriov44_0_port_vlanfilter': '4001', + 'vmxvpfe_sriov42_0_port_mac': '00:11:22:EF:AC:DF', + 'vmxvpfe_volume_id_0': '47cede15-da2f-4397-a101-aa683220aff3', + 'vmxvpfe_sriov42_0_port_unknownmulticastallow': 'true', + 'vmxvpfe_sriov44_0_port_vlanstrip': 'false', + 'vf_module_id': '123', + 'nf_function': 'JAI', + 'vmxvpfe_sriov43_0_port_unknownmulticastallow': 'true', + 'vmxvre_int_ctl_ip_0': '10.0.0.10', + 'AIC_CLLI': 'get_input:2017488_adiodvpe0_AIC_CLLI', + 'vnf_name': 'mtnj309me6vre', + 'vmxvpfe_sriov41_0_port_unknownunicastallow': 'true', + 'vmxvre_volume_type_1': 'HITACHI', + 'vmxvpfe_sriov44_0_port_broadcastallow': 'true', + 'vmxvre_volume_type_0': 'HITACHI', + 'vmxvpfe_volume_type_0': 'HITACHI', + 'vmxvpfe_sriov43_0_port_broadcastallow': 'true', + 'bandwidth_units': 'get_input:adiodvpe0_bandwidth_units', + 'vnf_id': '123', + 'vmxvre_oam_prefix': '24', + 'availability_zone_0': 'mtpocfo-kvm-az01', + 'ASN': 'get_input:2017488_adiodvpe0_ASN', + 'vmxvre_chassis_i2cid': '161', + 'vmxvpfe_name_0': 'vPFEXI', + 'bandwidth': 'get_input:adiodvpe0_bandwidth', + 'availability_zone_max_count': '1', + 'vmxvre_volume_size_0': '45.0', + 'vmxvre_volume_size_1': '50.0', + 'vmxvpfe_sriov42_0_port_broadcastallow': 'true', + 'vmxvre_oam_gateway': '10.0.0.10', + 'vmxvre_volume_name_1': 'vREXI_FAVolume', + 'vmxvre_ore_present': '0', + 'vmxvre_volume_name_0': 'vREXI_FBVolume', + 'vmxvre_type': '0', + 'vnf_instance_name': 'get_input:2017488_adiodvpe0_vnf_instance_name', + 'vmxvpfe_sriov41_0_port_unknownmulticastallow': 'true', + 'oam_net_id': 'b95eeb1d-d55d-4827-abb4-8ebb94941429', + 'vmx_int_ctl_len': '24', + 'vmxvpfe_sriov43_0_port_vlanstrip': 'false', + 'vmxvpfe_sriov41_0_port_broadcastallow': 'true', + 'vmxvre_volume_id_1': '6e86797e-03cd-4fdc-ba72-2957119c746d', + 'vmxvpfe_sriov41_0_port_vlanfilter': '4001', + 'nf_role': 'Testing', + 'vmxvre_volume_id_0': 'f4eacb79-f687-4e9d-b760-21847c8bb15a', + 'vmxvpfe_sriov42_0_port_unknownunicastallow': 'true', + 'vmxvpfe_flavor_name': 'ns.c20r16d25.v5' + }, + 'type': 'VF', + 'modelCustomizationName': '2017-388_ADIOD-vPE 1', + 'vfModules': {}, + 'volumeGroups': {} + }; } diff --git a/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts b/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts index b1e676fc5..b0baa82ec 100644 --- a/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts +++ b/vid-webpack-master/src/app/shared/services/defaultDataServiceGenerator/default.data.generator.service.ts @@ -1,67 +1,355 @@ -import { Injectable } from '@angular/core'; +import {Injectable} from '@angular/core'; import * as _ from 'lodash'; -import { createVFModuleInstance, updateVNFInstance } from '../../../service.actions'; -import { NgRedux } from '@angular-redux/store'; -import { AppState } from '../../../store/reducers'; + +import {NgRedux} from '@angular-redux/store'; +import {AppState} from '../../store/reducers'; +import {VnfTreeNode} from "../../models/vnfTreeNode"; +import {VfModuleInstance} from "../../models/vfModuleInstance"; +import {VfModule} from "../../models/vfModule"; +import {VfModuleTreeNode} from "../../models/vfModuleTreeNode"; +import {InputType} from "../../models/inputTypes"; +import {ServiceNodeTypes} from "../../models/ServiceNodeTypes"; +import {Constants} from "../../utils/constants"; +import {Utils} from "../../utils/utils"; +import {NetworkTreeNode} from "../../models/networkTreeNode"; +import {createVNFInstance} from "../../storeUtil/utils/vnf/vnf.actions"; +import {changeInstanceCounter} from "../../storeUtil/utils/general/general.actions"; +import {createNetworkInstance} from "../../storeUtil/utils/network/network.actions"; +import {createVFModuleInstance} from "../../storeUtil/utils/vfModule/vfModule.actions"; +import {createVnfGroupInstance} from "../../storeUtil/utils/vnfGroup/vnfGroup.actions"; +import {VnfGroupTreeNode} from "../../models/vnfGroupTreeNode"; +import {ModelInfo} from "../../models/modelInfo"; +import {ServiceInstanceActions} from "../../models/serviceInstanceActions"; +import Parameter = Constants.Parameter; @Injectable() export class DefaultDataGeneratorService { static controlsFieldsStatus = {}; + public requiredFields = { + VF: [InputType.LCP_REGION, InputType.TENANT, InputType.PLATFORM], + Network: [InputType.LCP_REGION, InputType.TENANT, InputType.PLATFORM], + VL: [InputType.LCP_REGION, InputType.TENANT, InputType.PLATFORM], + VFmodule: [], + VnfGroup: [] + }; + + constructor(private store: NgRedux<AppState>) { + } + + public getArbitraryInputs(inputs) { + let parameter; + let parameterList = []; + for (let key in inputs) { + parameter = { + id: key, + type: Parameter.STRING, + name: key, + value: inputs[key][Parameter.DEFAULT], + isRequired: inputs[key][Parameter.REQUIRED], + description: inputs[key][Parameter.DESCRIPTION] + }; + switch (inputs[key][Parameter.TYPE]) { + case Parameter.INTEGER: + parameter.type = Parameter.NUMBER; + break; + case Parameter.BOOLEAN: + parameter.type = Parameter.BOOLEAN; + break; + case Parameter.RANGE: + break; + case Parameter.LIST: + parameter.type = Parameter.LIST; + break; + case Parameter.MAP: + parameter.type = Parameter.MAP; + break; + } + if (Utils.hasContents(inputs[key][Parameter.CONSTRAINTS]) + && ( inputs[key][Parameter.CONSTRAINTS].length > 0 )) { + let constraintsArray = inputs[key][Parameter.CONSTRAINTS]; + this.addConstraintParameters(parameterList, constraintsArray, key, inputs, parameter); + } + else { + + parameterList.push(parameter); + } + } + return parameterList; + } + + private addConstraintParameters(parameterList, constraintsArray, key, inputs, parameter) { + // If there are constraints and the operator is "valid_values", + // use a select parameter type. + let i: number = constraintsArray.length; + let parameterPushed: boolean = false; + if (i > 0) { + while ((i--) && (!parameterPushed)) { + let keys = Object.keys(constraintsArray[i]); + for (let operator in keys) { + switch (keys[operator]) { + case Parameter.VALID_VALUES: + let j: number = constraintsArray[i][Parameter.VALID_VALUES].length; + if (j > 0) { + let oList = []; + let option; + while (j--) { + option = { + name: constraintsArray[i][Parameter.VALID_VALUES][j], + isDefault: false + }; + if ((Utils.hasContents(inputs[key][Parameter.DEFAULT]) ) + && (inputs[key][Parameter.DEFAULT] === constraintsArray[i][Parameter.VALID_VALUES][j] )) { + option = { + name: constraintsArray[i][Parameter.VALID_VALUES][j], + isDefault: true + } + } + oList.push(option); + } + parameter.type = Parameter.SELECT; + parameter.optionList = oList; + parameterList.push(parameter); + parameterPushed = true; + } + break; + + case Parameter.EQUAL: + if (constraintsArray[i][Parameter.EQUAL] != null) { + parameter.type = Parameter.STRING; + parameter.isReadOnly = true; + parameter.value = constraintsArray[i][Parameter.EQUAL]; + parameterList.push(parameter); + parameterPushed = true; + } + break; + + case Parameter.LENGTH: + if (constraintsArray[i][Parameter.LENGTH] != null) { + parameter.minLength = constraintsArray[i][Parameter.LENGTH]; + parameter.maxLength = constraintsArray[i][Parameter.LENGTH]; + parameterList.push(parameter); + parameterPushed = true; + } + break; + case Parameter.MAX_LENGTH: + if (constraintsArray[i][Parameter.MAX_LENGTH] != null) { + parameter.maxLength = constraintsArray[i][Parameter.MAX_LENGTH]; + parameterList.push(parameter); + parameterPushed = true; + } + break; + case Parameter.MIN_LENGTH: + if (constraintsArray[i][Parameter.MIN_LENGTH] != null) { + parameter.minLength = constraintsArray[i][Parameter.MIN_LENGTH]; + parameterList.push(parameter); + parameterPushed = true; + } + break; + case Parameter.IN_RANGE: + if (constraintsArray[i][Parameter.IN_RANGE] != null) { + if (constraintsArray[i][Parameter.IN_RANGE].length > 1) { + parameter.min = constraintsArray[i][Parameter.IN_RANGE][0]; + parameter.max = constraintsArray[i][Parameter.IN_RANGE][1]; + parameter.type = Parameter.NUMBER; + parameter.value = inputs[key][Parameter.DEFAULT]; + parameterList.push(parameter); + parameterPushed = true; + } + } + break; + case Parameter.GREATER_THAN: + if (constraintsArray[i][Parameter.GREATER_THAN] != null) { + parameter.type = Parameter.NUMBER; + parameter.min = constraintsArray[i][Parameter.GREATER_THAN]; + parameter.value = inputs[key][Parameter.DEFAULT]; + parameterList.push(parameter); + parameterPushed = true; + } + break; + } + } + } + } + }; + + updateDynamicInputsVnfDataFromModel(modelType: string, model: any): any[] { + let displayInputs; + if (modelType === ServiceNodeTypes.VFmodule) { + displayInputs = model.inputs; + } + return _.isEmpty(displayInputs) ? [] : this.getArbitraryInputs(displayInputs); + } + + updateNetworksOnFirstSet(serviceId: string, formServiceValues: any){ + const serviceHierarchy = this.store.getState().service.serviceHierarchy[serviceId]; + if (serviceHierarchy && !_.isEmpty(serviceHierarchy.networks)) { + for (let networkUUID in serviceHierarchy.networks) { + const isEcompGeneratedNaming = this.getIsEcompGeneratedNaming(serviceHierarchy.networks[networkUUID]); + let min_vnf_instances_greater_than_0 = serviceHierarchy.networks[networkUUID].properties['min_instances'] && serviceHierarchy.networks[networkUUID].properties['min_instances'] > 0; + if(this.store.getState().global.flags['FLAG_DEFAULT_VNF'] && min_vnf_instances_greater_than_0) + { + this.createNetworkInstanceReduxIfNotExist( + serviceId, + this.generateNetworkData(serviceHierarchy, networkUUID, formServiceValues, isEcompGeneratedNaming) + ); + } + } + } + } - constructor(private store: NgRedux<AppState>) { } + updateVnfGroupsOnFirstSet(serviceId: string, formServiceValues: any){ + const serviceHierarchy = this.store.getState().service.serviceHierarchy[serviceId]; + if (serviceHierarchy && !_.isEmpty(serviceHierarchy.vnfGroups)) { + for (let vnfGroupUUID in serviceHierarchy.vnfGroups) { + const isEcompGeneratedNaming = this.getIsEcompGeneratedNaming(serviceHierarchy.vnfGroups[vnfGroupUUID]); + let min_vnf_group_instances_greater_than_0 = serviceHierarchy.vnfGroups[vnfGroupUUID].properties['min_instances'] && serviceHierarchy.vnfGroups[vnfGroupUUID].properties['min_instances'] > 0; + if(this.store.getState().global.flags['FLAG_DEFAULT_VNF'] && min_vnf_group_instances_greater_than_0) + { + this.createVnfGroupInstanceReduxIfNotExist( + serviceId, + this.generateVnfGroupData(serviceHierarchy, vnfGroupUUID, formServiceValues, isEcompGeneratedNaming) + ); + } + } + } + } updateReduxOnFirstSet(serviceId: string, formServiceValues: any): void { + this.updateNetworksOnFirstSet(serviceId, formServiceValues); + this.updateVnfGroupsOnFirstSet(serviceId, formServiceValues); const serviceHierarchy = this.store.getState().service.serviceHierarchy[serviceId]; if (serviceHierarchy && !_.isEmpty(serviceHierarchy.vnfs)) { for (let vnfUUID in serviceHierarchy.vnfs) { + const isEcompGeneratedNaming = this.getIsEcompGeneratedNaming(serviceHierarchy.vnfs[vnfUUID]); for (let vnfModuleUUID in serviceHierarchy.vnfs[vnfUUID].vfModules) { - if (serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].properties.minCountInstances > 0) { - - let vfModule = this.generateVFModule(serviceHierarchy, vnfUUID, vnfModuleUUID); - this.updateVNFInstanceRedux( - serviceHierarchy.vnfs[vnfUUID].modelName, - serviceId, - serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].properties.initialCount, - vfModule, - this.generateVNFData(serviceHierarchy, vnfUUID, vnfModuleUUID, formServiceValues), - vnfModuleUUID - ); + const vfModuleModel = serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID]; + if (vfModuleModel.properties.minCountInstances > 0) { + let vfModule = this.generateVFModule(vfModuleModel, this.updateDynamicInputsVnfDataFromModel(ServiceNodeTypes.VFmodule, vfModuleModel), isEcompGeneratedNaming, formServiceValues.isALaCarte); + if (vfModuleModel.properties.initialCount > 0) { + this.createVNFInstanceReduxIfNotExist( + serviceId, + this.generateVNFData(serviceHierarchy, vnfUUID, formServiceValues, isEcompGeneratedNaming) + ); + + this.addDefaultVfModulesInRedux( + serviceId, + vfModuleModel.properties.initialCount, + vfModule, + vnfModuleUUID, + vnfUUID + ) + + } } } + + let min_vnf_instances_greater_than_0 = serviceHierarchy.vnfs[vnfUUID].properties['min_instances'] && serviceHierarchy.vnfs[vnfUUID].properties['min_instances'] > 0; + if(this.store.getState().global.flags['FLAG_DEFAULT_VNF'] && min_vnf_instances_greater_than_0) + { + this.createVNFInstanceReduxIfNotExist( + serviceId, + this.generateVNFData(serviceHierarchy, vnfUUID, formServiceValues, isEcompGeneratedNaming) + ); + } } } } - updateVNFInstanceRedux(vnfModelName: string, serviceId: string, numberOfVfModules: number, vfModuleData: any, vnfData: any, vfModuleName : string): void { - if (numberOfVfModules > 0) { - this.store.dispatch(updateVNFInstance(vnfData, vnfData.modelInfo.modelCustomizationName, serviceId)); - for (let i = 0; i < numberOfVfModules; i++) { - this.store.dispatch(createVFModuleInstance(vfModuleData, vfModuleName, serviceId)); - } + + private getIsEcompGeneratedNaming(vnfJson) { + const ecompGeneratedNaming = vnfJson.properties.ecomp_generated_naming; + return ecompGeneratedNaming === "true"; + }; + + createVNFInstanceReduxIfNotExist(serviceId: string, vnfData: any): void { + if(!this.store.getState().service.serviceInstance[serviceId].vnfs[vnfData.modelInfo.modelCustomizationName]){ + this.store.dispatch(createVNFInstance(vnfData, vnfData.modelInfo.modelCustomizationName, serviceId)); + this.store.dispatch(changeInstanceCounter(vnfData.modelInfo.modelUniqueId, serviceId, 1, <any> {data : {type : 'VF'}})); + } + } + + createNetworkInstanceReduxIfNotExist(serviceId: string, networkData: any): void { + if(!this.store.getState().service.serviceInstance[serviceId].vnfs[networkData.modelInfo.modelCustomizationName]){ + this.store.dispatch(createNetworkInstance(networkData, networkData.modelInfo.modelCustomizationName, serviceId)); + this.store.dispatch(changeInstanceCounter(networkData.modelInfo.modelUniqueId, serviceId, 1, <any> {data : {type : 'VL'}})); } } + createVnfGroupInstanceReduxIfNotExist(serviceId: string, vnfGroupData: any): void { + if(!this.store.getState().service.serviceInstance[serviceId].vnfGroups[vnfGroupData.modelInfo.modelCustomizationName]){ + this.store.dispatch(createVnfGroupInstance(vnfGroupData, vnfGroupData.modelInfo.modelCustomizationName, serviceId)); + this.store.dispatch(changeInstanceCounter(vnfGroupData.modelInfo.modelUniqueId , serviceId, 1, <any> {data : {type : 'VnfGroup'}})); + } + } + + addDefaultVfModulesInRedux(serviceId: string, numberOfVfModules: number, vfModuleData: any, vfModuleName: string, vnfUUID : string){ + for (let i = 0; i < numberOfVfModules; i++) { + this.store.dispatch(createVFModuleInstance(vfModuleData, vfModuleName, serviceId, null, vnfUUID)); + } + } - generateVFModule(serviceHierarchy: any, vnfUUID: string, vnfModuleUUID: string) { + generateVnfGroupInstance(vnfGroupModel: any, isEcompGeneratedNaming : boolean, isALaCarte: boolean, instanceName: string) { + let modelInfo = new ModelInfo(vnfGroupModel); + let instanceParams = {}; return { + 'uuid' : modelInfo.uuid, + 'action': ServiceInstanceActions.Create, + 'instanceName': (!isEcompGeneratedNaming) ? instanceName : null, + 'isMissingData' : false, + 'modelInfo': modelInfo, + 'rollbackOnFailure' : "true", + 'instanceParams': [ + instanceParams + ], + 'trackById': DefaultDataGeneratorService.createRandomTrackById() + }; + } + + + generateVFModule(vfModule: any, dynamicInputs: any, isEcompGeneratedNaming : boolean, isALaCarte: boolean) { + let instanceParams = {}; + dynamicInputs.forEach(field => { + instanceParams[field.id] = field.value; + }); + return { + 'isMissingData' : this.setIsMissingData(ServiceNodeTypes.VFmodule, dynamicInputs, isEcompGeneratedNaming, isALaCarte), 'sdncPreReload': null, 'modelInfo': { 'modelType': 'VFmodule', - 'modelInvariantId': serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].invariantUuid, - 'modelVersionId': serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].uuid, - 'modelName': serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].name, - 'modelVersion': serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].version, - 'modelCustomizationId': serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].customizationUuid, - 'modelCustomizationName': serviceHierarchy.vnfs[vnfUUID].vfModules[vnfModuleUUID].modelCustomizationName + 'modelInvariantId': vfModule.invariantUuid, + 'modelVersionId': vfModule.uuid, + 'modelName': vfModule.name, + 'modelVersion': vfModule.version, + 'modelCustomizationId': vfModule.customizationUuid, + 'modelCustomizationName': vfModule.modelCustomizationName, + 'modelUniqueId' : vfModule.customizationUuid || vfModule.uuid }, 'instanceParams': [ - {} - ] + instanceParams + ], + 'trackById': DefaultDataGeneratorService.createRandomTrackById(), }; } - generateVNFData(serviceHierarchy: any, vnfName: string, vnfUUID: string, formValues: any) { + setIsMissingData(type: string, dynamicInputs: any, isEcompGeneratedNaming: boolean, isAlaCarte?: boolean): boolean { + if (isAlaCarte || !isEcompGeneratedNaming || this.requiredFields[type].length > 0) { + return true; + } + + if (dynamicInputs) { + for(let input of dynamicInputs) { + if (input.isRequired && _.isEmpty(input.value)) { + return true; + } + } + } + return false; + } + + generateVNFData(serviceHierarchy: any, vnfName: string, formValues: any, isEcompGeneratedNaming) { return { + 'uuid' : serviceHierarchy.vnfs[vnfName].uuid, + 'isMissingData' :this.setIsMissingData(ServiceNodeTypes.VF, [], isEcompGeneratedNaming), 'productFamilyId': formValues.productFamilyId, 'lcpCloudRegionId': null, 'tenantId': null, @@ -73,10 +361,100 @@ export class DefaultDataGeneratorService { 'modelVersionId': formValues.modelInfo.modelVersionId, 'modelName': serviceHierarchy.vnfs[vnfName].name, 'modelVersion': serviceHierarchy.vnfs[vnfName].version, - 'modelCustomizationId': serviceHierarchy.vnfs[vnfName].modelCustomizationId, - 'modelCustomizationName': serviceHierarchy.vnfs[vnfName].modelCustomizationName + 'modelCustomizationId': serviceHierarchy.vnfs[vnfName].customizationUuid, + 'modelCustomizationName': serviceHierarchy.vnfs[vnfName].modelCustomizationName, + 'modelUniqueId' : serviceHierarchy.vnfs[vnfName].customizationUuid || serviceHierarchy.vnfs[vnfName].uuid, }, - 'isUserProvidedNaming': null + 'trackById': DefaultDataGeneratorService.createRandomTrackById(), } } + + generateNetworkData(serviceHierarchy: any, networkName: string, formValues: any, isEcompGeneratedNaming) { + return { + 'uuid' : serviceHierarchy.network[networkName].uuid, + 'isMissingData' :this.setIsMissingData(ServiceNodeTypes.VL, [], isEcompGeneratedNaming), + 'productFamilyId': formValues.productFamilyId, + 'lcpCloudRegionId': null, + 'tenantId': null, + 'lineOfBusiness': null, + 'platformName': null, + 'modelInfo': { + 'modelType': 'VF', + 'modelInvariantId': serviceHierarchy.network[networkName].invariantUuid, + 'modelVersionId': formValues.modelInfo.modelVersionId, + 'modelName': serviceHierarchy.network[networkName].name, + 'modelVersion': serviceHierarchy.network[networkName].version, + 'modelCustomizationId': serviceHierarchy.network[networkName].modelCustomizationId, + 'modelCustomizationName': serviceHierarchy.network[networkName].modelCustomizationName, + 'modelUniqueId' : serviceHierarchy.network[networkName].modelCustomizationId || serviceHierarchy.network[networkName].uuid, + }, + 'trackById': DefaultDataGeneratorService.createRandomTrackById(), + } + } + + generateVnfGroupData(serviceHierarchy: any, vnfGroupName: string, formValues: any, isEcompGeneratedNaming) { + return { + 'uuid' : serviceHierarchy.vnfGroups[vnfGroupName].uuid, + 'isMissingData' :this.setIsMissingData(ServiceNodeTypes.VnfGroup, [], isEcompGeneratedNaming), + 'platformName': null, + 'modelInfo': { + 'modelType': 'VnfGroup', + 'modelInvariantId': serviceHierarchy.vnfGroups[vnfGroupName].invariantUuid, + 'modelVersionId': formValues.modelInfo.modelVersionId, + 'modelName': serviceHierarchy.vnfGroups[vnfGroupName].name, + 'modelVersion': serviceHierarchy.vnfGroups[vnfGroupName].version, + 'modelCustomizationId': serviceHierarchy.vnfGroups[vnfGroupName].modelCustomizationId, + 'modelCustomizationName': serviceHierarchy.vnfGroups[vnfGroupName].modelCustomizationName, + 'modelUniqueId' : serviceHierarchy.vnfGroups[vnfGroupName].modelCustomizationId || serviceHierarchy.vnfGroups[vnfGroupName].uuid, + + }, + 'trackById': DefaultDataGeneratorService.createRandomTrackById(), + } + } + + + static createRandomTrackById() { + return Math.random().toString(36).slice(2); + } + + private checkMissingData(instance, type: string, dynamicInputs: any, isEcompGeneratedNaming: boolean): boolean { + if (!isEcompGeneratedNaming && _.isEmpty(instance.instanceName)) { + return true; + } + + for (let field of this.requiredFields[type]) { + if (_.isEmpty(instance[field])) { + return true; + } + } + + for (let field of dynamicInputs) { + if (field.isRequired && !_.isNil(instance.instanceParams) && _.isEmpty(instance.instanceParams[0][field.id])) { + return true; + } + } + + return false; + } + + createNewTreeNode(instance: any, model: any, storeKey : string, type : string): VnfTreeNode { + let tmp = null; + if(type === 'vnfs') { + tmp = new VnfTreeNode(instance, model, storeKey); + }else if (type === 'vnfGroups') { + tmp = new VnfGroupTreeNode(instance, model, storeKey); + }else { + tmp = new NetworkTreeNode(instance, model, storeKey); + } + tmp.missingData = this.checkMissingData(instance, ServiceNodeTypes.VF, [], model.isEcompGeneratedNaming); + + return tmp; + } + + createNewVfModuleTreeNode(instance: VfModuleInstance, vfModuleModel: VfModule, vfModuleModelName: string, isEcompGeneratedNamig: boolean, dynamicInputs, dynamicModelName :string): VfModuleTreeNode { + let newVfModule: VfModuleTreeNode = new VfModuleTreeNode(instance, vfModuleModel, vfModuleModelName, dynamicInputs, isEcompGeneratedNamig, dynamicModelName); + newVfModule.missingData = this.checkMissingData(instance, ServiceNodeTypes.VFmodule, dynamicInputs, isEcompGeneratedNamig); + return newVfModule; + } + } diff --git a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.spec.ts b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.spec.ts new file mode 100644 index 000000000..847af6676 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.spec.ts @@ -0,0 +1,47 @@ +import {FeatureFlagsService, Features} from "./feature-flags.service"; +import {getTestBed, TestBed} from "@angular/core/testing"; +import {NgRedux} from "@angular-redux/store"; +import each from 'jest-each'; +let flagValue:boolean; + +class MockReduxStore<T> { + + getState() { + return { + "global": { + "flags": { + "FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST": flagValue, + }, + }, + } + }; +} + +describe('Feature flags Service', () => { + + let injector; + let service: FeatureFlagsService; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + providers: [ + FeatureFlagsService, + {provide: NgRedux, useClass: MockReduxStore}] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + service = injector.get(FeatureFlagsService); + + })().then(done).catch(done.fail)); + + let flagValueDataProvider = [ + ['flag is true', true], + ['flag is false', false] + ]; + + each(flagValueDataProvider).test("should return the correct flag %s", (desc: string, flag: boolean) => { + flagValue = flag; + expect(service.getFlagState(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).toEqual(flag); + }); +}); diff --git a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts new file mode 100644 index 000000000..ec7bb0214 --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts @@ -0,0 +1,29 @@ +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../store/reducers"; +import {Injectable} from "@angular/core"; + +export enum Features { + FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST='FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST', + FLAG_1902_NEW_VIEW_EDIT='FLAG_1902_NEW_VIEW_EDIT', + FLAG_1902_VNF_GROUPING='FLAG_1902_VNF_GROUPING', + FLAG_VF_MODULE_RESUME_STATUS_CREATE = 'FLAG_VF_MODULE_RESUME_STATUS_CREATE', + DRAG_AND_DROP_OPERATION = 'DRAG_AND_DROP_OPERATION', + FLAG_1906_COMPONENT_INFO = 'FLAG_1906_COMPONENT_INFO', +} + +@Injectable() +export class FeatureFlagsService { + + constructor(private store: NgRedux<AppState>){} + + public getFlagState(flag: Features):boolean { + return FeatureFlagsService.getFlagState(flag, this.store); + } + + /*static method for easy refactoring of code, so no injection of FeatureFlagsService is needed*/ + public static getFlagState(flag: Features, store: NgRedux<AppState>):boolean { + return store.getState().global.flags[flag]; + } + + +} diff --git a/vid-webpack-master/src/app/shared/services/msoService/mso.service.spec.ts b/vid-webpack-master/src/app/shared/services/msoService/mso.service.spec.ts new file mode 100644 index 000000000..9142e8d0f --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/msoService/mso.service.spec.ts @@ -0,0 +1,37 @@ +import {getTestBed, TestBed} from '@angular/core/testing'; +import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; +import {MsoService} from './mso.service'; +import {Constants} from "../../utils/constants"; + + +describe('Mso Service', () => { + let injector; + let service: MsoService; + let httpMock: HttpTestingController; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [MsoService] + }); + await TestBed.compileComponents(); + + + injector = getTestBed(); + service = injector.get(MsoService); + httpMock = injector.get(HttpTestingController); + + })().then(done).catch(done.fail)); + + describe('#instantiation status tests ', ()=> { + test('retry should send the right request', ()=>{ + const jobId: string = '111'; + + service.retryMsoTask(jobId).subscribe(); + const req = httpMock.expectOne(Constants.Path.SERVICES_JOB_INFO_PATH + '/retry/' + jobId); + + expect(req.request.method).toBe('POST'); + }); + }); + +}); diff --git a/vid-webpack-master/src/app/shared/services/msoService/mso.service.ts b/vid-webpack-master/src/app/shared/services/msoService/mso.service.ts new file mode 100644 index 000000000..7d31c6f7c --- /dev/null +++ b/vid-webpack-master/src/app/shared/services/msoService/mso.service.ts @@ -0,0 +1,38 @@ +import {Injectable} from "@angular/core"; +import {HttpClient} from "@angular/common/http"; +import {Observable} from "rxjs"; +import {Constants} from "../../utils/constants"; +import {ServiceInstance} from "../../models/serviceInstance"; + +@Injectable() +export class MsoService { + httpClient: HttpClient; + + constructor(http: HttpClient) { + this.httpClient = http; + } + + + public submitMsoTask(instanceFields): Observable<any> { + let path = Constants.Path.SERVICES_JOB_INFO_PATH + '/bulk'; + return this.httpClient.post(path, instanceFields); + } + + public retryMsoTask(jobId: string): Observable<any> { + let pathQuery = Constants.Path.SERVICES_JOB_INFO_PATH + '/retry/' + jobId; + return this.httpClient.post<any>(pathQuery, null); + } + + public retryBulkMsoTask(jobId: string, instanceFields: ServiceInstance): Observable<any> { + let pathQuery = Constants.Path.SERVICES_JOB_INFO_PATH + '/retryJobWithChangedData/'+ jobId; + return this.httpClient.post<any>(pathQuery, instanceFields); + } + + public createVnf(requestDetails, serviceInstanceId): Observable<any> { + let pathQuery: string = Constants.Path.MSO_CREATE_VNF_INSTANCE + serviceInstanceId; + + return this.httpClient.post( pathQuery, { + requestDetails : requestDetails + }); + } +} |