blob: dd8c5b5205f41d416054dcbdce6ad94df30007c5 [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() {
56 return this.loopJsonCache["operationalPolicySchema"];
57 }
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
sebdet493c3832019-07-15 17:26:18 +020063 getGlobalProperties() {
sebdet2df6c082019-07-18 15:29:45 +020064 return this.loopJsonCache["globalPropertiesJson"];
sebdetc8d61302019-07-04 15:50:34 +020065 }
sebdet4946e5b2019-07-10 12:32:36 +020066
sebdet493c3832019-07-15 17:26:18 +020067 getDcaeDeploymentProperties() {
sebdet2df6c082019-07-18 15:29:45 +020068 return this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"];
sebdetc8d61302019-07-04 15:50:34 +020069 }
sebdet4946e5b2019-07-10 12:32:36 +020070
sebdet2df6c082019-07-18 15:29:45 +020071 getMicroServicePolicies() {
72 return this.loopJsonCache["microServicePolicies"];
73 }
74
75 getMicroServiceForName(name) {
76 var msProperties=this.getMicroServicePolicies();
sebdet4946e5b2019-07-10 12:32:36 +020077 for (var policy in msProperties) {
sebdet2df6c082019-07-18 15:29:45 +020078 if (msProperties[policy]["name"] === name) {
79 return msProperties[policy];
sebdet4946e5b2019-07-10 12:32:36 +020080 }
81 }
82 return null;
sebdetc8d61302019-07-04 15:50:34 +020083 }
sebdet4946e5b2019-07-10 12:32:36 +020084
sebdet2df6c082019-07-18 15:29:45 +020085 getMicroServicePropertiesForName(name) {
86 var msConfig = this.getMicroServiceForName(name);
87 if (msConfig !== null) {
88 return msConfig["properties"];
sebdet4946e5b2019-07-10 12:32:36 +020089 }
90 return null;
sebdetc8d61302019-07-04 15:50:34 +020091 }
sebdet4946e5b2019-07-10 12:32:36 +020092
sebdet2df6c082019-07-18 15:29:45 +020093 getMicroServiceJsonRepresentationForName(name) {
94 var msConfig = this.getMicroServiceForName(name);
95 if (msConfig !== null) {
96 return msConfig["jsonRepresentation"];
sebdet4946e5b2019-07-10 12:32:36 +020097 }
98 return null;
sebdetc8d61302019-07-04 15:50:34 +020099 }
sebdet4946e5b2019-07-10 12:32:36 +0200100
101 getResourceDetailsVfProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200102 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"];
103 }
sebdet4946e5b2019-07-10 12:32:36 +0200104
105 getResourceDetailsVfModuleProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200106 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"];
107 }
sebdet4946e5b2019-07-10 12:32:36 +0200108
109 getLoopLogsArray() {
sebdetc8d61302019-07-04 15:50:34 +0200110 return this.loopJsonCache.loopLogs;
111 }
sebdet4946e5b2019-07-10 12:32:36 +0200112
sebdet190227a2019-07-19 16:51:19 +0200113 getComputedState() {
114 return this.loopJsonCache.lastComputedState;
115 }
116
sebdet4946e5b2019-07-10 12:32:36 +0200117 getComponentStates() {
sebdetc8d61302019-07-04 15:50:34 +0200118 return this.loopJsonCache.components;
119 }
sebdetc8d61302019-07-04 15:50:34 +0200120}