Skip to content

Commit b69675c

Browse files
committed
add new ubuntu versions
1 parent acf6a5e commit b69675c

File tree

4 files changed

+52
-39
lines changed

4 files changed

+52
-39
lines changed

org.opentosca.container.core.tosca/src/org/opentosca/container/core/tosca/convention/Types.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ public class Types {
4040
new QName("http://opentosca.org/NodeTypes", "Ubuntu-14.04-VM");
4141

4242
public final static QName ubuntu1404ServerVmNodeType3 =
43-
new QName("http://opentosca.org/nodetypes/versioned", "Ubuntu-VM_14.04-w1");
43+
new QName("http://opentosca.org/nodetypes", "Ubuntu-VM_14.04-w1");
44+
45+
public final static QName ubuntu1604ServerVmNodeType =
46+
new QName("http://opentosca.org/nodetypes", "Ubuntu-VM_16.04-w1");
47+
48+
public final static QName ubuntu1804ServerVmNodeType =
49+
new QName("http://opentosca.org/nodetypes", "Ubuntu-VM_18.04-w1");
4450

4551
// raspbian nodeTypes
4652
public final static QName raspbianJessieOSNodeType = new QName("http://opentosca.org/nodetypes", "RaspbianJessie");

org.opentosca.container.core.tosca/src/org/opentosca/container/core/tosca/convention/Utils.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public static boolean isSupportedSSHKeyProperty(final String name) {
5757
}
5858

5959
/**
60-
* Checks whether the given property name represents a special case property: the ip property of
61-
* an virtual machine
60+
* Checks whether the given property name represents a special case property: the ip property of an
61+
* virtual machine
6262
*
6363
* @param name a String containing some property name
6464
* @return true iff the given name equals to the predefined IP property names of the plugins
@@ -74,17 +74,16 @@ public static boolean isSupportedVirtualMachineIPProperty(final String name) {
7474
* property of an virtual machine
7575
*
7676
* @param name a String containing some property name
77-
* @return true iff the given name equals to the predefined InstanceId property names of the
78-
* plugins
77+
* @return true iff the given name equals to the predefined InstanceId property names of the plugins
7978
*/
8079
public static boolean isSupportedVirtualMachineInstanceIdProperty(final String name) {
8180
return name.equals(Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_INSTANCEID)
8281
| name.equals(Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMINSTANCEID);
8382
}
8483

8584
/**
86-
* Checks whether the given NodeType is a cloud provider nodeType that can be handled by the set
87-
* of plugins used by the PlanBuilder.
85+
* Checks whether the given NodeType is a cloud provider nodeType that can be handled by the set of
86+
* plugins used by the PlanBuilder.
8887
*
8988
* @param nodeType a QName denoting some nodeType
9089
* @return a boolean. True if the given nodeType is a cloud provider nodeType
@@ -100,8 +99,8 @@ public static boolean isSupportedCloudProviderNodeType(final QName nodeType) {
10099
}
101100

102101
/**
103-
* Checks whether the given QName denotes a nodeType which can't/won't be managed by OpenTOSCA,
104-
* such as remote entites
102+
* Checks whether the given QName denotes a nodeType which can't/won't be managed by OpenTOSCA, such
103+
* as remote entites
105104
*
106105
* @param nodeType a QName denoting a NodeType
107106
* @return true if the nodeType is supported
@@ -132,7 +131,8 @@ public static boolean isSupportedInfrastructureNodeType(final QName nodeType) {
132131

133132
// code for new namespace http://opentosca.org/NodeTypes
134133
if (nodeType.equals(Types.ubuntu1404ServerVmNodeType) || nodeType.equals(Types.ubuntu1404ServerVmNodeType2)
135-
|| nodeType.equals(Types.ubuntu1404ServerVmNodeType3)) {
134+
|| nodeType.equals(Types.ubuntu1404ServerVmNodeType3) || nodeType.equals(Types.ubuntu1604ServerVmNodeType)
135+
|| nodeType.equals(Types.ubuntu1804ServerVmNodeType)) {
136136
return true;
137137
}
138138

@@ -212,8 +212,8 @@ public static boolean isSupportedVMNodeType(final QName nodeType) {
212212
}
213213

214214
/**
215-
* Checks whether the given NodeType is a docker engine nodeType that can be handled by the set
216-
* of plugins used by the PlanBuilder.
215+
* Checks whether the given NodeType is a docker engine nodeType that can be handled by the set of
216+
* plugins used by the PlanBuilder.
217217
*
218218
* @param nodeType a QName denoting some nodeType
219219
* @return a boolean. True if the given nodeType is a docker engine nodeType

org.opentosca.planbuilder.core.bpel/src/org/opentosca/planbuilder/core/bpel/context/BPELPlanContext.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.HashMap;
66
import java.util.List;
77
import java.util.Map;
8+
import java.util.Objects;
89
import java.util.Set;
910

1011
import javax.wsdl.Definition;
@@ -76,47 +77,50 @@ public enum Phase {
7677

7778
public static final String ServiceInstanceURLVarKeyword = "OpenTOSCAContainerAPIServiceInstanceURL";
7879
public static final String ServiceInstanceIDVarKeyword = "OpenTOSCAContainerAPIServiceInstanceID";
79-
public static final String ServiceTemplateURLVarKeyword = "OpenTOSCAContainerAPIServiceTemplateURL";
80+
public static final String ServiceTemplateURLVarKeyword = "OpenTOSCAContainerAPIServiceTemplateURL";
8081
public static final String InstanceDataAPIUrlKeyword = "instanceDataAPIUrl";
8182

82-
83-
83+
84+
8485
public static Variable getVariable(String varName) {
8586
return new Variable(null, varName);
8687
}
87-
88+
8889
public static String getVariableContent(final Variable variable, final BPELPlanContext context) {
8990
// check whether the property is empty --> external parameter
90-
for (final AbstractNodeTemplate node : context.getNodeTemplates()) {
91-
if (node.getId().equals(variable.getTemplateId())) {
92-
if (node.getProperties() == null) {
93-
continue;
94-
}
95-
final NodeList children = node.getProperties().getDOMElement().getChildNodes();
96-
for (int i = 0; i < children.getLength(); i++) {
97-
final Node child = children.item(i);
98-
if (child.getNodeType() != 1) {
91+
if (Objects.nonNull(variable)) {
92+
for (final AbstractNodeTemplate node : context.getNodeTemplates()) {
93+
if (node.getId().equals(variable.getTemplateId())) {
94+
if (node.getProperties() == null) {
9995
continue;
10096
}
101-
final String variableName = variable.getName();
102-
if (variable.getName().endsWith("_" + child.getLocalName())) {
103-
// check if content is empty
104-
return children.item(i).getTextContent();
97+
final NodeList children = node.getProperties().getDOMElement().getChildNodes();
98+
for (int i = 0; i < children.getLength(); i++) {
99+
final Node child = children.item(i);
100+
if (child.getNodeType() != 1) {
101+
continue;
102+
}
103+
final String variableName = variable.getName();
104+
if (variable.getName().endsWith("_" + child.getLocalName())) {
105+
// check if content is empty
106+
return children.item(i).getTextContent();
107+
}
105108
}
106109
}
107110
}
108-
}
109111

110-
for (final AbstractRelationshipTemplate relation : context.getRelationshipTemplates()) {
111-
if (relation.getId().equals(variable.getTemplateId())) {
112-
final NodeList children = relation.getProperties().getDOMElement().getChildNodes();
113-
for (int i = 0; i < children.getLength(); i++) {
114-
if (variable.getName().endsWith(children.item(i).getLocalName())) {
115-
// check if content is empty
116-
return children.item(i).getTextContent();
112+
for (final AbstractRelationshipTemplate relation : context.getRelationshipTemplates()) {
113+
if (relation.getId().equals(variable.getTemplateId())) {
114+
final NodeList children = relation.getProperties().getDOMElement().getChildNodes();
115+
for (int i = 0; i < children.getLength(); i++) {
116+
if (variable.getName().endsWith(children.item(i).getLocalName())) {
117+
// check if content is empty
118+
return children.item(i).getTextContent();
119+
}
117120
}
118121
}
119122
}
123+
120124
}
121125
return null;
122126
}

org.opentosca.planbuilder.type.plugin.ubuntuvm/src/org/opentosca/planbuilder/type/plugin/ubuntuvm/bpel/BPELUbuntuVmTypePluginHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ private String createUbuntuImageStringFromNodeType(final QName nodeType) {
7575
if (nodeType.equals(Types.ubuntu1404ServerVmNodeType) || nodeType.equals(Types.ubuntu1404ServerVmNodeType2)
7676
|| nodeType.equals(Types.ubuntu1404ServerVmNodeType3)) {
7777
return "ubuntu-14.04-trusty-server-cloudimg";
78+
} else if (nodeType.equals(Types.ubuntu1604ServerVmNodeType)) {
79+
return "ubuntu-16.04-server-cloudimg-amd64";
80+
} else if (nodeType.equals(Types.ubuntu1804ServerVmNodeType)) {
81+
return "ubuntu-18.04-server-cloudimg-amd64";
7882
}
7983

8084
final String localName = nodeType.getLocalPart();
@@ -1163,12 +1167,11 @@ public boolean handleWithLocalCloudProviderInterface(final BPELPlanContext conte
11631167

11641168
private Variable getUbtuntuAMIId(final BPELPlanContext context, final AbstractNodeTemplate nodeTemplate) {
11651169
Variable vmImageId = context.getPropertyVariable("VMImageID", true);
1166-
BPELPlanContext.isVariableValueEmpty(vmImageId, context);
11671170

11681171
// here either the ubuntu connected to the provider this handler is
11691172
// working on hasn't a version in the ID (ubuntu version must be written
11701173
// in AMIId property then) or something went really wrong
1171-
if (Objects.isNull(vmImageId)) {
1174+
if (BPELPlanContext.isVariableValueEmpty(vmImageId, context)) {
11721175
// we'll set a global variable with the necessary ubuntu image
11731176
// ubuntuAMIIdVar =
11741177
// context.createGlobalStringVariable("ubuntu_AMIId",

0 commit comments

Comments
 (0)