Search in sources :

Example 6 with StoragePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.

the class GwyResourceProfileImpl method getAllGatewayProfiles.

@Override
public List<GatewayResourceProfile> getAllGatewayProfiles() throws AppCatalogException {
    try {
        List<GatewayResourceProfile> gatewayResourceProfileList = new ArrayList<GatewayResourceProfile>();
        GatewayProfileResource profileResource = new GatewayProfileResource();
        List<AppCatalogResource> resourceList = profileResource.getAll();
        if (resourceList != null && !resourceList.isEmpty()) {
            for (AppCatalogResource resource : resourceList) {
                GatewayProfileResource gatewayProfileResource = (GatewayProfileResource) resource;
                List<ComputeResourcePreference> computeResourcePreferences = getAllComputeResourcePreferences(gatewayProfileResource.getGatewayID());
                List<StoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayProfileResource.getGatewayID());
                GatewayResourceProfile gatewayResourceProfile = AppCatalogThriftConversion.getGatewayResourceProfile(gatewayProfileResource, computeResourcePreferences, dataStoragePreferences);
                gatewayResourceProfileList.add(gatewayResourceProfile);
            }
        }
        return gatewayResourceProfileList;
    } catch (Exception e) {
        logger.error("Error while retrieving gateway ids...", e);
        throw new AppCatalogException(e);
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) GatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile) ArrayList(java.util.ArrayList) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 7 with StoragePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.

the class GwyResourceProfileImpl method getGatewayProfile.

@Override
public GatewayResourceProfile getGatewayProfile(String gatewayId) throws AppCatalogException {
    try {
        GatewayProfileResource resource = new GatewayProfileResource();
        GatewayProfileResource gwresource = (GatewayProfileResource) resource.get(gatewayId);
        ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
        List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
        List<ComputeResourcePreference> computeResourcePreferences = AppCatalogThriftConversion.getComputeResourcePreferences(computePrefList);
        List<StoragePreference> dataStoragePreferences = getAllStoragePreferences(gatewayId);
        return AppCatalogThriftConversion.getGatewayResourceProfile(gwresource, computeResourcePreferences, dataStoragePreferences);
    } catch (Exception e) {
        logger.error("Error while retrieving gateway profile...", e);
        throw new AppCatalogException(e);
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 8 with StoragePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.

the class GwyResourceProfileImpl method addGatewayResourceProfile.

@Override
public String addGatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile gatewayProfile) throws AppCatalogException {
    try {
        GatewayProfileResource profileResource = new GatewayProfileResource();
        if (!gatewayProfile.getGatewayID().equals("")) {
            profileResource.setGatewayID(gatewayProfile.getGatewayID());
        }
        if (gatewayProfile.getCredentialStoreToken() != null) {
            profileResource.setCredentialStoreToken(gatewayProfile.getCredentialStoreToken());
        }
        if (gatewayProfile.getIdentityServerTenant() != null) {
            profileResource.setIdentityServerTenant(gatewayProfile.getIdentityServerTenant());
        }
        if (gatewayProfile.getIdentityServerPwdCredToken() != null) {
            profileResource.setIdentityServerPwdCredToken(gatewayProfile.getIdentityServerPwdCredToken());
        }
        profileResource.setGatewayID(gatewayProfile.getGatewayID());
        profileResource.save();
        List<ComputeResourcePreference> computeResourcePreferences = gatewayProfile.getComputeResourcePreferences();
        if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()) {
            for (ComputeResourcePreference preference : computeResourcePreferences) {
                ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
                resource.setGatewayProfile(profileResource);
                resource.setResourceId(preference.getComputeResourceId());
                ComputeResourceResource computeHostResource = new ComputeResourceResource();
                resource.setComputeHostResource((ComputeResourceResource) computeHostResource.get(preference.getComputeResourceId()));
                resource.setGatewayId(profileResource.getGatewayID());
                resource.setOverrideByAiravata(preference.isOverridebyAiravata());
                resource.setLoginUserName(preference.getLoginUserName());
                resource.setResourceCSToken(preference.getResourceSpecificCredentialStoreToken());
                resource.setUsageReportingGatewayId(preference.getUsageReportingGatewayId());
                if (preference.getPreferredJobSubmissionProtocol() != null) {
                    resource.setPreferredJobProtocol(preference.getPreferredJobSubmissionProtocol().toString());
                }
                if (preference.getPreferredDataMovementProtocol() != null) {
                    resource.setPreferedDMProtocol(preference.getPreferredDataMovementProtocol().toString());
                }
                resource.setBatchQueue(preference.getPreferredBatchQueue());
                resource.setProjectNumber(preference.getAllocationProjectNumber());
                resource.setScratchLocation(preference.getScratchLocation());
                resource.setQualityOfService(preference.getQualityOfService());
                resource.setReservation(preference.getReservation());
                if (preference.getReservationStartTime() > 0) {
                    resource.setReservationStartTime(AiravataUtils.getTime(preference.getReservationStartTime()));
                }
                if (preference.getReservationEndTime() > 0) {
                    resource.setReservationEndTime(AiravataUtils.getTime(preference.getReservationEndTime()));
                }
                resource.setSshAccountProvisioner(preference.getSshAccountProvisioner());
                if (preference.getSshAccountProvisionerConfig() != null && !preference.getSshAccountProvisionerConfig().isEmpty()) {
                    Map<String, String> sshAccountProvisionerConfigurationsCopy = new HashMap<>(preference.getSshAccountProvisionerConfig());
                    resource.setSshAccountProvisionerConfigurations(sshAccountProvisionerConfigurationsCopy);
                }
                resource.setSshAccountProvisionerAdditionalInfo(preference.getSshAccountProvisionerAdditionalInfo());
                resource.save();
            }
        }
        List<StoragePreference> dataStoragePreferences = gatewayProfile.getStoragePreferences();
        if (dataStoragePreferences != null && !dataStoragePreferences.isEmpty()) {
            for (StoragePreference storagePreference : dataStoragePreferences) {
                StoragePreferenceResource resource = new StoragePreferenceResource();
                resource.setStorageResourceId(storagePreference.getStorageResourceId());
                resource.setGatewayId(profileResource.getGatewayID());
                resource.setFsRootLocation(storagePreference.getFileSystemRootLocation());
                resource.setLoginUserName(storagePreference.getLoginUserName());
                resource.setResourceCSToken(storagePreference.getResourceSpecificCredentialStoreToken());
                resource.setGatewayProfile(profileResource);
                resource.save();
            }
        }
        return profileResource.getGatewayID();
    } catch (Exception e) {
        logger.error("Error while saving gateway profile...", e);
        throw new AppCatalogException(e);
    }
}
Also used : ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) HashMap(java.util.HashMap) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException)

