From b58ca751d87cda69df2924b5d8a0c6d543940574 Mon Sep 17 00:00:00 2001 From: Josh Karlin Date: Thu, 25 Mar 2010 19:18:58 +0000 Subject: [PATCH] ListResources now works and compresses properly --- Makefile | 2 +- sfa/client/sfi.py | 8 +- sfa/managers/geni_am_pl.py | 23 ++- xmlbuilder-0.9/xmlbuilder.egg-info/PKG-INFO | 160 +++++++++--------- .../xmlbuilder.egg-info/SOURCES.txt | 4 +- 5 files changed, 110 insertions(+), 87 deletions(-) diff --git a/Makefile b/Makefile index 66219b0f..b3602ed8 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ keyconvert-clean: python: xmlbuilder-install: - python xmlbuilder-0.9/setup.py install + cd xmlbuilder-0.9 ; python setup.py install ; cd .. python-install: python setup.py install --root=$(DESTDIR) diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index 27192dfe..c6b0a616 100755 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -19,6 +19,7 @@ from sfa.util.rspec import RSpec from sfa.util.xmlrpcprotocol import ServerException import sfa.util.xmlrpcprotocol as xmlrpcprotocol from sfa.util.config import Config +import zlib # utility methods here # display methods @@ -910,9 +911,10 @@ class Sfi: def ListResources(self,opts,args): user_cred = self.get_user_cred().save_to_string(save_parents=True) server = self.geni_am - call_options = {} - print server.ListResources([user_cred], call_options) - + call_options = {'geni_compressed': True} + rspec = server.ListResources([user_cred], call_options) + rspec = zlib.decompress(rspec.decode('base64')) + print rspec # # Main: parse arguments and dispatch to command diff --git a/sfa/managers/geni_am_pl.py b/sfa/managers/geni_am_pl.py index bd3951f5..afa747aa 100644 --- a/sfa/managers/geni_am_pl.py +++ b/sfa/managers/geni_am_pl.py @@ -18,6 +18,8 @@ from sfa.plc.slices import Slices import sfa.plc.peers as peers from sfa.plc.api import SfaAPI from sfa.plc.slices import * +from sfa.util.sfalogging import * +import zlib def GetVersion(): version = {} @@ -25,5 +27,22 @@ def GetVersion(): version['geni_stitching'] = False return version -def ListResources(creds, options): - return "Hello World" +def ListResources(api, creds, options): + manager_base = 'sfa.managers' + mgr_type = 'pl' + manager_module = manager_base + ".aggregate_manager_%s" % mgr_type + manager = __import__(manager_module, fromlist=[manager_base]) + + urn = None + if options.has_key('geni_slice_urn'): + urn = options['geni_slice_urn'] + + rspec = manager.get_rspec(api, urn, None) + #outgoing_rules = SFATablesRules('OUTGOING') + + if options.has_key('geni_compressed') and options['geni_compressed'] == True: + rspec = zlib.compress(rspec).encode('base64') + + return rspec + + diff --git a/xmlbuilder-0.9/xmlbuilder.egg-info/PKG-INFO b/xmlbuilder-0.9/xmlbuilder.egg-info/PKG-INFO index d931c15a..bb65a9de 100644 --- a/xmlbuilder-0.9/xmlbuilder.egg-info/PKG-INFO +++ b/xmlbuilder-0.9/xmlbuilder.egg-info/PKG-INFO @@ -1,80 +1,80 @@ -Metadata-Version: 1.0 -Name: xmlbuilder -Version: 0.9 -Summary: Pythonic way to create xml files -Home-page: http://pypi.python.org/pypi/xmlbuilder -Author: koder -Author-email: koder_dot_mail@gmail_dot_com -License: MIT -Download-URL: http://pypi.python.org/pypi/xmlbuilder -Description: Example of usage: - ----------------- - - - from __future__ import with_statement - from xmlbuilder import XMLBuilder - x = XMLBuilder(format=True) - with x.root(a = 1): - with x.data: - [x << ('node',{'val':i}) for i in range(10)] - - print str(x) - - will print - - <root a="1"> - <data> - <node val="0" /> - <node val="1" /> - <node val="2" /> - <node val="3" /> - <node val="4" /> - <node val="5" /> - <node val="6" /> - <node val="7" /> - <node val="8" /> - <node val="9" /> - </data> - </root> - - Mercurial repo:http://hg.assembla.com/MyPackages/ - - Documentations - -------------- - `XMLBuilder` is simple library build on top of `ElementTree.TreeBuilder` to - simplify xml files creation as much as possible. Althow it can produce - structured result with identated child tags. `XMLBuilder` use python `with` - statement to define xml tag levels and `<<` operator for simple cases - - text and tag without childs. - - First we need to create xmlbuilder - - from xmlbuilder import XMLBuilder - # params - encoding = 'utf8', - # builder = None, - ElementTree.TreeBuilder - # tab_level = None, - current tab l;evel - for formatted output only - # format = False, - create formatted output - # tab_step = " " * 4 - indentation step - xml = XMLBuilder() - - - Use `with` statement to make document structure - #create and open tag 'root_tag' with text 'text' and attributes - with xml.root_tag(text,attr1=val1,attr2=val2): - #create and open tag 'sub_tag' - with xml.sub_tag(text,attr3=val3): - #create tag which are not valid python identificator - with xml('one-more-sub-tag',attr7=val37): - xml << "Some textual data" - #here tag 'one-more-sub-tag' are closed - #Tags without children can be created using `<<` operator - for val in range(15): - xml << ('message',"python rocks!"[:i]) - #create 15 child tag like <message> python r</message> - #all tags closed - node = ~x # get etree.ElementTree object - xml_data = str(x) - unicode_xml_data = unicode(x) - -Keywords: xml -Platform: UNKNOWN +Metadata-Version: 1.0 +Name: xmlbuilder +Version: 0.9 +Summary: Pythonic way to create xml files +Home-page: http://pypi.python.org/pypi/xmlbuilder +Author: koder +Author-email: koder_dot_mail@gmail_dot_com +License: MIT +Download-URL: http://pypi.python.org/pypi/xmlbuilder +Description: Example of usage: + ----------------- + + + from __future__ import with_statement + from xmlbuilder import XMLBuilder + x = XMLBuilder(format=True) + with x.root(a = 1): + with x.data: + [x << ('node',{'val':i}) for i in range(10)] + + print str(x) + + will print + + <root a="1"> + <data> + <node val="0" /> + <node val="1" /> + <node val="2" /> + <node val="3" /> + <node val="4" /> + <node val="5" /> + <node val="6" /> + <node val="7" /> + <node val="8" /> + <node val="9" /> + </data> + </root> + + Mercurial repo:http://hg.assembla.com/MyPackages/ + + Documentations + -------------- + `XMLBuilder` is simple library build on top of `ElementTree.TreeBuilder` to + simplify xml files creation as much as possible. Althow it can produce + structured result with identated child tags. `XMLBuilder` use python `with` + statement to define xml tag levels and `<<` operator for simple cases - + text and tag without childs. + + First we need to create xmlbuilder + + from xmlbuilder import XMLBuilder + # params - encoding = 'utf8', + # builder = None, - ElementTree.TreeBuilder + # tab_level = None, - current tab l;evel - for formatted output only + # format = False, - create formatted output + # tab_step = " " * 4 - indentation step + xml = XMLBuilder() + + + Use `with` statement to make document structure + #create and open tag 'root_tag' with text 'text' and attributes + with xml.root_tag(text,attr1=val1,attr2=val2): + #create and open tag 'sub_tag' + with xml.sub_tag(text,attr3=val3): + #create tag which are not valid python identificator + with xml('one-more-sub-tag',attr7=val37): + xml << "Some textual data" + #here tag 'one-more-sub-tag' are closed + #Tags without children can be created using `<<` operator + for val in range(15): + xml << ('message',"python rocks!"[:i]) + #create 15 child tag like <message> python r</message> + #all tags closed + node = ~x # get etree.ElementTree object + xml_data = str(x) + unicode_xml_data = unicode(x) + +Keywords: xml +Platform: UNKNOWN diff --git a/xmlbuilder-0.9/xmlbuilder.egg-info/SOURCES.txt b/xmlbuilder-0.9/xmlbuilder.egg-info/SOURCES.txt index 57272a81..107062ca 100644 --- a/xmlbuilder-0.9/xmlbuilder.egg-info/SOURCES.txt +++ b/xmlbuilder-0.9/xmlbuilder.egg-info/SOURCES.txt @@ -1,6 +1,8 @@ LICENSE MANIFEST.in +PKG-INFO README.txt +setup.cfg setup.py xmlbuilder/__init__.py xmlbuilder.egg-info/PKG-INFO @@ -8,4 +10,4 @@ xmlbuilder.egg-info/SOURCES.txt xmlbuilder.egg-info/dependency_links.txt xmlbuilder.egg-info/top_level.txt xmlbuilder/docs/long_descr.rst -xmlbuilder/tests/__init__.py \ No newline at end of file +xmlbuilder/tests/__init__.py -- 2.47.0