HooksMaster: Make RunPhase return the rpc output
[ganeti-local] / tools / cfgshell
index 253d32a..53dacb0 100755 (executable)
 
 """
 
+# functions in this module need to have a given name structure, so:
+# pylint: disable-msg=C0103
+
 
-import os
-import sys
 import optparse
-import time
 import cmd
 
 try:
@@ -63,7 +63,7 @@ class ConfigShell(cmd.Cmd):
 
     """
     cmd.Cmd.__init__(self)
-    self.cfg = self.cluster_name = None
+    self.cfg = None
     self.parents = []
     self.path = []
     if cfg_file:
@@ -133,7 +133,7 @@ class ConfigShell(cmd.Cmd):
     if self.cfg is None:
       self.prompt = "(#no config) "
     else:
-      self.prompt = "(%s:/%s) " % (self.cluster_name, "/".join(self.path))
+      self.prompt = "(/%s) " % ("/".join(self.path),)
     return stop
 
   def do_load(self, line):
@@ -155,7 +155,6 @@ class ConfigShell(cmd.Cmd):
       self.cfg._OpenConfig()
       self.parents = [self.cfg._config_data]
       self.path = []
-      self.cluster_name = self.cfg.GetClusterName()
     except errors.ConfigurationError, err:
       print "Error: %s" % str(err)
     return False
@@ -186,7 +185,8 @@ class ConfigShell(cmd.Cmd):
   def do_cd(self, line):
     """Changes the current path.
 
-    Valid arguments: either .. or a child of the current object.
+    Valid arguments: either .., /, "" (no argument) or a child of the current
+    object.
 
     """
     if line == "..":
@@ -197,6 +197,10 @@ class ConfigShell(cmd.Cmd):
       else:
         print "Already at top level"
         return False
+    elif len(line) == 0 or line == "/":
+      self.parents = self.parents[0:1]
+      self.path = []
+      return False
 
     pointer = self.parents[-1]
     dirs, entries = self._get_entries(pointer)
@@ -307,6 +311,9 @@ class ConfigShell(cmd.Cmd):
         print "Invalid node name"
 
   def do_EOF(self, line):
+    """Exit the application.
+
+    """
     print
     return True
 
@@ -317,6 +324,7 @@ class ConfigShell(cmd.Cmd):
     print
     return True
 
+
 class Error(Exception):
   """Generic exception"""
   pass