|
26 | 26 | import java.nio.file.Path; |
27 | 27 | import java.nio.file.Paths; |
28 | 28 | import java.nio.file.StandardCopyOption; |
| 29 | +import java.nio.file.StandardOpenOption; |
29 | 30 | import java.util.ArrayList; |
30 | 31 | import java.util.HashMap; |
31 | 32 | import java.util.List; |
|
79 | 80 | import com.cloud.vm.VmDetailConstants; |
80 | 81 | import com.cloud.vm.dao.UserVmDao; |
81 | 82 | import com.cloud.vm.dao.VMInstanceDao; |
82 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
83 | 83 |
|
84 | 84 | public class SimpleExternalProvisioner extends ManagerBase implements ExternalProvisioner, PluggableService, Configurable { |
85 | 85 |
|
@@ -523,16 +523,16 @@ public Pair<Boolean, String> executeExternalCommand(String file, String action, |
523 | 523 | List<String> command = new ArrayList<>(); |
524 | 524 | command.add(executablePath.toString()); |
525 | 525 | command.add(action); |
526 | | - String parameters = prepareParameters(accessDetails); |
527 | | - command.add(parameters); |
| 526 | + String dataFile = prepareActionData(accessDetails); |
| 527 | + command.add(dataFile); |
528 | 528 | command.add(Integer.toString(wait)); |
529 | 529 | ProcessBuilder builder = new ProcessBuilder(command); |
530 | 530 | builder.redirectErrorStream(true); |
531 | 531 |
|
532 | 532 | if (IS_DEBUG) { |
533 | 533 | logger.info("Executable: {}",executablePath); |
534 | 534 | logger.info("Action: {} with wait: {}", action, wait); |
535 | | - logger.info("Parameters: {}", parameters); |
| 535 | + logger.info("Data file: {}", dataFile); |
536 | 536 | return new Pair<>(true, "Operation successful!"); |
537 | 537 | } |
538 | 538 | logger.debug("Executing command: {}", command); |
@@ -573,8 +573,16 @@ public Answer checkHealth(String hostGuid, String extensionName, String extensio |
573 | 573 | return new Answer(cmd); |
574 | 574 | } |
575 | 575 |
|
576 | | - private String prepareParameters(Map<String, Object> details) throws JsonProcessingException { |
577 | | - return GsonHelper.getGson().toJson(details); |
| 576 | + private String prepareActionData(Map<String, Object> details) throws IOException { |
| 577 | + // ToDo: some mechanism to clean up these data files |
| 578 | + String json = GsonHelper.getGson().toJson(details); |
| 579 | + logger.debug("Data: {}", json); |
| 580 | + long epochMillis = System.currentTimeMillis(); |
| 581 | + String fileName = epochMillis + ".json"; |
| 582 | + Path tempDir = Files.createTempDirectory("orchestrator"); |
| 583 | + Path tempFile = tempDir.resolve(fileName); |
| 584 | + Files.writeString(tempFile, json, StandardOpenOption.CREATE_NEW); |
| 585 | + return tempFile.toAbsolutePath().toString(); |
578 | 586 | } |
579 | 587 |
|
580 | 588 | @Override |
|
0 commit comments