split api and driver
Thierry Parmentelat [Tue, 1 Nov 2011 16:37:59 +0000 (17:37 +0100)]
PL driver can take PLCAPI calls and automagically adds auth

49 files changed:
sfa/generic/__init__.py
sfa/generic/pl.py
sfa/generic/plcm.py
sfa/managers/aggregate_manager.py
sfa/managers/aggregate_manager_eucalyptus.py
sfa/managers/aggregate_manager_max.py
sfa/managers/component_manager_pl.py
sfa/managers/registry_manager.py
sfa/managers/vini/utils.py
sfa/managers/vini/vini_network.py
sfa/methods/CreateGid.py
sfa/methods/CreateSliver.py
sfa/methods/DeleteSliver.py
sfa/methods/GetCredential.py
sfa/methods/GetGids.py
sfa/methods/GetSelfCredential.py
sfa/methods/GetTicket.py
sfa/methods/GetVersion.py
sfa/methods/List.py
sfa/methods/ListResources.py
sfa/methods/ListSlices.py
sfa/methods/RedeemTicket.py
sfa/methods/Register.py
sfa/methods/Remove.py
sfa/methods/RemovePeerObject.py
sfa/methods/RenewSliver.py
sfa/methods/Resolve.py
sfa/methods/SliverStatus.py
sfa/methods/Start.py
sfa/methods/Stop.py
sfa/methods/Update.py
sfa/methods/get_key.py
sfa/methods/remove_peer_object.py
sfa/methods/reset_slice.py
sfa/plc/aggregate.py
sfa/plc/network.py
sfa/plc/peers.py
sfa/plc/plccomponentapi.py
sfa/plc/plcdriver.py [moved from sfa/plc/plcsfaapi.py with 82% similarity]
sfa/plc/plcshell.py [new file with mode: 0644]
sfa/plc/slices.py
sfa/rspecs/elements/element.py
sfa/server/modpython/SfaAggregateModPython.py
sfa/server/modpython/SfaRegistryModPython.py
sfa/server/modpython/SfaSliceMgrModPython.py
sfa/server/sfa-clean-peer-records.py
sfa/server/sfa-start.py
sfa/server/sfa_component_setup.py
sfa/util/xml.py

index 843cd7b..a4e7bdf 100644 (file)
@@ -58,12 +58,18 @@ class Generic:
     def make_api (self, *args, **kwargs):
         # interface is a required arg
         if not 'interface' in kwargs:
-            logger.fatal("Generic.make_api: no interface found")
+            logger.critical("Generic.make_api: no interface found")
         api = self.api_class()(*args, **kwargs)
-        interface=kwargs['interface']
-        # or simpler, interface=api.interface
-        manager = self.make_manager(interface)
-        api.manager = ManagerWrapper(manager,interface)
+        manager = self.make_manager(api.interface)
+        driver = self.make_driver (api.config)
+        ### arrange stuff together
+        # add a manager wrapper
+        manager = ManagerWrapper(manager,api.interface)
+        api.manager=manager
+        # insert driver in manager
+        manager.driver=driver
+        # add it in api as well for convenience
+        api.driver=driver
         return api
 
     def make_manager (self, interface):
@@ -80,25 +86,18 @@ class Generic:
             logger.info("%s : %s"%(message,module))
             return module
         except:
-            logger.log_exc(message)
-            logger.fatal("Aborting")
+            logger.log_exc_critical(message)
+        
+    def make_driver (self, config):
+        flavour = self.flavour
+        message="Generic.make_driver for flavour=%s"%(flavour)
+        
+        classname = "driver_class"
+        try:
+            class_obj = getattr(self,classname)()
+            logger.info("%s : %s"%(message,class_obj))
+            return class_obj(config)
+        except:
+            logger.log_exc_critical(message)
         
-# former logic was
-#        basepath = 'sfa.managers'
-#        qualified = "%s.%s_manager_%s"%(basepath,interface,flavour)
-#        generic = "%s.%s_manager"%(basepath,interface)
-#
-#        try: 
-#            manager = __import__(qualified, fromlist=[basepath])
-#            logger.info ("%s: loaded %s"%(message,qualified))
-#        except:
-#            try:
-#                manager = __import__ (generic, fromlist=[basepath])
-#                if flavour != 'pl' : 
-#                    logger.warn ("%s: using generic with flavour!='pl'"%(message))
-#                logger.info("%s: loaded %s"%(message,generic))
-#            except:
-#                logger.log_exc("%s: unable to import either %s or %s"%(message,qualified,generic))
-#                logger.fatal("Aborted")
-#        return manager
         
index 853053d..6a6cc36 100644 (file)
@@ -1,5 +1,7 @@
 from sfa.generic import Generic
-import sfa.plc.plcsfaapi
+
+import sfa.server.sfaapi
+import sfa.plc.plcdriver
 import sfa.managers.registry_manager
 import sfa.managers.slice_manager
 import sfa.managers.aggregate_manager
@@ -7,7 +9,7 @@ import sfa.managers.aggregate_manager
 class pl (Generic):
     
     def api_class (self):
-        return sfa.plc.plcsfaapi.PlcSfaApi
+        return sfa.server.sfaapi.SfaApi
 
     def registry_class (self) : 
         return sfa.managers.registry_manager
@@ -16,4 +18,6 @@ class pl (Generic):
     def aggregate_class (self) :
         return sfa.managers.aggregate_manager
 
+    def driver_class (self):
+        return sfa.plc.plcdriver.PlcDriver
 
index dd24d3c..fe31609 100644 (file)
@@ -1,11 +1,13 @@
 from sfa.generic.pl import pl
+
+import sfa.server.sfaapi
 import sfa.plc.plccomponentapi
 import sfa.managers.component_manager_pl
 
 class plcm (pl):
 
-    def api_class (self):
-        return sfa.plc.plccomponentapi.PlcComponentApi
-
     def component_class (self):
         return sfa.managers.component_manager_pl
+
+    def driver_class (self):
+        return 'xxx todo : transform plccomponentapi into plcnodedriver'
index 702fe7d..d57958b 100644 (file)
@@ -14,8 +14,9 @@ from sfa.trust.credential import Credential
 from sfa.rspecs.version_manager import VersionManager
 from sfa.rspecs.rspec import RSpec
 
+from sfa.server.sfaapi import SfaApi
+
 import sfa.plc.peers as peers
-from sfa.plc.plcsfaapi import PlcSfaApi
 from sfa.plc.aggregate import Aggregate
 from sfa.plc.slices import Slices
 
@@ -112,13 +113,13 @@ def SliverStatus(api, slice_xrn, creds, call_id):
     # find out where this slice is currently running
     slicename = hrn_to_pl_slicename(hrn)
     
-    slices = api.plshell.GetSlices(api.plauth, [slicename], ['slice_id', 'node_ids','person_ids','name','expires'])
+    slices = api.driver.GetSlices([slicename], ['slice_id', 'node_ids','person_ids','name','expires'])
     if len(slices) == 0:        
         raise Exception("Slice %s not found (used %s as slicename internally)" % (slice_xrn, slicename))
     slice = slices[0]
     
     # report about the local nodes only
-    nodes = api.plshell.GetNodes(api.plauth, {'node_id':slice['node_ids'],'peer_id':None},
+    nodes = api.driver.GetNodes({'node_id':slice['node_ids'],'peer_id':None},
                                  ['node_id', 'hostname', 'site_id', 'boot_state', 'last_contact'])
     site_ids = [node['site_id'] for node in nodes]
 
@@ -203,14 +204,14 @@ def RenewSliver(api, xrn, creds, expiration_time, call_id):
     if Callids().already_handled(call_id): return True
     (hrn, _) = urn_to_hrn(xrn)
     slicename = hrn_to_pl_slicename(hrn)
-    slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
+    slices = api.driver.GetSlices({'name': slicename}, ['slice_id'])
     if not slices:
         raise RecordNotFound(hrn)
     slice = slices[0]
     requested_time = utcparse(expiration_time)
     record = {'expires': int(time.mktime(requested_time.timetuple()))}
     try:
-        api.plshell.UpdateSlice(api.plauth, slice['slice_id'], record)
+        api.driver.UpdateSlice(slice['slice_id'], record)
         return True
     except:
         return False
@@ -218,30 +219,30 @@ def RenewSliver(api, xrn, creds, expiration_time, call_id):
 def start_slice(api, xrn, creds):
     (hrn, _) = urn_to_hrn(xrn)
     slicename = hrn_to_pl_slicename(hrn)
-    slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
+    slices = api.driver.GetSlices({'name': slicename}, ['slice_id'])
     if not slices:
         raise RecordNotFound(hrn)
     slice_id = slices[0]['slice_id']
-    slice_tags = api.plshell.GetSliceTags(api.plauth, {'slice_id': slice_id, 'tagname': 'enabled'}, ['slice_tag_id'])
+    slice_tags = api.driver.GetSliceTags({'slice_id': slice_id, 'tagname': 'enabled'}, ['slice_tag_id'])
     # just remove the tag if it exists
     if slice_tags:
-        api.plshell.DeleteSliceTag(api.plauth, slice_tags[0]['slice_tag_id'])
+        api.driver.DeleteSliceTag(slice_tags[0]['slice_tag_id'])
 
     return 1
  
 def stop_slice(api, xrn, creds):
     hrn, _ = urn_to_hrn(xrn)
     slicename = hrn_to_pl_slicename(hrn)
-    slices = api.plshell.GetSlices(api.plauth, {'name': slicename}, ['slice_id'])
+    slices = api.driver.GetSlices({'name': slicename}, ['slice_id'])
     if not slices:
         raise RecordNotFound(hrn)
     slice_id = slices[0]['slice_id']
-    slice_tags = api.plshell.GetSliceTags(api.plauth, {'slice_id': slice_id, 'tagname': 'enabled'})
+    slice_tags = api.driver.GetSliceTags({'slice_id': slice_id, 'tagname': 'enabled'})
     if not slice_tags:
-        api.plshell.AddSliceTag(api.plauth, slice_id, 'enabled', '0')
+        api.driver.AddSliceTag(slice_id, 'enabled', '0')
     elif slice_tags[0]['value'] != "0":
         tag_id = slice_tags[0]['slice_tag_id']
-        api.plshell.UpdateSliceTag(api.plauth, tag_id, '0')
+        api.driver.UpdateSliceTag(tag_id, '0')
     return 1
 
 def reset_slice(api, xrn):
@@ -252,7 +253,7 @@ def DeleteSliver(api, xrn, creds, call_id):
     if Callids().already_handled(call_id): return ""
     (hrn, _) = urn_to_hrn(xrn)
     slicename = hrn_to_pl_slicename(hrn)
-    slices = api.plshell.GetSlices(api.plauth, {'name': slicename})
+    slices = api.driver.GetSlices({'name': slicename})
     if not slices:
         return 1
     slice = slices[0]
@@ -261,11 +262,11 @@ def DeleteSliver(api, xrn, creds, call_id):
     peer = peers.get_peer(api, hrn)
     try:
         if peer:
-            api.plshell.UnBindObjectFromPeer(api.plauth, 'slice', slice['slice_id'], peer)
-        api.plshell.DeleteSliceFromNodes(api.plauth, slicename, slice['node_ids'])
+            api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer)
+        api.driver.DeleteSliceFromNodes(slicename, slice['node_ids'])
     finally:
         if peer:
-            api.plshell.BindObjectToPeer(api.plauth, 'slice', slice['slice_id'], peer, slice['peer_slice_id'])
+            api.driver.BindObjectToPeer('slice', slice['slice_id'], peer, slice['peer_slice_id'])
     return 1
 
 # xxx Thierry : caching at the aggregate level sounds wrong...
