summaryrefslogtreecommitdiffstats
path: root/heat-model/src
diff options
context:
space:
mode:
Diffstat (limited to 'heat-model/src')
-rw-r--r--heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java127
-rw-r--r--heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java77
-rw-r--r--heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java35
-rw-r--r--heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java122
-rw-r--r--heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java28
-rw-r--r--heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java243
-rw-r--r--heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java17
-rw-r--r--heat-model/src/main/java/com/woorea/openstack/heat/model/UpdateStackParam.java134
8 files changed, 783 insertions, 0 deletions
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java
new file mode 100644
index 0000000..bcf3e8a
--- /dev/null
+++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java
@@ -0,0 +1,127 @@
+package com.woorea.openstack.heat.model;
+
+/*
+ * Modifications copyright (c) 2017 AT&T Intellectual Property
+ */
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Map;
+
+public class CreateStackParam {
+ @JsonProperty("stack_name")
+ private String stackName;
+
+ @JsonProperty("template_url")
+ private String templateUrl;
+
+ @JsonProperty
+ private String template;
+
+ @JsonProperty("parameters")
+ private Map<String, Object> parameters;
+
+ @JsonProperty("timeout_mins")
+ private int timeoutMinutes;
+
+ @JsonProperty("environment")
+ private String environment;
+
+ @JsonProperty("disable_rollback")
+ private boolean disableRollback = true;
+
+ @JsonProperty("files")
+ private Map<String, Object> files;
+
+ public String getStackName() {
+ return stackName;
+ }
+
+ public void setStackName(String stackName) {
+ this.stackName = stackName;
+ }
+
+ public String getTemplateUrl() {
+ return templateUrl;
+ }
+
+ /**
+ * The URL of the template to instantiate. This value is ignored if the template is supplied inline.
+ *
+ * @param templateUrl a template url.
+ */
+ public void setTemplateUrl(String templateUrl) {
+ this.templateUrl = templateUrl;
+ }
+
+ public Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ public String getTemplate() {
+ return template;
+ }
+
+ /**
+ * A JSON template to instantiate. This value takes precedence over the template URL if both are supplied.
+ *
+ * @param template a template json.
+ */
+ public void setTemplate(String template) {
+ this.template = template;
+ }
+
+ public void setParameters(Map<String, Object> parameters) {
+ this.parameters = parameters;
+ }
+
+ public int getTimeoutMinutes() {
+ return timeoutMinutes;
+ }
+
+ public void setTimeoutMinutes(int timeoutMinutes) {
+ this.timeoutMinutes = timeoutMinutes;
+ }
+
+ public String getEnvironment() {
+ return environment;
+ }
+
+ /**
+ * A JSON environment for the stack.
+ *
+ * @param environment a environment.
+ */
+ public void setEnvironment(String environment) {
+ this.environment = environment;
+ }
+
+ public boolean getDisableRollback() {
+ return disableRollback;
+ }
+
+ public void setDisableRollback(boolean disableRollback) {
+ this.disableRollback = disableRollback;
+ }
+
+ public void setFiles(Map<String, Object> files) {
+ this.files = files;
+ }
+ public Map<String, Object> getFiles() {
+ return this.files;
+ }
+
+ @Override
+ public String toString() {
+ return "CreateStackParam{" +
+ "stackName='" + stackName + '\'' +
+ ", templateUrl='" + templateUrl + '\'' +
+ ", template='" + template + '\'' +
+ ", parameters=" + parameters +
+ ", timeoutMinutes=" + timeoutMinutes +
+ ", environment='" + environment + '\'' +
+ ", disableRollback='" + disableRollback + '\'' +
+ ", files=" + files +
+ '}';
+ }
+}
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java
new file mode 100644
index 0000000..816d2f8
--- /dev/null
+++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java
@@ -0,0 +1,77 @@
+package com.woorea.openstack.heat.model;
+
+/*
+ * Modifications copyright (c) 2017 AT&T Intellectual Property
+ */
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+// There is no Root element for the Explanation return
+//@JsonRootName("error")
+public class Explanation {
+ @JsonProperty("explanation")
+ private String explanation;
+
+ @JsonProperty("code")
+ private int code;
+
+ @JsonProperty("title")
+ private String title;
+
+ @JsonRootName("error")
+ public static class Error {
+ @JsonProperty("message")
+ private String message;
+
+ @JsonProperty("traceback")
+ private String traceback;
+
+ @JsonProperty("type")
+ private String type;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getTraceback() {
+ return traceback;
+ }
+
+ public String getType() {
+ return type;
+ }
+ }
+
+ private Error error;
+
+ public String getExplanation() {
+ return explanation;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public Error getError() {
+ return error;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "Explanation [ " +
+ "code='" + code +
+ "', title='" + title +
+ "', explanation='" + explanation +
+ "', Error [type='" + error.type +
+ "', message='" + error.message + "' ] ]";
+ }
+
+}
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java
new file mode 100644
index 0000000..ec1970f
--- /dev/null
+++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java
@@ -0,0 +1,35 @@
+package com.woorea.openstack.heat.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class Link {
+ @JsonProperty("href")
+ private String href;
+
+ @JsonProperty("rel")
+ private String rel;
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ public String getRel() {
+ return rel;
+ }
+
+ public void setRel(String rel) {
+ this.rel = rel;
+ }
+
+ @Override
+ public String toString() {
+ return "Link{" +
+ "href='" + href + '\'' +
+ ", rel='" + rel + '\'' +
+ '}';
+ }
+}
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java
new file mode 100644
index 0000000..159bbcd
--- /dev/null
+++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java
@@ -0,0 +1,122 @@
+package com.woorea.openstack.heat.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Date;
+import java.util.List;
+
+public class Resource {
+ @JsonProperty("resource_name")
+ private String name;
+
+ @JsonProperty("links")
+ private List<Link> links;
+
+ @JsonProperty("resource_status")
+ private String status;
+
+ @JsonProperty("physical_resource_id")
+ private String physicalResourceId;
+
+ @JsonProperty("logical_resource_id")
+ private String logicalResourceId;
+
+ @JsonProperty("required_by")
+ private List<String> requiredBy;
+
+ @JsonProperty("updated_time")
+ private Date updatedTime;
+
+ @JsonProperty("resource_type")
+ private String type;
+
+ @JsonProperty("resource_status_reason")
+ private String statusReason;
+
+ public String getStatusReason() {
+ return statusReason;
+ }
+
+ public void setStatusReason(String statusReason) {
+ this.statusReason = statusReason;
+ }
+
+ public String getLogicalResourceId() {
+ return logicalResourceId;
+ }
+
+ public void setLogicalResourceId(String logicalResourceId) {
+ this.logicalResourceId = logicalResourceId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getPhysicalResourceId() {
+ return physicalResourceId;
+ }
+
+ public void setPhysicalResourceId(String physicalResourceId) {
+ this.physicalResourceId = physicalResourceId;
+ }
+
+ public List<String> getRequiredBy() {
+ return requiredBy;
+ }
+
+ public void setRequiredBy(List<String> requiredBy) {
+ this.requiredBy = requiredBy;
+ }
+
+ public Date getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Date updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Link> getLinks() {
+ return links;
+ }
+
+ public void setLinks(List<Link> links) {
+ this.links = links;
+ }
+
+ @Override
+ public String toString() {
+ return "Resource{" +
+ "name='" + name + '\'' +
+ ", links=" + links +
+ ", status='" + status + '\'' +
+ ", physicalResourceId='" + physicalResourceId + '\'' +
+ ", logicalResourceId='" + logicalResourceId + '\'' +
+ ", requiredBy=" + requiredBy +
+ ", updatedTime=" + updatedTime +
+ ", type='" + type + '\'' +
+ ", statusReason='" + statusReason + '\'' +
+ '}';
+ }
+}
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java
new file mode 100644
index 0000000..068c5e0
--- /dev/null
+++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java
@@ -0,0 +1,28 @@
+package com.woorea.openstack.heat.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+public class Resources implements Iterable<Resource>, Serializable {
+ @JsonProperty("resources")
+ private List<Resource> list;
+
+ public List<Resource> getList() {
+ return list;
+ }
+
+ @Override
+ public Iterator<Resource> iterator() {
+ return list.iterator();
+ }
+
+ @Override
+ public String toString() {
+ return "Resources{" +
+ "list=" + list +
+ '}';
+ }
+} \ No newline at end of file
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java
new file mode 100644
index 0000000..5f58195
--- /dev/null
+++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java
@@ -0,0 +1,243 @@
+package com.woorea.openstack.heat.model;
+
+/*
+ * Modifications copyright (c) 2017 AT&T Intellectual Property
+ */
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonRootName("stack")
+public class Stack {
+ @JsonProperty("description")
+ private String description;
+
+ @JsonProperty("links")
+ private List<Link> links;
+
+ @JsonProperty("stack_status_reason")
+ private String stackStatusReason;
+
+ @JsonProperty("stack_name")
+ private String stackName;
+
+ @JsonProperty("updated_time")
+ private Date updatedTime;
+
+ @JsonProperty("creation_time")
+ private Date creationTime;
+
+ @JsonProperty("stack_status")
+ private String stackStatus;
+
+ @JsonProperty("id")
+ private String id;
+
+ @JsonProperty("files")
+ private Map<String, Object> files = null;
+
+ // ObjectMapper instance to parse Json stack outputs
+ @JsonIgnore
+ private static ObjectMapper mapper = new ObjectMapper();
+
+ public Date getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Date updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public String getStackStatus() {
+ return stackStatus;
+ }
+
+ public void setStackStatus(String stackStatus) {
+ this.stackStatus = stackStatus;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Date getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Date creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public String getStackName() {
+ return stackName;
+ }
+
+ public void setStackName(String stackName) {
+ this.stackName = stackName;
+ }
+
+ public String getStackStatusReason() {
+ return stackStatusReason;
+ }
+
+ public void setStackStatusReason(String stackStatusReason) {
+ this.stackStatusReason = stackStatusReason;
+ }
+
+ public List<Link> getLinks() {
+ return links;
+ }
+
+ public void setLinks(List<Link> links) {
+ this.links = links;
+ }
+
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, Object> getFiles() {
+ return this.files;
+ }
+ public void setFiles(Map<String, Object> files) {
+ this.files = files;
+ }
+
+
+ @Override
+ public String toString() {
+ return "Stack{" +
+ "description='" + description + '\'' +
+ ", links=" + links +
+ ", stackStatusReason='" + stackStatusReason + '\'' +
+ ", stackName='" + stackName + '\'' +
+ ", updatedTime=" + updatedTime +
+ ", creationTime=" + creationTime +
+ ", stackStatus='" + stackStatus + '\'' +
+ ", id='" + id + '\'' +
+ ", outputs='" + outputs + '\'' +
+ ", parameters='" + parameters + '\'' +
+ ", files='" + files + '\'' +
+ '}';
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ public static final class Output {
+ @JsonProperty("output_value")
+ private Object outputValue;
+
+ private String description;
+
+ @JsonProperty("output_key")
+ private String outputKey;
+
+ public Object getOutputValue() {
+ return outputValue;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getOutputKey() {
+ return outputKey;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "Output [key=" + outputKey + ", value="
+ + outputValue + "]";
+ }
+ }
+
+ private List<Output> outputs;
+
+ public List<Output> getOutputs() {
+ return outputs;
+ }
+
+ private Object _findOutputValue (String key) {
+ for (Output o : outputs) {
+ if (o.getOutputKey().equals(key)) {
+ return o.getOutputValue();
+ }
+ }
+ return null;
+ }
+
+ /*
+ * Return a stack output as a String.
+ * Generally speaking, most outputs will be Strings.
+ */
+ public String getOutputValue (String key)
+ {
+ Object value = _findOutputValue(key);
+ if (value != null)
+ return value.toString();
+ else
+ return null;
+ }
+
+ /*
+ * Return a stack output as a Json-mapped Object of the provided type.
+ * This is useful for json-object stack outputs.
+ */
+ public <T> T getOutputValue (String key, Class<T> type)
+ {
+ try {
+ String s = mapper.writeValueAsString(_findOutputValue(key));
+ return (mapper.readValue(s, type));
+ }
+ catch (IOException e) {
+ return null;
+ }
+ }
+
+ @JsonProperty("parameters")
+ private Map<String,Object> parameters = new HashMap<String,Object>();
+
+ public void setParameters (Map<String,Object> params)
+ {
+ // Need to "fix" comma-delimited-list parameters for pre-Juno Heat
+ // (see https://bugs.launchpad.net/heat/+bug/1367393)
+ parameters = params;
+
+ for (Entry<String,Object> param : parameters.entrySet())
+ {
+ // CDL params are returned as a string with format:
+ // "[u'<value1>',u'<value2>',...]"
+ String value = param.getValue().toString();
+ if (value.startsWith("[") && value.endsWith("]"))
+ {
+ param.setValue(value.substring(1,value.length()-1).replaceAll("u'([^\']+)'","$1"));
+ }
+ }
+ }
+
+ public Map<String,Object> getParameters() {
+ return parameters;
+ }
+}
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java
new file mode 100644
index 0000000..6f174aa
--- /dev/null
+++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java
@@ -0,0 +1,17 @@
+package com.woorea.openstack.heat.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+public class Stacks implements Iterable<Stack>, Serializable {
+ @JsonProperty("stacks")
+ private List<Stack> list;
+
+ @Override
+ public Iterator<Stack> iterator() {
+ return list.iterator();
+ }
+}
diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/UpdateStackParam.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/UpdateStackParam.java
new file mode 100644
index 0000000..5aa0b76
--- /dev/null
+++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/UpdateStackParam.java
@@ -0,0 +1,134 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ *
+ */
+
+package com.woorea.openstack.heat.model;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import java.util.Map;
+
+public class UpdateStackParam {
+ @JsonProperty("template_url")
+ private String templateUrl;
+
+ @JsonProperty
+ private String template;
+
+ @JsonProperty("parameters")
+ private Map<String, Object> parameters;
+
+ @JsonProperty("timeout_mins")
+ private int timeoutMinutes;
+
+ @JsonProperty("environment")
+ private String environment;
+
+ @JsonProperty("disable_rollback")
+ private boolean disableRollback = true;
+
+ @JsonProperty("files")
+ private Map<String, Object> files;
+
+ public String getTemplateUrl() {
+ return templateUrl;
+ }
+
+ /**
+ * The URL of the template to instantiate. This value is ignored if the template is supplied inline.
+ *
+ * @param templateUrl a template url.
+ */
+ public void setTemplateUrl(String templateUrl) {
+ this.templateUrl = templateUrl;
+ }
+
+ public Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ public String getTemplate() {
+ return template;
+ }
+
+ /**
+ * A JSON template to instantiate. This value takes precedence over the template URL if both are supplied.
+ *
+ * @param template a template json.
+ */
+ public void setTemplate(String template) {
+ this.template = template;
+ }
+
+ public void setParameters(Map<String, Object> parameters) {
+ this.parameters = parameters;
+ }
+
+ public int getTimeoutMinutes() {
+ return timeoutMinutes;
+ }
+
+ public void setTimeoutMinutes(int timeoutMinutes) {
+ this.timeoutMinutes = timeoutMinutes;
+ }
+
+ public String getEnvironment() {
+ return environment;
+ }
+
+ public void setFiles(Map<String, Object> files) {
+ this.files = files;
+ }
+ public Map<String, Object> getFiles() {
+ return this.files;
+ }
+
+ /**
+ * A JSON environment for the stack.
+ *
+ * @param environment a environment.
+ */
+ public void setEnvironment(String environment) {
+ this.environment = environment;
+ }
+
+ public boolean getDisableRollback() {
+ return disableRollback;
+ }
+
+ public void setDisableRollback(boolean disableRollback) {
+ this.disableRollback = disableRollback;
+ }
+
+ @Override
+ public String toString() {
+ return "UpdateStackParam{" +
+ " templateUrl='" + templateUrl + '\'' +
+ ", template='" + template + '\'' +
+ ", parameters=" + parameters +
+ ", timeoutMinutes=" + timeoutMinutes +
+ ", environment='" + environment + '\'' +
+ ", disableRollback='" + disableRollback + '\'' +
+ ", files=" + files +
+ '}';
+ }
+}