Get slice tags from within sliver using nm api.
authorFaiyaz Ahmed <faiyaza@cs.princeton.edu>
Mon, 6 Jul 2009 16:37:40 +0000 (16:37 +0000)
committerFaiyaz Ahmed <faiyaza@cs.princeton.edu>
Mon, 6 Jul 2009 16:37:40 +0000 (16:37 +0000)
api_calls.py
sm.py

index 6d3377b..931760b 100644 (file)
@@ -271,3 +271,12 @@ def SetLoans(sliver_name, loans):
     if not validate_loans(loans): raise xmlrpclib.Fault(102, 'Invalid argument: the second argument must be a well-formed loan specification')
     rec['_loans'] = loans
     database.db.sync()
+
+@export_to_docbook(roles=['nm-controller', 'self'], 
+                accepts=[ Parameter(str, 'A sliver/slice name.')],
+                         returns=Parameter(dict, 'Tag dictionary'))
+@export_to_api(1)
+def GetTags(sliver_name):
+    """Return sliver tags set at PLC"""
+    rec = sliver_name
+    return rec.get('attributes', [])
diff --git a/sm.py b/sm.py
index 395a3fb..5d5de69 100644 (file)
--- a/sm.py
+++ b/sm.py
@@ -92,6 +92,7 @@ def GetSlivers(data, plc = None, config = None, fullupdate=True):
         # convert attributes field to a proper dict
         attr_dict = {}
         for attr in rec.pop('attributes'): attr_dict[attr['tagname']] = attr['value']
+        rec.setdefault("attributes", attr_dict)
 
         # squash keys
         keys = rec.pop('keys')