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();
}
}
Aggregations