From: smbaker Date: Mon, 23 Apr 2012 23:36:31 +0000 (-0700) Subject: Merge branch 'newinterface' of ssh://bakers@git.planet-lab.org/git/plcapi into newint... X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=328caa57be5cebbb77b2f264e20083e03ec5c28a;hp=03026ae30ddd29f24afe67a0c56ea16ac0642132;p=plcapi.git Merge branch 'newinterface' of ssh://bakers@git.planet-lab.org/git/plcapi into newinterface --- diff --git a/Makefile b/Makefile index 7c1ec2c..23cc59a 100644 --- a/Makefile +++ b/Makefile @@ -61,14 +61,12 @@ tags: # $ run export # and cut'n paste the export lines before you run make sync -PLCHOST ?= testplc.onelab.eu - ifdef PLC SSHURL:=root@$(PLC):/ SSHCOMMAND:=ssh root@$(PLC) else ifdef PLCHOSTLXC -SSHURL:=root@$(PLCHOST):/var/lib/lxc/$(GUESTNAME)/rootfs +SSHURL:=root@$(PLCHOSTLXC):/var/lib/lxc/$(GUESTNAME)/rootfs SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh $(GUESTHOSTNAME) else ifdef PLCHOSTVS diff --git a/PLC/Methods/Legacy/AddInterface.py b/PLC/Methods/Legacy/AddInterface.py index 5d2774d..d9a245b 100644 --- a/PLC/Methods/Legacy/AddInterface.py +++ b/PLC/Methods/Legacy/AddInterface.py @@ -66,7 +66,9 @@ class AddInterface(Method): ] returns = Parameter(int, 'New interface_id (> 0) if successful') - + + # needed for generating the doc and prevent conflicts in the xml ids + status = 'legacy' def call(self, auth, node_id_or_hostname, interface_fields): diff --git a/PLC/Methods/Legacy/AddNode.py b/PLC/Methods/Legacy/AddNode.py index 0fc7e5a..1d032e6 100644 --- a/PLC/Methods/Legacy/AddNode.py +++ b/PLC/Methods/Legacy/AddNode.py @@ -78,6 +78,9 @@ class AddNode(Method): returns = Parameter(int, 'New node_id (> 0) if successful') + # needed for generating the doc and prevent conflicts in the xml ids + status = 'legacy' + def call(self, auth, site_id_or_login_base, node_fields): [native,tags,rejected]=Row.split_fields(node_fields,[legacy_node_fields,Node.tags]) diff --git a/PLC/Methods/Legacy/DeleteInterface.py b/PLC/Methods/Legacy/DeleteInterface.py index 82d0f7e..ff58b64 100644 --- a/PLC/Methods/Legacy/DeleteInterface.py +++ b/PLC/Methods/Legacy/DeleteInterface.py @@ -27,6 +27,8 @@ class DeleteInterface(Method): returns = Parameter(int, '1 if successful') + # needed for generating the doc and prevent conflicts in the xml ids + status = 'legacy' def call(self, auth, interface_id): diff --git a/PLC/Methods/Legacy/DeleteNode.py b/PLC/Methods/Legacy/DeleteNode.py index 01e382a..cd833f2 100644 --- a/PLC/Methods/Legacy/DeleteNode.py +++ b/PLC/Methods/Legacy/DeleteNode.py @@ -26,6 +26,9 @@ class DeleteNode(Method): returns = Parameter(int, '1 if successful') + # needed for generating the doc and prevent conflicts in the xml ids + status = 'legacy' + def call(self, auth, node_id_or_hostname): # Get account information nodes = Nodes(self.api, [node_id_or_hostname]) diff --git a/PLC/Methods/Legacy/GetInterfaces.py b/PLC/Methods/Legacy/GetInterfaces.py index d5938e9..67045f3 100644 --- a/PLC/Methods/Legacy/GetInterfaces.py +++ b/PLC/Methods/Legacy/GetInterfaces.py @@ -59,6 +59,9 @@ class GetInterfaces(Method): returns = [Interface.fields] + ["type", "ip", "netmask", "network", "broadcast"] + # needed for generating the doc and prevent conflicts in the xml ids + status = 'legacy' + def call(self, auth, interface_filter = None, return_fields = None): if (return_fields is not None): interface_return_fields = return_fields[:] diff --git a/PLC/Methods/Legacy/GetNodes.py b/PLC/Methods/Legacy/GetNodes.py index 84fddb9..b03e974 100644 --- a/PLC/Methods/Legacy/GetNodes.py +++ b/PLC/Methods/Legacy/GetNodes.py @@ -82,6 +82,8 @@ class GetNodes(Method): returns = [legacy_node_fields] + # needed for generating the doc and prevent conflicts in the xml ids + status = 'legacy' def call(self, auth, node_filter = None, return_fields = None): diff --git a/PLC/Methods/Legacy/UpdateInterface.py b/PLC/Methods/Legacy/UpdateInterface.py index d2119c9..6ca3fd2 100644 --- a/PLC/Methods/Legacy/UpdateInterface.py +++ b/PLC/Methods/Legacy/UpdateInterface.py @@ -70,6 +70,9 @@ class UpdateInterface(Method): returns = Parameter(int, '1 if successful') + # needed for generating the doc and prevent conflicts in the xml ids + status = 'legacy' + def call(self, auth, interface_id, interface_fields): [native,tags,rejected] = Row.split_fields(interface_fields,[legacy_interface_fields,Interface.tags]) diff --git a/PLC/Methods/Legacy/UpdateNode.py b/PLC/Methods/Legacy/UpdateNode.py index a0e8ee4..4aac1af 100644 --- a/PLC/Methods/Legacy/UpdateNode.py +++ b/PLC/Methods/Legacy/UpdateNode.py @@ -81,6 +81,9 @@ class UpdateNode(Method): returns = Parameter(int, '1 if successful') + # needed for generating the doc and prevent conflicts in the xml ids + status = 'legacy' + def call(self, auth, node_id_or_hostname, node_fields): # split provided fields diff --git a/PLC/PostgreSQL.py b/PLC/PostgreSQL.py index eced84e..1dfced5 100644 --- a/PLC/PostgreSQL.py +++ b/PLC/PostgreSQL.py @@ -57,23 +57,50 @@ class PostgreSQL: self.connection.close() self.connection = None + @staticmethod + # From pgdb, and simplify code + def _quote(x): + if isinstance(x, DateTimeType): + x = str(x) + elif isinstance(x, unicode): + x = x.encode( 'utf-8' ) + + if isinstance(x, types.StringType): + x = "'%s'" % str(x).replace("\\", "\\\\").replace("'", "''") + elif isinstance(x, (types.IntType, types.LongType, types.FloatType)): + pass + elif x is None: + x = 'NULL' + elif isinstance(x, (types.ListType, types.TupleType, set)): + x = 'ARRAY[%s]' % ', '.join(map(lambda x: str(_quote(x)), x)) + elif hasattr(x, '__pg_repr__'): + x = x.__pg_repr__() + else: + raise PLCDBError, 'Cannot quote type %s' % type(x) + return x + + def quote(self, value): """ Returns quoted version of the specified value. """ - # The pgdb._quote function is good enough for general SQL - # quoting, except for array types. - if isinstance (value, (types.ListType, types.TupleType, set)): - 'ARRAY[%s]' % ', '.join( [ str(self.quote(x)) for x in value ] ) - else: - try: - # up to PyGreSQL-3.x, function was pgdb._quote - import pgdb - return pgdb._quote(value) - except: - # with PyGreSQL-4.x, use psycopg2's adapt - from psycopg2.extensions import adapt - return adapt (value) + return PostgreSQL._quote (value) + +# following is an unsuccessful attempt to re-use lib code as much as possible +# def quote(self, value): +# # The pgdb._quote function is good enough for general SQL +# # quoting, except for array types. +# if isinstance (value, (types.ListType, types.TupleType, set)): +# 'ARRAY[%s]' % ', '.join( [ str(self.quote(x)) for x in value ] ) +# else: +# try: +# # up to PyGreSQL-3.x, function was pgdb._quote +# import pgdb +# return pgdb._quote(value) +# except: +# # with PyGreSQL-4.x, use psycopg2's adapt +# from psycopg2.extensions import adapt +# return adapt (value) @classmethod def param(self, name, value): diff --git a/PLCAPI.spec b/PLCAPI.spec index 6f4aa94..d140608 100644 --- a/PLCAPI.spec +++ b/PLCAPI.spec @@ -1,6 +1,6 @@ %define name PLCAPI %define version 5.1 -%define taglevel 0 +%define taglevel 1 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}} @@ -145,6 +145,14 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Mon Apr 16 2012 Thierry Parmentelat - plcapi-5.1-1 +- fix gpg-authentication for Persons (thanks Jordan) +- PostgreSQL.quote reviewed for f16/postgresql9 (used deprecated internal helper) +- ip address/network check: v4 or v6 +- customized DB Message survive upgrade +- make sync works in lxc-hosted tests +- no svn keywords anymore + * Fri Feb 24 2012 Thierry Parmentelat - plcapi-5.0-37 - fix sorting for methods list in docs - untested but needed tweak for postgres startup in f16 diff --git a/doc/DocBook.py b/doc/DocBook.py index 90b384d..832f052 100755 --- a/doc/DocBook.py +++ b/doc/DocBook.py @@ -108,16 +108,19 @@ class DocBook: def Process (self): for func in self.functions_list: - method = func.name if func.status == "deprecated": continue + method = func.name + if func.status == 'legacy': + method += "-legacy" + (min_args, max_args, defaults) = func.args() section = Element('section') - section.setAttribute('id', func.name) - section.appendChild(simpleElement('title', func.name)) + section.setAttribute('id', method) + section.appendChild(simpleElement('title', method)) prototype = "%s (%s)" % (method, ", ".join(max_args)) para = paraElement('Prototype:')