backend: Two small style fixes
[ganeti-local] / lib / rapi / connector.py
index eeae01e..3ef842b 100644 (file)
 
 """
 
+# pylint: disable-msg=C0103
+
+# C0103: Invalid name, since the R_* names are not conforming
+
 import cgi
 import re
 
@@ -42,12 +46,14 @@ class Mapper:
   """Map resource to method.
 
   """
-  def __init__(self, connector=CONNECTOR):
+  def __init__(self, connector=None):
     """Resource mapper constructor.
 
     @param connector: a dictionary, mapping method name with URL path regexp
 
     """
+    if connector is None:
+      connector = CONNECTOR
     self._connector = connector
 
   def getController(self, uri):
@@ -95,7 +101,8 @@ class R_root(baserlib.R_Generic):
   """/ resource.
 
   """
-  def GET(self):
+  @staticmethod
+  def GET():
     """Show the list of mapped resources.
 
     @return: a dictionary with 'name' and 'uri' keys for each of them.
@@ -114,7 +121,7 @@ class R_root(baserlib.R_Generic):
     return baserlib.BuildUriList(rootlist, "/%s")
 
 
-def _getResources(id):
+def _getResources(id_):
   """Return a list of resources underneath given id.
 
   This is to generalize querying of version resources lists.
@@ -122,7 +129,7 @@ def _getResources(id):
   @return: a list of resources names.
 
   """
-  r_pattern = re.compile('^R_%s_([a-zA-Z0-9]+)$' % id)
+  r_pattern = re.compile('^R_%s_([a-zA-Z0-9]+)$' % id_)
 
   rlist = []
   for handler in CONNECTOR.values():
@@ -138,7 +145,8 @@ class R_2(baserlib.R_Generic):
   """ /2 resource, the root of the version 2 API.
 
   """
-  def GET(self):
+  @staticmethod
+  def GET():
     """Show the list of mapped resources.
 
     @return: a dictionary with 'name' and 'uri' keys for each of them.
@@ -201,6 +209,7 @@ def GetHandlers(node_name_pattern, instance_name_pattern, job_id_pattern):
     "/2/tags": rlib2.R_2_tags,
     "/2/info": rlib2.R_2_info,
     "/2/os": rlib2.R_2_os,
+    "/2/redistribute-config": rlib2.R_2_redist_config,
     }