From 3f9a0c3183480d150089c0d5a6e507c877f7d121 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Thu, 2 May 2019 09:42:55 -0400 Subject: Enhance Openstack Client Update Openstack Client to support additional fields Updat all formatting issues Issue-ID: SO-1844 Change-Id: I1369e0c18cc25274db8df7e12855a020b8da38da Signed-off-by: Smokowski, Steve (ss835w) --- .../openstack/heat/model/CreateStackParam.java | 23 +-- .../com/woorea/openstack/heat/model/Event.java | 197 ++++++++++----------- .../com/woorea/openstack/heat/model/Events.java | 17 +- .../woorea/openstack/heat/model/Explanation.java | 30 ++-- .../java/com/woorea/openstack/heat/model/Link.java | 5 +- .../com/woorea/openstack/heat/model/Resource.java | 27 +-- .../com/woorea/openstack/heat/model/Resources.java | 5 +- .../com/woorea/openstack/heat/model/Stack.java | 160 +++++++++++------ .../com/woorea/openstack/heat/model/Stacks.java | 12 +- .../openstack/heat/model/UpdateStackParam.java | 18 +- 10 files changed, 264 insertions(+), 230 deletions(-) (limited to 'heat-model/src/main/java/com/woorea/openstack/heat') 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 index 09bb14c..9781184 100644 --- 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 @@ -21,7 +21,6 @@ package com.woorea.openstack.heat.model; */ import java.util.Map; - import com.fasterxml.jackson.annotation.JsonProperty; public class CreateStackParam { @@ -131,23 +130,9 @@ public class CreateStackParam { @Override public String toString() { - return String.format("CreateStackParam{" - + "stackName='%s'," - + " templateUrl='%s'," - + " template='%s'," - + " parameters=%s," - + " timeoutMinutes=%d," - + " environment='%s'," - + " disableRollback='%s'," - + " files=%s" - + "}", - stackName, - templateUrl, - template, - parameters, - timeoutMinutes, - environment, - disableRollback, - files); + return String.format( + "CreateStackParam{" + "stackName='%s'," + " templateUrl='%s'," + " template='%s'," + " parameters=%s," + + " timeoutMinutes=%d," + " environment='%s'," + " disableRollback='%s'," + " files=%s" + "}", + stackName, templateUrl, template, parameters, timeoutMinutes, environment, disableRollback, files); } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Event.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Event.java index 8abcdd5..c346ce3 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Event.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Event.java @@ -17,111 +17,110 @@ import java.util.List; * limitations under the License. * ============LICENSE_END========================================================= */ - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "event_time", "id", "links", "logical_resource_id", "physical_resource_id", "resource_name", - "resource_status", "resource_status_reason" }) +@JsonPropertyOrder({"event_time", "id", "links", "logical_resource_id", "physical_resource_id", "resource_name", + "resource_status", "resource_status_reason"}) public class Event { - @JsonProperty("event_time") - private String eventTime; - @JsonProperty("id") - private String id; - @JsonProperty("links") - private List links = null; - @JsonProperty("logical_resource_id") - private String logicalResourceId; - @JsonProperty("physical_resource_id") - private Object physicalResourceId; - @JsonProperty("resource_name") - private String resourceName; - @JsonProperty("resource_status") - private String resourceStatus; - @JsonProperty("resource_status_reason") - private String resourceStatusReason; - - @JsonProperty("event_time") - public String getEventTime() { - return eventTime; - } - - @JsonProperty("event_time") - public void setEventTime(String eventTime) { - this.eventTime = eventTime; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @JsonProperty("id") - public void setId(String id) { - this.id = id; - } - - @JsonProperty("links") - public List getLinks() { - return links; - } - - @JsonProperty("links") - public void setLinks(List links) { - this.links = links; - } - - @JsonProperty("logical_resource_id") - public String getLogicalResourceId() { - return logicalResourceId; - } - - @JsonProperty("logical_resource_id") - public void setLogicalResourceId(String logicalResourceId) { - this.logicalResourceId = logicalResourceId; - } - - @JsonProperty("physical_resource_id") - public Object getPhysicalResourceId() { - return physicalResourceId; - } - - @JsonProperty("physical_resource_id") - public void setPhysicalResourceId(Object physicalResourceId) { - this.physicalResourceId = physicalResourceId; - } - - @JsonProperty("resource_name") - public String getResourceName() { - return resourceName; - } - - @JsonProperty("resource_name") - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - @JsonProperty("resource_status") - public String getResourceStatus() { - return resourceStatus; - } - - @JsonProperty("resource_status") - public void setResourceStatus(String resourceStatus) { - this.resourceStatus = resourceStatus; - } - - @JsonProperty("resource_status_reason") - public String getResourceStatusReason() { - return resourceStatusReason; - } - - @JsonProperty("resource_status_reason") - public void setResourceStatusReason(String resourceStatusReason) { - this.resourceStatusReason = resourceStatusReason; - } + @JsonProperty("event_time") + private String eventTime; + @JsonProperty("id") + private String id; + @JsonProperty("links") + private List links = null; + @JsonProperty("logical_resource_id") + private String logicalResourceId; + @JsonProperty("physical_resource_id") + private Object physicalResourceId; + @JsonProperty("resource_name") + private String resourceName; + @JsonProperty("resource_status") + private String resourceStatus; + @JsonProperty("resource_status_reason") + private String resourceStatusReason; + + @JsonProperty("event_time") + public String getEventTime() { + return eventTime; + } + + @JsonProperty("event_time") + public void setEventTime(String eventTime) { + this.eventTime = eventTime; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("id") + public void setId(String id) { + this.id = id; + } + + @JsonProperty("links") + public List getLinks() { + return links; + } + + @JsonProperty("links") + public void setLinks(List links) { + this.links = links; + } + + @JsonProperty("logical_resource_id") + public String getLogicalResourceId() { + return logicalResourceId; + } + + @JsonProperty("logical_resource_id") + public void setLogicalResourceId(String logicalResourceId) { + this.logicalResourceId = logicalResourceId; + } + + @JsonProperty("physical_resource_id") + public Object getPhysicalResourceId() { + return physicalResourceId; + } + + @JsonProperty("physical_resource_id") + public void setPhysicalResourceId(Object physicalResourceId) { + this.physicalResourceId = physicalResourceId; + } + + @JsonProperty("resource_name") + public String getResourceName() { + return resourceName; + } + + @JsonProperty("resource_name") + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + @JsonProperty("resource_status") + public String getResourceStatus() { + return resourceStatus; + } + + @JsonProperty("resource_status") + public void setResourceStatus(String resourceStatus) { + this.resourceStatus = resourceStatus; + } + + @JsonProperty("resource_status_reason") + public String getResourceStatusReason() { + return resourceStatusReason; + } + + @JsonProperty("resource_status_reason") + public void setResourceStatusReason(String resourceStatusReason) { + this.resourceStatusReason = resourceStatusReason; + } } diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Events.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Events.java index ca4fdff..4363129 100644 --- a/heat-model/src/main/java/com/woorea/openstack/heat/model/Events.java +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Events.java @@ -20,25 +20,24 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; public class Events implements Iterable, Serializable { - /** - * - */ - private static final long serialVersionUID = 3598543745379474704L; - - @JsonProperty("events") - private List events = new ArrayList<>(); + /** + * + */ + private static final long serialVersionUID = 3598543745379474704L; + + @JsonProperty("events") + private List events = new ArrayList<>(); public List getEvents() { return events; } - + @Override public Iterator iterator() { return events.iterator(); 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 index 2b1628b..178ae0e 100644 --- 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 @@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; */ // There is no Root element for the Explanation return -//@JsonRootName("error") +// @JsonRootName("error") public class Explanation { @JsonProperty("explanation") private String explanation; @@ -34,7 +34,7 @@ public class Explanation { @JsonProperty("title") private String title; - + @JsonRootName("error") public static class Error { @JsonProperty("message") @@ -49,45 +49,43 @@ public class Explanation { 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) + /* + * (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 + "' ] ]"; + 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 index f70229e..d326e72 100644 --- 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 @@ -43,9 +43,6 @@ public class Link { @Override public String toString() { - return "Link{" + - "href='" + href + '\'' + - ", rel='" + rel + '\'' + - '}'; + 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 index df8ef01..5f2468d 100644 --- 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 @@ -18,7 +18,6 @@ package com.woorea.openstack.heat.model; import java.util.Date; import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; public class Resource { @@ -43,6 +42,9 @@ public class Resource { @JsonProperty("updated_time") private Date updatedTime; + @JsonProperty("creation_time") + private Date creationTime; + @JsonProperty("resource_type") private String type; @@ -53,6 +55,14 @@ public class Resource { return statusReason; } + public Date getCreationTime() { + return creationTime; + } + + public void setCreationTime(Date creationTime) { + this.creationTime = creationTime; + } + public void setStatusReason(String statusReason) { this.statusReason = statusReason; } @@ -123,16 +133,9 @@ public class Resource { @Override public String toString() { - return "Resource{" + - "name='" + name + '\'' + - ", links=" + links + - ", status='" + status + '\'' + - ", physicalResourceId='" + physicalResourceId + '\'' + - ", logicalResourceId='" + logicalResourceId + '\'' + - ", requiredBy=" + requiredBy + - ", updatedTime=" + updatedTime + - ", type='" + type + '\'' + - ", statusReason='" + statusReason + '\'' + - '}'; + 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 index db99f04..80069d5 100644 --- 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 @@ -19,7 +19,6 @@ package com.woorea.openstack.heat.model; import java.io.Serializable; import java.util.Iterator; import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; @@ -39,8 +38,6 @@ public class Resources implements Iterable, Serializable { @Override public String toString() { - return "Resources{" + - "list=" + list + - '}'; + return "Resources{" + "list=" + list + '}'; } } 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 index 340f3d1..cb2d254 100644 --- 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 @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @@ -42,6 +41,7 @@ public class Stack { @JsonProperty("links") private List links; + @JsonProperty("stack_status_reason") private String stackStatusReason; @@ -59,10 +59,76 @@ public class Stack { @JsonProperty("id") private String id; - + + @JsonProperty("template_description") + private String templateDescription; + + @JsonProperty("stack_owner") + private String stackOwner; + + @JsonProperty("disable_rollback") + private boolean disableRollback; + + @JsonProperty("stack_user_project_id") + private String userProjectId; + + @JsonProperty("timeout_mins") + private int timeouteMinutes; + + public String getTemplateDescription() { + return templateDescription; + } + + public void setTemplateDescription(String templateDescription) { + this.templateDescription = templateDescription; + } + + public String getStackOwner() { + return stackOwner; + } + + public void setStackOwner(String stackOwner) { + this.stackOwner = stackOwner; + } + + public boolean isDisableRollback() { + return disableRollback; + } + + public void setDisableRollback(boolean disableRollback) { + this.disableRollback = disableRollback; + } + + public String getUserProjectId() { + return userProjectId; + } + + public void setUserProjectId(String userProjectId) { + this.userProjectId = userProjectId; + } + + public int getTimeouteMinutes() { + return timeouteMinutes; + } + + public void setTimeouteMinutes(int timeouteMinutes) { + this.timeouteMinutes = timeouteMinutes; + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + @JsonProperty("project") + private String project; + @JsonProperty("files") private Map files = null; - + // ObjectMapper instance to parse Json stack outputs @JsonIgnore private static ObjectMapper mapper = new ObjectMapper(); @@ -131,10 +197,11 @@ public class Stack { public void setDescription(String description) { this.description = description; } - + public Map getFiles() { return this.files; } + public void setFiles(Map files) { this.files = files; } @@ -142,31 +209,23 @@ public class Stack { @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) + 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; } @@ -179,23 +238,24 @@ public class Stack { return outputKey; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { - return "Output [key=" + outputKey + ", value=" - + outputValue + "]"; + return "Output [key=" + outputKey + ", value=" + outputValue + "]"; } } - + private List outputs; public List getOutputs() { return outputs; } - - private Object _findOutputValue (String key) { + + private Object _findOutputValue(String key) { for (Output o : outputs) { if (o.getOutputKey().equals(key)) { return o.getOutputValue(); @@ -203,57 +263,49 @@ public class Stack { } return null; } - + /* - * Return a stack output as a String. - * Generally speaking, most outputs will be Strings. + * Return a stack output as a String. Generally speaking, most outputs will be Strings. */ - public String getOutputValue (String key) - { + 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. + * Return a stack output as a Json-mapped Object of the provided type. This is useful for json-object stack outputs. */ - public T getOutputValue (String key, Class type) - { + public T getOutputValue(String key, Class type) { try { String s = mapper.writeValueAsString(_findOutputValue(key)); return mapper.readValue(s, type); - } - catch (IOException e) { + } catch (IOException e) { return null; } } - + @JsonProperty("parameters") - private Map parameters = new HashMap<>(); - - public void setParameters (Map params) - { + private Map parameters = new HashMap<>(); + + public void setParameters(Map params) { // Need to "fix" comma-delimited-list parameters for pre-Juno Heat // (see https://bugs.launchpad.net/heat/+bug/1367393) parameters = params; - - for (Entry param : parameters.entrySet()) - { + + for (Entry param : parameters.entrySet()) { // CDL params are returned as a string with format: // "[u'',u'',...]" String value = param.getValue().toString(); - if (value.startsWith("[") && value.endsWith("]")) - { - param.setValue(value.substring(1,value.length()-1).replaceAll("u'([^\']+)'","$1")); + if (value.startsWith("[") && value.endsWith("]")) { + param.setValue(value.substring(1, value.length() - 1).replaceAll("u'([^\']+)'", "$1")); } } } - - public Map getParameters() { + + public Map 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 index d4b11d6..59ff5dd 100644 --- 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 @@ -19,13 +19,23 @@ package com.woorea.openstack.heat.model; import java.io.Serializable; import java.util.Iterator; import java.util.List; - import com.fasterxml.jackson.annotation.JsonProperty; public class Stacks implements Iterable, Serializable { @JsonProperty("stacks") private List list; + @JsonProperty("links") + private List links; + + public List getLinks() { + return links; + } + + public void setLinks(List links) { + this.links = links; + } + @Override public Iterator 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 index 220e400..9a7c719 100644 --- 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 @@ -16,7 +16,6 @@ package com.woorea.openstack.heat.model; import java.util.Map; - import com.fasterxml.jackson.annotation.JsonProperty; public class UpdateStackParam { @@ -37,7 +36,7 @@ public class UpdateStackParam { @JsonProperty("disable_rollback") private boolean disableRollback = true; - + @JsonProperty("files") private Map files; @@ -85,11 +84,12 @@ public class UpdateStackParam { public String getEnvironment() { return environment; - } + } public void setFiles(Map files) { this.files = files; } + public Map getFiles() { return this.files; } @@ -113,14 +113,8 @@ public class UpdateStackParam { @Override public String toString() { - return "UpdateStackParam{" + - " templateUrl='" + templateUrl + '\'' + - ", template='" + template + '\'' + - ", parameters=" + parameters + - ", timeoutMinutes=" + timeoutMinutes + - ", environment='" + environment + '\'' + - ", disableRollback='" + disableRollback + '\'' + - ", files=" + files + - '}'; + return "UpdateStackParam{" + " templateUrl='" + templateUrl + '\'' + ", template='" + template + '\'' + + ", parameters=" + parameters + ", timeoutMinutes=" + timeoutMinutes + ", environment='" + environment + + '\'' + ", disableRollback='" + disableRollback + '\'' + ", files=" + files + '}'; } } -- cgit 1.2.3-korg