Merge branch 'master' of ssh://git.planet-lab.org/git/sfa
authorAndy Bavier <acb@cs.princeton.edu>
Wed, 6 Jul 2011 18:18:36 +0000 (14:18 -0400)
committerAndy Bavier <acb@cs.princeton.edu>
Wed, 6 Jul 2011 18:18:36 +0000 (14:18 -0400)
sfa/managers/aggregate_manager_eucalyptus.py
sfa/managers/eucalyptus/eucalyptus.rnc
sfa/managers/eucalyptus/eucalyptus.rng
sfa/managers/slice_manager_pl.py

index 1b6d143..c5d2ba3 100644 (file)
@@ -12,13 +12,16 @@ from lxml import etree as ET
 from sqlobject import *
 
 from sfa.util.faults import *
-from sfa.util.xrn import urn_to_hrn
+from sfa.util.xrn import urn_to_hrn, Xrn
 from sfa.util.rspec import RSpec
 from sfa.server.registry import Registries
 from sfa.trust.credential import Credential
 from sfa.plc.api import SfaAPI
 from sfa.util.plxrn import hrn_to_pl_slicename, slicename_to_hrn
 from sfa.util.callids import Callids
+from sfa.util.sfalogging import sfa_logger
+from sfa.rspecs.sfa_rspec import sfa_rspec_version
+from sfa.util.version import version_core
 
 ##
 # The data structure used to represent a cloud.
@@ -404,7 +407,8 @@ def ListResources(api, creds, options, call_id):
     # get hrn of the original caller
     origin_hrn = options.get('origin_hrn', None)
     if not origin_hrn:
-        origin_hrn = Credential(string=creds[0]).get_gid_caller().get_hrn()
+        origin_hrn = Credential(string=creds).get_gid_caller().get_hrn()
+        # origin_hrn = Credential(string=creds[0]).get_gid_caller().get_hrn()
 
     conn = getEucaConnection()
 
@@ -505,6 +509,11 @@ def CreateSliver(api, xrn, creds, xml, users, call_id):
     schemaXML = ET.parse(EUCALYPTUS_RSPEC_SCHEMA)
     rspecValidator = ET.RelaxNG(schemaXML)
     rspecXML = ET.XML(xml)
+    for network in rspecXML.iterfind("./network"):
+        if network.get('id') != cloud['name']:
+            # Throw away everything except my own RSpec
+            # sfa_logger().error("CreateSliver: deleting %s from rspec"%network.get('id'))
+            network.getparent().remove(network)
     if not rspecValidator(rspecXML):
         error = rspecValidator.error_log.last_error
         message = '%s (line %s)' % (error.message, error.line) 
@@ -521,7 +530,7 @@ def CreateSliver(api, xrn, creds, xml, users, call_id):
     pendingRmInst = []
     for sliceInst in s.instances:
         pendingRmInst.append(sliceInst.instance_id)
-    existingInstGroup = rspecXML.findall('.//euca_instances')
+    existingInstGroup = rspecXML.findall(".//euca_instances")
     for instGroup in existingInstGroup:
         for existingInst in instGroup:
             if existingInst.get('id') in pendingRmInst:
@@ -533,7 +542,7 @@ def CreateSliver(api, xrn, creds, xml, users, call_id):
     conn.terminate_instances(pendingRmInst)
 
     # Process new instance requests
-    requests = rspecXML.findall('.//request')
+    requests = rspecXML.findall(".//request")
     if requests:
         # Get all the public keys associate with slice.
         pubKeys = getKeysForSlice(s.slice_hrn)
@@ -567,6 +576,19 @@ def CreateSliver(api, xrn, creds, xml, users, call_id):
     # with enough data for the client to understand what's happened
     return xml
 
+def GetVersion(api):
+    xrn=Xrn(api.hrn)
+    request_rspec_versions = [dict(sfa_rspec_version)]
+    ad_rspec_versions = [dict(sfa_rspec_version)]
+    version_more = {'interface':'aggregate',
+                    'testbed':'myplc',
+                    'hrn':xrn.get_hrn(),
+                    'request_rspec_versions': request_rspec_versions,
+                    'ad_rspec_versions': ad_rspec_versions,
+                    'default_ad_rspec': dict(sfa_rspec_version)
+                    }
+    return version_core(version_more)
+
 def main():
     init_server()
 
index bc61ce3..670a01e 100644 (file)
@@ -1,5 +1,7 @@
 start = RSpec
 RSpec = element RSpec {
+    attribute expires { xsd:NMTOKEN },
+    attribute generated { xsd:NMTOKEN },
     attribute type { xsd:NMTOKEN },
     network
 }
index d7a85b4..d8be05e 100644 (file)
@@ -5,10 +5,18 @@
   </start>
   <define name="RSpec">
     <element name="RSpec">
+      <attribute name="expires">
+        <data type="NMTOKEN"/>
+      </attribute>
+      <attribute name="generated">
+        <data type="NMTOKEN"/>
+      </attribute>
       <attribute name="type">
         <data type="NMTOKEN"/>
       </attribute>
-      <ref name="network"/>
+      <oneOrMore>
+        <ref name="network"/>
+      </oneOrMore>
     </element>
   </define>
   <define name="network">
index 2cbc823..7ceecd1 100644 (file)
@@ -128,6 +128,11 @@ def ListResources(api, creds, options, call_id):
         # unless the caller is the aggregate's SM
         if caller_hrn == aggregate and aggregate != api.hrn:
             continue
+
+        # For GENICloud
+        if aggregate == api.hrn:
+            continue
+
         # get the rspec from the aggregate
         server = api.aggregates[aggregate]
         #threads.run(server.ListResources, credentials, my_opts, call_id)