diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/services/aaiService')
11 files changed, 1348 insertions, 0 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[]; +} |