Search in sources :

Example 6 with com.viaversion.viaversion.protocols.protocol1_9to1_8.storage

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");
}
Also used : Storage(io.fabric8.openshift.api.model.operator.v1.Storage) Test(org.junit.jupiter.api.Test)

Example 7 with com.viaversion.viaversion.protocols.protocol1_9to1_8.storage

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();
    }
}
Also used : ResourceBackend(org.apache.airavata.mft.resource.server.backend.ResourceBackend) Logger(org.slf4j.Logger) org.apache.airavata.mft.resource.stubs.azure.storage(org.apache.airavata.mft.resource.stubs.azure.storage) JSONParser(org.json.simple.parser.JSONParser) org.apache.airavata.mft.resource.stubs.common(org.apache.airavata.mft.resource.stubs.common) org.apache.airavata.mft.resource.stubs.box.storage(org.apache.airavata.mft.resource.stubs.box.storage) org.apache.airavata.mft.resource.stubs.scp.storage(org.apache.airavata.mft.resource.stubs.scp.storage) org.apache.airavata.mft.resource.stubs.ftp.storage(org.apache.airavata.mft.resource.stubs.ftp.storage) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) org.apache.airavata.mft.resource.stubs.gcs.storage(org.apache.airavata.mft.resource.stubs.gcs.storage) JSONArray(org.json.simple.JSONArray) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) List(java.util.List) org.apache.airavata.mft.storage.stubs.storagesecret(org.apache.airavata.mft.storage.stubs.storagesecret) JSONObject(org.json.simple.JSONObject) org.apache.airavata.mft.resource.stubs.s3.storage(org.apache.airavata.mft.resource.stubs.s3.storage) org.apache.airavata.mft.resource.stubs.dropbox.storage(org.apache.airavata.mft.resource.stubs.dropbox.storage) org.apache.airavata.mft.resource.stubs.local.storage(org.apache.airavata.mft.resource.stubs.local.storage) Optional(java.util.Optional) InputStream(java.io.InputStream) InputStreamReader(java.io.InputStreamReader) JSONObject(org.json.simple.JSONObject) InputStream(java.io.InputStream) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) JSONObject(org.json.simple.JSONObject) List(java.util.List)

Example 8 with com.viaversion.viaversion.protocols.protocol1_9to1_8.storage

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();
    }
}
Also used : ResourceBackend(org.apache.airavata.mft.resource.server.backend.ResourceBackend) Logger(org.slf4j.Logger) org.apache.airavata.mft.resource.stubs.azure.storage(org.apache.airavata.mft.resource.stubs.azure.storage) JSONParser(org.json.simple.parser.JSONParser) org.apache.airavata.mft.resource.stubs.common(org.apache.airavata.mft.resource.stubs.common) org.apache.airavata.mft.resource.stubs.box.storage(org.apache.airavata.mft.resource.stubs.box.storage) org.apache.airavata.mft.resource.stubs.scp.storage(org.apache.airavata.mft.resource.stubs.scp.storage) org.apache.airavata.mft.resource.stubs.ftp.storage(org.apache.airavata.mft.resource.stubs.ftp.storage) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) org.apache.airavata.mft.resource.stubs.gcs.storage(org.apache.airavata.mft.resource.stubs.gcs.storage) JSONArray(org.json.simple.JSONArray) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) List(java.util.List) org.apache.airavata.mft.storage.stubs.storagesecret(org.apache.airavata.mft.storage.stubs.storagesecret) JSONObject(org.json.simple.JSONObject) org.apache.airavata.mft.resource.stubs.s3.storage(org.apache.airavata.mft.resource.stubs.s3.storage) org.apache.airavata.mft.resource.stubs.dropbox.storage(org.apache.airavata.mft.resource.stubs.dropbox.storage) org.apache.airavata.mft.resource.stubs.local.storage(org.apache.airavata.mft.resource.stubs.local.storage) Optional(java.util.Optional) InputStream(java.io.InputStream) InputStreamReader(java.io.InputStreamReader) JSONObject(org.json.simple.JSONObject) InputStream(java.io.InputStream) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) JSONObject(org.json.simple.JSONObject) List(java.util.List)

