blob: b1772308907480350b49b5c5a6b64d8b77898064 [file] [log] [blame]
sebdetc8d61302019-07-04 15:50:34 +02001/*-
2 * ============LICENSE_START=======================================================
3 * ONAP CLAMP
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
6 * reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
xuegaof248df62019-07-15 15:16:18 +020021 *
sebdetc8d61302019-07-04 15:50:34 +020022 */
sebdete44fdb12019-07-12 12:25:56 +020023
sebdet493c3832019-07-15 17:26:18 +020024export default class LoopCache {
sebdete44fdb12019-07-12 12:25:56 +020025 loopJsonCache;
26
27 constructor(loopJson) {
28 this.loopJsonCache=loopJson;
sebdetc8d61302019-07-04 15:50:34 +020029 }
sebdet4946e5b2019-07-10 12:32:36 +020030
sebdetb65f1212019-08-23 07:49:25 -070031 updateMicroServiceProperties(name, newMsProperties) {
sebdet4946e5b2019-07-10 12:32:36 +020032 for (var policy in this.loopJsonCache["microServicePolicies"]) {
sebdetb65f1212019-08-23 07:49:25 -070033 if (this.loopJsonCache["microServicePolicies"][policy]["name"] === name) {
sebdet2df6c082019-07-18 15:29:45 +020034 this.loopJsonCache["microServicePolicies"][policy]["properties"] = newMsProperties;
sebdet4946e5b2019-07-10 12:32:36 +020035 }
36 }
sebdetc8d61302019-07-04 15:50:34 +020037 }
sebdet4946e5b2019-07-10 12:32:36 +020038
39 updateGlobalProperties(newGlobalProperties) {
40 this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties;
sebdetc8d61302019-07-04 15:50:34 +020041 }
sebdet4946e5b2019-07-10 12:32:36 +020042
sebdet493c3832019-07-15 17:26:18 +020043 updateOperationalPolicyProperties(newOpProperties) {
sebdet4946e5b2019-07-10 12:32:36 +020044 this.loopJsonCache["operationalPolicies"] = newOpProperties;
sebdetc8d61302019-07-04 15:50:34 +020045 }
sebdet4946e5b2019-07-10 12:32:36 +020046
47 getLoopName() {
48 return this.loopJsonCache["name"];
sebdetc8d61302019-07-04 15:50:34 +020049 }
sebdet4946e5b2019-07-10 12:32:36 +020050
sebdet493c3832019-07-15 17:26:18 +020051 getOperationalPolicyConfigurationJson() {
sebdet2df6c082019-07-18 15:29:45 +020052 return this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"];
sebdetc8d61302019-07-04 15:50:34 +020053 }
sebdetf9e2cee2019-08-09 18:36:09 +020054
55 getOperationalPolicyJsonSchema() {
xuegaoc488fed2019-12-19 11:58:45 +010056 return this.loopJsonCache["operationalPolicies"]["0"]["jsonRepresentation"];
sebdetf9e2cee2019-08-09 18:36:09 +020057 }
sebdet4946e5b2019-07-10 12:32:36 +020058
59 getOperationalPolicies() {
sebdet2df6c082019-07-18 15:29:45 +020060 return this.loopJsonCache["operationalPolicies"];
sebdetc8d61302019-07-04 15:50:34 +020061 }
sebdet4946e5b2019-07-10 12:32:36 +020062
xuegaoc488fed2019-12-19 11:58:45 +010063 getOperationalPoliciesNoJsonSchema() {
64 var operationalPolicies = JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]));
65 delete operationalPolicies[0]["jsonRepresentation"];
66 return operationalPolicies;
67 }
68
sebdet493c3832019-07-15 17:26:18 +020069 getGlobalProperties() {
sebdet2df6c082019-07-18 15:29:45 +020070 return this.loopJsonCache["globalPropertiesJson"];
sebdetc8d61302019-07-04 15:50:34 +020071 }
sebdet4946e5b2019-07-10 12:32:36 +020072
sebdet493c3832019-07-15 17:26:18 +020073 getDcaeDeploymentProperties() {
sebdet2df6c082019-07-18 15:29:45 +020074 return this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"];
sebdetc8d61302019-07-04 15:50:34 +020075 }
sebdet4946e5b2019-07-10 12:32:36 +020076
sebdet2df6c082019-07-18 15:29:45 +020077 getMicroServicePolicies() {
78 return this.loopJsonCache["microServicePolicies"];
79 }
80
sebdetc11160e2020-02-25 15:13:31 -080081 getOperationalPolicyForName(name) {
82 var opProperties=this.getOperationalPolicies();
83 for (var policy in opProperties) {
84 if (opProperties[policy]["name"] === name) {
85 return opProperties[policy];
86 }
87 }
88 return null;
89 }
90
91 getOperationalPolicyPropertiesForName(name) {
92 var opConfig = this.getOperationalPolicyForName(name);
93 if (opConfig !== null) {
94 return opConfig["properties"];
95 }
96 return null;
97 }
98
99 getOperationalPolicyJsonRepresentationForName(name) {
100 var opConfig = this.getOperationalPolicyForName(name);
101 if (opConfig !== null) {
102 return opConfig["jsonRepresentation"];
103 }
104 return null;
105 }
106
107
sebdet2df6c082019-07-18 15:29:45 +0200108 getMicroServiceForName(name) {
109 var msProperties=this.getMicroServicePolicies();
sebdet4946e5b2019-07-10 12:32:36 +0200110 for (var policy in msProperties) {
sebdet2df6c082019-07-18 15:29:45 +0200111 if (msProperties[policy]["name"] === name) {
112 return msProperties[policy];
sebdet4946e5b2019-07-10 12:32:36 +0200113 }
114 }
115 return null;
sebdetc8d61302019-07-04 15:50:34 +0200116 }
sebdet4946e5b2019-07-10 12:32:36 +0200117
sebdet2df6c082019-07-18 15:29:45 +0200118 getMicroServicePropertiesForName(name) {
119 var msConfig = this.getMicroServiceForName(name);
120 if (msConfig !== null) {
121 return msConfig["properties"];
sebdet4946e5b2019-07-10 12:32:36 +0200122 }
123 return null;
sebdetc8d61302019-07-04 15:50:34 +0200124 }
sebdet4946e5b2019-07-10 12:32:36 +0200125
sebdet2df6c082019-07-18 15:29:45 +0200126 getMicroServiceJsonRepresentationForName(name) {
127 var msConfig = this.getMicroServiceForName(name);
128 if (msConfig !== null) {
129 return msConfig["jsonRepresentation"];
sebdet4946e5b2019-07-10 12:32:36 +0200130 }
131 return null;
sebdetc8d61302019-07-04 15:50:34 +0200132 }
sebdet4946e5b2019-07-10 12:32:36 +0200133
134 getResourceDetailsVfProperty() {
xuegao289e8e12019-11-08 13:10:36 +0100135 return this.loopJsonCache["modelService"]["resourceDetails"]["VF"];
sebdetc8d61302019-07-04 15:50:34 +0200136 }
sebdet4946e5b2019-07-10 12:32:36 +0200137
138 getResourceDetailsVfModuleProperty() {
xuegao289e8e12019-11-08 13:10:36 +0100139 return this.loopJsonCache["modelService"]["resourceDetails"]["VFModule"];
sebdetc8d61302019-07-04 15:50:34 +0200140 }
sebdet4946e5b2019-07-10 12:32:36 +0200141
142 getLoopLogsArray() {
sebdetc8d61302019-07-04 15:50:34 +0200143 return this.loopJsonCache.loopLogs;
144 }
sebdet4946e5b2019-07-10 12:32:36 +0200145
sebdet190227a2019-07-19 16:51:19 +0200146 getComputedState() {
147 return this.loopJsonCache.lastComputedState;
148 }
149
sebdet4946e5b2019-07-10 12:32:36 +0200150 getComponentStates() {
sebdetc8d61302019-07-04 15:50:34 +0200151 return this.loopJsonCache.components;
152 }
sebdetc8d61302019-07-04 15:50:34 +0200153}