Merge branch 'master' into thgeneric
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 3 Nov 2011 15:57:26 +0000 (16:57 +0100)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 3 Nov 2011 15:57:26 +0000 (16:57 +0100)
Conflicts:
sfa/methods/CreateSliver.py

config/topology [new file with mode: 0644]
setup.py
sfa.spec
sfa/methods/CreateSliver.py
sfa/plc/aggregate.py
sfa/util/topology.py [new file with mode: 0644]

diff --git a/config/topology b/config/topology
new file mode 100644 (file)
index 0000000..24a8e13
--- /dev/null
@@ -0,0 +1,20 @@
+# Links in the physical topology, gleaned from looking at the Internet2
+# topology map.  Link (a, b) connects sites with IDs a and b.
+#
+# 2 12  # I2 Princeton - New York
+# 11 13 # I2 Chicago - Wash DC
+# 11 15 # I2 Chicago - Atlanta
+# 11 16 # I2 Chicago - CESNET
+# 11 17 # I2 Chicago - Kansas City
+# 12 13 # I2 New York - Wash DC
+# 13 15 # I2 Wash DC - Atlanta
+# 14 15 # Ga Tech - I2 Atlanta
+# 15 19 # I2 Atlanta - Houston
+# 17 19 # I2 Kansas City - Houston
+# 17 22 # I2 Kansas City - Salt Lake City
+# 17 24 # I2 Kansas City - UMKC
+# 19 20 # I2 Houston - Los Angeles
+# 20 21 # I2 Los Angeles - Seattle
+# 20 22 # I2 Los Angeles - Salt Lake City
+# 21 22 # I2 Seattle - Salt Lake City
+
index ffd8406..698b388 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -61,6 +61,7 @@ data_files = [('/etc/sfa/', [ 'config/aggregates.xml',
                               'config/registries.xml',
                               'config/default_config.xml',
                               'config/sfi_config',
+                              'config/topology',
                               'sfa/managers/pl/pl.rng',
                               'sfa/trust/credential.xsd',
                               'sfa/trust/top.xsd',
index c470c49..d2979e4 100644 (file)
--- a/sfa.spec
+++ b/sfa.spec
@@ -144,6 +144,7 @@ rm -rf $RPM_BUILD_ROOT
 /etc/sfa/sig.xsd
 /etc/sfa/xml.xsd
 /etc/sfa/protogeni-rspec-common.xsd
+/etc/sfa/topology
 %{_bindir}/sfa-config-tty
 %{_bindir}/sfa-import-plc.py*
 %{_bindir}/sfa-clean-peer-records.py*
index d5a507e..dd76d9b 100644 (file)
@@ -4,6 +4,7 @@ from sfa.util.method import Method
 from sfa.util.parameter import Parameter, Mixed
 from sfa.util.sfatablesRuntime import run_sfatables
 from sfa.trust.credential import Credential
+from sfa.rspecs.rspec import RSpec
 
 class CreateSliver(Method):
     """
@@ -49,5 +50,9 @@ class CreateSliver(Method):
             chain_name = 'FORWARD-INCOMING'
         self.api.logger.debug("CreateSliver: sfatables on chain %s"%chain_name)
         rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec)
-
-        return self.api.manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, call_id)
+        slivers = RSpec(rspec).version.get_nodes_with_slivers()
+        if slivers:
+            result = self.api.manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, call_id)
+        else:
+            result = rspec     
+        return result
index c1dcd06..654a84f 100644 (file)
@@ -6,7 +6,7 @@ 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.util.topology import Topology
 from sfa.rspecs.version_manager import VersionManager
 from sfa.plc.vlink import get_tc_rate
 
@@ -73,7 +73,8 @@ class Aggregate:
             if not self.api.config.SFA_AGGREGATE_TYPE.lower() == 'vini':
                 return
 
-            for (site_id1, site_id2) in PhysicalLinks:
+            topology = Topology() 
+            for (site_id1, site_id2) in topology:
                 link = Link()
                 if not site_id1 in self.sites or site_id2 not in self.sites:
                     continue
diff --git a/sfa/util/topology.py b/sfa/util/topology.py
new file mode 100644 (file)
index 0000000..bd7eb18
--- /dev/null
@@ -0,0 +1,40 @@
+##
+# SFA Topology Info
+#
+# This module holds topology configuration for SFA. It is implemnted as a 
+# list of site_id tuples
+
+import os.path
+import traceback
+from sfa.util.sfalogging import logger
+
+class Topology(set):
+    """
+    Parse the topology configuration file. 
+    """
+
+    #def __init__(self, config_file = "/etc/sfa/topology"):
+    def __init__(self, config_file = "/tmp/topology"):
+        set.__init__(self) 
+        self.config_file = None
+        self.config_path = None
+        self.load(config_file)
+
+    def load(self, config_file):
+        try:
+            
+            self.config_file = config_file
+            # path to configuration data
+            self.config_path = os.path.dirname(config_file)
+            # load the links
+            f = open(config_file, 'r')
+            for line in f:
+                ignore = line.find('#')
+                if ignore > -1:
+                    line = line[0:ignore]
+                tup = line.split()
+                if len(tup) > 1:
+                    self.add((tup[0], tup[1]))    
+        except Exception, e:
+            logger.log_exc("Could not find or load the configuration file: %s" % config_file)
+            raise