use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class RegistryServerHandler method addGatewayComputeResourcePreference.
/**
* Add a Compute Resource Preference to a registered gateway profile.
*
* @param gatewayID The identifier for the gateway profile to be added.
* @param computeResourceId Preferences related to a particular compute resource
* @param computeResourcePreference The ComputeResourcePreference object to be added to the resource profile.
* @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 addGatewayComputeResourcePreference(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();
if (!gatewayProfile.isGatewayResourceProfileExists(gatewayID)) {
throw new RegistryServiceException("Gateway resource profile '" + gatewayID + "' does not exist!!!");
}
GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID);
// gatewayProfile.removeGatewayResourceProfile(gatewayID);
profile.addToComputeResourcePreferences(computeResourcePreference);
gatewayProfile.updateGatewayResourceProfile(gatewayID, profile);
logger.debug("Airavata added gateway compute resource preference with gateway id : " + gatewayID + " and for compute resource id : " + computeResourceId);
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 GatewayProfileTest method gatewayProfileTest.
@Test
public void gatewayProfileTest() throws Exception {
GwyResourceProfile gatewayProfile = appcatalog.getGatewayProfile();
GatewayResourceProfile gf = new GatewayResourceProfile();
ComputeResource computeRs = appcatalog.getComputeResource();
ComputeResourceDescription cm1 = new ComputeResourceDescription();
cm1.setHostName("localhost");
cm1.setResourceDescription("test compute host");
String hostId1 = computeRs.addComputeResource(cm1);
ComputeResourceDescription cm2 = new ComputeResourceDescription();
cm2.setHostName("localhost");
cm2.setResourceDescription("test compute host");
String hostId2 = computeRs.addComputeResource(cm2);
ComputeResourcePreference preference1 = new ComputeResourcePreference();
preference1.setComputeResourceId(hostId1);
preference1.setOverridebyAiravata(true);
preference1.setPreferredJobSubmissionProtocol(JobSubmissionProtocol.SSH);
preference1.setPreferredDataMovementProtocol(DataMovementProtocol.SCP);
preference1.setPreferredBatchQueue("queue1");
preference1.setScratchLocation("/tmp");
preference1.setAllocationProjectNumber("project1");
ComputeResourcePreference preference2 = new ComputeResourcePreference();
preference2.setComputeResourceId(hostId2);
preference2.setOverridebyAiravata(true);
preference2.setPreferredJobSubmissionProtocol(JobSubmissionProtocol.LOCAL);
preference2.setPreferredDataMovementProtocol(DataMovementProtocol.GridFTP);
preference2.setPreferredBatchQueue("queue2");
preference2.setScratchLocation("/tmp");
preference2.setAllocationProjectNumber("project2");
List<ComputeResourcePreference> list = new ArrayList<ComputeResourcePreference>();
list.add(preference1);
list.add(preference2);
gf.setComputeResourcePreferences(list);
gf.setGatewayID("testGateway");
String gwId = gatewayProfile.addGatewayResourceProfile(gf);
GatewayResourceProfile retrievedProfile = null;
if (gatewayProfile.isGatewayResourceProfileExists(gwId)) {
retrievedProfile = gatewayProfile.getGatewayProfile(gwId);
System.out.println("************ gateway id ************** :" + retrievedProfile.getGatewayID());
}
List<ComputeResourcePreference> preferences = gatewayProfile.getAllComputeResourcePreferences(gwId);
System.out.println("compute preferences size : " + preferences.size());
if (preferences != null && !preferences.isEmpty()) {
for (ComputeResourcePreference cm : preferences) {
System.out.println("******** host id ********* : " + cm.getComputeResourceId());
System.out.println(cm.getPreferredBatchQueue());
System.out.println(cm.getPreferredDataMovementProtocol());
System.out.println(cm.getPreferredJobSubmissionProtocol());
}
}
assertTrue("App interface saved successfully", retrievedProfile != null);
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class SampleEchoExperiment method registerGatewayProfile.
private void registerGatewayProfile() throws TException {
GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
ComputeResourcePreference localhostResourcePreference = RegisterSampleApplicationsUtils.createComputeResourcePreference(localhostId, gatewayId, false, null, null, null, "/tmp");
gatewayResourceProfile.setGatewayID(gatewayId);
gatewayResourceProfile.addToComputeResourcePreferences(localhostResourcePreference);
airavataClient.registerGatewayResourceProfile(new AuthzToken(""), gatewayResourceProfile);
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class RegisterOGCEUS3Application method registerGatewayResourceProfile.
public static void registerGatewayResourceProfile() {
try {
System.out.println("#### Registering Gateway proflie #### \n");
ComputeResourcePreference stampedeResourcePreferences = RegisterSampleApplicationsUtils.createComputeResourcePreference(stampedeResourceId, "TG-STA110014S", false, null, null, null, "/scratch/01437/ogce/ultrascan_testing/");
ComputeResourcePreference trestlesResourcePreferences = RegisterSampleApplicationsUtils.createComputeResourcePreference(trestlesResourceId, "sds128", false, null, null, null, "/oasis/scratch/trestles/ogce/temp_project/gta-work-dirs/");
// ComputeResourcePreference lonestarResourcePreferences = RegisterSampleApplicationsUtils.
// createComputeResourcePreference(lonestarResourceId, "ULTRASCAN", false, null, null, null,
// "/scratch/01623/us3/airavata/");
//
// ComputeResourcePreference alamoResourcePreferences = RegisterSampleApplicationsUtils.
// createComputeResourcePreference(alamoResourceId, null, false, null, null, null,
// "/mnt/glusterfs/work/");
GatewayResourceProfile gatewayResourceProfile = new GatewayResourceProfile();
gatewayResourceProfile.setGatewayID(DEFAULT_GATEWAY);
gatewayResourceProfile.addToComputeResourcePreferences(stampedeResourcePreferences);
gatewayResourceProfile.addToComputeResourcePreferences(trestlesResourcePreferences);
// gatewayResourceProfile.addToComputeResourcePreferences(lonestarResourcePreferences);
// gatewayResourceProfile.addToComputeResourcePreferences(alamoResourcePreferences);
String gatewayProfile = airavataClient.registerGatewayResourceProfile(new AuthzToken(""), gatewayResourceProfile);
System.out.println("Gateway Profile is registered with Id " + gatewayProfile);
} catch (TException e) {
e.printStackTrace();
}
}
use of org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile in project airavata by apache.
the class AiravataServerHandler method postInitDefaultGateway.
/**
* This method creates a password token for the default gateway profile. Default gateway is originally initialized
* at the registry server but we can not add the password token at that step as the credential store is not initialized
* before registry server.
*/
private void postInitDefaultGateway() {
RegistryService.Client registryClient = registryClientPool.getResource();
try {
GatewayResourceProfile gatewayResourceProfile = registryClient.getGatewayResourceProfile(ServerSettings.getDefaultUserGateway());
if (gatewayResourceProfile != null && gatewayResourceProfile.getCredentialStoreToken() == null) {
logger.debug("Starting to add the password credential for default gateway : " + ServerSettings.getDefaultUserGateway());
PasswordCredential passwordCredential = new PasswordCredential();
passwordCredential.setPortalUserName(ServerSettings.getDefaultUser());
passwordCredential.setGatewayId(ServerSettings.getDefaultUserGateway());
passwordCredential.setLoginUserName(ServerSettings.getDefaultUser());
passwordCredential.setPassword(ServerSettings.getDefaultUserPassword());
passwordCredential.setDescription("Credentials for default gateway");
CredentialStoreService.Client csClient = csClientPool.getResource();
String token = null;
try {
logger.info("Creating password credential for default gateway");
token = csClient.addPasswordCredential(passwordCredential);
csClientPool.returnResource(csClient);
} catch (Exception ex) {
logger.error("Failed to create the password credential for the default gateway : " + ServerSettings.getDefaultUserGateway(), ex);
if (csClient != null) {
csClientPool.returnBrokenResource(csClient);
}
}
if (token != null) {
logger.debug("Adding password credential token " + token + " to the default gateway : " + ServerSettings.getDefaultUserGateway());
gatewayResourceProfile.setIdentityServerPwdCredToken(token);
registryClient.updateGatewayResourceProfile(ServerSettings.getDefaultUserGateway(), gatewayResourceProfile);
}
registryClientPool.returnResource(registryClient);
}
} catch (Exception e) {
logger.error("Failed to add the password credentials for the default gateway", e);
if (registryClient != null) {
registryClientPool.returnBrokenResource(registryClient);
}
}
}
Aggregations