aggregate.prepare_interfaces({'node_id': aggregate.nodes.keys()})
slices.verify_slice_links(slice, rspec.version.get_link_requests(), aggregate)
- # hanlde MyPLC peer association.
+ # handle MyPLC peer association.
# only used by plc and ple.
slices.handle_peer(site, slice, persons, peer)
#!/usr/bin/python
from sfa.util.xrn import hrn_to_urn, urn_to_hrn
from sfa.util.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename
+
from sfa.rspecs.rspec import RSpec
from sfa.rspecs.elements.link import Link
from sfa.rspecs.elements.interface import Interface
+
from sfa.managers.vini.topology import PhysicalLinks
from sfa.rspecs.version_manager import VersionManager
from sfa.plc.vlink import get_tc_rate
####################
class PlcComponentApi(SfaApi):
+ """
+ This class is the type for the toplevel 'api' object
+ when running the component manager inside a planetlab node.
+ As such it runs an SFA-compliant interface and thus inherits SfaApi
+ However the fact that we run inside a planetlab nodes requires
+ 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",
from sfa.util.faults import MissingSfaInfo
from sfa.util.sfalogging import logger
from sfa.util.table import SfaTable
+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
-#################### xxx should move into util/defaultdict
-try:
- from collections import defaultdict
-except:
- class defaultdict(dict):
- def __init__(self, default_factory=None, *a, **kw):
- if (default_factory is not None and
- not hasattr(default_factory, '__call__')):
- raise TypeError('first argument must be callable')
- dict.__init__(self, *a, **kw)
- self.default_factory = default_factory
- def __getitem__(self, key):
- try:
- return dict.__getitem__(self, key)
- except KeyError:
- return self.__missing__(key)
- def __missing__(self, key):
- if self.default_factory is None:
- raise KeyError(key)
- self[key] = value = self.default_factory()
- return value
- def __reduce__(self):
- if self.default_factory is None:
- args = tuple()
- else:
- args = self.default_factory,
- return type(self), args, None, None, self.items()
- def copy(self):
- return self.__copy__()
- def __copy__(self):
- return type(self)(self.default_factory, self)
- def __deepcopy__(self, memo):
- import copy
- return type(self)(self.default_factory,
- copy.deepcopy(self.items()))
- def __repr__(self):
- return 'defaultdict(%s, %s)' % (self.default_factory,
- dict.__repr__(self))
-## end of http://code.activestate.com/recipes/523034/ }}}
-
def list_to_dict(recs, key):
"""
convert a list of dictionaries into a dictionary keyed on the
"""
An SfaApi instance is a basic xmlrcp service
augmented with the local cryptographic material and hrn
- It also has the notion of neighbour sfa services
- as defined in /etc/sfa/{aggregates,registries}.xml
+
+ It also has the notion of its own interface (a string describing
+ whether we run a registry, aggregate or slicemgr) and has
+ the notion of neighbour sfa services as defined
+ in /etc/sfa/{aggregates,registries}.xml
+
Finally it contains a cache instance
+
It gets augmented by the generic layer with
(*) an instance of manager (actually a manager module for now)
(*) which in turn holds an instance of a testbed driver
+ For convenience api.manager.driver == api.driver
"""
def __init__ (self, encoding="utf-8", methods='sfa.methods',
except: pass
except IOError, e:
- raise IOError, "Could not find the configuration file: %s" % config_file
+ raise IOError, "Could not find or load the configuration file: %s" % config_file
def get_trustedroots_dir(self):
return self.config_path + os.sep + 'trusted_roots'
--- /dev/null
+# from http://code.activestate.com/recipes/523034/
+try:
+ from collections import defaultdict
+except:
+ class defaultdict(dict):
+ def __init__(self, default_factory=None, *a, **kw):
+ if (default_factory is not None and
+ not hasattr(default_factory, '__call__')):
+ raise TypeError('first argument must be callable')
+ dict.__init__(self, *a, **kw)
+ self.default_factory = default_factory
+ def __getitem__(self, key):
+ try:
+ return dict.__getitem__(self, key)
+ except KeyError:
+ return self.__missing__(key)
+ def __missing__(self, key):
+ if self.default_factory is None:
+ raise KeyError(key)
+ self[key] = value = self.default_factory()
+ return value
+ def __reduce__(self):
+ if self.default_factory is None:
+ args = tuple()
+ else:
+ args = self.default_factory,
+ return type(self), args, None, None, self.items()
+ def copy(self):
+ return self.__copy__()
+ def __copy__(self):
+ return type(self)(self.default_factory, self)
+ def __deepcopy__(self, memo):
+ import copy
+ return type(self)(self.default_factory,
+ copy.deepcopy(self.items()))
+ def __repr__(self):
+ return 'defaultdict(%s, %s)' % (self.default_factory,
+ dict.__repr__(self))