sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 1 | /*- |
| 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 | * =================================================================== |
xuegao | f248df6 | 2019-07-15 15:16:18 +0200 | [diff] [blame] | 21 | * |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 22 | */ |
sebdet | e44fdb1 | 2019-07-12 12:25:56 +0200 | [diff] [blame] | 23 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 24 | export default class LoopCache { |
sebdet | e44fdb1 | 2019-07-12 12:25:56 +0200 | [diff] [blame] | 25 | loopJsonCache; |
| 26 | |
| 27 | constructor(loopJson) { |
| 28 | this.loopJsonCache=loopJson; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 29 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 30 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 31 | updateMicroServiceProperties(type, newMsProperties) { |
xuegao | f248df6 | 2019-07-15 15:16:18 +0200 | [diff] [blame] | 32 | if (newMsProperties["name"] === type) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 33 | for (var policy in this.loopJsonCache["microServicePolicies"]) { |
xuegao | f248df6 | 2019-07-15 15:16:18 +0200 | [diff] [blame] | 34 | if (this.loopJsonCache["microServicePolicies"][policy]["name"] === type) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 35 | this.loopJsonCache["microServicePolicies"][policy] = newMsProperties; |
| 36 | } |
| 37 | } |
| 38 | } |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 39 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 40 | |
| 41 | updateGlobalProperties(newGlobalProperties) { |
| 42 | this.loopJsonCache["globalPropertiesJson"] = newGlobalProperties; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 43 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 44 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 45 | updateOperationalPolicyProperties(newOpProperties) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 46 | this.loopJsonCache["operationalPolicies"] = newOpProperties; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 47 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 48 | |
| 49 | getLoopName() { |
| 50 | return this.loopJsonCache["name"]; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 51 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 52 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 53 | getOperationalPolicyConfigurationJson() { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 54 | return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"]["0"]["configurationsJson"])); |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 55 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 56 | |
| 57 | getOperationalPolicies() { |
| 58 | return JSON.parse(JSON.stringify(this.loopJsonCache["operationalPolicies"])); |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 59 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 60 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 61 | getGlobalProperties() { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 62 | return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"])); |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 63 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 64 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 65 | getDcaeDeploymentProperties() { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 66 | return JSON.parse(JSON.stringify(this.loopJsonCache["globalPropertiesJson"]["dcaeDeployParameters"])); |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 67 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 68 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 69 | getMicroServicesJsonForType(type) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 70 | var msProperties = this.loopJsonCache["microServicePolicies"]; |
| 71 | for (var policy in msProperties) { |
xuegao | f248df6 | 2019-07-15 15:16:18 +0200 | [diff] [blame] | 72 | if (msProperties[policy]["name"] === type) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 73 | return JSON.parse(JSON.stringify(msProperties[policy])); |
| 74 | } |
| 75 | } |
| 76 | return null; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 77 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 78 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 79 | getMicroServiceProperties(type) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 80 | var msProperties = this.loopJsonCache["microServicePolicies"]; |
| 81 | for (var policy in msProperties) { |
xuegao | f248df6 | 2019-07-15 15:16:18 +0200 | [diff] [blame] | 82 | if (msProperties[policy]["name"] === type) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 83 | if (msProperties[policy]["properties"] !== null && msProperties[policy]["properties"] !== undefined) { |
| 84 | return JSON.parse(JSON.stringify(msProperties[policy]["properties"])); |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | return null; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 89 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 90 | |
sebdet | 493c383 | 2019-07-15 17:26:18 +0200 | [diff] [blame^] | 91 | getMicroServiceJsonRepresentationForType(type) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 92 | var msProperties = this.loopJsonCache["microServicePolicies"]; |
| 93 | for (var policy in msProperties) { |
xuegao | f248df6 | 2019-07-15 15:16:18 +0200 | [diff] [blame] | 94 | if (msProperties[policy]["name"] === type) { |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 95 | return JSON.parse(JSON.stringify(msProperties[policy]["jsonRepresentation"])); |
| 96 | } |
| 97 | } |
| 98 | return null; |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 99 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 100 | |
| 101 | getResourceDetailsVfProperty() { |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 102 | return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VF"]; |
| 103 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 104 | |
| 105 | getResourceDetailsVfModuleProperty() { |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 106 | return this.loopJsonCache["modelPropertiesJson"]["resourceDetails"]["VFModule"]; |
| 107 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 108 | |
| 109 | getLoopLogsArray() { |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 110 | return this.loopJsonCache.loopLogs; |
| 111 | } |
sebdet | 4946e5b | 2019-07-10 12:32:36 +0200 | [diff] [blame] | 112 | |
| 113 | getComponentStates() { |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 114 | return this.loopJsonCache.components; |
| 115 | } |
sebdet | c8d6130 | 2019-07-04 15:50:34 +0200 | [diff] [blame] | 116 | } |