From ff76b5ed0aa91d5fdf9dc4f95e8b20f91ed9d072 Mon Sep 17 00:00:00 2001 From: "Sonsino, Ofir (os0695)" Date: Tue, 10 Jul 2018 15:57:37 +0300 Subject: New Angular UI from 1806 Change-Id: I39c160db0e0a6ec2e587ccf007ee1b23c6a08666 Issue-ID: VID-208 Signed-off-by: Sonsino, Ofir (os0695) --- .../src/app/services/aaiService/aai.actions.ts | 75 +++ .../src/app/services/aaiService/aai.epics.ts | 81 ++++ .../src/app/services/aaiService/aai.service.ts | 189 ++++++++ .../getAicZonesResponseInterface.ts | 3 + .../getCategoryParamsResponseInterface.ts | 10 + .../getServiceModelResponseInterface.ts | 5 + .../getServicesResponseInterface.ts | 9 + .../getSubDetailsResponseInterface.ts | 12 + .../getSubscribersResponseInterface.ts | 5 + .../src/app/services/configuration.service.ts | 34 ++ .../src/app/services/data.service.ts | 528 +++++++++++++++++++++ .../src/app/services/flags.resolve.ts | 14 + .../src/app/services/msoService/mso.service.ts | 26 + vid-webpack-master/src/app/services/sdc.service.ts | 28 ++ .../app/services/service-planning.service.spec.ts | 467 ++++++++++++++++++ .../src/app/services/service-planning.service.ts | 282 +++++++++++ 16 files changed, 1768 insertions(+) create mode 100644 vid-webpack-master/src/app/services/aaiService/aai.actions.ts create mode 100644 vid-webpack-master/src/app/services/aaiService/aai.epics.ts create mode 100644 vid-webpack-master/src/app/services/aaiService/aai.service.ts create mode 100644 vid-webpack-master/src/app/services/aaiService/responseInterfaces/getAicZonesResponseInterface.ts create mode 100644 vid-webpack-master/src/app/services/aaiService/responseInterfaces/getCategoryParamsResponseInterface.ts create mode 100644 vid-webpack-master/src/app/services/aaiService/responseInterfaces/getServiceModelResponseInterface.ts create mode 100644 vid-webpack-master/src/app/services/aaiService/responseInterfaces/getServicesResponseInterface.ts create mode 100644 vid-webpack-master/src/app/services/aaiService/responseInterfaces/getSubDetailsResponseInterface.ts create mode 100644 vid-webpack-master/src/app/services/aaiService/responseInterfaces/getSubscribersResponseInterface.ts create mode 100644 vid-webpack-master/src/app/services/configuration.service.ts create mode 100644 vid-webpack-master/src/app/services/data.service.ts create mode 100644 vid-webpack-master/src/app/services/flags.resolve.ts create mode 100644 vid-webpack-master/src/app/services/msoService/mso.service.ts create mode 100644 vid-webpack-master/src/app/services/sdc.service.ts create mode 100644 vid-webpack-master/src/app/services/service-planning.service.spec.ts create mode 100644 vid-webpack-master/src/app/services/service-planning.service.ts (limited to 'vid-webpack-master/src/app/services') diff --git a/vid-webpack-master/src/app/services/aaiService/aai.actions.ts b/vid-webpack-master/src/app/services/aaiService/aai.actions.ts new file mode 100644 index 000000000..649fb1456 --- /dev/null +++ b/vid-webpack-master/src/app/services/aaiService/aai.actions.ts @@ -0,0 +1,75 @@ +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 = + (uuid : string) =>({ + type : LOAD_SERVICE_MDOEL_BY_UUID, + modelId : uuid + }) + + +export const loadProductFamiliesAction: ActionCreator = + () => ({ + type: LOAD_PRODUCT_FAMILIES, + }); + + +export const loadUserId: ActionCreator = +() => ({ + type: LOAD_USER_ID, +}); + + + export const loadLcpTenant: ActionCreator = + () => ({ + type: LOAD_LCP_TENANT, + }); + + +export const loadAicZones: ActionCreator = + () => ({ + type: LOAD_AIC_ZONES, + }); + +export const loadCategoryParameters: ActionCreator = + () => ({ + type: LOAD_CATEGORY_PARAMETERS, + }); + + +export const loadAaiNetworkAccordingToNetworkCF: ActionCreator = + (networkFunction,cloudOwner,cloudRegionId) => ({ + type: LOAD_NETWORK_ACCORDING_TO_NF, + networkFunctions: networkFunction, + cloudOwner: cloudOwner, + cloudRegionId: cloudRegionId + }); diff --git a/vid-webpack-master/src/app/services/aaiService/aai.epics.ts b/vid-webpack-master/src/app/services/aaiService/aai.epics.ts new file mode 100644 index 000000000..5249cea82 --- /dev/null +++ b/vid-webpack-master/src/app/services/aaiService/aai.epics.ts @@ -0,0 +1,81 @@ +import {updateServiceInstance} from './../../service.actions'; +import {Injectable} from '@angular/core'; +import {createEpicMiddleware} 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 { + updateAicZones, updateCategoryParameters, updateLcpRegionsAndTenants, updateNetworkCollectionFunction, + updateProductFamilies, updateUserId +} from "../../service.actions"; +import {AppState} from "../../store/reducers"; + +const notFetchedAlready = (state: AppState): boolean => state.service.productFamilies !== null; + +@Injectable() +export class AAIEpics { + constructor(private aaiService: AaiService) { + } + + public createEpic() { + return [createEpicMiddleware(this.loadProductFamiliesEpic) + , createEpicMiddleware(this.loadLcpTenants) + , createEpicMiddleware(this.loadAicZones) + , createEpicMiddleware(this.loadCategoryParameters) + , createEpicMiddleware(this.loadServiceAccordingToUuid) + , createEpicMiddleware(this.loadNetworkAccordingToNetworkFunction) + , createEpicMiddleware(this.loadUserId) + ]; + } + + private loadLcpTenants = (action$, store) => + action$ + .ofType(LOAD_LCP_TENANT) + .switchMap(() => this + .aaiService + .getLcpRegionsAndTenants('e433710f-9217-458d-a79d-1c7aff376d89', 'VIRTUAL USP') + .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 => updateServiceInstance(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/services/aaiService/aai.service.ts b/vid-webpack-master/src/app/services/aaiService/aai.service.ts new file mode 100644 index 000000000..dd9d9fb29 --- /dev/null +++ b/vid-webpack-master/src/app/services/aaiService/aai.service.ts @@ -0,0 +1,189 @@ +import {Injectable} from '@angular/core'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import { Constants } from '../../shared/utils/constants'; +import { ServiceType } from "../../shared/models/serviceType"; +import {GetSubDetailsResponse} from "./responseInterfaces/getSubDetailsResponseInterface"; +import {Observable} from "rxjs/Observable"; +import * as _ from 'lodash'; +import {CategoryParams} from "../../shared/models/categoryParams"; +import {GetCategoryParamsResponseInterface} from "./responseInterfaces/getCategoryParamsResponseInterface"; +import {Project} from "../../shared/models/project"; +import {OwningEntity} from "../../shared/models/owningEntity"; +import {GetServicesResponseInterface} from "./responseInterfaces/getServicesResponseInterface"; +import {Subscriber} from "../../shared/models/subscriber"; +import {GetSubscribersResponse} from "./responseInterfaces/getSubscribersResponseInterface"; +import {AicZone} from "../../shared/models/aicZone"; +import {GetAicZonesResponse} from "./responseInterfaces/getAicZonesResponseInterface"; +import {LcpRegionsAndTenants} from "../../shared/models/lcpRegionsAndTenants"; +import {LcpRegion} from "../../shared/models/lcpRegion"; +import {Tenant} from "../../shared/models/tenant"; +import {ProductFamily} from "../../shared/models/productFamily" +import { + updateAicZones, updateCategoryParameters, updateLcpRegionsAndTenants, updateModel, updateProductFamilies, + updateServiceTypes, updateSubscribers, updateUserId +} from '../../service.actions'; +import {SelectOption} from '../../shared/models/selectOption'; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../store/reducers"; +import {ResponseContentType, ResponseType} from "@angular/http"; +import 'rxjs/add/operator/do'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/catch'; + +@Injectable() +export class AaiService { + + constructor (private http: HttpClient, private store: NgRedux) {} + + public getServiceModelById(serviceModelId: string): Observable { + if (_.has(this.store.getState().service.serviceHierarchy,serviceModelId)){ + return Observable.of( 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)); + }); + } + + public getUserId() : Observable{ + return this.http.get("../../getuserID",{responseType: 'text'}).do((res)=>this.store.dispatch(updateUserId(res))); + } + + + public 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)); + } + + public getCategoryParameters(familyName): Observable { + familyName = familyName || Constants.Path.PARAMETER_STANDARDIZATION_FAMILY; + let pathQuery: string = Constants.Path.GET_CATEGORY_PARAMETERS +"?familyName=" + familyName+ "&r=" + Math.random(); + + return this.http.get(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(); + } + } + + public getProductFamilies(): Observable { + return this.getServices().map(res => res.service.map(service => new ProductFamily(service))); + } + + public getServices(): Observable { + let pathQuery: string = Constants.Path.AAI_GET_SERVICES + Constants.Path.ASSIGN + Math.random(); + + return this.http.get(pathQuery); + } + + public getSubscribers(): Observable { + if (this.store.getState().service.subscribers){ + return Observable.of( 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(pathQuery).map(res => + res.customer.map( subscriber => new Subscriber(subscriber))).do((res) => { + this.store.dispatch(updateSubscribers(res)); + }); + } + + public getAicZones(): Observable { + if (this.store.getState().service.aicZones){ + return Observable.of( 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(pathQuery).map(res => + res.zone.map(aicZone => new AicZone(aicZone))).do((res) => { + this.store.dispatch(updateAicZones(res)); + }); + } + + public getLcpRegionsAndTenants(globalCustomerId, serviceType): Observable { + if (this.store.getState().service.lcpRegionsAndTenants.lcpRegionList.length !== 0){ + return Observable.of( JSON.parse(JSON.stringify(this.store.getState().service.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) => { + return new LcpRegion(cloudRegionTenant) + }); + + 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 getServiceTypes(subscriberId): Observable { + console.log("AaiService:getSubscriptionServiceTypeList: globalCustomerId: " + subscriberId); + if (_.has(this.store.getState().service.serviceTypes, subscriberId)){ + return Observable.of( 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));}); + } + + public getSubscriberDetails(subscriberId): Observable { + let pathQuery: string = Constants.Path.AAI_SUB_DETAILS_PATH + subscriberId + Constants.Path.ASSIGN + Math.random(); + + if (subscriberId != null) { + return this.http.get(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 []; + } + } +} diff --git a/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getAicZonesResponseInterface.ts b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getAicZonesResponseInterface.ts new file mode 100644 index 000000000..62581c9e2 --- /dev/null +++ b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getAicZonesResponseInterface.ts @@ -0,0 +1,3 @@ +export interface GetAicZonesResponse { + zone: any[]; +} diff --git a/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getCategoryParamsResponseInterface.ts b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getCategoryParamsResponseInterface.ts new file mode 100644 index 000000000..06398904c --- /dev/null +++ b/vid-webpack-master/src/app/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/services/aaiService/responseInterfaces/getServiceModelResponseInterface.ts b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getServiceModelResponseInterface.ts new file mode 100644 index 000000000..87671155d --- /dev/null +++ b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getServiceModelResponseInterface.ts @@ -0,0 +1,5 @@ +import {ServiceModelResponseInterface} from "../../../shared/models/serviceModel"; + +export interface GetServiceModelResponseInterface { + service: ServiceModelResponseInterface +} diff --git a/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getServicesResponseInterface.ts b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getServicesResponseInterface.ts new file mode 100644 index 000000000..ae04055e4 --- /dev/null +++ b/vid-webpack-master/src/app/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/services/aaiService/responseInterfaces/getSubDetailsResponseInterface.ts b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getSubDetailsResponseInterface.ts new file mode 100644 index 000000000..dbfb695d0 --- /dev/null +++ b/vid-webpack-master/src/app/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/services/aaiService/responseInterfaces/getSubscribersResponseInterface.ts b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getSubscribersResponseInterface.ts new file mode 100644 index 000000000..065f66e21 --- /dev/null +++ b/vid-webpack-master/src/app/services/aaiService/responseInterfaces/getSubscribersResponseInterface.ts @@ -0,0 +1,5 @@ +import {Subscriber} from "../../../shared/models/subscriber"; + +export interface GetSubscribersResponse { + customer: Subscriber[]; +} diff --git a/vid-webpack-master/src/app/services/configuration.service.ts b/vid-webpack-master/src/app/services/configuration.service.ts new file mode 100644 index 000000000..4edd8ffb5 --- /dev/null +++ b/vid-webpack-master/src/app/services/configuration.service.ts @@ -0,0 +1,34 @@ +import {Injectable} from '@angular/core'; +import {HttpClient} from "@angular/common/http"; +import {Constants} from "../shared/utils/constants"; +import {Observable} from 'rxjs/Observable'; +import {updateFlags} from "../global.actions"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../store/reducers"; + +@Injectable() +export class ConfigurationService { + store : NgRedux; + + constructor(private _http: HttpClient, _store : NgRedux) { + this.store = _store; + } + + getConfiguration(key : string): Observable { + 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 Observable.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/services/data.service.ts b/vid-webpack-master/src/app/services/data.service.ts new file mode 100644 index 000000000..4f8bf3623 --- /dev/null +++ b/vid-webpack-master/src/app/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/services/flags.resolve.ts b/vid-webpack-master/src/app/services/flags.resolve.ts new file mode 100644 index 000000000..70449379f --- /dev/null +++ b/vid-webpack-master/src/app/services/flags.resolve.ts @@ -0,0 +1,14 @@ +import {ActivatedRouteSnapshot, Resolve} from "@angular/router"; +import {Injectable} from "@angular/core"; +import {ConfigurationService} from "./configuration.service"; +import {Observable} from "rxjs/Observable"; + +@Injectable() +export class FlagsResolve implements Resolve> { + + constructor(private _configurationService: ConfigurationService) {} + + resolve(route: ActivatedRouteSnapshot) { + return this._configurationService.getFlags(); + } +} diff --git a/vid-webpack-master/src/app/services/msoService/mso.service.ts b/vid-webpack-master/src/app/services/msoService/mso.service.ts new file mode 100644 index 000000000..1402b50f7 --- /dev/null +++ b/vid-webpack-master/src/app/services/msoService/mso.service.ts @@ -0,0 +1,26 @@ +import {Injectable} from "@angular/core"; +import {HttpClient} from "@angular/common/http"; +import {Observable} from "rxjs/Observable"; +import {Constants} from "../../shared/utils/constants"; + +@Injectable() +export class MsoService { + httpClient: HttpClient; + + constructor(http: HttpClient) { + this.httpClient = http; + } + + + public submitMsoTask(instanceFields): Observable { + let path = '../../asyncInstantiation/bulk'; + return this.httpClient.post(path, instanceFields); + } + public createVnf(requestDetails, serviceInstanceId): Observable { + let pathQuery: string = Constants.Path.MSO_CREATE_VNF_INSTANCE + serviceInstanceId; + + return this.httpClient.post( pathQuery, { + requestDetails : requestDetails + }); + } +} diff --git a/vid-webpack-master/src/app/services/sdc.service.ts b/vid-webpack-master/src/app/services/sdc.service.ts new file mode 100644 index 000000000..d4eba260a --- /dev/null +++ b/vid-webpack-master/src/app/services/sdc.service.ts @@ -0,0 +1,28 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import 'rxjs/add/operator/map'; +import { Constants } from '../shared/utils/constants'; +import { VidConfiguration } from '../configuration/vid.configuration'; + +@Injectable() +export class SdcService { + + + constructor (private http: HttpClient) { + } + + public getServicesModels(): any { + let pathQuery: string = Constants.Path.SERVICES_DIST_STATUS_PATH + VidConfiguration.ASDC_MODEL_STATUS; + + if ( VidConfiguration.ASDC_MODEL_STATUS === Constants.Status.ALL) { + pathQuery = Constants.Path.SERVICES_PATH; + } + + return this.http.get(pathQuery); + } + + getService(uuid: string) { + return this.http.get(Constants.Path.SERVICES_PATH + uuid); + } + +} diff --git a/vid-webpack-master/src/app/services/service-planning.service.spec.ts b/vid-webpack-master/src/app/services/service-planning.service.spec.ts new file mode 100644 index 000000000..5d60e29f7 --- /dev/null +++ b/vid-webpack-master/src/app/services/service-planning.service.spec.ts @@ -0,0 +1,467 @@ +import {ServicePlanningService} from "./service-planning.service"; +import {ReflectiveInjector} from "@angular/core"; +import {NgRedux} from "@angular-redux/store"; +import {ServiceNodeTypes} from "../shared/models/ServiceNodeTypes"; + +export class MockAppStore { +} + +describe('Service planning service', () => { + let injector; + let service: ServicePlanningService; + + beforeEach(() => { + + let injector = ReflectiveInjector.resolveAndCreate([ + ServicePlanningService, + {provide: NgRedux, useClass: MockAppStore} + ]); + + service = injector.get(ServicePlanningService); + }); + + describe('#updateDynamicInputsVnfDataFromModel', () => { + it('get vfModule instance params', (done: DoneFn) => { + //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([]); + done(); + }); + }); + + describe('#isUserProvidedNaming', () => { + it('get vfModule with generate ecompNaming should return userProvided false', (done: DoneFn) => { + //get vfModule with generate ecompNaming should return userProvided false + let isUserProvidedNaming = service.isUserProvidedNaming(ServiceNodeTypes.VFmodule, generateVFModule(), generateVNF()); + expect(isUserProvidedNaming).toBeFalsy(); + + //get vfModule without generate ecompNaming should return userProvided true + isUserProvidedNaming = service.isUserProvidedNaming(ServiceNodeTypes.VFmodule, generateVFModule(), generateVNF_ecompNamingFalse()); + expect(isUserProvidedNaming).toBeTruthy(); + + //get vnf with generate ecompNaming should return userProvided false + isUserProvidedNaming = service.isUserProvidedNaming(ServiceNodeTypes.VF, generateVNF(), null); + expect(isUserProvidedNaming).toBeFalsy(); + + //get vnf without generate ecompNaming should return userProvided true + isUserProvidedNaming = service.isUserProvidedNaming(ServiceNodeTypes.VF, generateVNF_ecompNamingFalse(), null); + expect(isUserProvidedNaming).toBeTruthy(); + done(); + }); + }); + + 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': '128.0.0.0', + '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': '128.0.0.16', + 'is_AVPN_service': 'false', + 'vmx_RSG_name': 'vREXI-affinity', + 'vmx_int_ctl_forwarding': 'l2', + 'vmxvre_oam_ip_0': '10.40.123.5', + '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': '128.0.0.1', + '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.40.123.1', + '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': {} + }; + } + + function generateVNF_ecompNamingFalse() { + 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': { + 'ecomp_generated_naming': "false", + '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': '128.0.0.0', + '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': '128.0.0.16', + 'is_AVPN_service': 'false', + 'vmx_RSG_name': 'vREXI-affinity', + 'vmx_int_ctl_forwarding': 'l2', + 'vmxvre_oam_ip_0': '10.40.123.5', + '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=false}', + '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': '128.0.0.1', + '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.40.123.1', + '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/services/service-planning.service.ts b/vid-webpack-master/src/app/services/service-planning.service.ts new file mode 100644 index 000000000..75720c8a1 --- /dev/null +++ b/vid-webpack-master/src/app/services/service-planning.service.ts @@ -0,0 +1,282 @@ +import {Injectable} from '@angular/core'; +import {Constants} from "../shared/utils/constants"; +import {Utils} from "../utils/utils"; +import * as _ from 'lodash'; +import Parameter = Constants.Parameter; +import {ITreeNode} from "angular-tree-component/dist/defs/api"; +import {ServiceInstance} from "../shared/models/serviceInstance"; +import {VNFModel} from "../shared/models/vnfModel"; +import {ServiceNodeTypes} from "../shared/models/ServiceNodeTypes"; +import {VfModuleMap} from "../shared/models/vfModulesMap"; +import {VnfInstance} from "../shared/models/vnfInstance"; +import {VfModuleTreeNode} from "../shared/models/vfModuleTreeNode"; +import {VfModule} from "../shared/models/vfModule"; +import {VnfTreeNode} from "../shared/models/vnfTreeNode"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../store/reducers"; +import {InputType} from "../shared/models/inputTypes"; + + +@Injectable() +export class ServicePlanningService { + + modelDataTree: any[] = []; + drawingDataTree: any[] = []; + service: any = {name:'My Service'} ; + public requiredFields = { + VF: [InputType.LCP_REGION, InputType.TENANT, InputType.PLATFORM], + VFmodule: [] + }; + + constructor(private store: NgRedux) {} + + + public getServiceName() :string{ + return this.service.name; + } + + public getServiceInstance(serviceModelId): ServiceInstance { + return this.store.getState().service.serviceInstance[serviceModelId]; + } + + public getVnfInstance(serviceModelId, vnfModelName): VnfInstance { + return this.getServiceInstance(serviceModelId).vnfs[vnfModelName]; + } + + public getVfModuleMap(serviceModelId, vnfModelName, vfModuleModelName): VfModuleMap { + let vnfInstance = this.getVnfInstance(serviceModelId, vnfModelName); + return _.get(vnfInstance, ['vfModules', vfModuleModelName]); + } + + public convertServiceModelToTreeNodes(serviceModel) { + let _this = this; + + _.forOwn(serviceModel.vnfs, function(item, key) { + _this.addFirstLevelModel(key, item, item.type, serviceModel); + }); + + _.forOwn(serviceModel.configurations, function(item, key) { + _this.addFirstLevelModel(key, item, ServiceNodeTypes.Configuration, serviceModel); + }); + + _.forOwn(serviceModel.networks, function(network, key) { + _this.addFirstLevelModel(key, network, ServiceNodeTypes.Network, serviceModel); + }); + + return this.modelDataTree; + } + + private addFirstLevelModel(key, value, valueType, serviceModel) { + + let node = this.convertItemToTreeNode(key, value, valueType, null, false); + let vnfInstance = this.getVnfInstance(serviceModel.service.uuid, key); + if(value.vfModules) { + node.children = Object.keys(value.vfModules).map((vmKey) => + this.convertItemToTreeNode(vmKey, value.vfModules[vmKey], ServiceNodeTypes.VFmodule, value, !vnfInstance)); + } + this.modelDataTree.push(node); + } + + private convertItemToTreeNode(key, value, valueType, parentModel , disabled) { + + return { + id: value.uuid, + name: key, + tooltip: valueType, + type: valueType, + count: value.count || 0, + max: value.max || 1, + children: [], + disabled: disabled, + dynamicInputs: this.updateDynamicInputsVnfDataFromModel(valueType, value), + userProvidedNaming: this.isUserProvidedNaming(valueType, value, parentModel) + } + } + + public convertServiceInstanceToTreeData(serviceInstance: ServiceInstance, modelId: string): any { + let drawingBoardData = []; + let _this = this; + _.forOwn(serviceInstance.vnfs, (vnfInstance, vnfModelName) => { + let vnfModel: VNFModel = _this.store.getState().service.serviceHierarchy[modelId].vnfs[vnfModelName]; + let vnfNode = new VnfTreeNode(vnfInstance, vnfModel); + + let vfModuleNodes = []; + _.forOwn(vnfInstance.vfModules, (vfModuleMap, vfModuleModelName) => { + _.forOwn(vfModuleMap, (vfModuleInstance, vfModuleInstsanceName) => { + let vfModule: VfModule = _this.store.getState().service.serviceHierarchy[modelId].vnfs[vnfModelName].vfModules[vfModuleModelName]; + let vfModuleNode: VfModuleTreeNode = new VfModuleTreeNode(vfModuleInstance, vfModule, vfModuleModelName); + vfModuleNodes.push(vfModuleNode); + }); + }); + vnfNode.children = vfModuleNodes; + drawingBoardData.push(vnfNode); + }); + + return drawingBoardData; + } + + 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 ) { + //override parameter type + 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; + }//switch + }//for + }//while + }//if + }; + + public static isVfModule(node:ITreeNode): boolean { + return node.data.type=='VFmodule'; + } + + public static isVnf(node:ITreeNode): boolean { + return node.data.type == ServiceNodeTypes.VF; + } + + updateDynamicInputsVnfDataFromModel(modelType: string, model: any): Array { + let displayInputs; + if (modelType === ServiceNodeTypes.VFmodule) { + displayInputs = model.inputs; + } + return _.isEmpty(displayInputs) ? [] : this.getArbitraryInputs(displayInputs); + } + + isUserProvidedNaming(type: string, nodeModel: any, parentModel: any) : boolean { + let model; + if (type === ServiceNodeTypes.VFmodule) { + model = parentModel; + } + else { + model = nodeModel; + } + const ecompGeneratedNaming = model.properties.ecomp_generated_naming; + return ecompGeneratedNaming !== undefined && ecompGeneratedNaming === "false"; + } +} -- cgit 1.2.3-korg