3 * Copyright 2016 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * Created by onvelocity on 11/23/15.
24 import utils
from '../../utils'
25 import DescriptorModel
from '../DescriptorModel'
26 import DescriptorModelFactory
from '../DescriptorModelFactory'
27 import DescriptorModelMetaFactory
from '../DescriptorModelMetaFactory'
29 export default class VirtualNetworkFunction
extends DescriptorModel
{
35 static get className() {
36 return 'VirtualNetworkFunction';
39 constructor(model
, parent
) {
42 this.className
= 'VirtualNetworkFunction';
46 const list
= this.model
.vdu
|| (this.model
.vdu
= []);
47 return list
.map(d
=> DescriptorModelFactory
.newVirtualDeploymentUnit(d
, this));
51 this.updateModelList('vdu', obj
, DescriptorModelFactory
.VirtualDeploymentUnit
);
55 const model
= DescriptorModelMetaFactory
.createModelInstanceForType('vnfd.vdu');
56 return this.vdu
= DescriptorModelFactory
.newVirtualDeploymentUnit(model
, this);
59 removeVirtualDeploymentUnit(vdu
) {
60 vdu
.connectors
.forEach(cp
=> this.removeAnyConnectionsForConnector(cp
));
61 return this.vdu
= this.vdu
.filter(d
=> d
.id
!== vdu
.id
);
65 const list
= this.model
['internal-vld'] || (this.model
['internal-vld'] = []);
66 return list
.map(d
=> DescriptorModelFactory
.newInternalVirtualLink(d
, this));
70 this.updateModelList('internal-vld', obj
, DescriptorModelFactory
.InternalVirtualLink
);
74 const model
= DescriptorModelMetaFactory
.createModelInstanceForType('vnfd.internal-vld');
75 return this.vld
= DescriptorModelFactory
.newInternalVirtualLink(model
, this);
79 * @deprecated use `removeInternalVirtualLink()`
84 return this.removeModelListItem('vld', vld
);
87 get connectionPoint() {
88 const list
= this.model
['connection-point'] || (this.model
['connection-point'] = []);
89 return list
.map(d
=> DescriptorModelFactory
.newVirtualNetworkFunctionConnectionPoint(d
, this));
92 set connectionPoint(obj
) {
93 return this.updateModelList('connection-point', obj
, DescriptorModelFactory
.VirtualNetworkFunctionConnectionPoint
);
96 removeConnectionPoint(cp
) {
97 return this.removeModelListItem('connectionPoint', cp
);
101 return this.connectionPoint
;
106 this.parent
.removeConstituentVnfd(this);
107 this.connectors
.forEach(cpc
=> this.parent
.removeAnyConnectionsForConnector(cpc
));
111 removeAnyConnectionsForConnector(cpc
) {
112 this.vld
.forEach(vld
=> vld
.removeInternalConnectionPointRefForId(cpc
.id
));
115 removeInternalVirtualLink(ivl
) {
116 return this.removeModelListItem('vld', ivl
);