@@ -280,7 +281,7 @@ def ListSlices(api, creds, call_id):
             return slices
 
     # get data from db 
-    slices = api.plshell.GetSlices(api.plauth, {'peer_id': None}, ['name'])
+    slices = api.driver.GetSlices({'peer_id': None}, ['name'])
     slice_hrns = [slicename_to_hrn(api.hrn, slice['name']) for slice in slices]
     slice_urns = [hrn_to_urn(slice_hrn, 'slice') for slice_hrn in slice_hrns]
 
@@ -393,20 +394,20 @@ def get_ticket(api, xrn, creds, rspec, users):
 
 
 
-def main():
-    """
-    rspec = ListResources(api, "plc.princeton.sapan", None, 'pl_test_sapan')
-    #rspec = ListResources(api, "plc.princeton.coblitz", None, 'pl_test_coblitz')
-    #rspec = ListResources(api, "plc.pl.sirius", None, 'pl_test_sirius')
-    print rspec
-    """
-    api = PlcSfaApi()
-    f = open(sys.argv[1])
-    xml = f.read()
-    f.close()
-#Error (E1120, main): No value passed for parameter 'users' in function call
-#Error (E1120, main): No value passed for parameter 'call_id' in function call
-    CreateSliver(api, "plc.princeton.sapan", xml, 'CreateSliver_sapan')
-
-if __name__ == "__main__":
-    main()
+#def main():
+#    """
+#    rspec = ListResources(api, "plc.princeton.sapan", None, 'pl_test_sapan')
+#    #rspec = ListResources(api, "plc.princeton.coblitz", None, 'pl_test_coblitz')
+#    #rspec = ListResources(api, "plc.pl.sirius", None, 'pl_test_sirius')
+#    print rspec
+#    """
+#    api = PlcSfaApi()
+#    f = open(sys.argv[1])
+#    xml = f.read()
+#    f.close()
+##Error (E1120, main): No value passed for parameter 'users' in function call
+##Error (E1120, main): No value passed for parameter 'call_id' in function call
+#    CreateSliver(api, "plc.princeton.sapan", xml, 'CreateSliver_sapan')
+#
+#if __name__ == "__main__":
+#    main()
index 6c68118..3f04ce9 100644 (file)
@@ -4,6 +4,8 @@ import sys
 import os, errno
 import logging
 import datetime
+from multiprocessing import Process
+from time import sleep
 
 import boto
 from boto.ec2.regioninfo import RegionInfo
@@ -15,19 +17,19 @@ from sqlobject import *
 
 from sfa.util.faults import *
 from sfa.util.xrn import urn_to_hrn, Xrn
-from sfa.server.registry import Registries
-from sfa.trust.credential import Credential
-from sfa.plc.plcsfaapi import PlcSfaApi
-from sfa.plc.aggregate import Aggregate
-from sfa.plc.slices import *
 from sfa.util.plxrn import hrn_to_pl_slicename, slicename_to_hrn
 from sfa.util.callids import Callids
 from sfa.util.sfalogging import logger
-from sfa.rspecs.sfa_rspec import sfa_rspec_version
 from sfa.util.version import version_core
 
-from multiprocessing import Process
-from time import sleep
+from sfa.trust.credential import Credential
+
+from sfa.server.sfaapi import SfaApi
+
+from sfa.plc.aggregate import Aggregate
+from sfa.plc.slices import *
+from sfa.rspecs.sfa_rspec import sfa_rspec_version
+
 
 ##
 # The data structure used to represent a cloud.
@@ -41,8 +43,6 @@ cloud = {}
 #
 EUCALYPTUS_RSPEC_SCHEMA='/etc/sfa/eucalyptus.rng'
 
-api = PlcSfaApi()
-
 ##
 # Meta data of an instance.
 #
@@ -722,22 +722,22 @@ def GetVersion(api):
                     }
     return version_core(version_more)
 
-def main():
-    init_server()
-
-    #theRSpec = None
-    #with open(sys.argv[1]) as xml:
-    #    theRSpec = xml.read()
-    #CreateSliver(None, 'planetcloud.pc.test', theRSpec, 'call-id-cloudtest')
-
-    #rspec = ListResources('euca', 'planetcloud.pc.test', 'planetcloud.pc.marcoy', 'test_euca')
-    #print rspec
-
-    server_key_file = '/var/lib/sfa/authorities/server.key'
-    server_cert_file = '/var/lib/sfa/authorities/server.cert'
-    api = PlcSfaApi(key_file = server_key_file, cert_file = server_cert_file, interface='aggregate')
-    print getKeysForSlice(api, 'gc.gc.test1')
-
-if __name__ == "__main__":
-    main()
+#def main():
+#    init_server()
+#
+#    #theRSpec = None
+#    #with open(sys.argv[1]) as xml:
+#    #    theRSpec = xml.read()
+#    #CreateSliver(None, 'planetcloud.pc.test', theRSpec, 'call-id-cloudtest')
+#
+#    #rspec = ListResources('euca', 'planetcloud.pc.test', 'planetcloud.pc.marcoy', 'test_euca')
+#    #print rspec
+#
+#    server_key_file = '/var/lib/sfa/authorities/server.key'
+#    server_cert_file = '/var/lib/sfa/authorities/server.cert'
+#    api = PlcSfaApi(key_file = server_key_file, cert_file = server_cert_file, interface='aggregate')
+#    print getKeysForSlice(api, 'gc.gc.test1')
+#
+#if __name__ == "__main__":
+#    main()
 
index ff6ea73..315f543 100644 (file)
@@ -1,20 +1,26 @@
-from sfa.plc.slices import Slices\r
-from sfa.server.registry import Registries\r
-from sfa.util.xrn import urn_to_hrn, hrn_to_urn, get_authority, Xrn\r
-from sfa.util.plxrn import hrn_to_pl_slicename\r
-from sfa.util.sfalogging import logger\r
+import os\r
+import time\r
+import re\r
+\r
 from sfa.util.faults import *\r
+from sfa.util.sfalogging import logger\r
 from sfa.util.config import Config\r
 from sfa.util.sfatime import utcparse\r
 from sfa.util.callids import Callids\r
 from sfa.util.version import version_core\r
+from sfa.util.xrn import urn_to_hrn, hrn_to_urn, get_authority, Xrn\r
+from sfa.util.plxrn import hrn_to_pl_slicename\r
+\r
+from sfa.server.sfaapi import SfaApi\r
+from sfa.server.registry import Registries\r
 from sfa.rspecs.rspec_version import RSpecVersion\r
 from sfa.rspecs.sfa_rspec import sfa_rspec_version\r
 from sfa.rspecs.rspec_parser import parse_rspec\r
-from sfa.managers.aggregate_manager_pl import __get_registry_objects, ListSlices\r
-import os\r
-import time\r
-import re\r
+\r
+from sfa.managers.aggregate_manager import __get_registry_objects, ListSlices\r
+\r
+from sfa.plc.slices import Slices\r
+\r
 \r
 RSPEC_TMP_FILE_PREFIX = "/tmp/max_rspec"\r
 \r
@@ -251,14 +257,14 @@ def ListResources(api, creds, options,call_id):
     slice_urn = options.get('geni_slice_urn')\r
     return get_rspec(api, creds, slice_urn)\r
 \r
-"""\r
-Returns the request context required by sfatables. At some point, this mechanism should be changed\r
-to refer to "contexts", which is the information that sfatables is requesting. But for now, we just\r
-return the basic information needed in a dict.\r
-"""\r
 def fetch_context(slice_hrn, user_hrn, contexts):\r
+    """\r
+    Returns the request context required by sfatables. At some point, this mechanism should be changed\r
+    to refer to "contexts", which is the information that sfatables is requesting. But for now, we just\r
+    return the basic information needed in a dict.\r
+    """\r
     base_context = {'sfa':{'user':{'hrn':user_hrn}}}\r
     return base_context\r
-    api = PlcSfaApi()\r
+    api = SfaApi()\r
     create_slice(api, "plc.maxpl.test000", None, rspec_xml, None)\r
 \r
index 8aca53c..d8e64dc 100644 (file)
@@ -29,7 +29,7 @@ def SliverStatus(api, slice_xrn, creds):
            
 def start_slice(api, xrn, creds):
     slicename = PlXrn(xrn, type='slice').pl_slicename()
-    api.nodemanger.Start(slicename)
+    api.nodemanager.Start(slicename)
 
 def stop_slice(api, xrn, creds):
     slicename = PlXrn(xrn, type='slice').pl_slicename()
index 085bc39..903a8b8 100644 (file)
@@ -46,7 +46,7 @@ def get_credential(api, xrn, type, is_self=False):
 
     # verify_cancreate_credential requires that the member lists
     # (researchers, pis, etc) be filled in
-    api.fill_record_info(record)
+    api.driver.fill_record_info(record, api.aggregates)
     if record['type']=='user':
        if not record['enabled']:
           raise AccountNotEnabled(": PlanetLab account %s is not enabled. Please contact your site PI" %(record['email']))
@@ -131,7 +131,7 @@ def resolve(api, xrns, type=None, full=True):
     table = SfaTable()
     local_records = table.findObjects({'hrn': remaining_hrns})
     if full:
-        api.fill_record_info(local_records)
+        api.driver.fill_record_info(local_records, api.aggregates)
     
     # convert local record objects to dicts
     records.extend([dict(record) for record in local_records])
@@ -234,10 +234,10 @@ def register(api, record):
         # get the GID from the newly created authority
         gid = auth_info.get_gid_object()
         record.set_gid(gid.save_to_string(save_parents=True))
-        pl_record = api.sfa_fields_to_pl_fields(type, hrn, record)
-        sites = api.plshell.GetSites(api.plauth, [pl_record['login_base']])
+        pl_record = api.driver.sfa_fields_to_pl_fields(type, hrn, record)
+        sites = api.driver.GetSites([pl_record['login_base']])
         if not sites:
-            pointer = api.plshell.AddSite(api.plauth, pl_record)
+            pointer = api.driver.AddSite(pl_record)
         else:
             pointer = sites[0]['site_id']
 
@@ -246,45 +246,45 @@ def register(api, record):
 
     elif (type == "slice"):
         acceptable_fields=['url', 'instantiation', 'name', 'description']
-        pl_record = api.sfa_fields_to_pl_fields(type, hrn, record)
+        pl_record = api.driver.sfa_fields_to_pl_fields(type, hrn, record)
         for key in pl_record.keys():
             if key not in acceptable_fields:
                 pl_record.pop(key)
-        slices = api.plshell.GetSlices(api.plauth, [pl_record['name']])
+        slices = api.driver.GetSlices([pl_record['name']])
         if not slices:
-             pointer = api.plshell.AddSlice(api.plauth, pl_record)
+             pointer = api.driver.AddSlice(pl_record)
         else:
              pointer = slices[0]['slice_id']
         record.set_pointer(pointer)
         record['pointer'] = pointer
 
     elif  (type == "user"):
-        persons = api.plshell.GetPersons(api.plauth, [record['email']])
+        persons = api.driver.GetPersons([record['email']])
         if not persons:
-            pointer = api.plshell.AddPerson(api.plauth, dict(record))
+            pointer = api.driver.AddPerson(dict(record))
         else:
             pointer = persons[0]['person_id']
 
         if 'enabled' in record and record['enabled']:
-            api.plshell.UpdatePerson(api.plauth, pointer, {'enabled': record['enabled']})
+            api.driver.UpdatePerson(pointer, {'enabled': record['enabled']})
         # add this persons to the site only if he is being added for the first
         # time by sfa and doesont already exist in plc
         if not persons or not persons[0]['site_ids']:
             login_base = get_leaf(record['authority'])
