blob: 3ee5acc68d3e0136d0896bad6546312a2cd0d4e2 [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
sebdet493c3832019-07-15 17:26:18 +020031 updateMicroServiceProperties(type, newMsProperties) {
sebdet4946e5b2019-07-10 12:32:36 +020032 for (var policy in this.loopJsonCache["microServicePolicies"]) {
xuegaof248df62019-07-15 15:16:18 +020033 if (this.loopJsonCache["microServicePolicies"][policy]["name"] === type) {
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 }
sebdet4946e5b2019-07-10 12:32:36 +020054
55 getOperationalPolicies() {
sebdet2df6c082019-07-18 15:29:45 +020056 return this.loopJsonCache["operationalPolicies"];
sebdetc8d61302019-07-04 15:50:34 +020057 }
sebdet4946e5b2019-07-10 12:32:36 +020058
sebdet493c3832019-07-15 17:26:18 +020059 getGlobalProperties() {
sebdet2df6c082019-07-18 15:29:45 +020060 return this.loopJsonCache["globalPropertiesJson"];
sebdetc8d61302019-07-04 15:50:34 +020061 }
sebdet4946e5b2019-07-10 12:32:36 +020062
sebdet493c3832019-07-15 17:26:18 +020063 getDcaeDeploymentProperties() {
sebdet2df6c082019-07-18 15:29:45 +020064 return this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"];
sebdetc8d61302019-07-04 15:50:34 +020065 }
sebdet4946e5b2019-07-10 12:32:36 +020066
sebdet2df6c082019-07-18 15:29:45 +020067 getMicroServicePolicies() {
68 return this.loopJsonCache["microServicePolicies"];
69 }
70
71 getMicroServiceForName(name) {
72 var msProperties=this.getMicroServicePolicies();
sebdet4946e5b2019-07-10 12:32:36 +020073 for (var policy in msProperties) {
sebdet2df6c082019-07-18 15:29:45 +020074 if (msProperties[policy]["name"] === name) {
75 return msProperties[policy];
sebdet4946e5b2019-07-10 12:32:36 +020076 }
77 }
78 return null;
sebdetc8d61302019-07-04 15:50:34 +020079 }
sebdet4946e5b2019-07-10 12:32:36 +020080
sebdet2df6c082019-07-18 15:29:45 +020081 getMicroServicePropertiesForName(name) {
82 var msConfig = this.getMicroServiceForName(name);
83 if (msConfig !== null) {
84 return msConfig["properties"];
sebdet4946e5b2019-07-10 12:32:36 +020085 }
86 return null;
sebdetc8d61302019-07-04 15:50:34 +020087 }
sebdet4946e5b2019-07-10 12:32:36 +020088
sebdet2df6c082019-07-18 15:29:45 +020089 getMicroServiceJsonRepresentationForName(name) {
90 var msConfig = this.getMicroServiceForName(name);
91 if (msConfig !== null) {
92 return msConfig["jsonRepresentation"];
sebdet4946e5b2019-07-10 12:32:36 +020093 }
94 return null;
sebdetc8d61302019-07-04 15:50:34 +020095 }
sebdet4946e5b2019-07-10 12:32:36 +020096
97 getResourceDetailsVfProperty() {
sebdetc8d61302019-07-04 15:50:34 +020098 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"];
99 }
sebdet4946e5b2019-07-10 12:32:36 +0200100
101 getResourceDetailsVfModuleProperty() {
sebdetc8d61302019-07-04 15:50:34 +0200102 return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"];
103 }
sebdet4946e5b2019-07-10 12:32:36 +0200104
105 getLoopLogsArray() {
sebdetc8d61302019-07-04 15:50:34 +0200106 return this.loopJsonCache.loopLogs;
107 }
sebdet4946e5b2019-07-10 12:32:36 +0200108
sebdet190227a2019-07-19 16:51:19 +0200109 getComputedState() {
110 return this.loopJsonCache.lastComputedState;
111 }
112
sebdet4946e5b2019-07-10 12:32:36 +0200113 getComponentStates() {
sebdetc8d61302019-07-04 15:50:34 +0200114 return this.loopJsonCache.components;
115 }
sebdetc8d61302019-07-04 15:50:34 +0200116}