Merge branch 'newinterface' of ssh://bakers@git.planet-lab.org/git/plcapi into newint... newinterface
authorsmbaker <smbaker@fc8clean.lan>
Mon, 23 Apr 2012 23:36:31 +0000 (16:36 -0700)
committersmbaker <smbaker@fc8clean.lan>
Mon, 23 Apr 2012 23:36:31 +0000 (16:36 -0700)
12 files changed:
Makefile
PLC/Methods/Legacy/AddInterface.py
PLC/Methods/Legacy/AddNode.py
PLC/Methods/Legacy/DeleteInterface.py
PLC/Methods/Legacy/DeleteNode.py
PLC/Methods/Legacy/GetInterfaces.py
PLC/Methods/Legacy/GetNodes.py
PLC/Methods/Legacy/UpdateInterface.py
PLC/Methods/Legacy/UpdateNode.py
PLC/PostgreSQL.py
PLCAPI.spec
doc/DocBook.py

index 7c1ec2c..23cc59a 100644 (file)
--- 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
index 5d2774d..d9a245b 100644 (file)
@@ -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):
 
index 0fc7e5a..1d032e6 100644 (file)
@@ -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])
index 82d0f7e..ff58b64 100644 (file)
@@ -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):
 
index 01e382a..cd833f2 100644 (file)
@@ -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])
index d5938e9..67045f3 100644 (file)
@@ -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[:]
index 84fddb9..b03e974 100644 (file)
@@ -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):
 
index d2119c9..6ca3fd2 100644 (file)
@@ -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])
index a0e8ee4..4aac1af 100644 (file)
@@ -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
index eced84e..1dfced5 100644 (file)
@@ -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):
index 6f4aa94..d140608 100644 (file)
@@ -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 <thierry.parmentelat@sophia.inria.fr> - 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 <thierry.parmentelat@sophia.inria.fr> - plcapi-5.0-37
 - fix sorting for methods list in docs
 - untested but needed tweak for postgres startup in f16
index 90b384d..832f052 100755 (executable)
@@ -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:')