-            api.plshell.AddPersonToSite(api.plauth, pointer, login_base)
+            api.driver.AddPersonToSite(pointer, login_base)
 
         # What roles should this user have?
-        api.plshell.AddRoleToPerson(api.plauth, 'user', pointer)
+        api.driver.AddRoleToPerson('user', pointer)
         # Add the user's key
         if pub_key:
-            api.plshell.AddPersonKey(api.plauth, pointer, {'key_type' : 'ssh', 'key' : pub_key})
+            api.driver.AddPersonKey(pointer, {'key_type' : 'ssh', 'key' : pub_key})
 
     elif (type == "node"):
-        pl_record = api.sfa_fields_to_pl_fields(type, hrn, record)
+        pl_record = api.driver.sfa_fields_to_pl_fields(type, hrn, record)
         login_base = hrn_to_pl_login_base(record['authority'])
-        nodes = api.plshell.GetNodes(api.plauth, [pl_record['hostname']])
+        nodes = api.driver.GetNodes([pl_record['hostname']])
         if not nodes:
-            pointer = api.plshell.AddNode(api.plauth, login_base, pl_record)
+            pointer = api.driver.AddNode(login_base, pl_record)
         else:
             pointer = nodes[0]['node_id']
 
@@ -294,7 +294,7 @@ def register(api, record):
     record['record_id'] = record_id
 
     # update membership for researchers, pis, owners, operators
-    api.update_membership(None, record)
+    api.driver.update_membership(None, record)
 
     return record.get_gid_object().save_to_string(save_parents=True)
 
@@ -313,7 +313,7 @@ def update(api, record_dict):
 
     # Update_membership needs the membership lists in the existing record
     # filled in, so it can see if members were added or removed
-    api.fill_record_info(record)
+    api.driver.fill_record_info(record, api.aggregates)
 
     # Use the pointer from the existing record, not the one that the user
     # gave us. This prevents the user from inserting a forged pointer
@@ -321,13 +321,13 @@ def update(api, record_dict):
     # update the PLC information that was specified with the record
 
     if (type == "authority"):
-        api.plshell.UpdateSite(api.plauth, pointer, new_record)
+        api.driver.UpdateSite(pointer, new_record)
 
     elif type == "slice":
-        pl_record=api.sfa_fields_to_pl_fields(type, hrn, new_record)
+        pl_record=api.driver.sfa_fields_to_pl_fields(type, hrn, new_record)
         if 'name' in pl_record:
             pl_record.pop('name')
-            api.plshell.UpdateSlice(api.plauth, pointer, pl_record)
+            api.driver.UpdateSlice(pointer, pl_record)
 
     elif type == "user":
         # SMBAKER: UpdatePerson only allows a limited set of fields to be
@@ -340,14 +340,14 @@ def update(api, record_dict):
                        'password', 'phone', 'url', 'bio', 'accepted_aup',
                        'enabled']:
                 update_fields[key] = all_fields[key]
-        api.plshell.UpdatePerson(api.plauth, pointer, update_fields)
+        api.driver.UpdatePerson(pointer, update_fields)
 
         if 'key' in new_record and new_record['key']:
             # must check this key against the previous one if it exists
-            persons = api.plshell.GetPersons(api.plauth, [pointer], ['key_ids'])
+            persons = api.driver.GetPersons([pointer], ['key_ids'])
             person = persons[0]
             keys = person['key_ids']
-            keys = api.plshell.GetKeys(api.plauth, person['key_ids'])
+            keys = api.driver.GetKeys(person['key_ids'])
             key_exists = False
             if isinstance(new_record['key'], types.ListType):
                 new_key = new_record['key'][0]
@@ -357,11 +357,11 @@ def update(api, record_dict):
             # Delete all stale keys
             for key in keys:
                 if new_record['key'] != key['key']:
-                    api.plshell.DeleteKey(api.plauth, key['key_id'])
+                    api.driver.DeleteKey(key['key_id'])
                 else:
                     key_exists = True
             if not key_exists:
-                api.plshell.AddPersonKey(api.plauth, pointer, {'key_type': 'ssh', 'key': new_key})
+                api.driver.AddPersonKey(pointer, {'key_type': 'ssh', 'key': new_key})
 
             # update the openssl key and gid
             pkey = convert_public_key(new_key)
@@ -373,13 +373,13 @@ def update(api, record_dict):
             table.update(record)
 
     elif type == "node":
-        api.plshell.UpdateNode(api.plauth, pointer, new_record)
+        api.driver.UpdateNode(pointer, new_record)
 
     else:
         raise UnknownSfaType(type)
 
     # update membership for researchers, pis, owners, operators
-    api.update_membership(record, new_record)
+    api.driver.update_membership(record, new_record)
     
     return 1 
 
@@ -411,20 +411,20 @@ def remove(api, xrn, origin_hrn=None):
                 except:
                     pass
     if type == "user":
-        persons = api.plshell.GetPersons(api.plauth, record['pointer'])
+        persons = api.driver.GetPersons(record['pointer'])
         # only delete this person if he has site ids. if he doesnt, it probably means
         # he was just removed from a site, not actually deleted
         if persons and persons[0]['site_ids']:
-            api.plshell.DeletePerson(api.plauth, record['pointer'])
+            api.driver.DeletePerson(record['pointer'])
     elif type == "slice":
-        if api.plshell.GetSlices(api.plauth, record['pointer']):
-            api.plshell.DeleteSlice(api.plauth, record['pointer'])
+        if api.driver.GetSlices(record['pointer']):
+            api.driver.DeleteSlice(record['pointer'])
     elif type == "node":
-        if api.plshell.GetNodes(api.plauth, record['pointer']):
-            api.plshell.DeleteNode(api.plauth, record['pointer'])
+        if api.driver.GetNodes(record['pointer']):
+            api.driver.DeleteNode(record['pointer'])
     elif type == "authority":
-        if api.plshell.GetSites(api.plauth, record['pointer']):
-            api.plshell.DeleteSite(api.plauth, record['pointer'])
+        if api.driver.GetSites(record['pointer']):
+            api.driver.DeleteSite(record['pointer'])
     else:
         raise UnknownSfaType(type)
 
index b0d7e51..a718c03 100644 (file)
@@ -367,12 +367,11 @@ class Slicetag:
     def write(self, api):
         if self.changed:
             if int(self.id) > 0:
-                api.plshell.UpdateSliceTag(api.plauth, self.id, self.value)
+                api.driver.UpdateSliceTag(self.id, self.value)
             else:
-                api.plshell.AddSliceTag(api.plauth, self.slice_id, 
-                                        self.tagname, self.value, self.node_id)
+                api.driver.AddSliceTag(self.slice_id, self.tagname, self.value, self.node_id)
         elif self.deleted and int(self.id) > 0:
-            api.plshell.DeleteSliceTag(api.plauth, self.id)
+            api.driver.DeleteSliceTag(self.id)
 
 
 """
@@ -662,7 +661,7 @@ Create a dictionary of site objects keyed by site ID
 """
 def get_sites(api):
     tmp = []
-    for site in api.plshell.GetSites(api.plauth):
+    for site in api.driver.GetSites():
         t = site['site_id'], Site(site)
         tmp.append(t)
     return dict(tmp)
@@ -673,7 +672,7 @@ Create a dictionary of node objects keyed by node ID
 """
 def get_nodes(api):
     tmp = []
-    for node in api.plshell.GetNodes(api.plauth):
+    for node in api.driver.GetNodes():
         t = node['node_id'], Node(node)
         tmp.append(t)
     return dict(tmp)
@@ -682,7 +681,7 @@ def get_nodes(api):
 Create a dictionary of slice objects keyed by slice ID
 """
 def get_slice(api, slicename):
-    slice = api.plshell.GetSlices(api.plauth, [slicename])
+    slice = api.driver.GetSlices([slicename])
     if slice:
         return Slice(slice[0])
     else:
@@ -693,7 +692,7 @@ Create a dictionary of slicetag objects keyed by slice tag ID
 """
 def get_slice_tags(api):
     tmp = []
-    for tag in api.plshell.GetSliceTags(api.plauth):
+    for tag in api.driver.GetSliceTags():
         t = tag['slice_tag_id'], Slicetag(tag)
         tmp.append(t)
     return dict(tmp)
index fcade6c..ba1ce2a 100644 (file)
@@ -437,7 +437,7 @@ class ViniNetwork(Network):
     """
     def get_sites(self, api):
         tmp = []
-        for site in api.plshell.GetSites(api.plauth, {'peer_id': None}):
+        for site in api.driver.GetSites({'peer_id': None}):
             t = site['site_id'], ViniSite(self, site)
             tmp.append(t)
         return dict(tmp)
@@ -448,7 +448,7 @@ class ViniNetwork(Network):
     """
     def get_nodes(self, api):
         tmp = []
-        for node in api.plshell.GetNodes(api.plauth, {'peer_id': None}):
+        for node in api.driver.GetNodes({'peer_id': None}):
             t = node['node_id'], ViniNode(self, node)
             tmp.append(t)
         return dict(tmp)
@@ -458,7 +458,7 @@ class ViniNetwork(Network):
     """
     def get_slice(self, api, hrn):
         slicename = hrn_to_pl_slicename(hrn)
-        slice = api.plshell.GetSlices(api.plauth, [slicename])
+        slice = api.driver.GetSlices([slicename])
         if slice:
             self.slice = ViniSlice(self, slicename, slice[0])
             return self.slice
index b25fbd1..74ce9de 100644 (file)
@@ -43,6 +43,4 @@ class CreateGid(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, xrn, self.name))
 
-        manager = self.api.get_interface_manager()
-
-        return manager.create_gid(self.api, xrn, cert)
+        return self.api.manager.create_gid(self.api, xrn, cert)
index dcb25eb..d5a507e 100644 (file)
@@ -42,8 +42,6 @@ class CreateSliver(Method):
             msg = "'users' musst be specified and cannot be null. You may need to update your client." 
             raise SfaInvalidArgument(name='users', extra=msg)  
 
-        manager = self.api.get_interface_manager()
-        
         # flter rspec through sfatables
         if self.api.interface in ['aggregate']:
             chain_name = 'INCOMING'
@@ -52,4 +50,4 @@ class CreateSliver(Method):
         self.api.logger.debug("CreateSliver: sfatables on chain %s"%chain_name)
         rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec)
 
-        return manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, call_id)
+        return self.api.manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, call_id)
index f766cb1..58b8846 100644 (file)
@@ -32,7 +32,6 @@ class DeleteSliver(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
 
-        manager = self.api.get_interface_manager() 
-        manager.DeleteSliver(self.api, xrn, creds, call_id)
+        self.api.manager.DeleteSliver(self.api, xrn, creds, call_id)
  
         return 1 
index da3e97b..b645cd4 100644 (file)
@@ -42,7 +42,5 @@ class GetCredential(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))        
 
-        manager = self.api.get_interface_manager()
-        
-        return manager.get_credential(self.api, xrn, type)
+        return self.api.manager.get_credential(self.api, xrn, type)
 
