public static SshPutTaskFactory newSshPutTaskFactory(SshMachineLocation machine, String remoteFile) { return new SshPutTaskFactory(machine, remoteFile); }
/** convenience constructor to supply machine immediately */ public SshPutTaskFactory(SshMachineLocation machine, String remoteFile) { machine(machine); remoteFile(remoteFile); }
public static TaskFactory<?> buildChefFile(String runDirectory, String chefDirectory, String phase, Iterable<? extends String> runList, Map<String, Object> optionalAttributes) { // TODO if it's server, try knife first // TODO configure add'l properties String phaseRb = "root = File.absolute_path(File.dirname(__FILE__))\n"+ "\n"+ "file_cache_path root\n"+ // "cookbook_path root + '/cookbooks'\n"; "cookbook_path '"+chefDirectory+"'\n"; Map<String,Object> phaseJsonMap = MutableMap.of(); if (optionalAttributes!=null) phaseJsonMap.putAll(optionalAttributes); if (runList!=null) phaseJsonMap.put("run_list", ImmutableList.copyOf(runList)); Gson json = new GsonBuilder().create(); String phaseJson = json.toJson(phaseJsonMap); return Tasks.sequential("build chef files for "+phase, SshEffectorTasks.put(Urls.mergePaths(runDirectory)+"/"+phase+".rb").contents(phaseRb).createDirectory(), SshEffectorTasks.put(Urls.mergePaths(runDirectory)+"/"+phase+".json").contents(phaseJson)); }
@Override public SshPutTaskWrapper newTask(Entity entity, Effector<Void> effector, ConfigBag parameters) { machine(EffectorTasks.getSshMachine(entity)); return super.newTask(); } @Override
/** constructor where machine will be added later */ public SshPutTaskFactory(String remoteFile) { remoteFile(remoteFile); }
public SshPutTaskFactory remoteFile(String remoteFile) { this.remoteFile = remoteFile; return self(); }
public static TaskFactory<?> buildChefFile(String runDirectory, String chefDirectory, String phase, Iterable<? extends String> runList, Map<String, Object> optionalAttributes) { // TODO if it's server, try knife first // TODO configure add'l properties String phaseRb = "root = File.absolute_path(File.dirname(__FILE__))\n"+ "\n"+ "file_cache_path root\n"+ // "cookbook_path root + '/cookbooks'\n"; "cookbook_path '"+chefDirectory+"'\n"; Map<String,Object> phaseJsonMap = MutableMap.of(); if (optionalAttributes!=null) phaseJsonMap.putAll(optionalAttributes); if (runList!=null) phaseJsonMap.put("run_list", ImmutableList.copyOf(runList)); Gson json = new GsonBuilder().create(); String phaseJson = json.toJson(phaseJsonMap); return Tasks.sequential("build chef files for "+phase, SshEffectorTasks.put(Urls.mergePaths(runDirectory)+"/"+phase+".rb").contents(phaseRb).createDirectory(), SshEffectorTasks.put(Urls.mergePaths(runDirectory)+"/"+phase+".json").contents(phaseJson)); }
@Override public SshPutTaskWrapper newTask() { Entity entity = BrooklynTasks.getTargetOrContextEntity(Tasks.current()); if (entity!=null) machine(EffectorTasks.getSshMachine(entity)); return super.newTask(); } }