Containerization feature of SO
[so.git] / adapters / mso-adapter-utils / src / main / java / org / onap / so / cloud / CloudifyManager.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.cloud;
22
23 import java.security.GeneralSecurityException;
24 import java.util.Comparator;
25
26 import org.onap.so.logger.MessageEnum;
27 import org.onap.so.logger.MsoLogger;
28 import org.onap.so.utils.CryptoUtils;
29
30 import com.fasterxml.jackson.annotation.JsonProperty;
31 import com.openpojo.business.annotation.BusinessKey;
32 import org.apache.commons.lang3.builder.ToStringBuilder;
33 import org.apache.commons.lang3.builder.ToStringStyle;
34 import org.apache.commons.lang3.builder.HashCodeBuilder;
35 import org.apache.commons.lang3.builder.EqualsBuilder;
36
37 /**
38  * JavaBean JSON class for a Cloudify Manager.  This bean represents a Cloudify
39  * node through which TOSCA-based VNFs may be deployed.  Each CloudSite in the
40  * CloudConfig may have a Cloudify Manager for deployments using TOSCA blueprints.
41  * Cloudify Managers may support multiple Cloud Sites, but each site will have
42  * at most one Cloudify Manager.
43  * 
44  * This does not replace the ability to use the CloudSite directly via Openstack.
45  *
46  * Note that this is only used to access Cloud Configurations loaded from a
47  * JSON config file, so there are no explicit setters.
48  *
49  * @author JC1348
50  */
51 public class CloudifyManager {
52         
53     private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, CloudifyManager.class);
54
55         @BusinessKey
56         @JsonProperty
57         private String id;
58         
59         @BusinessKey
60         @JsonProperty ("cloudify_url")
61         private String cloudifyUrl;
62         
63         @BusinessKey
64         @JsonProperty("username")
65         private String username;
66         
67         @BusinessKey
68         @JsonProperty("password")
69         private String password;
70         
71         @BusinessKey
72         @JsonProperty("version")
73         private String version;
74
75         public CloudifyManager() {}
76         
77         public String getId() {
78                 return id;
79         }
80         public void setId(String id) {
81                 this.id = id;
82         }
83         
84         public String getCloudifyUrl() {
85                 return cloudifyUrl;
86         }
87
88         public void setCloudifyUrl(String cloudifyUrl) {
89                 this.cloudifyUrl = cloudifyUrl;
90         }
91
92         public String getUsername() {
93                 return username;
94         }
95
96         public void setUsername(String username) {
97                 this.username = username;
98         }
99
100         public String getPassword() {
101         return password;
102         }
103
104         public void setPassword(String password) {
105                 this.password = password;
106         }
107
108         public String getVersion() {
109                 return version;
110         }
111
112         public void setVersion(String version) {
113                 this.version = version;
114         }
115
116         @Override
117         public CloudifyManager clone() {
118                 CloudifyManager cloudifyManagerCopy = new CloudifyManager();
119                 cloudifyManagerCopy.id = this.id;
120                 cloudifyManagerCopy.cloudifyUrl = this.cloudifyUrl;
121                 cloudifyManagerCopy.username = this.username;
122                 cloudifyManagerCopy.password = this.password;
123                 cloudifyManagerCopy.version = this.version;
124                 return cloudifyManagerCopy;
125         }
126
127         @Override
128         public String toString() {
129                 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
130                                 .append("cloudifyUrl", getCloudifyUrl()).append("username", getUsername())
131                                 .append("password", getPassword()).append("version", getVersion()).toString();
132         }
133
134         @Override
135         public boolean equals(final Object other) {
136                 if (other == null) {
137                         return false;
138                 }
139                 if (!getClass().equals(other.getClass())) {
140                         return false;
141                 }
142                 CloudifyManager castOther = (CloudifyManager) other;
143                 return new EqualsBuilder().append(getId(), castOther.getId())
144                                 .append(getCloudifyUrl(), castOther.getCloudifyUrl()).append(getUsername(), castOther.getUsername())
145                                 .append(getPassword(), castOther.getPassword()).append(getVersion(), castOther.getVersion()).isEquals();
146         }
147
148         @Override
149         public int hashCode() {
150                 return new HashCodeBuilder(1, 31).append(getId()).append(getCloudifyUrl()).append(getUsername())
151                                 .append(getPassword()).append(getVersion()).toHashCode();
152         }
153 }