2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.openstack.beans;
25 import java.util.HashMap;
27 import com.woorea.openstack.heat.model.Stack;
30 * This Java bean class relays Heat stack status information to ActiveVOS processes.
32 * This bean is returned by all Heat-specific adapter operations (create, query, delete)
35 public class StackInfo {
36 // Set defaults for everything
37 private String name = "";
38 private String canonicalName = "";
39 private HeatStatus status = HeatStatus.UNKNOWN;
40 private String statusMessage = "";
41 private Map<String,Object> outputs = new HashMap<>();
42 private Map<String,Object> parameters = new HashMap<>();
44 static Map<String,HeatStatus> HeatStatusMap;
46 HeatStatusMap = new HashMap<>();
47 HeatStatusMap.put("CREATE_IN_PROGRESS", HeatStatus.BUILDING);
48 HeatStatusMap.put("CREATE_COMPLETE", HeatStatus.CREATED);
49 HeatStatusMap.put("CREATE_FAILED", HeatStatus.FAILED);
50 HeatStatusMap.put("DELETE_IN_PROGRESS", HeatStatus.DELETING);
51 HeatStatusMap.put("DELETE_COMPLETE", HeatStatus.NOTFOUND);
52 HeatStatusMap.put("DELETE_FAILED", HeatStatus.FAILED);
53 HeatStatusMap.put("UPDATE_IN_PROGRESS", HeatStatus.UPDATING);
54 HeatStatusMap.put("UPDATE_FAILED", HeatStatus.FAILED);
55 HeatStatusMap.put("UPDATE_COMPLETE", HeatStatus.UPDATED);
61 public StackInfo (String name, HeatStatus status, String statusMessage, Map<String,Object> outputs) {
63 this.canonicalName = name; // Don't have an ID, so just use name
66 if (statusMessage != null) this.statusMessage = statusMessage;
67 if (outputs != null) this.outputs = outputs;
70 public StackInfo (String name, HeatStatus status) {
72 this.canonicalName = name; // Don't have an ID, so just use name
76 public StackInfo (Stack stack)
79 this.status = HeatStatus.NOTFOUND;
83 this.name = stack.getStackName();
84 this.canonicalName = stack.getStackName() + "/" + stack.getId();
86 if (stack.getStackStatus() == null) {
87 this.status = HeatStatus.INIT;
88 } else if (HeatStatusMap.containsKey(stack.getStackStatus())) {
89 this.status = HeatStatusMap.get(stack.getStackStatus());
91 this.status = HeatStatusMap.getOrDefault(stack.getStackStatus(), HeatStatus.UNKNOWN);
94 this.statusMessage = stack.getStackStatusReason();
96 if (stack.getOutputs() != null) {
97 this.outputs = new HashMap<>();
98 for (Stack.Output output : stack.getOutputs()) {
99 this.outputs.put(output.getOutputKey(), output.getOutputValue());
103 this.parameters = stack.getParameters();
106 public String getName() {
110 public void setName (String name) {
114 public String getCanonicalName() {
115 return canonicalName;
118 public void setCanonicalName (String name) {
119 this.canonicalName = name;
122 public HeatStatus getStatus() {
126 public void setStatus (HeatStatus status) {
127 this.status = status;
130 public String getStatusMessage() {
131 return statusMessage;
134 public void setStatusMessage (String statusMessage) {
135 this.statusMessage = statusMessage;
138 public Map<String,Object> getOutputs () {
142 public void setOutputs (Map<String,Object> outputs) {
143 this.outputs = outputs;
146 public Map<String,Object> getParameters () {
150 public void setParameters (Map<String,Object> parameters) {
151 this.parameters = parameters;