use of org.openstack.client.storage.OpenstackStorageClient in project platformlayer by platformlayer.
the class DirectOpenstackDownload method download.
public void download(OpsTarget target, File targetPath, OpenstackCredentials credentials, String containerName, String objectPath) throws OpsException {
RemoteCurlOpenstackSession session = new RemoteCurlOpenstackSession(target);
session.authenticate(credentials, false);
OpenstackStorageClient storageClient = session.getStorageClient();
RequestBuilder request = storageClient.root().containers().id(containerName).objects().id(objectPath).buildDownloadRequest();
CurlRequest curlRequest = session.toCurlRequest(request);
curlRequest.bareRequest = true;
Command curlCommand = curlRequest.toCommand();
curlCommand.addLiteral(">");
curlCommand.addFile(targetPath);
ProcessExecution execution = target.executeCommand(curlCommand);
// CurlResult curlResult = curlRequest.parseResponse(execution);
//
// int httpResult = curlResult.getHttpResult();
// switch (httpResult) {
// case 200:
// break;
// case 201:
// break;
// default:
// throw new OpsException("Unexpected result code while downloading file: " + httpResult + " Result=" +
// curlResult);
// }
}
use of org.openstack.client.storage.OpenstackStorageClient in project platformlayer by platformlayer.
the class OpenstackCasStore method findArtifact.
@Override
public CasStoreObject findArtifact(Md5Hash hash) {
OpenstackStorageClient storageClient = getStorageClient();
try {
List<StorageObject> storageObjects = Lists.newArrayList(storageClient.listObjects(containerName, null, null));
String findHash = hash.toHex();
for (StorageObject storageObject : storageObjects) {
String storageObjectHash = storageObject.getHash();
if (storageObjectHash.equalsIgnoreCase(findHash)) {
return new OpenstackCasObject(storageObject);
}
}
} catch (OpenstackNotFoundException e) {
log.debug("Not found (404) returned from Openstack");
return null;
}
return null;
}
Aggregations