Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / plugins / composer / src / src / libraries / model / descriptors / ConstituentVnfd.js
1 /*
2 *
3 * Copyright 2016 RIFT.IO Inc
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 *
17 */
18 /**
19 * Created by onvelocity on 11/23/15.
20 */
21
22 'use strict';
23
24 import DescriptorModel from '../DescriptorModel'
25 import DescriptorModelFactory from '../DescriptorModelFactory'
26
27 export default class ConstituentVnfd extends DescriptorModel {
28
29 static get type() {
30 return 'constituent-vnfd';
31 }
32
33 static get className() {
34 return 'ConstituentVnfd';
35 }
36
37 constructor(model, parent) {
38 super(model, parent);
39 this.type = 'constituent-vnfd';
40 this.uiState['qualified-type'] = 'nsd.constituent-vnfd';
41 this.className = 'ConstituentVnfd';
42 this.addProp('vnfdRef', DescriptorModelFactory.newVirtualNetworkFunctionReadOnlyWrapper({}, this));
43 }
44
45 get id() {
46 return this.vnfdIndex;
47 }
48
49 get vld() {
50 if (this.vnfdRef) {
51 return this.vnfdRef.vld;
52 }
53 return [];
54 }
55
56 get connectionPoint() {
57 if (this.vnfdRef) {
58 return this.vnfdRef.connectionPoint;
59 }
60 return [];
61 }
62
63 get connectors() {
64 return this.connectionPoint
65 }
66
67 get vnfdRef() {
68 return this.getProp('vnfdRef');
69 }
70
71 set vnfdRef(ref) {
72 this.addProp('vnfdRef', DescriptorModelFactory.newVirtualNetworkFunctionReadOnlyWrapper(ref, this));
73 // since this vnfd reference is not part of
74 // the YANG, we need to provide info needed
75 // for the details editor to manipulate it.
76 this.uiState.vnfdIndex = this.vnfdIndex;
77 this.uiState.displayName = this.title;
78 }
79
80 get vnfdIndex() {
81 return this.model['member-vnf-index'];
82 }
83
84 set vnfdIndex(index) {
85 this.model['member-vnf-index'] = index;
86 }
87
88 get vnfdId() {
89 return this.model['vnfd-id-ref'];
90 }
91
92 set vnfdId(id) {
93 this.model['vnfd-id-ref'] = id;
94 }
95
96 get name() {
97 return this.vnfdRef.name;
98 }
99
100 get 'short-name'() {
101 return this.vnfdRef['short-name'];
102 }
103
104 get title() {
105 return (this['short-name'] || this.name) + `/${this.vnfdIndex}`;
106 }
107
108 get vnfdServiceFunctionChain() {
109 return this.vnfdRef.model['service-function-chain'] || 'UNAWARE';
110 }
111
112 remove() {
113 return this.parent.removeConstituentVnfd(this);
114 }
115
116 }