index e50f940..601db6f 100644 (file)
@@ -31,8 +31,7 @@ class GetGids(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         
         # resolve the record
-        manager = self.api.get_interface_manager()
-        records = manager.resolve(self.api, xrns, full = False)
+        records = self.api.manager.resolve(self.api, xrns, full = False)
         if not records:
             raise RecordNotFound(xrns)
 
index de21ab5..37f2e7b 100644 (file)
@@ -52,10 +52,9 @@ class GetSelfCredential(Method):
         origin_hrn = Certificate(string=cert).get_subject()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
         
-        manager = self.api.get_interface_manager()
  
         # authenticate the gid
-        records = manager.resolve(self.api, xrn, type)
+        records = self.api.manager.resolve(self.api, xrn, type)
         if not records:
             raise RecordNotFound(hrn)
         record = SfaRecord(dict=records[0])
@@ -72,4 +71,4 @@ class GetSelfCredential(Method):
                     self.api.logger.debug("ConnectionKeyGIDMismatch, %s filename: %s"%(name,obj.filename))
             raise ConnectionKeyGIDMismatch(gid.get_subject())
         
-        return manager.get_credential(self.api, xrn, type, is_self=True)
+        return self.api.manager.get_credential(self.api, xrn, type, is_self=True)
index 1469693..c21ce16 100644 (file)
@@ -43,8 +43,6 @@ class GetTicket(Method):
         #log the call
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
 
-        manager = self.api.get_interface_manager()
-
         # filter rspec through sfatables
         if self.api.interface in ['aggregate']:
             chain_name = 'OUTGOING'
@@ -53,7 +51,5 @@ class GetTicket(Method):
         rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec)
         
         # remove nodes that are not available at this interface from the rspec
-        ticket = manager.get_ticket(self.api, xrn, creds, rspec, users)
-        
-        return ticket
+        return self.api.manager.get_ticket(self.api, xrn, creds, rspec, users)
         
index 72fe806..8c215c4 100644 (file)
@@ -13,5 +13,4 @@ class GetVersion(Method):
 
     def call(self):
         self.api.logger.info("interface: %s\tmethod-name: %s" % (self.api.interface, self.name))
-        manager = self.api.get_interface_manager()
-        return manager.GetVersion(self.api)
+        return self.api.manager.GetVersion(self.api)
index a5d1123..ccd66b4 100644 (file)
@@ -31,5 +31,4 @@ class List(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
        
-        manager = self.api.get_interface_manager()
-        return manager.list(self.api, xrn) 
+        return self.api.manager.list(self.api, xrn) 
index b8d7e2d..a12447f 100644 (file)
@@ -36,9 +36,7 @@ class ListResources(Method):
         origin_hrn = options.get('origin_hrn', None)
         if not origin_hrn:
             origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
-        # get manager for this interface    
-        manager = self.api.get_interface_manager()
-        rspec = manager.ListResources(self.api, creds, options, call_id)
+        rspec = self.api.manager.ListResources(self.api, creds, options, call_id)
 
         # filter rspec through sfatables 
         if self.api.interface in ['aggregate']:
index 7fc8513..e8521c1 100644 (file)
@@ -27,6 +27,5 @@ class ListSlices(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, self.name))
 
-        manager = self.api.get_interface_manager() 
-        return manager.ListSlices(self.api, creds, call_id)
+        return self.api.manager.ListSlices(self.api, creds, call_id)
  
index cab0e93..c6a75e2 100644 (file)
@@ -23,8 +23,6 @@ class RedeemTicket(Method):
         valid_creds = self.api.auth.checkCredentials(cred, 'redeemticket')
         self.api.auth.check_ticket(ticket)
 
-        
         # send the call to the right manager
-        manager = self.api.get_interface_manager()
-        manager.redeem_ticket(self.api, ticket) 
+        self.api.manager.redeem_ticket(self.api, ticket) 
         return 1 
index 619ed00..92f230a 100644 (file)
@@ -36,6 +36,4 @@ class Register(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
         
-        manager = self.api.get_interface_manager()
-
-        return manager.register(self.api, record)
+        return self.api.manager.register(self.api, record)
index c547c26..98ef38b 100644 (file)
@@ -39,6 +39,4 @@ class Remove(Method):
         self.api.logger.info("interface: %s\tmethod-name: %s\tcaller-hrn: %s\ttarget-urn: %s"%(
                 self.api.interface, self.name, origin_hrn, xrn.get_urn()))
 
-        manager = self.api.get_interface_manager()
-
-        return manager.remove(self.api, xrn) 
+        return self.api.manager.remove(self.api, xrn) 
index fa30e88..c831924 100644 (file)
@@ -55,33 +55,33 @@ class RemovePeerObject(Method):
     def remove_plc_record(self, record):
         type = record['type']        
         if type == "user":
-            persons = self.api.plshell.GetPersons(self.api.plauth, {'person_id' : record['pointer']})
+            persons = self.api.driver.GetPersons({'person_id' : record['pointer']})
             if not persons:
                 return 1
             person = persons[0]
             if person['peer_id']:
                 peer = self.get_peer_name(person['peer_id']) 
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'person', person['person_id'], peer)
-            self.api.plshell.DeletePerson(self.api.plauth, person['person_id'])
+                self.api.driver.UnBindObjectFromPeer('person', person['person_id'], peer)
+            self.api.driver.DeletePerson(person['person_id'])
            
         elif type == "slice":
-            slices=self.api.plshell.GetSlices(self.api.plauth, {'slice_id' : record['pointer']})
+            slices=self.api.driver.GetSlices({'slice_id' : record['pointer']})
             if not slices:
                 return 1
             slice=slices[0]
             if slice['peer_id']:
                 peer = self.get_peer_name(slice['peer_id']) 
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer)
-            self.api.plshell.DeleteSlice(self.api.plauth, slice['slice_id'])
+                self.api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer)
+            self.api.driver.DeleteSlice(slice['slice_id'])
         elif type == "authority":
-            sites=self.api.plshell.GetSites(self.api.plauth, {'site_id' : record['pointer']})
+            sites=self.api.driver.GetSites({'site_id' : record['pointer']})
             if not sites:
                 return 1
             site=sites[0]
             if site['peer_id']:
                 peer = self.get_peer_name(site['peer_id']) 
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'site', site['site_id'], peer)
-            self.api.plshell.DeleteSite(self.api.plauth, site['site_id'])
+                self.api.driver.UnBindObjectFromPeer('site', site['site_id'], peer)
+            self.api.driver.DeleteSite(site['site_id'])
            
         else:
             raise UnknownSfaType(type)
@@ -89,7 +89,7 @@ class RemovePeerObject(Method):
         return 1
 
     def get_peer_name(self, peer_id):
-        peers = self.api.plshell.GetPeers(self.api.plauth, [peer_id], ['peername', 'shortname', 'hrn_root'])
+        peers = self.api.driver.GetPeers([peer_id], ['peername', 'shortname', 'hrn_root'])
         if not peers:
             raise SfaInvalidArgument, "No such peer"
         peer = peers[0]
index 4a0e836..b34d424 100644 (file)
@@ -40,6 +40,5 @@ class RenewSliver(Method):
             raise InsufficientRights('Renewsliver: Credential expires before requested expiration time')
         if requested_time > datetime.datetime.utcnow() + datetime.timedelta(days=max_renew_days):
             raise Exception('Cannot renew > %s days from now' % max_renew_days)
-        manager = self.api.get_interface_manager()
-        return manager.RenewSliver(self.api, slice_xrn, valid_creds, expiration_time, call_id)    
+        return self.api.manager.RenewSliver(self.api, slice_xrn, valid_creds, expiration_time, call_id)    
     
index 74972cc..6277e1b 100644 (file)
@@ -40,6 +40,5 @@ class Resolve(Method):
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrns, self.name))
  
         # send the call to the right manager
-        manager = self.api.get_interface_manager()
-        return manager.resolve(self.api, xrns, type)
+        return self.api.manager.resolve(self.api, xrns, type)
             
index 18613b2..2f4bc0c 100644 (file)
@@ -24,8 +24,7 @@ class SliverStatus(Method):
 
         self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
     
-        manager = self.api.get_interface_manager()
-        status = manager.SliverStatus(self.api, hrn, valid_creds, call_id)
+        status = self.api.manager.SliverStatus(self.api, hrn, valid_creds, call_id)
 
         return status
     
index 6882a37..7f8aefd 100644 (file)
@@ -30,7 +30,6 @@ class Start(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
 
-        manager = self.api.get_interface_manager() 
-        manager.start_slice(self.api, xrn, creds)
+        self.api.manager.start_slice(self.api, xrn, creds)
  
         return 1 
index e8d3397..48974ab 100644 (file)
@@ -30,7 +30,6 @@ class Stop(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
 
-        manager = self.api.get_interface_manager() 
-        manager.stop_slice(self.api, xrn, creds)
+        self.api.manager.stop_slice(self.api, xrn, creds)
  
         return 1 
index 31b17e9..a90a44e 100644 (file)
@@ -35,7 +35,5 @@ class Update(Method):
         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
        
-        manager = self.api.get_interface_manager()
-        return manager.update(self.api, record_dict)
+        return self.api.manager.update(self.api, record_dict)
 
index 4bb6587..638332e 100644 (file)
@@ -25,10 +25,10 @@ class get_key(Method):
         # verify that the callers's ip address exist in the db and is an inteface
         # for a node in the db
         (ip, port) = self.api.remote_addr
-        interfaces = self.api.plshell.GetInterfaces(self.api.plauth, {'ip': ip}, ['node_id'])
+        interfaces = self.api.driver.GetInterfaces({'ip': ip}, ['node_id'])
         if not interfaces:
             raise NonExistingRecord("no such ip %(ip)s" % locals())
-        nodes = self.api.plshell.GetNodes(self.api.plauth, [interfaces[0]['node_id']], ['node_id', 'hostname'])
+        nodes = self.api.driver.GetNodes([interfaces[0]['node_id']], ['node_id', 'hostname'])
         if not nodes:
             raise NonExistingRecord("no such node using ip %(ip)s" % locals())
         node = nodes[0]
index a510189..465ed05 100644 (file)
@@ -55,33 +55,33 @@ class remove_peer_object(Method):
     def remove_plc_record(self, record):
         type = record['type']        
         if type == "user":
-            persons = self.api.plshell.GetPersons(self.api.plauth, {'person_id' : record['pointer']})
+            persons = self.api.driver.GetPersons({'person_id' : record['pointer']})
             if not persons:
                 return 1
             person = persons[0]
             if person['peer_id']:
                 peer = self.get_peer_name(person['peer_id']) 
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'person', person['person_id'], peer)
-            self.api.plshell.DeletePerson(self.api.plauth, person['person_id'])
+                self.api.driver.UnBindObjectFromPeer('person', person['person_id'], peer)
+            self.api.driver.DeletePerson(person['person_id'])
            
         elif type == "slice":
-            slices=self.api.plshell.GetSlices(self.api.plauth, {'slice_id' : record['pointer']})
+            slices=self.api.driver.GetSlices({'slice_id' : record['pointer']})
             if not slices:
                 return 1
             slice=slices[0]
             if slice['peer_id']:
                 peer = self.get_peer_name(slice['peer_id']) 
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer)
-            self.api.plshell.DeleteSlice(self.api.plauth, slice['slice_id'])
+                self.api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer)
+            self.api.driver.DeleteSlice(slice['slice_id'])
         elif type == "authority":
-            sites=self.api.plshell.GetSites(self.api.plauth, {'site_id' : record['pointer']})
+            sites=self.api.driver.GetSites({'site_id' : record['pointer']})
             if not sites:
                 return 1
             site=sites[0]
             if site['peer_id']:
                 peer = self.get_peer_name(site['peer_id']) 
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'site', site['site_id'], peer)
-            self.api.plshell.DeleteSite(self.api.plauth, site['site_id'])
+                self.api.driver.UnBindObjectFromPeer('site', site['site_id'], peer)
+            self.api.driver.DeleteSite(site['site_id'])
            
         else:
             raise UnknownSfaType(type)
@@ -89,7 +89,7 @@ class remove_peer_object(Method):
         return 1
 
     def get_peer_name(self, peer_id):
