From: Faiyaz Ahmed Date: Mon, 6 Jul 2009 16:37:40 +0000 (+0000) Subject: Get slice tags from within sliver using nm api. X-Git-Tag: NodeManager-1.8-8~20 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=48b2b410b41507a04128d4c733b6fa208de6eb1a;p=nodemanager.git Get slice tags from within sliver using nm api. --- diff --git a/api_calls.py b/api_calls.py index 6d3377b..931760b 100644 --- a/api_calls.py +++ b/api_calls.py @@ -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 --- 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')