Skip to content

Commit

Permalink
add support for manually defining VMImageID
Browse files Browse the repository at this point in the history
  • Loading branch information
lharzenetter committed Mar 13, 2019
1 parent 0dcacaa commit acf6a5e
Showing 1 changed file with 22 additions and 52 deletions.
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 javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -227,26 +228,13 @@ public boolean handle(final BPELPlanContext context, final AbstractNodeTemplate
// directly then trough some vm nodetemplate) is a nodetype with a
// ubuntu version e.g. Ubuntu_13.10 and stuff
final AbstractNodeTemplate ubuntuNodeTemplate = findUbuntuNode(nodeTemplate);
Variable ubuntuAMIIdVar = null;

if (ubuntuNodeTemplate == null) {
LOG.error("Couldn't find Ubuntu Node");
return false;
}

// 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 (isUbuntuNodeTypeWithImplicitImage(ubuntuNodeTemplate.getType().getId())) {
// we'll set a global variable with the necessary ubuntu image
// ubuntuAMIIdVar =
// context.createGlobalStringVariable("ubuntu_AMIId",
// "ubuntu-13.10-server-cloudimg-amd64");
ubuntuAMIIdVar =
context.createGlobalStringVariable("ubuntu_AMIId",
createUbuntuImageStringFromNodeType(ubuntuNodeTemplate.getType()
.getId()));
}
Variable ubuntuAMIIdVar = getUbtuntuAMIId(context, ubuntuNodeTemplate);

LOG.debug("Found following Ubuntu Node " + ubuntuNodeTemplate.getId() + " of Type "
+ ubuntuNodeTemplate.getType().getId().toString());
Expand Down Expand Up @@ -425,26 +413,12 @@ public boolean handleWithCloudProviderInterface(final BPELPlanContext context,
// and an OS node (check for ssh service..)
final AbstractNodeTemplate ubuntuNodeTemplate = findUbuntuNode(nodeTemplate);

Variable ubuntuAMIIdVar = null;

if (ubuntuNodeTemplate == null) {
LOG.error("Couldn't find Ubuntu Node");
return false;
}

// 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 (isUbuntuNodeTypeWithImplicitImage(ubuntuNodeTemplate.getType().getId())) {
// we'll set a global variable with the necessary ubuntu image
// ubuntuAMIIdVar =
// context.createGlobalStringVariable("ubuntu_AMIId",
// "ubuntu-13.10-server-cloudimg-amd64");
ubuntuAMIIdVar =
context.createGlobalStringVariable("ubuntu_AMIId",
createUbuntuImageStringFromNodeType(ubuntuNodeTemplate.getType()
.getId()));
}
Variable ubuntuAMIIdVar = getUbtuntuAMIId(context, ubuntuNodeTemplate);

LOG.debug("Found following Ubuntu Node " + ubuntuNodeTemplate.getId() + " of Type "
+ ubuntuNodeTemplate.getType().getId().toString());
Expand Down Expand Up @@ -969,26 +943,13 @@ public boolean handleWithLocalCloudProviderInterface(final BPELPlanContext conte

// and an OS node (check for ssh service..)
final AbstractNodeTemplate ubuntuNodeTemplate = findUbuntuNode(nodeTemplate);
Variable ubuntuAMIIdVar = null;

if (ubuntuNodeTemplate == null) {
BPELUbuntuVmTypePluginHandler.LOG.error("Couldn't find Ubuntu Node");
return false;
}

// 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 (isUbuntuNodeTypeWithImplicitImage(ubuntuNodeTemplate.getType().getId())) {
// we'll set a global variable with the necessary ubuntu image
// ubuntuAMIIdVar =
// context.createGlobalStringVariable("ubuntu_AMIId",
// "ubuntu-13.10-server-cloudimg-amd64");
ubuntuAMIIdVar =
context.createGlobalStringVariable("ubuntu_AMIId",
createUbuntuImageStringFromNodeType(ubuntuNodeTemplate.getType()
.getId()));
}
Variable ubuntuAMIIdVar = getUbtuntuAMIId(context, ubuntuNodeTemplate);

BPELUbuntuVmTypePluginHandler.LOG.debug("Found following Ubuntu Node " + ubuntuNodeTemplate.getId()
+ " of Type " + ubuntuNodeTemplate.getType().getId().toString());
Expand Down Expand Up @@ -1200,15 +1161,24 @@ public boolean handleWithLocalCloudProviderInterface(final BPELPlanContext conte
return true;
}

/**
* This method checks whether the given QName represents a Ubuntu NodeType which has an implicit
* Ubuntu Image (e.g. Ubuntu 13.10 Server)
*
* @param nodeType a QName
* @return true if the given QName represents an Ubuntu NodeType with implicit image information
*/
private boolean isUbuntuNodeTypeWithImplicitImage(final QName nodeType) {
return createUbuntuImageStringFromNodeType(nodeType) != null;
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)) {
// we'll set a global variable with the necessary ubuntu image
// ubuntuAMIIdVar =
// context.createGlobalStringVariable("ubuntu_AMIId",
// "ubuntu-13.10-server-cloudimg-amd64");
return context.createGlobalStringVariable("ubuntu_AMIId",
createUbuntuImageStringFromNodeType(nodeTemplate.getType()
.getId()));
}

return vmImageId;
}

}

0 comments on commit acf6a5e

Please sign in to comment.