-        peers = self.api.plshell.GetPeers(self.api.plauth, [peer_id], ['peername', 'shortname', 'hrn_root'])
+        peers = self.api.driver.GetPeers([peer_id], ['peername', 'shortname', 'hrn_root'])
         if not peers:
             raise SfaInvalidArgument, "No such peer"
         peer = peers[0]
index 15fb4a5..387981d 100644 (file)
@@ -25,22 +25,5 @@ class reset_slice(Method):
     def call(self, cred, xrn, origin_hrn=None):
         hrn, type = urn_to_hrn(xrn)
         self.api.auth.check(cred, 'resetslice', hrn)
-        # send the call to the right manager
-        manager_base = 'sfa.managers'
-        if self.api.interface in ['component']:
-            mgr_type = self.api.config.SFA_CM_TYPE
-            manager_module = manager_base + ".component_manager_%s" % mgr_type
-            manager = __import__(manager_module, fromlist=[manager_base])
-            manager.reset_slice(self.api, xrn)
-        elif self.api.interface in ['aggregate']:
-            mgr_type = self.api.config.SFA_AGGREGATE_TYPE
-            manager_module = manager_base + ".aggregate_manager_%s" % mgr_type
-            manager = __import__(manager_module, fromlist=[manager_base])
-            manager.reset_slice(self.api, xrn)
-        elif self.api.interface in ['slicemgr']:
-            mgr_type = self.api.config.SFA_SM_TYPE
-            manager_module = manager_base + ".slice_manager_%s" % mgr_type
-            manager = __import__(manager_module, fromlist=[manager_base])
-            manager.reset_slice(self.api, xrn) 
-
+        self.api.manager.reset_slice (self.api, xrn)
         return 1 
index 4cbeff7..c1dcd06 100644 (file)
@@ -29,13 +29,13 @@ class Aggregate:
 
     def prepare_sites(self, filter={}, force=False):
         if not self.sites or force:  
-            for site in self.api.plshell.GetSites(self.api.plauth, filter):
+            for site in self.api.driver.GetSites(filter):
                 self.sites[site['site_id']] = site
     
     def prepare_nodes(self, filter={}, force=False):
         if not self.nodes or force:
             filter.update({'peer_id': None})
-            nodes = self.api.plshell.GetNodes(self.api.plauth, filter)
+            nodes = self.api.driver.GetNodes(filter)
             site_ids = []
             interface_ids = []
             tag_ids = []
@@ -63,10 +63,12 @@ class Aggregate:
 
     def prepare_interfaces(self, filter={}, force=False):
         if not self.interfaces or force:
-            for interface in self.api.plshell.GetInterfaces(self.api.plauth, filter):
+            for interface in self.api.driver.GetInterfaces(filter):
                 self.interfaces[interface['interface_id']] = interface
 
     def prepare_links(self, filter={}, force=False):
+        # we're aobut to deprecate sfa_aggregate_type, need to get this right 
+        # with the generic framework
         if not self.links or force:
             if not self.api.config.SFA_AGGREGATE_TYPE.lower() == 'vini':
                 return
@@ -106,13 +108,13 @@ class Aggregate:
 
     def prepare_node_tags(self, filter={}, force=False):
         if not self.node_tags or force:
-            for node_tag in self.api.plshell.GetNodeTags(self.api.plauth, filter):
+            for node_tag in self.api.driver.GetNodeTags(filter):
                 self.node_tags[node_tag['node_tag_id']] = node_tag
 
     def prepare_pl_initscripts(self, filter={}, force=False):
         if not self.pl_initscripts or force:
             filter.update({'enabled': True})
-            for initscript in self.api.plshell.GetInitScripts(self.api.plauth, filter):
+            for initscript in self.api.driver.GetInitScripts(filter):
                 self.pl_initscripts[initscript['initscript_id']] = initscript
 
     def prepare(self, slice = None, force=False):
@@ -147,7 +149,7 @@ class Aggregate:
         if slice_xrn:
             slice_hrn, _ = urn_to_hrn(slice_xrn)
             slice_name = hrn_to_pl_slicename(slice_hrn)
-            slices = self.api.plshell.GetSlices(self.api.plauth, slice_name)
+            slices = self.api.driver.GetSlices(slice_name)
             if slices:
                 slice = slices[0]
             self.prepare(slice=slice)
@@ -175,7 +177,7 @@ class Aggregate:
         # add slivers
         if slice_xrn and slice:
             slivers = []
-            tags = self.api.plshell.GetSliceTags(self.api.plauth, slice['slice_tag_ids'])
+            tags = self.api.driver.GetSliceTags(slice['slice_tag_ids'])
 
             # add default tags
             for tag in tags:
index 5b2983b..e97565c 100644 (file)
@@ -282,12 +282,11 @@ class Slicetag:
     
     def write(self, api):
         if self.was_added():
-            api.plshell.AddSliceTag(api.plauth, self.slice_id, 
-                                    self.tagname, self.value, self.node_id)
+            api.driver.AddSliceTag(self.slice_id, self.tagname, self.value, self.node_id)
         elif self.was_changed():
-            api.plshell.UpdateSliceTag(api.plauth, self.id, self.value)
+            api.driver.UpdateSliceTag(self.id, self.value)
         elif self.was_deleted():
-            api.plshell.DeleteSliceTag(api.plauth, self.id)
+            api.driver.DeleteSliceTag(self.id)
 
 
 class TagType:
@@ -560,7 +559,7 @@ class Network:
         Create a dictionary of site objects keyed by site ID
         """
         tmp = []
-        for site in api.plshell.GetSites(api.plauth, {'peer_id': None}):
+        for site in api.driver.GetSites({'peer_id': None}):
             t = site['site_id'], Site(self, site)
             tmp.append(t)
         return dict(tmp)
@@ -571,7 +570,7 @@ class Network:
         Create a dictionary of node objects keyed by node ID
         """
         tmp = []
-        for node in api.plshell.GetNodes(api.plauth, {'peer_id': None}):
+        for node in api.driver.GetNodes({'peer_id': None}):
             try:
                 t = node['node_id'], Node(self, node)
                 tmp.append(t)
@@ -585,7 +584,7 @@ class Network:
         Create a dictionary of node objects keyed by node ID
         """
         tmp = []
-        for iface in api.plshell.GetInterfaces(api.plauth):
+        for iface in api.driver.GetInterfaces():
             t = iface['interface_id'], Iface(self, iface)
             tmp.append(t)
         return dict(tmp)
@@ -595,7 +594,7 @@ class Network:
         Create a dictionary of slicetag objects keyed by slice tag ID
         """
         tmp = []
-        for tag in api.plshell.GetSliceTags(api.plauth, {'~tagname':Slicetag.ignore_tags}, Slicetag.filter_fields): 
+        for tag in api.driver.GetSliceTags({'~tagname':Slicetag.ignore_tags}, Slicetag.filter_fields): 
             t = tag['slice_tag_id'], Slicetag(tag)
             tmp.append(t)
         return dict(tmp)
@@ -605,7 +604,7 @@ class Network:
         Create a list of tagtype obects keyed by tag name
         """
         tmp = []
-        for tag in api.plshell.GetTagTypes(api.plauth, {'~tagname':TagType.ignore_tags}):
+        for tag in api.driver.GetTagTypes({'~tagname':TagType.ignore_tags}):
             t = tag['tagname'], TagType(tag)
             tmp.append(t)
         return dict(tmp)
@@ -615,7 +614,7 @@ class Network:
         Return a Slice object for a single slice
         """
         slicename = hrn_to_pl_slicename(hrn)
-        slice = api.plshell.GetSlices(api.plauth, [slicename])
+        slice = api.driver.GetSlices([slicename])
         if len(slice):
             self.slice = Slice(self, slicename, slice[0])
             return self.slice
index e85800c..b659ea9 100644 (file)
@@ -13,8 +13,7 @@ def get_peer(api, hrn):
     # get this site's authority (sfa root authority or sub authority)
     site_authority = get_authority(slice_authority).lower()
     # check if we are already peered with this site_authority, if so
-    peers = api.plshell.GetPeers(api.plauth, {}, \
-                    ['peer_id', 'peername', 'shortname', 'hrn_root'])
+    peers = api.driver.GetPeers( {}, ['peer_id', 'peername', 'shortname', 'hrn_root'])
     for peer_record in peers:
         names = [name.lower() for name in peer_record.values() if isinstance(name, StringTypes)]
         if site_authority in names:
index d326482..ebd238d 100644 (file)
@@ -8,10 +8,8 @@ from sfa.trust.credential import Credential
 from sfa.trust.certificate import Certificate, Keypair
 from sfa.trust.gid import GID
 
-from sfa.server.sfaapi import SfaApi
-
 ####################
-class PlcComponentApi(SfaApi):
+class PlcComponentDriver:
     """
     This class is the type for the toplevel 'api' object 
     when running the component manager inside a planetlab node.
@@ -20,17 +18,8 @@ class PlcComponentApi(SfaApi):
     some tweaks as compared with a service running in the infrastructure.
     """
 
-    def __init__ (self, encoding="utf-8", methods='sfa.methods', 
-                  config = "/etc/sfa/sfa_config.py", 
-                  peer_cert = None, interface = None, 
-                  key_file = None, cert_file = None, cache = None):
-        SfaApi.__init__(self, encoding=encoding, methods=methods, 
-                        config=config, 
-                        peer_cert=peer_cert, interface=interface, 
-                        key_file=key_file, 
-                        cert_file=cert_file, cache=cache)
-
-        self.nodemanager = NodeManager(self.config)
+    def __init__ (self, config):
+        self.nodemanager = NodeManager(config)
 
     def sliver_exists(self):
         sliver_dict = self.nodemanager.GetXIDs()
@@ -43,6 +32,7 @@ class PlcComponentApi(SfaApi):
     def get_registry(self):
         addr, port = self.config.SFA_REGISTRY_HOST, self.config.SFA_REGISTRY_PORT
         url = "http://%(addr)s:%(port)s" % locals()
+        ### xxx this would require access to the api...
         server = xmlrpcprotocol.get_server(url, self.key_file, self.cert_file)
         return server
 
similarity index 82%
rename from sfa/plc/plcsfaapi.py
rename to sfa/plc/plcdriver.py
index 842df31..e920ce6 100644 (file)
@@ -1,4 +1,3 @@
-import xmlrpclib
 #
 from sfa.util.faults import MissingSfaInfo
 from sfa.util.sfalogging import logger
@@ -8,7 +7,7 @@ from sfa.util.defaultdict import defaultdict
 from sfa.util.xrn import hrn_to_urn
 from sfa.util.plxrn import slicename_to_hrn, hostname_to_hrn, hrn_to_pl_slicename, hrn_to_pl_login_base
 
