diff --git a/org.opentosca.bus.management.service.impl/src/org/opentosca/bus/management/service/impl/ManagementBusServiceImpl.java b/org.opentosca.bus.management.service.impl/src/org/opentosca/bus/management/service/impl/ManagementBusServiceImpl.java index eaf6b3b66..2559ab451 100644 --- a/org.opentosca.bus.management.service.impl/src/org/opentosca/bus/management/service/impl/ManagementBusServiceImpl.java +++ b/org.opentosca.bus.management.service.impl/src/org/opentosca/bus/management/service/impl/ManagementBusServiceImpl.java @@ -649,9 +649,9 @@ private boolean containsInvocationType(final Node currentNode) { * * @return the updated input parameters. */ - private HashMap updateInputParams(final HashMap inputParams, final CSARID csarID, + private HashMap updateInputParams(HashMap inputParams, final CSARID csarID, final QName serviceTemplateID, QName nodeTypeID, - final String nodeTemplateID, final String neededInterface, + String nodeTemplateID, final String neededInterface, final String neededOperation, final URI serviceInstanceID) { ManagementBusServiceImpl.LOG.debug("{} inital input parameters for operation: {} found: {}", inputParams.size(), @@ -666,97 +666,119 @@ private HashMap updateInputParams(final HashMap ManagementBusServiceImpl.LOG.debug("Operation: {} expects {} parameters: {}", neededOperation, expectedParams.size(), expectedParams.toString()); + boolean update = true; + if (!expectedParams.isEmpty()) { - // Check if instanceID is set and merge input params with - // instance data. Priority on instance data. - if (serviceInstanceID != null && !serviceInstanceID.toString().equals("?")) { + while (update) { - ManagementBusServiceImpl.LOG.debug("Getting InstanceData from InstanceDataService for ServiceInstanceID: {} ...", - serviceInstanceID); + // Check if instanceID is set and merge input params with + // instance data. Priority on instance data. + if (serviceInstanceID != null && !serviceInstanceID.toString().equals("?")) { - final HashMap propertiesMap = - MBUtils.getInstanceDataProperties(csarID, serviceTemplateID, nodeTemplateID.trim(), - serviceInstanceID); + ManagementBusServiceImpl.LOG.debug("Getting InstanceData for NodeTemplate: {} and ServiceInstanceID: {} ...", + nodeTemplateID.trim(), serviceInstanceID); - ManagementBusServiceImpl.LOG.debug("Found following properties: "); + final HashMap propertiesMap = + MBUtils.getInstanceDataProperties(csarID, serviceTemplateID, nodeTemplateID.trim(), + serviceInstanceID); - for (final String key : propertiesMap.keySet()) { - ManagementBusServiceImpl.LOG.debug("Prop: " + key + " Val: " + propertiesMap.get(key)); - } + ManagementBusServiceImpl.LOG.debug("Found following properties: "); - if (propertiesMap != null) { + for (final String key : propertiesMap.keySet()) { + ManagementBusServiceImpl.LOG.debug("Prop: " + key + " Val: " + propertiesMap.get(key)); + } - final List supportedIPPropertyNames = Utils.getSupportedVirtualMachineIPPropertyNames(); - final List supportedInstanceIdPropertyNames = - Utils.getSupportedVirtualMachineInstanceIdPropertyNames(); - final List supportedPasswordPropertyNames = - Utils.getSupportedVirtualMachineLoginPasswordPropertyNames(); - final List supportedUsernamePropertyNames = - Utils.getSupportedVirtualMachineLoginUserNamePropertyNames(); + if (propertiesMap != null) { - ManagementBusServiceImpl.LOG.debug("The stored properties from InstanceDataService for ServiceInstanceID: {} and NodeTemplateID: {} are: {}", - serviceInstanceID, nodeTemplateID, propertiesMap.toString()); + inputParams = updateInputParams(expectedParams, inputParams, propertiesMap); - String prop; - // Check for property convention - for (final String expectedParam : expectedParams) { + } + } - if (supportedIPPropertyNames.contains(expectedParam)) { - ManagementBusServiceImpl.LOG.debug("Supported IP-Property found."); - prop = getSupportedProperty(supportedIPPropertyNames, propertiesMap); - if (prop != null) { - putOnlyIfNotSet(inputParams, expectedParam, prop); - } + // If not all params are filled, check if properties of nodes below are matching. + if (expectedParams.size() != inputParams.size()) { + ManagementBusServiceImpl.LOG.debug("Not all expected Params are filled. Checking for nodes below..."); + nodeTemplateID = MBUtils.getHostedOnNodeTemplateID(csarID, serviceTemplateID, nodeTemplateID); + if (nodeTemplateID != null) { + ManagementBusServiceImpl.LOG.debug("Node found: {}", nodeTemplateID); + } else { + ManagementBusServiceImpl.LOG.debug("No operating system node found."); + update = false; + } + } else { + update = false; + } + } + } - } else if (supportedInstanceIdPropertyNames.contains(expectedParam)) { - ManagementBusServiceImpl.LOG.debug("Supported InstanceID-Property found."); - prop = getSupportedProperty(supportedInstanceIdPropertyNames, propertiesMap); + ManagementBusServiceImpl.LOG.debug("Final {} input parameters for operation {} : {}", inputParams.size(), + neededOperation, inputParams.toString()); - if (prop != null) { - putOnlyIfNotSet(inputParams, expectedParam, prop); - } + return inputParams; + } - } else if (supportedPasswordPropertyNames.contains(expectedParam)) { - ManagementBusServiceImpl.LOG.debug("Supported Password-Property found."); - prop = getSupportedProperty(supportedPasswordPropertyNames, propertiesMap); - if (prop != null) { - putOnlyIfNotSet(inputParams, expectedParam, prop); - } - } else if (supportedUsernamePropertyNames.contains(expectedParam)) { - ManagementBusServiceImpl.LOG.debug("Supported Username-Property found."); - prop = getSupportedProperty(supportedUsernamePropertyNames, propertiesMap); + private HashMap updateInputParams(final List expectedParams, + final HashMap inputParams, + final HashMap propertiesMap) { - if (prop != null) { - putOnlyIfNotSet(inputParams, expectedParam, prop); - } + final List supportedIPPropertyNames = Utils.getSupportedVirtualMachineIPPropertyNames(); + final List supportedInstanceIdPropertyNames = Utils.getSupportedVirtualMachineInstanceIdPropertyNames(); + final List supportedPasswordPropertyNames = + Utils.getSupportedVirtualMachineLoginPasswordPropertyNames(); + final List supportedUsernamePropertyNames = + Utils.getSupportedVirtualMachineLoginUserNamePropertyNames(); - } else { + String prop; + // Check for property convention + for (final String expectedParam : expectedParams) { - for (final String propName : propertiesMap.keySet()) { - if (expectedParam.equals(propName)) { - putOnlyIfNotSet(inputParams, expectedParam, propertiesMap.get(propName)); - } - } + if (supportedIPPropertyNames.contains(expectedParam)) { + ManagementBusServiceImpl.LOG.debug("Supported IP-Property found."); + prop = getSupportedProperty(supportedIPPropertyNames, propertiesMap); - } + if (prop != null) { + putOnlyIfNotSet(inputParams, expectedParam, prop); + } - } + } else if (supportedInstanceIdPropertyNames.contains(expectedParam)) { + ManagementBusServiceImpl.LOG.debug("Supported InstanceID-Property found."); + prop = getSupportedProperty(supportedInstanceIdPropertyNames, propertiesMap); - ManagementBusServiceImpl.LOG.debug("Final {} input parameters for operation {} : {}", - inputParams.size(), neededOperation, inputParams.toString()); + if (prop != null) { + putOnlyIfNotSet(inputParams, expectedParam, prop); + } - } else { - ManagementBusServiceImpl.LOG.debug("No stored InstanceData found."); + } else if (supportedPasswordPropertyNames.contains(expectedParam)) { + ManagementBusServiceImpl.LOG.debug("Supported Password-Property found."); + prop = getSupportedProperty(supportedPasswordPropertyNames, propertiesMap); + + if (prop != null) { + putOnlyIfNotSet(inputParams, expectedParam, prop); + } + + } else if (supportedUsernamePropertyNames.contains(expectedParam)) { + ManagementBusServiceImpl.LOG.debug("Supported Username-Property found."); + prop = getSupportedProperty(supportedUsernamePropertyNames, propertiesMap); + + if (prop != null) { + putOnlyIfNotSet(inputParams, expectedParam, prop); } + } else { - ManagementBusServiceImpl.LOG.debug("No InstanceDataID specified."); + + for (final String propName : propertiesMap.keySet()) { + if (expectedParam.equals(propName)) { + putOnlyIfNotSet(inputParams, expectedParam, propertiesMap.get(propName)); + } + } + } - } + } return inputParams; } diff --git a/org.opentosca.bus.management/src/org/opentosca/bus/management/utils/MBUtils.java b/org.opentosca.bus.management/src/org/opentosca/bus/management/utils/MBUtils.java index 970926fb4..33e523443 100644 --- a/org.opentosca.bus.management/src/org/opentosca/bus/management/utils/MBUtils.java +++ b/org.opentosca.bus.management/src/org/opentosca/bus/management/utils/MBUtils.java @@ -72,17 +72,11 @@ public static String getOperatingSystemNodeTemplateID(final CSARID csarID, final nodeTemplateID = ServiceHandler.toscaEngineService.getRelatedNodeTemplateID(csarID, serviceTemplateID, nodeTemplateID, - Types.deployedOnRelationType); - - if (nodeTemplateID == null) { - nodeTemplateID = - ServiceHandler.toscaEngineService.getRelatedNodeTemplateID(csarID, serviceTemplateID, - nodeTemplateID, - Types.dependsOnRelationType); - } + Types.dependsOnRelationType); } } + if (nodeTemplateID != null) { MBUtils.LOG.debug("Checking if the underneath Node: {} is the OperatingSystemNode.", nodeTemplateID); nodeType = ServiceHandler.toscaEngineService.getNodeTypeOfNodeTemplate(csarID, serviceTemplateID, @@ -100,6 +94,41 @@ public static String getOperatingSystemNodeTemplateID(final CSARID csarID, final return nodeTemplateID; } + + + /** + * + * Returns the NodeTemplate connected with a HostedOn/DeployedOn/... Relation. + * + * @param csarID + * @param serviceTemplateID + * @param nodeTemplateID + * + * @return name of the related NodeTemplate. + */ + public static String getHostedOnNodeTemplateID(final CSARID csarID, final QName serviceTemplateID, + String nodeTemplateID) { + + MBUtils.LOG.debug("Searching the Node, on which the NodeTemplate: {} of ServiceTemplate: {} & CSAR: {} is hosted on ...", + nodeTemplateID, serviceTemplateID, csarID); + + MBUtils.LOG.debug("Getting the underneath Node..."); + + nodeTemplateID = + ServiceHandler.toscaEngineService.getRelatedNodeTemplateID(csarID, serviceTemplateID, nodeTemplateID, + Types.hostedOnRelationType); + + if (nodeTemplateID == null) { + nodeTemplateID = + ServiceHandler.toscaEngineService.getRelatedNodeTemplateID(csarID, serviceTemplateID, nodeTemplateID, + Types.deployedOnRelationType); + + } + + return nodeTemplateID; + } + + /** * * Checks if the specified NodeType is the OperatingSystem NodeType. diff --git a/org.opentosca.planbuilder.model/src/org/opentosca/planbuilder/model/utils/ModelUtils.java b/org.opentosca.planbuilder.model/src/org/opentosca/planbuilder/model/utils/ModelUtils.java index edef4e017..8b146ae58 100644 --- a/org.opentosca.planbuilder.model/src/org/opentosca/planbuilder/model/utils/ModelUtils.java +++ b/org.opentosca.planbuilder.model/src/org/opentosca/planbuilder/model/utils/ModelUtils.java @@ -298,8 +298,7 @@ public static void getInfrastructureNodes(final AbstractNodeTemplate nodeTemplat for (final AbstractRelationshipTemplate relation : nodeTemplate.getOutgoingRelations()) { ModelUtils.LOG.debug("Checking if relation is infrastructure edge, relation: " + relation.getId()); - if (ModelUtils.getRelationshipBaseType(relation).equals(ModelUtils.TOSCABASETYPE_DEPENDSON) - || ModelUtils.getRelationshipBaseType(relation).equals(ModelUtils.TOSCABASETYPE_HOSTEDON) + if (ModelUtils.getRelationshipBaseType(relation).equals(ModelUtils.TOSCABASETYPE_HOSTEDON) || ModelUtils.getRelationshipBaseType(relation).equals(ModelUtils.TOSCABASETYPE_DEPLOYEDON)) { ModelUtils.LOG.debug("traversing edge to node: " + relation.getTarget().getId());