Skip to content

Commit

Permalink
Merge pull request #73 from OpenTOSCA/fix/IA-invocation-without-sudo
Browse files Browse the repository at this point in the history
Fix/ia invocation without sudo
  • Loading branch information
nyuuyn committed Aug 16, 2018
2 parents 6be09f1 + a97320c commit d3c1e35
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,26 @@ public Exchange invoke(final Exchange exchange) {
artifactTypeSpecificCommand =
artifactTypeSpecificCommand.replace(ManagementBusPluginRemoteServiceImpl.PLACEHOLDER_TARGET_FILE_NAME_WITHOUT_EXTENSION,
fileNameWithoutE);
// hacky check if sudo is available or not
artifactTypeSpecificCommand =
artifactTypeSpecificCommand.replace(ManagementBusPluginRemoteServiceImpl.PLACEHOLDER_DA_NAME_PATH_MAP,
"sudo -E "
"CAN_SUDO=$(sudo -n uptime 2>&1|grep \"load\"|wc -l)\r\n"
+ "if [ ${CAN_SUDO} -gt 0 ]\r\n" + "then\r\n"
+ "sudo -E "
+ createDANamePathMapEnvVar(csarID,
serviceTemplateID,
nodeTypeID,
nodeTemplateID)
+ " CSAR='" + csarID + "' NodeInstanceID='"
+ nodeInstanceID + "' ServiceInstanceID='"
+ serviceInstanceID + "' ");
+ serviceInstanceID + "'\r\n" + "else\r\n"
+ createDANamePathMapEnvVar(csarID,
serviceTemplateID,
nodeTypeID,
nodeTemplateID)
+ " CSAR='" + csarID + "' NodeInstanceID='"
+ nodeInstanceID + "' ServiceInstanceID='"
+ serviceInstanceID + "'\r\n" + "fi\r\n");
artifactTypeSpecificCommand =
artifactTypeSpecificCommand.replace(ManagementBusPluginRemoteServiceImpl.PLACEHOLDER_DA_INPUT_PARAMETER,
createParamsString(params));
Expand Down

0 comments on commit d3c1e35

Please sign in to comment.