-from sfa.server.sfaapi import SfaApi
+from sfa.plc.plcshell import PlcShell
 
 def list_to_dict(recs, key):
     """
@@ -18,45 +17,17 @@ def list_to_dict(recs, key):
     keys = [rec[key] for rec in recs]
     return dict(zip(keys, recs))
 
-class PlcSfaApi(SfaApi):
-
-    def __init__ (self, encoding="utf-8", methods='sfa.methods', 
-                  config = "/etc/sfa/sfa_config.py", 
-                  peer_cert = None, interface = None, 
-                  key_file = None, cert_file = None, cache = None):
-        SfaApi.__init__(self, encoding=encoding, methods=methods, 
-                        config=config, 
-                        peer_cert=peer_cert, interface=interface, 
-                        key_file=key_file, 
-                        cert_file=cert_file, cache=cache)
+class PlcDriver (PlcShell):
+
+    def __init__ (self, config):
+        PlcShell.__init__ (self, config)
  
+        self.hrn = config.SFA_INTERFACE_HRN
         self.SfaTable = SfaTable
         # Initialize the PLC shell only if SFA wraps a myPLC
-        rspec_type = self.config.get_aggregate_type()
-        if (rspec_type == 'pl' or rspec_type == 'vini' or \
-            rspec_type == 'eucalyptus' or rspec_type == 'max'):
-            self.plshell = self.getPLCShell()
-            self.plshell_version = "4.3"
-
-    def getPLCShell(self):
-        self.plauth = {'Username': self.config.SFA_PLC_USER,
-                       'AuthMethod': 'password',
-                       'AuthString': self.config.SFA_PLC_PASSWORD}
-
-        # The native shell (PLC.Shell.Shell) is more efficient than xmlrpc,
-        # but it leaves idle db connections open. use xmlrpc until we can figure
-        # out why PLC.Shell.Shell doesn't close db connection properly     
-        #try:
-        #    sys.path.append(os.path.dirname(os.path.realpath("/usr/bin/plcsh")))
-        #    self.plshell_type = 'direct'
-        #    import PLC.Shell
-        #    shell = PLC.Shell.Shell(globals = globals())
-        #except:
-        
-        self.plshell_type = 'xmlrpc' 
-        url = self.config.SFA_PLC_URL
-        shell = xmlrpclib.Server(url, verbose = 0, allow_none = True)
-        return shell
+        rspec_type = config.get_aggregate_type()
+        assert (rspec_type == 'pl' or rspec_type == 'vini' or \
+                    rspec_type == 'eucalyptus' or rspec_type == 'max')
 
     ##
     # Convert SFA fields to PLC fields for use when registering up updating
@@ -138,16 +109,16 @@ class PlcSfaApi(SfaApi):
         # get pl records
         nodes, sites, slices, persons, keys = {}, {}, {}, {}, {}
         if node_ids:
-            node_list = self.plshell.GetNodes(self.plauth, node_ids)
+            node_list = self.GetNodes(node_ids)
             nodes = list_to_dict(node_list, 'node_id')
         if site_ids:
-            site_list = self.plshell.GetSites(self.plauth, site_ids)
+            site_list = self.GetSites(site_ids)
             sites = list_to_dict(site_list, 'site_id')
         if slice_ids:
-            slice_list = self.plshell.GetSlices(self.plauth, slice_ids)
+            slice_list = self.GetSlices(slice_ids)
             slices = list_to_dict(slice_list, 'slice_id')
         if person_ids:
-            person_list = self.plshell.GetPersons(self.plauth, person_ids)
+            person_list = self.GetPersons(person_ids)
             persons = list_to_dict(person_list, 'person_id')
             for person in persons:
                 key_ids.extend(persons[person]['key_ids'])
@@ -156,7 +127,7 @@ class PlcSfaApi(SfaApi):
                       'slice': slices, 'user': persons}
 
         if key_ids:
-            key_list = self.plshell.GetKeys(self.plauth, key_ids)
+            key_list = self.GetKeys(key_ids)
             keys = list_to_dict(key_list, 'key_id')
 
         # fill record info
@@ -207,16 +178,16 @@ class PlcSfaApi(SfaApi):
         # get pl records
         slices, persons, sites, nodes = {}, {}, {}, {}
         if site_ids:
-            site_list = self.plshell.GetSites(self.plauth, site_ids, ['site_id', 'login_base'])
+            site_list = self.GetSites(site_ids, ['site_id', 'login_base'])
             sites = list_to_dict(site_list, 'site_id')
         if person_ids:
-            person_list = self.plshell.GetPersons(self.plauth, person_ids, ['person_id', 'email'])
+            person_list = self.GetPersons(person_ids, ['person_id', 'email'])
             persons = list_to_dict(person_list, 'person_id')
         if slice_ids:
-            slice_list = self.plshell.GetSlices(self.plauth, slice_ids, ['slice_id', 'name'])
+            slice_list = self.GetSlices(slice_ids, ['slice_id', 'name'])
             slices = list_to_dict(slice_list, 'slice_id')       
         if node_ids:
-            node_list = self.plshell.GetNodes(self.plauth, node_ids, ['node_id', 'hostname'])
+            node_list = self.GetNodes(node_ids, ['node_id', 'hostname'])
             nodes = list_to_dict(node_list, 'node_id')
        
         # convert ids to hrns
@@ -257,7 +228,8 @@ class PlcSfaApi(SfaApi):
             
         return records   
 
-    def fill_record_sfa_info(self, records):
+    # aggregates is basically api.aggregates
+    def fill_record_sfa_info(self, records, aggregates):
 
         def startswith(prefix, values):
             return [value for value in values if value.startswith(prefix)]
@@ -276,7 +248,7 @@ class PlcSfaApi(SfaApi):
         site_pis = {}
         if site_ids:
             pi_filter = {'|roles': ['pi'], '|site_ids': site_ids} 
-            pi_list = self.plshell.GetPersons(self.plauth, pi_filter, ['person_id', 'site_ids'])
+            pi_list = self.GetPersons(pi_filter, ['person_id', 'site_ids'])
             for pi in pi_list:
                 # we will need the pi's hrns also
                 person_ids.append(pi['person_id'])
@@ -306,7 +278,7 @@ class PlcSfaApi(SfaApi):
 
         # get the pl records
         pl_person_list, pl_persons = [], {}
-        pl_person_list = self.plshell.GetPersons(self.plauth, person_ids, ['person_id', 'roles'])
+        pl_person_list = self.GetPersons(person_ids, ['person_id', 'roles'])
         pl_persons = list_to_dict(pl_person_list, 'person_id')
 
         # fill sfa info
@@ -336,9 +308,9 @@ class PlcSfaApi(SfaApi):
                 
             elif (type.startswith("authority")):
                 record['url'] = None
-                if record['hrn'] in self.aggregates:
+                if record['hrn'] in aggregates:
                     
-                    record['url'] = self.aggregates[record['hrn']].get_url()
+                    record['url'] = aggregates[record['hrn']].get_url()
 
                 if record['pointer'] != -1:
                     record['PI'] = []
@@ -368,7 +340,7 @@ class PlcSfaApi(SfaApi):
                 # xxx TODO: PostalAddress, Phone
             record.update(sfa_info)
 
-    def fill_record_info(self, records):
+    def fill_record_info(self, records, aggregates):
         """
         Given a SFA record, fill in the PLC specific and SFA specific
         fields in the record. 
@@ -377,7 +349,7 @@ class PlcSfaApi(SfaApi):
             records = [records]
 
         self.fill_record_pl_info(records)
-        self.fill_record_sfa_info(records)
+        self.fill_record_sfa_info(records, aggregates)
 
     def update_membership_list(self, oldRecord, record, listName, addFunc, delFunc):
         # get a list of the HRNs that are members of the old and new records
@@ -412,18 +384,18 @@ class PlcSfaApi(SfaApi):
     # add people who are in the new list, but not the oldList
         for personId in newIdList:
             if not (personId in oldIdList):
-                addFunc(self.plauth, personId, containerId)
+                addFunc(personId, containerId)
 
         # remove people who are in the old list, but not the new list
         for personId in oldIdList:
             if not (personId in newIdList):
-                delFunc(self.plauth, personId, containerId)
+                delFunc(personId, containerId)
 
     def update_membership(self, oldRecord, record):
         if record.type == "slice":
             self.update_membership_list(oldRecord, record, 'researcher',
-                                        self.plshell.AddPersonToSlice,
-                                        self.plshell.DeletePersonFromSlice)
+                                        self.AddPersonToSlice,
+                                        self.DeletePersonFromSlice)
         elif record.type == "authority":
             # xxx TODO
             pass
diff --git a/sfa/plc/plcshell.py b/sfa/plc/plcshell.py
new file mode 100644 (file)
index 0000000..c686b1a
--- /dev/null
@@ -0,0 +1,46 @@
+import xmlrpclib
+
+class PlcShell:
+    """
+    A simple xmlrpc shell to a myplc instance
+    This class can receive all PLCAPI calls to the underlying testbed
+    For safety this is limited to a set of hard-coded calls
+    """
+    
+    direct_calls = ['AddNode', 'AddPerson', 'AddPersonKey', 'AddPersonToSite',
+                    'AddPersonToSlice', 'AddRoleToPerson', 'AddSite', 'AddSiteTag', 'AddSlice',
+                    'AddSliceTag', 'AddSliceToNodes', 'BindObjectToPeer', 'DeleteKey',
+                    'DeleteNode', 'DeletePerson', 'DeletePersonFromSlice', 'DeleteSite',
+                    'DeleteSlice', 'DeleteSliceFromNodes', 'DeleteSliceTag', 'GetInitScripts',
+                    'GetInterfaces', 'GetKeys', 'GetNodeTags', 'GetPeers',
+                    'GetPersons', 'GetSlices', 'GetSliceTags', 'GetTagTypes',
+                    'UnBindObjectFromPeer', 'UpdateNode', 'UpdatePerson', 'UpdateSite',
+                    'UpdateSlice', 'UpdateSliceTag',
+                    # also used as-is in importer
+                    'GetSites','GetNodes',
+                    ]
+    # support for other names - this is experimental
+    alias_calls = { 'get_authorities':'GetSites',
+                    'get_nodes':'GetNodes',
+                    }
+
+    def __init__ ( self, config ) :
+        self.plauth = {'Username': config.SFA_PLC_USER,
+                       'AuthMethod': 'password',
+                       'AuthString': config.SFA_PLC_PASSWORD}
+        
+        self.url = config.SFA_PLC_URL
+        self.plauth = {'Username': 'root@test.onelab.eu',
+                       'AuthMethod': 'password',
+                       'AuthString': 'test++'}
+        self.proxy_server = xmlrpclib.Server(self.url, verbose = 0, allow_none = True)
+
+    def __getattr__(self, name):
+        def func(*args, **kwds):
+            actual_name=None
+            if name in PlcShell.direct_calls: actual_name=name
+            if name in PlcShell.alias_calls: actual_name=PlcShell.alias_calls[name]
+            if not actual_name:
+                raise Exception, "Illegal method call %s for PL driver"%(name)
+            return getattr(self.proxy_server, actual_name)(self.plauth, *args, **kwds)
+        return func
index 5cead3b..fcef25e 100644 (file)
@@ -30,11 +30,11 @@ class Slices:
         slice_name = hrn_to_pl_slicename(hrn)
         # XX Should we just call PLCAPI.GetSliceTicket(slice_name) instead
         # of doing all of this?
-        #return self.api.GetSliceTicket(self.auth, slice_name) 
+        #return self.api.driver.GetSliceTicket(self.auth, slice_name) 
         
         # from PLCAPI.GetSlivers.get_slivers()
         slice_fields = ['slice_id', 'name', 'instantiation', 'expires', 'person_ids', 'slice_tag_ids']
-        slices = self.api.plshell.GetSlices(self.api.plauth, slice_name, slice_fields)
+        slices = self.api.driver.GetSlices(slice_name, slice_fields)
         # Build up list of users and slice attributes
         person_ids = set()
         all_slice_tag_ids = set()
@@ -44,7 +44,7 @@ class Slices:
         person_ids = list(person_ids)
         all_slice_tag_ids = list(all_slice_tag_ids)
         # Get user information
-        all_persons_list = self.api.plshell.GetPersons(self.api.plauth, {'person_id':person_ids,'enabled':True}, ['person_id', 'enabled', 'key_ids'])
+        all_persons_list = self.api.driver.GetPersons({'person_id':person_ids,'enabled':True}, ['person_id', 'enabled', 'key_ids'])
         all_persons = {}
         for person in all_persons_list:
             all_persons[person['person_id']] = person        
