From: KIRAN KASHALKAR Date: Fri, 21 Oct 2016 15:20:10 +0000 (-0400) Subject: RIFT-14705 - UI Composer: Add IVLD to VNFD is broken X-Git-Tag: v1.0.1~10^2~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=c02d242125c45704991405449fbeb35de8c9687c;p=osm%2FUI.git RIFT-14705 - UI Composer: Add IVLD to VNFD is broken Signed-off-by: KIRAN KASHALKAR --- diff --git a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js index 02bbfcd32..1a2ba4f04 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js +++ b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js @@ -182,7 +182,10 @@ export default class DescriptorModel { throw new ReferenceError('child must be an instance of DescriptorModel class'); } if (this.findChildByUid(child.uid)) { - throw new ReferenceError('child already exists'); + console.warn('Child already exists'); + // NOTE: Commented out this line because it was causing issues with Internal VLD. + // TODO: Check why it caused issues with Internal VLD + // throw new ReferenceError('child already exists'); } if (child.parent instanceof DescriptorModel) { throw new ReferenceError('child already has a parent'); diff --git a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelFactory.js b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelFactory.js index 68b70d7d5..ac59872c6 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelFactory.js +++ b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelFactory.js @@ -262,7 +262,7 @@ class DescriptorModelFactory { static newInternalConnectionPointRef(model, parent) { // note do not find children bc model is not an object it is a leaf-list primative and so the class manages it - return new InternalConnectionPointRef(model, parent); + return findChildDescriptorModelAndUpdateModel(model, parent) || new InternalConnectionPointRef(model, parent); } /** diff --git a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelSerializer.js b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelSerializer.js index 7581ed5ba..4e6b79264 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelSerializer.js +++ b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelSerializer.js @@ -165,6 +165,11 @@ const DescriptorModelSerializer = { return _.pick(ref, ['member-vnf-index-ref', 'vnfd-id-ref', 'vnfd-connection-point-ref']); } }, + 'internal-connection-point': { + serialize(ref) { + return _.pick(ref, ['id-ref']); + } + }, 'constituent-vnfd': { serialize(cvnfdModel) { if(!cvnfdFields) cvnfdFields = DescriptorModelMetaFactory.getModelFieldNamesForType('nsd.constituent-vnfd'); diff --git a/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPoint.js b/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPoint.js index 6648dc92c..14a74f0fe 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPoint.js +++ b/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPoint.js @@ -15,15 +15,13 @@ * limitations under the License. * */ -/** - * Created by onvelocity on 11/23/15. - */ 'use strict'; -import Position from '../../graph/Position' -import DescriptorModel from '../DescriptorModel' -import DescriptorModelFactory from '../DescriptorModelFactory' +import Position from '../../graph/Position'; +import DescriptorModel from '../DescriptorModel'; +import DescriptorModelFactory from '../DescriptorModelFactory'; +import InternalConnectionPointRef from './InternalConnectionPointRef'; export default class InternalConnectionPoint extends DescriptorModel { @@ -56,8 +54,31 @@ export default class InternalConnectionPoint extends DescriptorModel { return this.id; } + get id() { + return this.model.id; + } + + get name() { + return this.model.name + } + + get idRef() { + return this.parent.idRef; + } + + get cpNumber() { + return this.uiState.cpNumber; + } + + set cpNumber(n) { + this.uiState.cpNumber = n; + } + toInternalConnectionPointRef() { - return DescriptorModelFactory.newInternalConnectionPointRef(this.id); + const ref = new InternalConnectionPointRef({}); + ref.idRef = this.id; + // ref.cpNumber = this.cpNumber; + return ref; } canConnectTo(obj) { diff --git a/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPointRef.js b/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPointRef.js index a7ea7519f..ad70b57c4 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPointRef.js +++ b/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPointRef.js @@ -15,9 +15,6 @@ * limitations under the License. * */ -/** - * Created by onvelocity on 11/23/15. - */ 'use strict'; @@ -27,7 +24,7 @@ import DescriptorModelFactory from '../DescriptorModelFactory' export default class InternalConnectionPointRef extends DescriptorModel { static get type() { - return 'internal-connection-point-ref'; + return 'internal-connection-point'; } static get className() { @@ -39,23 +36,35 @@ export default class InternalConnectionPointRef extends DescriptorModel { } constructor(m, parent) { - super(!m || typeof m === 'string' ? {id: m, isLeaf: true} : m, parent); + super(m, parent); this.uid = this.id; this.type = InternalConnectionPointRef.type; this.uiState['qualified-type'] = InternalConnectionPointRef.qualifiedType; this.className = InternalConnectionPointRef.className; } - toString() { - return this.valueOf(); + get key() { + return this.model['id-ref']; } - remove() { - return this.parent.removeInternalConnectionPointRefForId(this.id); + get idRef() { + return this.model['id-ref']; } - valueOf() { - return this.id; + set idRef(id) { + return this.model['id-ref'] = id; + } + + get cpNumber() { + return this.uiState.cpNumber; + } + + set cpNumber(n) { + this.uiState.cpNumber = n; + } + + remove() { + return this.parent.removeInternalConnectionPointRefForId(this.idRef); } } diff --git a/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js b/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js index c3822d562..b3e4fc6b2 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js +++ b/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js @@ -15,14 +15,12 @@ * limitations under the License. * */ -/** - * Created by onvelocity on 11/23/15. - */ 'use strict'; import DescriptorModel from '../DescriptorModel' import DescriptorModelFactory from '../DescriptorModelFactory' +import DescriptorModelMetaFactory from '../DescriptorModelMetaFactory' export default class InternalVirtualLink extends DescriptorModel { @@ -50,22 +48,37 @@ export default class InternalVirtualLink extends DescriptorModel { } get connection() { - const list = this.model['internal-connection-point-ref'] || (this.model['internal-connection-point-ref'] = []); - return list.map(d => DescriptorModelFactory.newInternalConnectionPointRef(d, this)); + if (!this.model['internal-connection-point']) { + this.model['internal-connection-point'] = []; + } + return this.model['internal-connection-point'].map(d => DescriptorModelFactory.newInternalConnectionPointRef(d, this)); } set connection(connections) { - return this.updateModelList('internal-connection-point-ref', connections, DescriptorModelFactory.InternalConnectionPointRef); + return this.updateModelList('internal-connection-point', connections, DescriptorModelFactory.InternalConnectionPointRef); + } + + createInternalConnectionPoint(model) { + model = model || DescriptorModelMetaFactory.createModelInstanceForType('vnfd.internal-vld.internal-connection-point'); + return this.connection = DescriptorModelFactory.newInternalConnectionPointRef(model, this); + } + + removeInternalConnectionPointRefForIdRefKey(cpRefKey) { + const child = this.connection.filter(d => d.key === cpRefKey)[0]; + return this.removeModelListItem('connection', child); } addConnectionPoint(icp) { - icp.model['internal-vld-ref'] = this.id; this.parent.removeAnyConnectionsForConnector(icp); - this.connection = icp.toInternalConnectionPointRef(); + const icpRef = icp.toInternalConnectionPointRef(); + // this.connection = icp.toInternalConnectionPointRef(); + this.connection = this.connection.concat(icpRef); } - removeInternalConnectionPointRefForId(id) { - return this.connection = this.connection.filter(d => d.id !== id).map(d => d.id); + removeInternalConnectionPointRefForId(idRef) { + // return this.connection = this.connection.filter(d => d.idRef !== idRef).map(d => d.idRef); + // KKTODO: Check if below works instead + return this.connection = this.connection.filter(d => d.idRef !== idRef).map(d => d.model); } remove() { diff --git a/skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualDeploymentUnitInternalConnectionPoint.js b/skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualDeploymentUnitInternalConnectionPoint.js index 47947c8fe..c34d82357 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualDeploymentUnitInternalConnectionPoint.js +++ b/skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualDeploymentUnitInternalConnectionPoint.js @@ -15,21 +15,16 @@ * limitations under the License. * */ -/** - * Created by onvelocity on 11/23/15. - */ 'use strict'; import Position from '../../graph/Position' -import DescriptorModel from '../DescriptorModel' import InternalConnectionPoint from './InternalConnectionPoint' -import RspConnectionPointRef from './RspConnectionPointRef' -import VnfdConnectionPointRef from './VnfdConnectionPointRef' -import DescriptorModelFactory from '../DescriptorModelFactory' + /** - * A VirtualNetworkFunctionConnectionPoint is always a child of a VNFD. We use it to build VnfdConnectionPointRef instances. So convenience + * A VirtualDeploymentUnitInternalConnectionPoint is always a child of a VDU. + * We use it to build internal-connection-point.id-ref instances. So convenience * methods are add to access the fields needed to do that. */ export default class VirtualDeploymentUnitInternalConnectionPoint extends InternalConnectionPoint { diff --git a/skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualLink.js b/skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualLink.js index 50c465394..47370e5e7 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualLink.js +++ b/skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualLink.js @@ -15,9 +15,6 @@ * limitations under the License. * */ -/** - * Created by onvelocity on 11/23/15. - */ 'use strict';