Example 9 with com.viaversion.viaversion.protocols.protocol1_9to1_8.storage

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());
}
Also used : ResourceBackend(org.apache.airavata.mft.resource.server.backend.ResourceBackend) StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) SCPDataMovement(org.apache.airavata.model.data.movement.SCPDataMovement) RegistryServiceClientFactory(org.apache.airavata.registry.api.client.RegistryServiceClientFactory) Logger(org.slf4j.Logger) org.apache.airavata.mft.resource.stubs.azure.storage(org.apache.airavata.mft.resource.stubs.azure.storage) org.apache.airavata.mft.resource.stubs.common(org.apache.airavata.mft.resource.stubs.common) org.apache.airavata.mft.resource.stubs.box.storage(org.apache.airavata.mft.resource.stubs.box.storage) org.apache.airavata.mft.resource.stubs.scp.storage(org.apache.airavata.mft.resource.stubs.scp.storage) org.apache.airavata.mft.resource.stubs.ftp.storage(org.apache.airavata.mft.resource.stubs.ftp.storage) DataMovementProtocol(org.apache.airavata.model.data.movement.DataMovementProtocol) LoggerFactory(org.slf4j.LoggerFactory) org.apache.airavata.mft.resource.stubs.gcs.storage(org.apache.airavata.mft.resource.stubs.gcs.storage) org.apache.airavata.mft.storage.stubs.storagesecret(org.apache.airavata.mft.storage.stubs.storagesecret) org.apache.airavata.mft.resource.stubs.s3.storage(org.apache.airavata.mft.resource.stubs.s3.storage) org.apache.airavata.mft.resource.stubs.dropbox.storage(org.apache.airavata.mft.resource.stubs.dropbox.storage) org.apache.airavata.mft.resource.stubs.local.storage(org.apache.airavata.mft.resource.stubs.local.storage) Optional(java.util.Optional) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) DataMovementInterface(org.apache.airavata.model.data.movement.DataMovementInterface) RegistryService(org.apache.airavata.registry.api.RegistryService) SCPDataMovement(org.apache.airavata.model.data.movement.SCPDataMovement) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) RegistryService(org.apache.airavata.registry.api.RegistryService) DataMovementInterface(org.apache.airavata.model.data.movement.DataMovementInterface)

Example 10 with com.viaversion.viaversion.protocols.protocol1_9to1_8.storage

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();
    }
}
Also used : ResourceBackend(org.apache.airavata.mft.resource.server.backend.ResourceBackend) Logger(org.slf4j.Logger) org.apache.airavata.mft.resource.stubs.azure.storage(org.apache.airavata.mft.resource.stubs.azure.storage) JSONParser(org.json.simple.parser.JSONParser) org.apache.airavata.mft.resource.stubs.common(org.apache.airavata.mft.resource.stubs.common) org.apache.airavata.mft.resource.stubs.box.storage(org.apache.airavata.mft.resource.stubs.box.storage) org.apache.airavata.mft.resource.stubs.scp.storage(org.apache.airavata.mft.resource.stubs.scp.storage) org.apache.airavata.mft.resource.stubs.ftp.storage(org.apache.airavata.mft.resource.stubs.ftp.storage) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) org.apache.airavata.mft.resource.stubs.gcs.storage(org.apache.airavata.mft.resource.stubs.gcs.storage) JSONArray(org.json.simple.JSONArray) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) List(java.util.List) org.apache.airavata.mft.storage.stubs.storagesecret(org.apache.airavata.mft.storage.stubs.storagesecret) JSONObject(org.json.simple.JSONObject) org.apache.airavata.mft.resource.stubs.s3.storage(org.apache.airavata.mft.resource.stubs.s3.storage) org.apache.airavata.mft.resource.stubs.dropbox.storage(org.apache.airavata.mft.resource.stubs.dropbox.storage) org.apache.airavata.mft.resource.stubs.local.storage(org.apache.airavata.mft.resource.stubs.local.storage) Optional(java.util.Optional) InputStream(java.io.InputStream) InputStreamReader(java.io.InputStreamReader) JSONObject(org.json.simple.JSONObject) InputStream(java.io.InputStream) JSONArray(org.json.simple.JSONArray) JSONParser(org.json.simple.parser.JSONParser) JSONObject(org.json.simple.JSONObject) List(java.util.List) IOException(java.io.IOException)

Aggregations

Optional (java.util.Optional)9 ResourceBackend (org.apache.airavata.mft.resource.server.backend.ResourceBackend)9 org.apache.airavata.mft.resource.stubs.azure.storage (org.apache.airavata.mft.resource.stubs.azure.storage)9 org.apache.airavata.mft.resource.stubs.box.storage (org.apache.airavata.mft.resource.stubs.box.storage)9 org.apache.airavata.mft.resource.stubs.common (org.apache.airavata.mft.resource.stubs.common)9 org.apache.airavata.mft.resource.stubs.dropbox.storage (org.apache.airavata.mft.resource.stubs.dropbox.storage)9 org.apache.airavata.mft.resource.stubs.ftp.storage (org.apache.airavata.mft.resource.stubs.ftp.storage)9 org.apache.airavata.mft.resource.stubs.gcs.storage (org.apache.airavata.mft.resource.stubs.gcs.storage)9 org.apache.airavata.mft.resource.stubs.local.storage (org.apache.airavata.mft.resource.stubs.local.storage)9 org.apache.airavata.mft.resource.stubs.s3.storage (org.apache.airavata.mft.resource.stubs.s3.storage)9 org.apache.airavata.mft.resource.stubs.scp.storage (org.apache.airavata.mft.resource.stubs.scp.storage)9 org.apache.airavata.mft.storage.stubs.storagesecret (org.apache.airavata.mft.storage.stubs.storagesecret)9 Logger (org.slf4j.Logger)9 LoggerFactory (org.slf4j.LoggerFactory)9 IOException (java.io.IOException)8 InputStream (java.io.InputStream)8 InputStreamReader (java.io.InputStreamReader)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 JSONArray (org.json.simple.JSONArray)8