2 * Copyright 2016 [ZTE] and others.
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.
17 package org.openo.commontosca.catalog.model.externalservice.entity.container;
19 import org.openo.commontosca.catalog.common.ToolUtil;
21 import java.util.ArrayList;
22 import java.util.List;
24 import javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlAttribute;
27 import javax.xml.bind.annotation.XmlElement;
28 import javax.xml.bind.annotation.XmlElementWrapper;
29 import javax.xml.bind.annotation.XmlRootElement;
32 @XmlAccessorType(XmlAccessType.NONE)
33 public class ContainerServiceNodeTemplate {
35 @XmlAttribute(name = "nodetemplateid")
38 @XmlAttribute(name = "nodetemplatename")
44 @XmlElementWrapper(name = "properties")
45 @XmlElement(name = "property")
46 private List<ContainerServiceCommonParam> properties;
48 @XmlElementWrapper(name = "relationshipInfos")
49 @XmlElement(name = "relationship")
50 private List<ContainerServiceRelationShip> relationShips;
52 @XmlElement(name = "Capabilities")
53 private ContainerServiceNodeTemplate.Capablitiies capabilities;
55 public ContainerServiceNodeTemplate.Capablitiies getCapabilities() {
59 public void setCapabilities(ContainerServiceNodeTemplate.Capablitiies capabilities) {
60 this.capabilities = capabilities;
63 public String getId() {
67 public void setId(String id) {
71 public String getName() {
75 public void setName(String name) {
79 public String getType() {
83 public void setType(String type) {
87 public List<ContainerServiceCommonParam> getProperties() {
91 public void setProperties(List<ContainerServiceCommonParam> properties) {
92 this.properties = properties;
95 public List<ContainerServiceRelationShip> getRelationShips() {
99 public void setRelationShips(List<ContainerServiceRelationShip> relationShips) {
100 this.relationShips = relationShips;
104 @XmlAccessorType(XmlAccessType.NONE)
105 public static class Capablitiies {
106 @XmlElement(name = "Capability")
107 private List<ContainerServiceNodeTemplate.Capability> capabilityList;
109 public List<ContainerServiceNodeTemplate.Capability> getCapabilityList() {
110 return capabilityList;
113 public void setCapabilityList(List<ContainerServiceNodeTemplate.Capability> capabilityList) {
114 this.capabilityList = capabilityList;
119 @XmlAccessorType(XmlAccessType.NONE)
120 public static class Capability {
121 @XmlAttribute(name = "id")
122 private String flavorName;
124 @XmlElement(name = "Properties")
125 private ContainerServiceNodeTemplate.CapabilityProperties properties;
127 public String getFlavorName() {
131 public void setFlavorName(String flavorName) {
132 this.flavorName = flavorName;
135 public ContainerServiceNodeTemplate.CapabilityProperties getProperties() {
139 public void setProperties(ContainerServiceNodeTemplate.CapabilityProperties properties) {
140 this.properties = properties;
146 @XmlAccessorType(XmlAccessType.NONE)
147 public static class CapabilityProperties {
148 @XmlElement(name = "Properties")
149 private ContainerServiceNodeTemplate.CapabilityProperty property;
151 public ContainerServiceNodeTemplate.CapabilityProperty getProperty() {
155 public void setProperty(ContainerServiceNodeTemplate.CapabilityProperty property) {
156 this.property = property;
161 @XmlAccessorType(XmlAccessType.FIELD)
162 public static class CapabilityProperty {
170 private String rootDisk;
173 private String swapDisk;
176 private String tempDisk;
178 public String getVcpu() {
182 public void setVcpu(String vcpu) {
186 public String getVram() {
190 public void setVram(String vram) {
194 public String getRootDisk() {
198 public void setRootDisk(String rootDisk) {
199 this.rootDisk = rootDisk;
202 public String getSwapDisk() {
206 public void setSwapDisk(String swapDisk) {
207 this.swapDisk = swapDisk;
210 public String getTempDisk() {
214 public void setTempDisk(String tempDisk) {
215 this.tempDisk = tempDisk;
219 public class NtFlavor {
220 private String flavorName;
226 private String rootDisk;
228 private String swapDisk;
230 private String tempDisk;
232 public String getFlavorName() {
236 public void setFlavorName(String flavorName) {
237 this.flavorName = flavorName;
240 public String getVcpu() {
244 public void setVcpu(String vcpu) {
248 public String getVram() {
252 public void setVram(String vram) {
256 public String getRootDisk() {
260 public void setRootDisk(String rootDisk) {
261 this.rootDisk = rootDisk;
264 public String getSwapDisk() {
268 public void setSwapDisk(String swapDisk) {
269 this.swapDisk = swapDisk;
272 public String getTempDisk() {
276 public void setTempDisk(String tempDisk) {
277 this.tempDisk = tempDisk;
283 * get nt flavor list.
284 * @return nt flavor list
286 public List<NtFlavor> getNtFlavorList() {
287 if (null == this.capabilities || ToolUtil.isEmptyCollection(capabilities.getCapabilityList())) {
291 List<NtFlavor> ntFlavors = new ArrayList<NtFlavor>();
292 List<Capability> capabilityList = capabilities.getCapabilityList();
293 for (Capability capabilty : capabilityList) {
294 NtFlavor ntFlavor = convertCap2Flavor(capabilty);
295 ntFlavors.add(ntFlavor);
301 private NtFlavor convertCap2Flavor(Capability capabilty) {
302 NtFlavor ntFlavor = new NtFlavor();
303 ntFlavor.setFlavorName(capabilty.getFlavorName());
304 if (null != capabilty.getProperties() && null != capabilty.getProperties().getProperty()) {
305 CapabilityProperty property = capabilty.getProperties().getProperty();
306 ntFlavor.setRootDisk(property.getRootDisk());
307 ntFlavor.setSwapDisk(property.getSwapDisk());
308 ntFlavor.setTempDisk(property.getTempDisk());
309 ntFlavor.setVcpu(property.getVcpu());
310 ntFlavor.setVram(property.getVram());