Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/OpenTOSCA/container
Browse files Browse the repository at this point in the history
  • Loading branch information
miwurster committed Nov 27, 2018
2 parents 1524665 + 7df69a8 commit 7f0d46c
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 75 deletions.
Expand Up @@ -649,9 +649,9 @@ private boolean containsInvocationType(final Node currentNode) {
*
* @return the updated input parameters.
*/
private HashMap<String, String> updateInputParams(final HashMap<String, String> inputParams, final CSARID csarID,
private HashMap<String, String> updateInputParams(HashMap<String, String> 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(),
Expand All @@ -666,97 +666,119 @@ private HashMap<String, String> updateInputParams(final HashMap<String, String>
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<String, String> 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<String, String> 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<String> supportedIPPropertyNames = Utils.getSupportedVirtualMachineIPPropertyNames();
final List<String> supportedInstanceIdPropertyNames =
Utils.getSupportedVirtualMachineInstanceIdPropertyNames();
final List<String> supportedPasswordPropertyNames =
Utils.getSupportedVirtualMachineLoginPasswordPropertyNames();
final List<String> 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<String, String> updateInputParams(final List<String> expectedParams,
final HashMap<String, String> inputParams,
final HashMap<String, String> propertiesMap) {

if (prop != null) {
putOnlyIfNotSet(inputParams, expectedParam, prop);
}
final List<String> supportedIPPropertyNames = Utils.getSupportedVirtualMachineIPPropertyNames();
final List<String> supportedInstanceIdPropertyNames = Utils.getSupportedVirtualMachineInstanceIdPropertyNames();
final List<String> supportedPasswordPropertyNames =
Utils.getSupportedVirtualMachineLoginPasswordPropertyNames();
final List<String> 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;
}

Expand Down
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
Expand Up @@ -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());

Expand Down

0 comments on commit 7f0d46c

Please sign in to comment.