use of org.platformlayer.ops.CommandEnvironment in project platformlayer by platformlayer.
the class PersistIptablesScripts method addChildren.
@Override
protected void addChildren() throws OpsException {
addChild(ManagedDirectory.build(BASE_DIR, "0644"));
addChild(SimpleFile.build(getClass(), new File("/etc/network/if-pre-up.d/iptables-lockdown")).setFileMode("755").setUpdateAction(new FilesystemAction() {
@Override
public void execute(OpsTarget target, ManagedFilesystemItem managedFilesystemItem) throws OpsException {
if (managedFilesystemItem.getNewFileWasCreated()) {
// Set the parameters the ifup sets
CommandEnvironment env = new CommandEnvironment();
env.put("MODE", "start");
env.put("IFACE", "--all");
env.put("ADDRFAM", "meta");
Command runLockdown = Command.build("/etc/network/if-pre-up.d/iptables-lockdown");
runLockdown.setEnvironment(env);
target.executeCommand(runLockdown);
}
}
}));
addChild(SimpleFile.build(getClass(), new File("/etc/network/if-up.d/iptables-ifup")).setFileMode("755"));
}
use of org.platformlayer.ops.CommandEnvironment in project platformlayer by platformlayer.
the class HttpProxyHelper method getHttpProxyEnvironment.
public CommandEnvironment getHttpProxyEnvironment(OpsTarget target, Usage usage, URI uri) throws OpsException {
if (httpProxyEnvironment == null) {
List<String> proxies = findHttpProxies(target, uri);
httpProxyEnvironment = new CommandEnvironment();
String proxy = chooseProxy(target, proxies);
if (proxy != null) {
log.info("Will use http proxy: " + proxy);
httpProxyEnvironment.put("http_proxy", proxy);
} else {
log.info("No suitable http proxy found");
}
}
return httpProxyEnvironment;
}
Aggregations