@@ -55,12 +55,12 @@ class Slices:
             key_ids.update(person['key_ids'])
         key_ids = list(key_ids)
         # Get user account keys
-        all_keys_list = self.api.plshell.GetKeys(self.api.plauth, key_ids, ['key_id', 'key', 'key_type'])
+        all_keys_list = self.api.driver.GetKeys(key_ids, ['key_id', 'key', 'key_type'])
         all_keys = {}
         for key in all_keys_list:
             all_keys[key['key_id']] = key
         # Get slice attributes
-        all_slice_tags_list = self.api.plshell.GetSliceTags(self.api.plauth, all_slice_tag_ids)
+        all_slice_tags_list = self.api.driver.GetSliceTags(all_slice_tag_ids)
         all_slice_tags = {}
         for slice_tag in all_slice_tags_list:
             all_slice_tags[slice_tag['slice_tag_id']] = slice_tag
@@ -143,7 +143,7 @@ class Slices:
         site_authority = get_authority(slice_authority).lower()
 
         # check if we are already peered with this site_authority, if so
-        peers = self.api.plshell.GetPeers(self.api.plauth, {}, ['peer_id', 'peername', 'shortname', 'hrn_root'])
+        peers = self.api.driver.GetPeers({}, ['peer_id', 'peername', 'shortname', 'hrn_root'])
         for peer_record in peers:
             names = [name.lower() for name in peer_record.values() if isinstance(name, StringTypes)]
             if site_authority in names:
@@ -166,7 +166,7 @@ class Slices:
 
     def verify_slice_nodes(self, slice, requested_slivers, peer):
         
-        nodes = self.api.plshell.GetNodes(self.api.plauth, slice['node_ids'], ['hostname'])
+        nodes = self.api.driver.GetNodes(slice['node_ids'], ['hostname'])
         current_slivers = [node['hostname'] for node in nodes]
 
         # remove nodes not in rspec
@@ -177,9 +177,9 @@ class Slices:
 
         try:
             if peer:
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer['shortname'])
-            self.api.plshell.AddSliceToNodes(self.api.plauth, slice['name'], added_nodes)
-            self.api.plshell.DeleteSliceFromNodes(self.api.plauth, slice['name'], deleted_nodes)
+                self.api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname'])
+            self.api.driver.AddSliceToNodes(slice['name'], added_nodes)
+            self.api.driver.DeleteSliceFromNodes(slice['name'], deleted_nodes)
 
         except: 
             self.api.logger.log_exc('Failed to add/remove slice from nodes')
@@ -198,7 +198,7 @@ class Slices:
             if1 = aggregate.interfaces[node['interface_ids'][0]]
             ipaddr = if1['ip']
             topo_rspec = VLink.get_topo_rspec(link, ipaddr)
-            self.api.plshell.AddSliceTag(self.api.plauth, slice['name'], 'topo_rspec', str([topo_rspec]), node_id) 
+            self.api.driver.AddSliceTag(slice['name'], 'topo_rspec', str([topo_rspec]), node_id) 
                         
         
 
@@ -207,36 +207,33 @@ class Slices:
             # bind site
             try:
                 if site:
-                    self.api.plshell.BindObjectToPeer(self.api.plauth, 'site', \
-                       site['site_id'], peer['shortname'], slice['site_id'])
+                    self.api.driver.BindObjectToPeer('site', site['site_id'], peer['shortname'], slice['site_id'])
             except Exception,e:
-                self.api.plshell.DeleteSite(self.api.plauth, site['site_id'])
+                self.api.driver.DeleteSite(site['site_id'])
                 raise e
             
             # bind slice
             try:
                 if slice:
-                    self.api.plshell.BindObjectToPeer(self.api.plauth, 'slice', \
-                       slice['slice_id'], peer['shortname'], slice['slice_id'])
+                    self.api.driver.BindObjectToPeer('slice', slice['slice_id'], peer['shortname'], slice['slice_id'])
             except Exception,e:
-                self.api.plshell.DeleteSlice(self.api.plauth, slice['slice_id'])
+                self.api.driver.DeleteSlice(slice['slice_id'])
                 raise e 
 
             # bind persons
             for person in persons:
                 try:
-                    self.api.plshell.BindObjectToPeer(self.api.plauth, 'person', \
-                        person['person_id'], peer['shortname'], person['peer_person_id'])
+                    self.api.driver.BindObjectToPeer('person', 
+                                                     person['person_id'], peer['shortname'], person['peer_person_id'])
 
                     for (key, remote_key_id) in zip(person['keys'], person['key_ids']):
                         try:
-                            self.api.plshell.BindObjectToPeer(self.api.plauth, 'key',\
-                                key['key_id'], peer['shortname'], remote_key_id)
+                            self.api.driver.BindObjectToPeer( 'key', key['key_id'], peer['shortname'], remote_key_id)
                         except:
-                            self.api.plshell.DeleteKey(self.api.plauth, key['key_id'])
+                            self.api.driver.DeleteKey(key['key_id'])
                             self.api.logger("failed to bind key: %s to peer: %s " % (key['key_id'], peer['shortname']))
                 except Exception,e:
-                    self.api.plshell.DeletePerson(self.api.plauth, person['person_id'])
+                    self.api.driver.DeletePerson(person['person_id'])
                     raise e       
 
         return slice
@@ -248,7 +245,7 @@ class Slices:
         slicename = hrn_to_pl_slicename(slice_hrn)
         authority_name = slicename.split('_')[0]
         login_base = authority_name[:20]
-        sites = self.api.plshell.GetSites(self.api.plauth, login_base)
+        sites = self.api.driver.GetSites(login_base)
         if not sites:
             # create new site record
             site = {'name': 'geni.%s' % authority_name,
@@ -260,9 +257,9 @@ class Slices:
                     'peer_site_id': None}
             if peer:
                 site['peer_site_id'] = slice_record.get('site_id', None)
-            site['site_id'] = self.api.plshell.AddSite(self.api.plauth, site)
+            site['site_id'] = self.api.driver.AddSite(site)
             # exempt federated sites from monitor policies
-            self.api.plshell.AddSiteTag(self.api.plauth, site['site_id'], 'exempt_site_until', "20200101")
+            self.api.driver.AddSiteTag(site['site_id'], 'exempt_site_until', "20200101")
             
             # is this still necessary?
             # add record to the local registry 
@@ -274,7 +271,7 @@ class Slices:
             site =  sites[0]
             if peer:
                 # unbind from peer so we can modify if necessary. Will bind back later
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'site', site['site_id'], peer['shortname']) 
+                self.api.driver.UnBindObjectFromPeer('site', site['site_id'], peer['shortname']) 
         
         return site        
 
@@ -282,13 +279,13 @@ class Slices:
         slicename = hrn_to_pl_slicename(slice_hrn)
         parts = slicename.split("_")
         login_base = parts[0]
-        slices = self.api.plshell.GetSlices(self.api.plauth, [slicename]) 
+        slices = self.api.driver.GetSlices([slicename]) 
         if not slices:
             slice = {'name': slicename,
                      'url': slice_record.get('url', slice_hrn), 
                      'description': slice_record.get('description', slice_hrn)}
             # add the slice                          
-            slice['slice_id'] = self.api.plshell.AddSlice(self.api.plauth, slice)
+            slice['slice_id'] = self.api.driver.AddSlice(slice)
             slice['node_ids'] = []
             slice['person_ids'] = []
             if peer:
@@ -303,12 +300,10 @@ class Slices:
             if peer:
                 slice['peer_slice_id'] = slice_record.get('slice_id', None)
                 # unbind from peer so we can modify if necessary. Will bind back later
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice',\
-                             slice['slice_id'], peer['shortname'])
+                self.api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname'])
                #Update existing record (e.g. expires field) it with the latest info.
             if slice_record and slice['expires'] != slice_record['expires']:
-                self.api.plshell.UpdateSlice(self.api.plauth, slice['slice_id'],\
-                             {'expires' : slice_record['expires']})
+                self.api.driver.UpdateSlice( slice['slice_id'], {'expires' : slice_record['expires']})
        
         return slice
 
@@ -334,13 +329,13 @@ class Slices:
         existing_user_ids = []
         if users_by_email:
             # get existing users by email 
-            existing_users = self.api.plshell.GetPersons(self.api.plauth, \
-                {'email': users_by_email.keys()}, ['person_id', 'key_ids', 'email'])
+            existing_users = self.api.driver.GetPersons({'email': users_by_email.keys()}, 
+                                                        ['person_id', 'key_ids', 'email'])
             existing_user_ids.extend([user['email'] for user in existing_users])
 
         if users_by_site:
             # get a list of user sites (based on requeste user urns
-            site_list = self.api.plshell.GetSites(self.api.plauth, users_by_site.keys(), \
+            site_list = self.api.driver.GetSites(users_by_site.keys(), \
                 ['site_id', 'login_base', 'person_ids'])
             sites = {}
             site_user_ids = []
@@ -350,8 +345,8 @@ class Slices:
                 sites[site['site_id']] = site
                 site_user_ids.extend(site['person_ids'])
 
-            existing_site_persons_list = self.api.plshell.GetPersons(self.api.plauth, \
-              site_user_ids,  ['person_id', 'key_ids', 'email', 'site_ids'])
+            existing_site_persons_list = self.api.driver.GetPersons(site_user_ids,  
+                                                                    ['person_id', 'key_ids', 'email', 'site_ids'])
 
             # all requested users are either existing users or new (added) users      
             for login_base in users_by_site:
@@ -379,8 +374,8 @@ class Slices:
         requested_user_ids = users_dict.keys()
         # existing slice users
         existing_slice_users_filter = {'person_id': slice_record.get('person_ids', [])}
-        existing_slice_users = self.api.plshell.GetPersons(self.api.plauth, \
-             existing_slice_users_filter, ['person_id', 'key_ids', 'email'])
+        existing_slice_users = self.api.driver.GetPersons(existing_slice_users_filter,
+                                                          ['person_id', 'key_ids', 'email'])
         existing_slice_user_ids = [user['email'] for user in existing_slice_users]
         
         # users to be added, removed or updated
@@ -392,7 +387,7 @@ class Slices:
         # Remove stale users (only if we are not appending).
         if append == False:
             for removed_user_id in removed_user_ids:
-                self.api.plshell.DeletePersonFromSlice(self.api.plauth, removed_user_id, slice_record['name'])
+                self.api.driver.DeletePersonFromSlice(removed_user_id, slice_record['name'])
         # update_existing users
         updated_users_list = [user for user in existing_slice_users if user['email'] in \
           updated_user_ids]
@@ -411,20 +406,20 @@ class Slices:
                 'keys': [],
                 'key_ids': added_user.get('key_ids', []),
             }
-            person['person_id'] = self.api.plshell.AddPerson(self.api.plauth, person)
+            person['person_id'] = self.api.driver.AddPerson(person)
             if peer:
                 person['peer_person_id'] = added_user['person_id']
             added_persons.append(person)
            
             # enable the account 
-            self.api.plshell.UpdatePerson(self.api.plauth, person['person_id'], {'enabled': True})
+            self.api.driver.UpdatePerson(person['person_id'], {'enabled': True})
             
             # add person to site
-            self.api.plshell.AddPersonToSite(self.api.plauth, added_user_id, login_base)
+            self.api.driver.AddPersonToSite(added_user_id, login_base)
 
             for key_string in added_user.get('keys', []):
                 key = {'key':key_string, 'key_type':'ssh'}
-                key['key_id'] = self.api.plshell.AddPersonKey(self.api.plauth, person['person_id'], key)
+                key['key_id'] = self.api.driver.AddPersonKey(person['person_id'], key)
                 person['keys'].append(key)
 
             # add the registry record