Example 9 with StoragePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.

the class AppCatalogThriftConversion method getDataStoragePreference.

public static StoragePreference getDataStoragePreference(StoragePreferenceResource resource) {
    StoragePreference preference = new StoragePreference();
    preference.setStorageResourceId(resource.getStorageResourceId());
    preference.setFileSystemRootLocation(resource.getFsRootLocation());
    preference.setLoginUserName(resource.getLoginUserName());
    preference.setResourceSpecificCredentialStoreToken(resource.getResourceCSToken());
    return preference;
}
Also used : UserStoragePreference(org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)

Example 10 with StoragePreference

use of org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference in project airavata by apache.

the class AiravataIT method testStorageResource.

@org.testng.annotations.Test(priority = 3)
public void testStorageResource() {
    try {
        logger.info("testStorageResource() -> Creating test storage resource......");
        storageResource = setup.getStorageResourceRegister().addStorageResourceResource();
        ;
        Assert.assertNotNull(storageResource);
        StorageResourceDescription storageResourceDescription = setup.getStorageResourceRegister().getStorageResourceDescription(storageResource);
        Assert.assertNotNull(storageResourceDescription.getHostName(), HOST_NAME);
        Assert.assertNotNull(storageResourceDescription.getStorageResourceDescription(), HOST_DESC);
        setup.getStorageResourceRegister().registerGatewayStorageProfile(storageResource);
        StoragePreference storagePreference = setup.getStorageResourceRegister().getStoragePreference(properties.getGname(), storageResource);
        Assert.assertEquals(storagePreference.getLoginUserName(), LOGIN_USER);
        Assert.assertEquals(storagePreference.getFileSystemRootLocation(), TestFrameworkConstants.STORAGE_LOCATION);
        logger.info("testStorageResource() -> Created test storage resource. Storage Resource Id : " + storageResource);
    } catch (Exception e) {
        logger.error("Error occured while testStorageResource", e);
        Assert.fail();
    }
}
Also used : StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) StoragePreference(org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)

Aggregations

StoragePreference (org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference)11 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)4 UserStoragePreference (org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference)4 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)4 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)3 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)3 HashMap (java.util.HashMap)2 TException (org.apache.thrift.TException)2 ArrayList (java.util.ArrayList)1 AiravataException (org.apache.airavata.common.exception.AiravataException)1 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)1 CredentialStoreException (org.apache.airavata.credential.store.exception.CredentialStoreException)1 StorageResourceDescription (org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription)1 RegistryService (org.apache.airavata.registry.api.RegistryService)1 SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)1 SharingRegistryService (org.apache.airavata.sharing.registry.service.cpi.SharingRegistryService)1