hv_xen.py: rename GetXmList to GetInstanceList
authorHelga Velroyen <helgav@google.com>
Fri, 24 May 2013 13:55:31 +0000 (15:55 +0200)
committerHelga Velroyen <helgav@google.com>
Wed, 12 Jun 2013 07:17:08 +0000 (09:17 +0200)
Since one can retrieve xen's instance list via both 'xm'
or 'xl', it is no longer appropriate to call the function
'GetXmList'. This patch renames it to 'GetInstanceList'.
Other than that, there are no functional changes.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

lib/hypervisor/hv_xen.py
test/py/ganeti.hypervisor.hv_xen_unittest.py

index b7a7578..476979a 100644 (file)
@@ -83,7 +83,7 @@ def _CreateConfigCpus(cpu_mask):
 
 
 def _RunXmList(fn, xmllist_errors):
-  """Helper function for L{_GetXmList} to run "xm list".
+  """Helper function for L{_GetInstanceList} to run "xm list".
 
   @type fn: callable
   @param fn: Function returning result of running C{xm list}
@@ -141,7 +141,7 @@ def _ParseXmList(lines, include_node):
   return result
 
 
-def _GetXmList(fn, include_node, _timeout=5):
+def _GetInstanceList(fn, include_node, _timeout=5):
   """Return the list of running instances.
 
   See L{_RunXmList} and L{_ParseXmList} for parameter details.
@@ -432,18 +432,18 @@ class XenHypervisor(hv_base.BaseHypervisor):
     utils.RenameFile(old_filename, new_filename)
     return new_filename
 
-  def _GetXmList(self, include_node):
-    """Wrapper around module level L{_GetXmList}.
+  def _GetInstanceList(self, include_node):
+    """Wrapper around module level L{_GetInstanceList}.
 
     """
-    return _GetXmList(lambda: self._RunXen(["list"]), include_node)
+    return _GetInstanceList(lambda: self._RunXen(["list"]), include_node)
 
   def ListInstances(self):
     """Get the list of running instances.
 
     """
-    xm_list = self._GetXmList(False)
-    names = [info[0] for info in xm_list]
+    instance_list = self._GetInstanceList(False)
+    names = [info[0] for info in instance_list]
     return names
 
   def GetInstanceInfo(self, instance_name):
@@ -454,9 +454,9 @@ class XenHypervisor(hv_base.BaseHypervisor):
     @return: tuple (name, id, memory, vcpus, stat, times)
 
     """
-    xm_list = self._GetXmList(instance_name == _DOM0_NAME)
+    instance_list = self._GetInstanceList(instance_name == _DOM0_NAME)
     result = None
-    for data in xm_list:
+    for data in instance_list:
       if data[0] == instance_name:
         result = data
         break
@@ -468,8 +468,7 @@ class XenHypervisor(hv_base.BaseHypervisor):
     @return: list of tuples (name, id, memory, vcpus, stat, times)
 
     """
-    xm_list = self._GetXmList(False)
-    return xm_list
+    return self._GetInstanceList(False)
 
   def _MakeConfigFile(self, instance, startup_memory, block_devices):
     """Gather configuration details and write to disk.
@@ -605,7 +604,7 @@ class XenHypervisor(hv_base.BaseHypervisor):
                     result.output)
       return None
 
-    return _GetNodeInfo(result.stdout, self._GetXmList)
+    return _GetNodeInfo(result.stdout, self._GetInstanceList)
 
   @classmethod
   def GetInstanceConsole(cls, instance, hvparams, beparams):
index 9cc6575..e5c1399 100755 (executable)
@@ -159,7 +159,7 @@ class TestParseXmList(testutils.GanetiTestCase):
         self.fail("Exception was not raised")
 
 
-class TestGetXmList(testutils.GanetiTestCase):
+class TestGetInstanceList(testutils.GanetiTestCase):
   def _Fail(self):
     return utils.RunResult(constants.EXIT_FAILURE, None,
                            "stdout", "stderr", None,
@@ -168,7 +168,7 @@ class TestGetXmList(testutils.GanetiTestCase):
   def testTimeout(self):
     fn = testutils.CallCounter(self._Fail)
     try:
-      hv_xen._GetXmList(fn, False, _timeout=0.1)
+      hv_xen._GetInstanceList(fn, False, _timeout=0.1)
     except errors.HypervisorError, err:
       self.assertTrue("timeout exceeded" in str(err))
     else:
@@ -186,7 +186,7 @@ class TestGetXmList(testutils.GanetiTestCase):
 
     fn = testutils.CallCounter(compat.partial(self._Success, data))
 
-    result = hv_xen._GetXmList(fn, True, _timeout=0.1)
+    result = hv_xen._GetInstanceList(fn, True, _timeout=0.1)
 
     self.assertEqual(len(result), 4)