@@ -435,7 +430,7 @@ class Slices:
     
         for added_slice_user_id in added_slice_user_ids.union(added_user_ids):
             # add person to the slice 
-            self.api.plshell.AddPersonToSlice(self.api.plauth, added_slice_user_id, slice_record['name'])
+            self.api.driver.AddPersonToSlice(added_slice_user_id, slice_record['name'])
             # if this is a peer record then it should already be bound to a peer.
             # no need to return worry about it getting bound later 
 
@@ -447,7 +442,7 @@ class Slices:
         key_ids = []
         for person in persons:
             key_ids.extend(person['key_ids'])
-        keylist = self.api.plshell.GetKeys(self.api.plauth, key_ids, ['key_id', 'key'])
+        keylist = self.api.driver.GetKeys(key_ids, ['key_id', 'key'])
         keydict = {}
         for key in keylist:
             keydict[key['key']] = key['key_id']     
@@ -469,16 +464,16 @@ class Slices:
                     try:
                         if peer:
                             person = persondict[user['email']]
-                            self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'person', person['person_id'], peer['shortname'])
-                        key['key_id'] = self.api.plshell.AddPersonKey(self.api.plauth, user['email'], key)
+                            self.api.driver.UnBindObjectFromPeer('person', person['person_id'], peer['shortname'])
+                        key['key_id'] = self.api.driver.AddPersonKey(user['email'], key)
                         if peer:
                             key_index = user_keys.index(key['key'])
                             remote_key_id = user['key_ids'][key_index]
-                            self.api.plshell.BindObjectToPeer(self.api.plauth, 'key', key['key_id'], peer['shortname'], remote_key_id)
+                            self.api.driver.BindObjectToPeer('key', key['key_id'], peer['shortname'], remote_key_id)
                             
                     finally:
                         if peer:
-                            self.api.plshell.BindObjectToPeer(self.api.plauth, 'person', person['person_id'], peer['shortname'], user['person_id'])
+                            self.api.driver.BindObjectToPeer('person', person['person_id'], peer['shortname'], user['person_id'])
         
         # remove old keys (only if we are not appending)
         if append == False: 
@@ -487,21 +482,21 @@ class Slices:
                 if keydict[existing_key_id] in removed_keys:
                     try:
                         if peer:
-                            self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'key', existing_key_id, peer['shortname'])
-                        self.api.plshell.DeleteKey(self.api.plauth, existing_key_id)
+                            self.api.driver.UnBindObjectFromPeer('key', existing_key_id, peer['shortname'])
+                        self.api.driver.DeleteKey(existing_key_id)
                     except:
                         pass   
 
     def verify_slice_attributes(self, slice, requested_slice_attributes):
         # get list of attributes users ar able to manage
-        slice_attributes = self.api.plshell.GetTagTypes(self.api.plauth, {'category': '*slice*', '|roles': ['user']})
+        slice_attributes = self.api.driver.GetTagTypes({'category': '*slice*', '|roles': ['user']})
         valid_slice_attribute_names = [attribute['tagname'] for attribute in slice_attributes]
 
         # get sliver attributes
         added_slice_attributes = []
         removed_slice_attributes = []
         ignored_slice_attribute_names = []
-        existing_slice_attributes = self.api.plshell.GetSliceTags(self.api.plauth, {'slice_id': slice['slice_id']})
+        existing_slice_attributes = self.api.driver.GetSliceTags({'slice_id': slice['slice_id']})
 
         # get attributes that should be removed
         for slice_tag in existing_slice_attributes:
@@ -539,7 +534,7 @@ class Slices:
         # remove stale attributes
         for attribute in removed_slice_attributes:
             try:
-                self.api.plshell.DeleteSliceTag(self.api.plauth, attribute['slice_tag_id'])
+                self.api.driver.DeleteSliceTag(attribute['slice_tag_id'])
             except Exception, e:
                 self.api.logger.warn('Failed to remove sliver attribute. name: %s, value: %s, node_id: %s\nCause:%s'\
                                 % (name, value,  node_id, str(e)))
@@ -547,7 +542,7 @@ class Slices:
         # add requested_attributes
         for attribute in added_slice_attributes:
             try:
-                self.api.plshell.AddSliceTag(self.api.plauth, slice['name'], attribute['name'], attribute['value'], attribute.get('node_id', None))
+                self.api.driver.AddSliceTag(slice['name'], attribute['name'], attribute['value'], attribute.get('node_id', None))
             except Exception, e:
                 self.api.logger.warn('Failed to add sliver attribute. name: %s, value: %s, node_id: %s\nCause:%s'\
                                 % (name, value,  node_id, str(e)))
@@ -570,7 +565,7 @@ class Slices:
         slice = self.verify_slice(registry, credential, hrn, site_id, remote_site_id, peer, sfa_peer)
 
         # find out where this slice is currently running
-        nodelist = self.api.plshell.GetNodes(self.api.plauth, slice['node_ids'], ['hostname'])
+        nodelist = self.api.driver.GetNodes(slice['node_ids'], ['hostname'])
         hostnames = [node['hostname'] for node in nodelist]
 
         # get netspec details
@@ -610,9 +605,9 @@ class Slices:
 
         try:
             if peer:
-                self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer)
+                self.api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer)
 
-            self.api.plshell.AddSliceToNodes(self.api.plauth, slicename, added_nodes) 
+            self.api.driver.AddSliceToNodes(slicename, added_nodes) 
 
             # Add recognized slice tags
             for node_name in node_names:
@@ -622,12 +617,12 @@ class Slices:
                     if (isinstance(value, list)):
                         value = value[0]
 
-                    self.api.plshell.AddSliceTag(self.api.plauth, slicename, slice_tag, value, node_name)
+                    self.api.driver.AddSliceTag(slicename, slice_tag, value, node_name)
 
-            self.api.plshell.DeleteSliceFromNodes(self.api.plauth, slicename, deleted_nodes)
+            self.api.driver.DeleteSliceFromNodes(slicename, deleted_nodes)
         finally:
             if peer:
-                self.api.plshell.BindObjectToPeer(self.api.plauth, 'slice', slice['slice_id'], peer, slice['peer_slice_id'])
+                self.api.driver.BindObjectToPeer('slice', slice['slice_id'], peer, slice['peer_slice_id'])
 
         return 1
 
index 8217c11..401ca31 100644 (file)
@@ -10,7 +10,7 @@ class Element:
 
     def add_element(self, name, attrs={}, parent=None, text=""):
         """
-        Generic wrapper around etree.SubElement(). Adds an element to
+        Wrapper around etree.SubElement(). Adds an element to
         specified parent node. Adds element to root node is parent is
         not specified.
         """
index 8638ce9..515b083 100755 (executable)
@@ -12,10 +12,10 @@ import traceback
 import xmlrpclib
 from mod_python import apache
 
-from sfa.plc.plcsfaapi import PlcSfaApi
 from sfa.util.sfalogging import logger
+from sfa.plc.server import SfaApi
 
-api = PlcSfaApi(interface='aggregate')
+api = SfaApi(interface='aggregate')
 
 def handler(req):
     try:
index 115fcba..1be5480 100755 (executable)
@@ -12,10 +12,10 @@ import traceback
 import xmlrpclib
 from mod_python import apache
 
-from sfa.plc.plcsfaapi import PlcSfaApi
 from sfa.util.sfalogging import logger
+from sfa.plc.server import SfaApi
 
-api = PlcSfaApi(interface='registry')
+api = SfaApi(interface='registry')
 
 def handler(req):
     try:
index 3de4519..cd655a7 100755 (executable)
@@ -12,10 +12,10 @@ import traceback
 import xmlrpclib
 from mod_python import apache
 
-from sfa.plc.plcsfaapi import PlcSfaApi
 from sfa.util.sfalogging import logger
+from sfa.plc.server import SfaApi
 
-api = PlcSfaApi(interface='slicemgr')
+api = SfaApi(interface='slicemgr')
 
 def handler(req):
     try:
index 93fef14..178ae6e 100644 (file)
@@ -3,15 +3,18 @@
 import sys
 import os
 import traceback
+import socket
+
+import sfa.util.xmlrpcprotocol as xmlrpcprotocol 
 from sfa.util.table import SfaTable
 from sfa.util.prefixTree import prefixTree
-from sfa.plc.plcsfaapi import PlcSfaApi
 from sfa.util.config import Config
+
+from sfa.generic import Generic
+
 from sfa.trust.certificate import Keypair
 from sfa.trust.hierarchy import Hierarchy
 from sfa.server.registry import Registries
-import sfa.util.xmlrpcprotocol as xmlrpcprotocol 
-import socket
 
 def main():
     config = Config()
@@ -31,7 +34,7 @@ def main():
     authority = config.SFA_INTERFACE_HRN
     url = 'http://%s:%s/' %(config.SFA_REGISTRY_HOST, config.SFA_REGISTRY_PORT)
     registry = xmlrpcprotocol.get_server(url, key_file, cert_file)
-    sfa_api = PlcSfaApi(key_file = key_file, cert_file = cert_file, interface='registry')
+    sfa_api = Generic.the_flavour()
     credential = sfa_api.getCredential()
 
     # get peer registries
index 966a13e..b13b6a7 100755 (executable)
@@ -34,19 +34,21 @@ component_port=12346
 import os, os.path
 import traceback
 import sys
-import sfa.util.xmlrpcprotocol as xmlrpcprotocol
 from optparse import OptionParser
 
 from sfa.util.sfalogging import logger
+from sfa.util.xrn import get_authority, hrn_to_urn
+from sfa.util.config import Config
+import sfa.util.xmlrpcprotocol as xmlrpcprotocol
+
 from sfa.trust.certificate import Keypair, Certificate
 from sfa.trust.hierarchy import Hierarchy
 from sfa.trust.gid import GID
-from sfa.util.config import Config
-from sfa.plc.plcsfaapi import PlcSfaApi
+
+from sfa.server.sfaapi import SfaApi
+
 from sfa.server.registry import Registries
 from sfa.server.aggregate import Aggregates
-from sfa.util.xrn import get_authority, hrn_to_urn
-from sfa.util.sfalogging import logger
 
 # after http://www.erlenstar.demon.co.uk/unix/faq_2.html
 def daemon():
@@ -143,7 +145,7 @@ def install_peer_certs(server_key_file, server_cert_file):
     # There should be a gid file in /etc/sfa/trusted_roots for every
     # peer registry found in in the registries.xml config file. If there
     # are any missing gids, request a new one from the peer registry.
-    api = PlcSfaApi(key_file = server_key_file, cert_file = server_cert_file)
+    api = SfaApi(key_file = server_key_file, cert_file = server_cert_file)
     registries = Registries()
     aggregates = Aggregates()
     interfaces = dict(registries.items() + aggregates.items())
index 954ff6d..b2ce084 100755 (executable)
@@ -222,9 +222,9 @@ def get_gids(registry=None, verbose=False):
     if verbose:
         print "Getting current slices on this node"
     # get a list of slices on this node
-    from sfa.plc.plcsfaapi import PlcComponentApi
+    from sfa.plc.plcdriver import PlcComponentApi
     api = PlcComponentApi()
-    xids_tuple = api.nodemanager.GetXIDs()
+    xids_tuple = api.driver.nodemanager.GetXIDs()
     slices = eval(xids_tuple[1])
     slicenames = slices.keys()
 
index 25f1656..1abdad7 100755 (executable)
@@ -139,7 +139,7 @@ class XML:
 
     def add_element(self, name, attrs={}, parent=None, text=""):
         """
-        Generic wrapper around etree.SubElement(). Adds an element to 
+        Wrapper around etree.SubElement(). Adds an element to 
         specified parent node. Adds element to root node is parent is 
         not specified. 
         """