2 * Copyright 2016 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openo.commontosca.catalog.model.externalservice.entity.container;
18 import org.openo.commontosca.catalog.common.ToolUtil;
20 import java.util.ArrayList;
21 import java.util.List;
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlAttribute;
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlElementWrapper;
28 import javax.xml.bind.annotation.XmlRootElement;
31 @XmlAccessorType(XmlAccessType.NONE)
32 public class ContainerServiceNodeTemplate {
34 @XmlAttribute(name = "nodetemplateid")
37 @XmlAttribute(name = "nodetemplatename")
43 @XmlElementWrapper(name = "properties")
44 @XmlElement(name = "property")
45 private List<ContainerServiceCommonParam> properties;
47 @XmlElementWrapper(name = "relationshipInfos")
48 @XmlElement(name = "relationship")
49 private List<ContainerServiceRelationShip> relationShips;
51 @XmlElement(name = "Capabilities")
52 private ContainerServiceNodeTemplate.Capablitiies capabilities;
54 public ContainerServiceNodeTemplate.Capablitiies getCapabilities() {
58 public void setCapabilities(ContainerServiceNodeTemplate.Capablitiies capabilities) {
59 this.capabilities = capabilities;
62 public String getId() {
66 public void setId(String id) {
70 public String getName() {
74 public void setName(String name) {
78 public String getType() {
82 public void setType(String type) {
86 public List<ContainerServiceCommonParam> getProperties() {
90 public void setProperties(List<ContainerServiceCommonParam> properties) {
91 this.properties = properties;
94 public List<ContainerServiceRelationShip> getRelationShips() {
98 public void setRelationShips(List<ContainerServiceRelationShip> relationShips) {
99 this.relationShips = relationShips;
103 @XmlAccessorType(XmlAccessType.NONE)
104 public static class Capablitiies {
105 @XmlElement(name = "Capability")
106 private List<ContainerServiceNodeTemplate.Capability> capabilityList;
108 public List<ContainerServiceNodeTemplate.Capability> getCapabilityList() {
109 return capabilityList;
112 public void setCapabilityList(List<ContainerServiceNodeTemplate.Capability> capabilityList) {
113 this.capabilityList = capabilityList;
118 @XmlAccessorType(XmlAccessType.NONE)
119 public static class Capability {
120 @XmlAttribute(name = "id")
121 private String flavorName;
123 @XmlElement(name = "Properties")
124 private ContainerServiceNodeTemplate.CapabilityProperties properties;
126 public String getFlavorName() {
130 public void setFlavorName(String flavorName) {
131 this.flavorName = flavorName;
134 public ContainerServiceNodeTemplate.CapabilityProperties getProperties() {
138 public void setProperties(ContainerServiceNodeTemplate.CapabilityProperties properties) {
139 this.properties = properties;
145 @XmlAccessorType(XmlAccessType.NONE)
146 public static class CapabilityProperties {
147 @XmlElement(name = "Properties")
148 private ContainerServiceNodeTemplate.CapabilityProperty property;
150 public ContainerServiceNodeTemplate.CapabilityProperty getProperty() {
154 public void setProperty(ContainerServiceNodeTemplate.CapabilityProperty property) {
155 this.property = property;
160 @XmlAccessorType(XmlAccessType.FIELD)
161 public static class CapabilityProperty {
169 private String rootDisk;
172 private String swapDisk;
175 private String tempDisk;
177 public String getVcpu() {
181 public void setVcpu(String vcpu) {
185 public String getVram() {
189 public void setVram(String vram) {
193 public String getRootDisk() {
197 public void setRootDisk(String rootDisk) {
198 this.rootDisk = rootDisk;
201 public String getSwapDisk() {
205 public void setSwapDisk(String swapDisk) {
206 this.swapDisk = swapDisk;
209 public String getTempDisk() {
213 public void setTempDisk(String tempDisk) {
214 this.tempDisk = tempDisk;
218 public class NtFlavor {
219 private String flavorName;
225 private String rootDisk;
227 private String swapDisk;
229 private String tempDisk;
231 public String getFlavorName() {
235 public void setFlavorName(String flavorName) {
236 this.flavorName = flavorName;
239 public String getVcpu() {
243 public void setVcpu(String vcpu) {
247 public String getVram() {
251 public void setVram(String vram) {
255 public String getRootDisk() {
259 public void setRootDisk(String rootDisk) {
260 this.rootDisk = rootDisk;
263 public String getSwapDisk() {
267 public void setSwapDisk(String swapDisk) {
268 this.swapDisk = swapDisk;
271 public String getTempDisk() {
275 public void setTempDisk(String tempDisk) {
276 this.tempDisk = tempDisk;
282 * get nt flavor list.
283 * @return nt flavor list
285 public List<NtFlavor> getNtFlavorList() {
286 if (null == this.capabilities || ToolUtil.isEmptyCollection(capabilities.getCapabilityList())) {
290 List<NtFlavor> ntFlavors = new ArrayList<NtFlavor>();
291 List<Capability> capabilityList = capabilities.getCapabilityList();
292 for (Capability capabilty : capabilityList) {
293 NtFlavor ntFlavor = convertCap2Flavor(capabilty);
294 ntFlavors.add(ntFlavor);
300 private NtFlavor convertCap2Flavor(Capability capabilty) {
301 NtFlavor ntFlavor = new NtFlavor();
302 ntFlavor.setFlavorName(capabilty.getFlavorName());
303 if (null != capabilty.getProperties() && null != capabilty.getProperties().getProperty()) {
304 CapabilityProperty property = capabilty.getProperties().getProperty();
305 ntFlavor.setRootDisk(property.getRootDisk());
306 ntFlavor.setSwapDisk(property.getSwapDisk());
307 ntFlavor.setTempDisk(property.getTempDisk());
308 ntFlavor.setVcpu(property.getVcpu());
309 ntFlavor.setVram(property.getVram());