Search in sources :

Example 11 with CommandEnvironment

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"));
}
Also used : OpsTarget(org.platformlayer.ops.OpsTarget) Command(org.platformlayer.ops.Command) CommandEnvironment(org.platformlayer.ops.CommandEnvironment) ManagedFilesystemItem(org.platformlayer.ops.filesystem.ManagedFilesystemItem) File(java.io.File) SimpleFile(org.platformlayer.ops.filesystem.SimpleFile) FilesystemAction(org.platformlayer.ops.filesystem.FilesystemAction)

Example 12 with CommandEnvironment

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;
}
Also used : CommandEnvironment(org.platformlayer.ops.CommandEnvironment)

Aggregations

CommandEnvironment (org.platformlayer.ops.CommandEnvironment)12 Command (org.platformlayer.ops.Command)11 File (java.io.File)4 OpsException (org.platformlayer.ops.OpsException)3 OpsTarget (org.platformlayer.ops.OpsTarget)3 IOException (java.io.IOException)2 CurlRequest (org.platformlayer.ops.helpers.CurlRequest)2 Md5Hash (com.fathomdb.hash.Md5Hash)1 InputStream (java.io.InputStream)1 InetAddress (java.net.InetAddress)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 List (java.util.List)1 CasStoreMap (org.platformlayer.cas.CasStoreMap)1 CasStoreObject (org.platformlayer.cas.CasStoreObject)1 HostPolicy (org.platformlayer.core.model.HostPolicy)1 TagChanges (org.platformlayer.core.model.TagChanges)1 Tags (org.platformlayer.core.model.Tags)1 DiskImageRecipe (org.platformlayer.images.model.DiskImageRecipe)1 ChrootOpsTarget (org.platformlayer.ops.ChrootOpsTarget)1