Skip to content

Commit

Permalink
add new ubuntu versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lharzenetter committed Mar 14, 2019
1 parent acf6a5e commit b69675c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ public class Types {
new QName("http://opentosca.org/NodeTypes", "Ubuntu-14.04-VM");

public final static QName ubuntu1404ServerVmNodeType3 =
new QName("http://opentosca.org/nodetypes/versioned", "Ubuntu-VM_14.04-w1");
new QName("http://opentosca.org/nodetypes", "Ubuntu-VM_14.04-w1");

public final static QName ubuntu1604ServerVmNodeType =
new QName("http://opentosca.org/nodetypes", "Ubuntu-VM_16.04-w1");

public final static QName ubuntu1804ServerVmNodeType =
new QName("http://opentosca.org/nodetypes", "Ubuntu-VM_18.04-w1");

// raspbian nodeTypes
public final static QName raspbianJessieOSNodeType = new QName("http://opentosca.org/nodetypes", "RaspbianJessie");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static boolean isSupportedSSHKeyProperty(final String name) {
}

/**
* Checks whether the given property name represents a special case property: the ip property of
* an virtual machine
* Checks whether the given property name represents a special case property: the ip property of an
* virtual machine
*
* @param name a String containing some property name
* @return true iff the given name equals to the predefined IP property names of the plugins
Expand All @@ -74,17 +74,16 @@ public static boolean isSupportedVirtualMachineIPProperty(final String name) {
* property of an virtual machine
*
* @param name a String containing some property name
* @return true iff the given name equals to the predefined InstanceId property names of the
* plugins
* @return true iff the given name equals to the predefined InstanceId property names of the plugins
*/
public static boolean isSupportedVirtualMachineInstanceIdProperty(final String name) {
return name.equals(Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_INSTANCEID)
| name.equals(Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMINSTANCEID);
}

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

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

// code for new namespace http://opentosca.org/NodeTypes
if (nodeType.equals(Types.ubuntu1404ServerVmNodeType) || nodeType.equals(Types.ubuntu1404ServerVmNodeType2)
|| nodeType.equals(Types.ubuntu1404ServerVmNodeType3)) {
|| nodeType.equals(Types.ubuntu1404ServerVmNodeType3) || nodeType.equals(Types.ubuntu1604ServerVmNodeType)
|| nodeType.equals(Types.ubuntu1804ServerVmNodeType)) {
return true;
}

Expand Down Expand Up @@ -212,8 +212,8 @@ public static boolean isSupportedVMNodeType(final QName nodeType) {
}

/**
* Checks whether the given NodeType is a docker engine nodeType that can be handled by the set
* of plugins used by the PlanBuilder.
* Checks whether the given NodeType is a docker engine nodeType that can be handled by the set of
* plugins used by the PlanBuilder.
*
* @param nodeType a QName denoting some nodeType
* @return a boolean. True if the given nodeType is a docker engine nodeType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import javax.wsdl.Definition;
Expand Down Expand Up @@ -76,47 +77,50 @@ public enum Phase {

public static final String ServiceInstanceURLVarKeyword = "OpenTOSCAContainerAPIServiceInstanceURL";
public static final String ServiceInstanceIDVarKeyword = "OpenTOSCAContainerAPIServiceInstanceID";
public static final String ServiceTemplateURLVarKeyword = "OpenTOSCAContainerAPIServiceTemplateURL";
public static final String ServiceTemplateURLVarKeyword = "OpenTOSCAContainerAPIServiceTemplateURL";
public static final String InstanceDataAPIUrlKeyword = "instanceDataAPIUrl";



public static Variable getVariable(String varName) {
return new Variable(null, varName);
}

public static String getVariableContent(final Variable variable, final BPELPlanContext context) {
// check whether the property is empty --> external parameter
for (final AbstractNodeTemplate node : context.getNodeTemplates()) {
if (node.getId().equals(variable.getTemplateId())) {
if (node.getProperties() == null) {
continue;
}
final NodeList children = node.getProperties().getDOMElement().getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (child.getNodeType() != 1) {
if (Objects.nonNull(variable)) {
for (final AbstractNodeTemplate node : context.getNodeTemplates()) {
if (node.getId().equals(variable.getTemplateId())) {
if (node.getProperties() == null) {
continue;
}
final String variableName = variable.getName();
if (variable.getName().endsWith("_" + child.getLocalName())) {
// check if content is empty
return children.item(i).getTextContent();
final NodeList children = node.getProperties().getDOMElement().getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
final Node child = children.item(i);
if (child.getNodeType() != 1) {
continue;
}
final String variableName = variable.getName();
if (variable.getName().endsWith("_" + child.getLocalName())) {
// check if content is empty
return children.item(i).getTextContent();
}
}
}
}
}

for (final AbstractRelationshipTemplate relation : context.getRelationshipTemplates()) {
if (relation.getId().equals(variable.getTemplateId())) {
final NodeList children = relation.getProperties().getDOMElement().getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
if (variable.getName().endsWith(children.item(i).getLocalName())) {
// check if content is empty
return children.item(i).getTextContent();
for (final AbstractRelationshipTemplate relation : context.getRelationshipTemplates()) {
if (relation.getId().equals(variable.getTemplateId())) {
final NodeList children = relation.getProperties().getDOMElement().getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
if (variable.getName().endsWith(children.item(i).getLocalName())) {
// check if content is empty
return children.item(i).getTextContent();
}
}
}
}

}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ private String createUbuntuImageStringFromNodeType(final QName nodeType) {
if (nodeType.equals(Types.ubuntu1404ServerVmNodeType) || nodeType.equals(Types.ubuntu1404ServerVmNodeType2)
|| nodeType.equals(Types.ubuntu1404ServerVmNodeType3)) {
return "ubuntu-14.04-trusty-server-cloudimg";
} else if (nodeType.equals(Types.ubuntu1604ServerVmNodeType)) {
return "ubuntu-16.04-server-cloudimg-amd64";
} else if (nodeType.equals(Types.ubuntu1804ServerVmNodeType)) {
return "ubuntu-18.04-server-cloudimg-amd64";
}

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

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

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

0 comments on commit b69675c

Please sign in to comment.