Skip to content

Commit d3c1e35

Browse files
authored
Merge pull request #73 from OpenTOSCA/fix/IA-invocation-without-sudo
Fix/ia invocation without sudo
2 parents 6be09f1 + a97320c commit d3c1e35

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

org.opentosca.bus.management.plugins.remote.service.impl/src/org/opentosca/bus/management/plugins/remote/service/impl/ManagementBusPluginRemoteServiceImpl.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,26 @@ public Exchange invoke(final Exchange exchange) {
244244
artifactTypeSpecificCommand =
245245
artifactTypeSpecificCommand.replace(ManagementBusPluginRemoteServiceImpl.PLACEHOLDER_TARGET_FILE_NAME_WITHOUT_EXTENSION,
246246
fileNameWithoutE);
247+
// hacky check if sudo is available or not
247248
artifactTypeSpecificCommand =
248249
artifactTypeSpecificCommand.replace(ManagementBusPluginRemoteServiceImpl.PLACEHOLDER_DA_NAME_PATH_MAP,
249-
"sudo -E "
250+
"CAN_SUDO=$(sudo -n uptime 2>&1|grep \"load\"|wc -l)\r\n"
251+
+ "if [ ${CAN_SUDO} -gt 0 ]\r\n" + "then\r\n"
252+
+ "sudo -E "
250253
+ createDANamePathMapEnvVar(csarID,
251254
serviceTemplateID,
252255
nodeTypeID,
253256
nodeTemplateID)
254257
+ " CSAR='" + csarID + "' NodeInstanceID='"
255258
+ nodeInstanceID + "' ServiceInstanceID='"
256-
+ serviceInstanceID + "' ");
259+
+ serviceInstanceID + "'\r\n" + "else\r\n"
260+
+ createDANamePathMapEnvVar(csarID,
261+
serviceTemplateID,
262+
nodeTypeID,
263+
nodeTemplateID)
264+
+ " CSAR='" + csarID + "' NodeInstanceID='"
265+
+ nodeInstanceID + "' ServiceInstanceID='"
266+
+ serviceInstanceID + "'\r\n" + "fi\r\n");
257267
artifactTypeSpecificCommand =
258268
artifactTypeSpecificCommand.replace(ManagementBusPluginRemoteServiceImpl.PLACEHOLDER_DA_INPUT_PARAMETER,
259269
createParamsString(params));

0 commit comments

Comments
 (0)