use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage in project kubernetes-client by fabric8io.
the class StorageTest method get.
@Test
void get() {
// Given
server.expect().get().withPath("/apis/operator.openshift.io/v1/storages/test-get").andReturn(HttpURLConnection.HTTP_OK, createNewStorage("test-get")).once();
// When
Storage storage = client.operator().storages().withName("test-get").get();
// Then
assertThat(storage).isNotNull().hasFieldOrPropertyWithValue("metadata.name", "test-get");
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage in project airavata-mft by apache.
the class FileBasedResourceBackend method getBoxStorage.
@Override
public Optional<BoxStorage> getBoxStorage(BoxStorageGetRequest request) throws Exception {
JSONParser jsonParser = new JSONParser();
InputStream inputStream = FileBasedResourceBackend.class.getClassLoader().getResourceAsStream(storageFile);
try (InputStreamReader reader = new InputStreamReader(inputStream)) {
Object obj = jsonParser.parse(reader);
JSONArray storageList = (JSONArray) obj;
System.out.println("All resources ");
List<BoxStorage> boxStorages = (List<BoxStorage>) storageList.stream().filter(storage -> "BOX".equals(((JSONObject) storage).get("type").toString())).map(storage -> {
JSONObject s = (JSONObject) storage;
BoxStorage st = BoxStorage.newBuilder().setStorageId(s.get("storageId").toString()).build();
return st;
}).collect(Collectors.toList());
return boxStorages.stream().filter(s -> request.getStorageId().equals(s.getStorageId())).findFirst();
}
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage in project airavata-mft by apache.
the class FileBasedResourceBackend method getGCSStorage.
@Override
public Optional<GCSStorage> getGCSStorage(GCSStorageGetRequest request) throws Exception {
JSONParser jsonParser = new JSONParser();
InputStream inputStream = FileBasedResourceBackend.class.getClassLoader().getResourceAsStream(storageFile);
try (InputStreamReader reader = new InputStreamReader(inputStream)) {
Object obj = jsonParser.parse(reader);
JSONArray storageList = (JSONArray) obj;
List<GCSStorage> gcsStorages = (List<GCSStorage>) storageList.stream().filter(storage -> "GCS".equals(((JSONObject) storage).get("type").toString())).map(storage -> {
JSONObject s = (JSONObject) storage;
GCSStorage st = GCSStorage.newBuilder().setStorageId(s.get("storageId").toString()).setBucketName(s.get("bucketName").toString()).build();
return st;
}).collect(Collectors.toList());
return gcsStorages.stream().filter(s -> request.getStorageId().equals(s.getStorageId())).findFirst();
}
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage in project airavata-mft by apache.
the class AiravataResourceBackend method getSCPStorage.
@Override
public Optional<SCPStorage> getSCPStorage(SCPStorageGetRequest request) throws Exception {
String resourceId = request.getStorageId();
String[] parts = resourceId.split(":");
String type = parts[0];
String storageOrComputeId = parts[2];
logger.info("Connecting to registry service {}:{}", registryServerHost, registryServerPort);
RegistryService.Client registryClient = RegistryServiceClientFactory.createRegistryClient(registryServerHost, registryServerPort);
SCPStorage.Builder builder = SCPStorage.newBuilder().setStorageId(resourceId);
if ("STORAGE".equals(type)) {
StorageResourceDescription storageResource = registryClient.getStorageResource(storageOrComputeId);
Optional<DataMovementInterface> dmInterfaceOp = storageResource.getDataMovementInterfaces().stream().filter(iface -> iface.getDataMovementProtocol() == DataMovementProtocol.SCP).findFirst();
DataMovementInterface scpInterface = dmInterfaceOp.orElseThrow(() -> new Exception("Could not find a SCP interface for storage resource " + storageOrComputeId));
SCPDataMovement scpDataMovement = registryClient.getSCPDataMovement(scpInterface.getDataMovementInterfaceId());
String alternateHostName = scpDataMovement.getAlternativeSCPHostName();
String selectedHostName = (alternateHostName == null || "".equals(alternateHostName)) ? storageResource.getHostName() : alternateHostName;
int selectedPort = scpDataMovement.getSshPort() == 0 ? 22 : scpDataMovement.getSshPort();
builder.setHost(selectedHostName);
builder.setPort(selectedPort);
} else if ("CLUSTER".equals(type)) {
ComputeResourceDescription computeResource = registryClient.getComputeResource(storageOrComputeId);
builder.setHost(computeResource.getHostName());
builder.setPort(22);
}
return Optional.of(builder.build());
}
use of com.viaversion.viaversion.protocols.protocol1_9to1_8.storage in project airavata-mft by apache.
the class FileBasedResourceBackend method getFTPStorage.
@Override
public Optional<FTPStorage> getFTPStorage(FTPStorageGetRequest request) throws Exception {
InputStream inputStream = FileBasedResourceBackend.class.getClassLoader().getResourceAsStream(storageFile);
JSONParser jsonParser = new JSONParser();
if (inputStream == null) {
throw new IOException("resources file not found");
}
try (InputStreamReader reader = new InputStreamReader(inputStream)) {
Object obj = jsonParser.parse(reader);
JSONArray storageList = (JSONArray) obj;
List<FTPStorage> ftpStorages = (List<FTPStorage>) storageList.stream().filter(storage -> "FTP".equals(((JSONObject) storage).get("type").toString())).map(storage -> {
JSONObject s = (JSONObject) storage;
FTPStorage st = FTPStorage.newBuilder().setStorageId(s.get("storageId").toString()).setHost(s.get("host").toString()).setPort(Integer.parseInt(s.get("port").toString())).build();
return st;
}).collect(Collectors.toList());
return ftpStorages.stream().filter(s -> request.getStorageId().equals(s.getStorageId())).findFirst();
}
}
Aggregations