airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hes...@apache.org
Subject svn commit: r1204290 - in /incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac: provider/impl/EC2Provider.java scheduler/impl/SchedulerImpl.java
Date Sun, 20 Nov 2011 22:28:06 GMT
Author: heshan
Date: Sun Nov 20 22:28:05 2011
New Revision: 1204290

URL: http://svn.apache.org/viewvc?rev=1204290&view=rev
Log:
Updating the EC2Provier and the Schedular. AIRAVATA-202

Modified:
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java?rev=1204290&r1=1204289&r2=1204290&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java
(original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/impl/EC2Provider.java
Sun Nov 20 22:28:05 2011
@@ -32,9 +32,13 @@ import org.apache.airavata.core.gfac.con
 import org.apache.airavata.core.gfac.context.security.impl.SSHSecurityContextImpl;
 import org.apache.airavata.core.gfac.exception.GfacException;
 import org.apache.airavata.core.gfac.exception.ProviderException;
+import org.apache.airavata.schemas.wec.ContextHeaderDocument;
+import org.apache.airavata.schemas.wec.SecurityContextDocument;
+import org.apache.axiom.om.OMElement;
+import org.apache.xmlbeans.XmlException;
 import org.bouncycastle.openssl.PEMWriter;
-import xsul.lead.LeadResourceMapping;
 
+import javax.xml.stream.XMLStreamException;
 import java.io.*;
 import java.security.KeyPairGenerator;
 import java.security.NoSuchAlgorithmException;
@@ -63,18 +67,27 @@ public class EC2Provider extends SSHProv
 
     private String username;
 
-    public EC2Provider(InvocationContext invocationContext/*ExectionContext execContext*/)
throws ProviderException {
+    public EC2Provider(InvocationContext invocationContext) throws ProviderException {
         ExecutionContext execContext = invocationContext.getExecutionContext();
+        OMElement omSecurityContextHeader = execContext.getSecurityContextHeader();
 
-        LeadResourceMapping mapping = null;
-        // TODO
-        //mapping = execContext.getLeadHeader().getResourceMapping();
-        String access_key = mapping.getAttributeValue(null, "ACCESS_KEY");
-        String secret_key = mapping.getAttributeValue(null, "SECRET_KEY");
-        String ami_id = mapping.getAttributeValue(null, "AMI_ID");
-        String ins_id = mapping.getAttributeValue(null, "INS_ID");
-        String ins_type = mapping.getAttributeValue(null, "INS_TYPE");
-        this.username = mapping.getAttributeValue(null, "USERNAME");
+        ContextHeaderDocument document = null;
+        try {
+            document = ContextHeaderDocument.Factory.parse(omSecurityContextHeader.toStringWithConsume());
+        } catch (XMLStreamException e) {
+            e.printStackTrace();
+        } catch (XmlException e) {
+            e.printStackTrace();
+        }
+        SecurityContextDocument.SecurityContext.AmazonWebservices amazonWebservices =
+                document.getContextHeader().getSecurityContext().getAmazonWebservices();
+
+        String access_key = amazonWebservices.getAccessKeyId();
+        String secret_key = amazonWebservices.getSecretAccessKey();
+        String ami_id = amazonWebservices.getAmiId();
+        String ins_id = amazonWebservices.getInstanceId();
+        String ins_type = amazonWebservices.getInstanceType();
+        this.username = amazonWebservices.getUsername();
 
         log.info("ACCESS_KEY:" + access_key);
         log.info("SECRET_KEY:" + secret_key);

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java?rev=1204290&r1=1204289&r2=1204290&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
(original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
Sun Nov 20 22:28:05 2011
@@ -21,26 +21,33 @@
 
 package org.apache.airavata.core.gfac.scheduler.impl;
 
-import java.net.UnknownHostException;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.core.gfac.context.invocation.InvocationContext;
 import org.apache.airavata.core.gfac.context.invocation.impl.DefaultExecutionDescription;
+import org.apache.airavata.core.gfac.exception.ProviderException;
 import org.apache.airavata.core.gfac.exception.SchedulerException;
 import org.apache.airavata.core.gfac.provider.Provider;
+import org.apache.airavata.core.gfac.provider.impl.EC2Provider;
 import org.apache.airavata.core.gfac.provider.impl.GramProvider;
 import org.apache.airavata.core.gfac.provider.impl.LocalProvider;
 import org.apache.airavata.core.gfac.scheduler.Scheduler;
 import org.apache.airavata.core.gfac.utils.GfacUtils;
 import org.apache.airavata.registry.api.Registry;
 import org.apache.airavata.registry.api.exception.RegistryException;
+import org.apache.airavata.schemas.wec.ContextHeaderDocument;
+import org.apache.airavata.schemas.wec.SecurityContextDocument;
+import org.apache.axiom.om.OMElement;
+import org.apache.xmlbeans.XmlException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.xml.stream.XMLStreamException;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.Map;
+
 /**
  * This class selects {@link Provider} based on information in {@link Registry}
  */
@@ -100,6 +107,19 @@ public class SchedulerImpl implements Sc
         context.getExecutionDescription().setService(serviceDesc);
         context.getExecutionDescription().setApp(app);
 
+        OMElement omSecurityContextHeader = context.getExecutionContext().getSecurityContextHeader();
+
+        ContextHeaderDocument document = null;
+        try {
+            document = ContextHeaderDocument.Factory.parse(omSecurityContextHeader.toStringWithConsume());
+        } catch (XMLStreamException e) {
+            e.printStackTrace();
+        } catch (XmlException e) {
+            e.printStackTrace();
+        }
+        SecurityContextDocument.SecurityContext.AmazonWebservices amazonWebservices =
+                document.getContextHeader().getSecurityContext().getAmazonWebservices();
+
         /*
          * Determine provider
          */
@@ -107,6 +127,18 @@ public class SchedulerImpl implements Sc
         try {
             if (GfacUtils.isLocalHost(hostName)) {
                 return new LocalProvider();
+            } else if (amazonWebservices != null && hostName != null) {
+                log.info("host name: " + hostName);
+
+                // Amazon Provider
+                if (hostName.equalsIgnoreCase("AMAZON")){
+                    log.info("EC2 Provider Selected");
+                    try {
+                        return new EC2Provider(context);
+                    } catch (ProviderException e) {
+                        throw new SchedulerException("Unable to select the EC2Provider",
e);
+                    }
+                }
             } else {
                 return new GramProvider();
             }
@@ -114,6 +146,7 @@ public class SchedulerImpl implements Sc
             throw new SchedulerException("Cannot get IP for current host", e);
         }
 
+        return null;
     }
 
     private HostDescription scheduleToHost(Registry regService, String serviceName) {



Mime
View raw message