Search in sources :

Example 6 with CreateJCloudsContainerOptions

use of io.fabric8.service.jclouds.CreateJCloudsContainerOptions in project fabric8 by jboss-fuse.

the class ToRunScriptOptions method apply.

public Optional<RunScriptOptions> apply(CreateJCloudsContainerMetadata containerMetadata) {
    CreateJCloudsContainerOptions options = containerMetadata.getCreateOptions();
    NodeMetadata nodeMetadata = computeService.getNodeMetadata(containerMetadata.getNodeId());
    LoginCredentials credentials = nodeMetadata.getCredentials();
    LoginCredentials.Builder loginBuilder;
    if (options.getUser() != null) {
        if (credentials == null) {
            loginBuilder = LoginCredentials.builder();
        } else {
            loginBuilder = credentials.toBuilder();
        }
        if (options.getPassword() != null) {
            credentials = loginBuilder.user(options.getUser()).password(options.getPassword()).build();
        } else {
            credentials = loginBuilder.user(options.getUser()).build();
        }
    }
    if (credentials != null) {
        return Optional.of(RunScriptOptions.Builder.overrideLoginCredentials(credentials).runAsRoot(false));
    } else {
        return Optional.absent();
    }
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) LoginCredentials(org.jclouds.domain.LoginCredentials) CreateJCloudsContainerOptions(io.fabric8.service.jclouds.CreateJCloudsContainerOptions)

Aggregations

ComputeService (org.jclouds.compute.ComputeService)5 CreateContainerMetadata (io.fabric8.api.CreateContainerMetadata)3 CreateJCloudsContainerOptions (io.fabric8.service.jclouds.CreateJCloudsContainerOptions)2 ToRunScriptOptions (io.fabric8.service.jclouds.functions.ToRunScriptOptions)2 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 RunNodesException (org.jclouds.compute.RunNodesException)2 ExecResponse (org.jclouds.compute.domain.ExecResponse)2 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)2 RunScriptOptions (org.jclouds.compute.options.RunScriptOptions)2 CreateJCloudsContainerMetadata (io.fabric8.service.jclouds.CreateJCloudsContainerMetadata)1 ToTemplate (io.fabric8.service.jclouds.functions.ToTemplate)1 Template (org.jclouds.compute.domain.Template)1 LoginCredentials (org.jclouds.domain.LoginCredentials)1