use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class RegistryServerHandler method updateGatewayComputeResourcePreference.
/**
* Update a Compute Resource Preference to a registered gateway profile.
*
* @param gatewayID The identifier for the gateway profile to be updated.
* @param computeResourceId Preferences related to a particular compute resource
* @param computeResourcePreference The ComputeResourcePreference object to be updated to the resource profile.
* @return status
* Returns a success/failure of the updation.
*/
@Override
public boolean updateGatewayComputeResourcePreference(String gatewayID, String computeResourceId, ComputeResourcePreference computeResourcePreference) throws RegistryServiceException, TException {
try {
if (!isGatewayExistInternal(gatewayID)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
appCatalog = RegistryFactory.getAppCatalog();
GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID);
List<ComputeResourcePreference> computeResourcePreferences = profile.getComputeResourcePreferences();
ComputeResourcePreference preferenceToRemove = null;
for (ComputeResourcePreference preference : computeResourcePreferences) {
if (preference.getComputeResourceId().equals(computeResourceId)) {
preferenceToRemove = preference;
break;
}
}
if (preferenceToRemove != null) {
profile.getComputeResourcePreferences().remove(preferenceToRemove);
}
profile.getComputeResourcePreferences().add(computeResourcePreference);
gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
logger.debug("Airavata updated compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId);
return true;
} catch (AppCatalogException e) {
logger.error(gatewayID, "Error while reading gateway compute resource preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while updating gateway compute resource preference. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class RegistryServerHandler method updateGateway.
/**
* Update previously registered Gateway metadata.
*
* @param gatewayId The gateway Id of the Gateway which require an update.
* @param updatedGateway
* @return gateway
* Modified gateway obejct.
* @throws AiravataClientException
*/
@Override
public boolean updateGateway(String gatewayId, Gateway updatedGateway) throws RegistryServiceException, TException {
try {
experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
if (!experimentCatalog.isExist(ExperimentCatalogModelType.GATEWAY, gatewayId)) {
logger.error("Gateway does not exist in the system. Please provide a valid gateway ID...");
AiravataSystemException exception = new AiravataSystemException();
exception.setMessage("Gateway does not exist in the system. Please provide a valid gateway ID...");
throw exception;
}
experimentCatalog.update(ExperimentCatalogModelType.GATEWAY, updatedGateway, gatewayId);
// check if gatewayprofile exists and check if the identity server password token equals the admin password token, if not update
GatewayResourceProfile existingGwyResourceProfile = appCatalog.getGatewayProfile().getGatewayProfile(gatewayId);
if (existingGwyResourceProfile.getIdentityServerPwdCredToken() == null || !existingGwyResourceProfile.getIdentityServerPwdCredToken().equals(updatedGateway.getIdentityServerPasswordToken())) {
existingGwyResourceProfile.setIdentityServerPwdCredToken(updatedGateway.getIdentityServerPasswordToken());
appCatalog.getGatewayProfile().updateGatewayResourceProfile(gatewayId, existingGwyResourceProfile);
}
logger.debug("Airavata update gateway with gateway id : " + gatewayId);
return true;
} catch (RegistryException e) {
logger.error("Error while updating the gateway", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while updating the gateway. More info : " + e.getMessage());
throw exception;
} catch (AppCatalogException e) {
logger.error("Error while updating gateway profile", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while updating gateway profile. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class RegistryServerHandler method addGatewayStoragePreference.
/**
* Add a Storage Resource Preference to a registered gateway profile.
*
* @param gatewayID The identifier of the gateway profile to be added.
* @param storageResourceId Preferences related to a particular compute resource
* @param dataStoragePreference
* @return status
* Returns a success/failure of the addition. If a profile already exists, this operation will fail.
* Instead an update should be used.
*/
@Override
public boolean addGatewayStoragePreference(String gatewayID, String storageResourceId, StoragePreference dataStoragePreference) throws RegistryServiceException, TException {
try {
if (!isGatewayExistInternal(gatewayID)) {
logger.error("Gateway does not exist.Please provide a valid gateway id...");
throw new RegistryServiceException("Gateway does not exist.Please provide a valid gateway id...");
}
appCatalog = RegistryFactory.getAppCatalog();
GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile();
if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)) {
throw new RegistryServiceException("Gateway resource profile '" + gatewayID + "' does not exist!!!");
}
GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID);
// gatewayProfile.removeGatewayResourceProfile(gatewayID);
dataStoragePreference.setStorageResourceId(storageResourceId);
profile.addToStoragePreferences(dataStoragePreference);
gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
logger.debug("Airavata added storage resource preference with gateway id : " + gatewayID + " and for storage resource id : " + storageResourceId);
return true;
} catch (AppCatalogException e) {
logger.error(gatewayID, "Error while registering gateway resource profile preference...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while registering gateway resource profile preference. More info : " + e.getMessage());
throw exception;
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class DocumentCreatorNew method createLocalHostDocs.
public String createLocalHostDocs() throws AppCatalogException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
// Define compute resource host
ComputeResourceDescription host = DocumentCreatorUtils.createComputeResourceDescription("localhost", new ArrayList<String>(Arrays.asList(new String[] { "127.0.0.1" })), new ArrayList<String>(Arrays.asList(new String[] { "127.0.0.1" })));
// host.setIsEmpty(true);
host.setComputeResourceId(client.registerComputeResource(authzToken, host));
LOCALSubmission localSubmission = new LOCALSubmission();
ResourceJobManager resourceJobManager = DocumentCreatorUtils.createResourceJobManager(ResourceJobManagerType.FORK, null, null, null);
localSubmission.setResourceJobManager(resourceJobManager);
client.addLocalSubmissionDetails(authzToken, host.getComputeResourceId(), 1, localSubmission);
LOCALDataMovement localDataMovement = new LOCALDataMovement();
client.addLocalDataMovementDetails(authzToken, host.getComputeResourceId(), 1, localDataMovement);
// Define application module
ApplicationModule module = DocumentCreatorUtils.createApplicationModule("echo", "1.0.0", "Local host echo applications");
module.setAppModuleId(client.registerApplicationModule(authzToken, DEFAULT_GATEWAY, module));
// Define application interfaces
ApplicationInterfaceDescription application = new ApplicationInterfaceDescription();
// application.setIsEmpty(false);
application.setApplicationName("SimpleEcho0");
application.addToApplicationModules(module.getAppModuleId());
application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("echo_input", "echo_input", "Echo Input Data", null, DataType.STRING));
application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("echo_output", null, DataType.STRING));
application.setApplicationInterfaceId(client.registerApplicationInterface(authzToken, DEFAULT_GATEWAY, application));
// Define application deployment
ApplicationDeploymentDescription deployment = DocumentCreatorUtils.createApplicationDeployment(host.getComputeResourceId(), module.getAppModuleId(), "/bin/echo", ApplicationParallelismType.SERIAL, "Local echo app depoyment");
deployment.setAppDeploymentId(client.registerApplicationDeployment(authzToken, DEFAULT_GATEWAY, deployment));
// Define gateway profile
ComputeResourcePreference computeResourcePreference = DocumentCreatorUtils.createComputeResourcePreference(host.getComputeResourceId(), "/tmp", null, false, null, null, null);
gatewayResourceProfile = new GatewayResourceProfile();
// gatewayResourceProfile.setGatewayID("default");
gatewayResourceProfile.setGatewayID(DEFAULT_GATEWAY);
gatewayResourceProfile.addToComputeResourcePreferences(computeResourcePreference);
String gatewayId = client.registerGatewayResourceProfile(authzToken, gatewayResourceProfile);
gatewayResourceProfile.setGatewayID(gatewayId);
client.addGatewayComputeResourcePreference(authzToken, gatewayResourceProfile.getGatewayID(), host.getComputeResourceId(), computeResourcePreference);
return host.getComputeResourceId() + "," + application.getApplicationInterfaceId();
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class AppCatalogThriftConversion method getGatewayResourceProfile.
public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileResource gw, List<ComputeResourcePreference> preferences, List<StoragePreference> storagePreferences) {
GatewayResourceProfile gatewayProfile = new GatewayResourceProfile();
gatewayProfile.setGatewayID(gw.getGatewayID());
gatewayProfile.setCredentialStoreToken(gw.getCredentialStoreToken());
gatewayProfile.setIdentityServerTenant(gw.getIdentityServerTenant());
gatewayProfile.setIdentityServerPwdCredToken(gw.getIdentityServerPwdCredToken());
gatewayProfile.setComputeResourcePreferences(preferences);
gatewayProfile.setStoragePreferences(storagePreferences);
return gatewayProfile;
}
Aggregations