projects
/
ganeti-local
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'stable-2.6'
[ganeti-local]
/
tools
/
cfgshell
diff --git
a/tools/cfgshell
b/tools/cfgshell
index
53dacb0
..
3e79561
100755
(executable)
--- a/
tools/cfgshell
+++ b/
tools/cfgshell
@@
-24,7
+24,7
@@
"""
# functions in this module need to have a given name structure, so:
"""
# functions in this module need to have a given name structure, so:
-# pylint: disable-msg=C0103
+# pylint: disable=C0103
import optparse
import optparse
@@
-53,6
+53,8
@@
class ConfigShell(cmd.Cmd):
responsibility to know what they're doing.
"""
responsibility to know what they're doing.
"""
+ # all do_/complete_* functions follow the same API
+ # pylint: disable=W0613
prompt = "(/) "
def __init__(self, cfg_file=None):
prompt = "(/) "
def __init__(self, cfg_file=None):
@@
-91,7
+93,9
@@
class ConfigShell(cmd.Cmd):
dirs = []
entries = []
if isinstance(obj, objects.ConfigObject):
dirs = []
entries = []
if isinstance(obj, objects.ConfigObject):
- for name in obj.__slots__:
+ # pylint: disable=W0212
+ # yes, we're using a protected member
+ for name in obj._all_slots():
child = getattr(obj, name, None)
if isinstance(child, (list, dict, tuple, objects.ConfigObject)):
dirs.append(name)
child = getattr(obj, name, None)
if isinstance(child, (list, dict, tuple, objects.ConfigObject)):
dirs.append(name)
@@
-152,8
+156,7
@@
class ConfigShell(cmd.Cmd):
arg = None
try:
self.cfg = config.ConfigWriter(cfg_file=arg, offline=True)
arg = None
try:
self.cfg = config.ConfigWriter(cfg_file=arg, offline=True)
- self.cfg._OpenConfig()
- self.parents = [self.cfg._config_data]
+ self.parents = [self.cfg._config_data] # pylint: disable=W0212
self.path = []
except errors.ConfigurationError, err:
print "Error: %s" % str(err)
self.path = []
except errors.ConfigurationError, err:
print "Error: %s" % str(err)
@@
-178,7
+181,7
@@
class ConfigShell(cmd.Cmd):
"""
pointer = self.parents[-1]
"""
pointer = self.parents[-1]
- dirs, entries = self._get_entries(pointer)
+ dirs, _ = self._get_entries(pointer)
matches = [str(name) for name in dirs if name.startswith(text)]
return matches
matches = [str(name) for name in dirs if name.startswith(text)]
return matches
@@
-203,7
+206,7
@@
class ConfigShell(cmd.Cmd):
return False
pointer = self.parents[-1]
return False
pointer = self.parents[-1]
- dirs, entries = self._get_entries(pointer)
+ dirs, _ = self._get_entries(pointer)
if line not in dirs:
print "No such child"
if line not in dirs:
print "No such child"
@@
-233,7
+236,7
@@
class ConfigShell(cmd.Cmd):
"""
pointer = self.parents[-1]
"""
pointer = self.parents[-1]
- dirs, entries = self._get_entries(pointer)
+ _, entries = self._get_entries(pointer)
matches = [name for name in entries if name.startswith(text)]
return matches
matches = [name for name in entries if name.startswith(text)]
return matches
@@
-245,7
+248,7
@@
class ConfigShell(cmd.Cmd):
"""
pointer = self.parents[-1]
"""
pointer = self.parents[-1]
- dirs, entries = self._get_entries(pointer)
+ _, entries = self._get_entries(pointer)
if line not in entries:
print "No such entry"
return False
if line not in entries:
print "No such entry"
return False
@@
-285,7
+288,7
@@
class ConfigShell(cmd.Cmd):
if self.cfg.VerifyConfig():
print "Config data does not validate, refusing to save."
return False
if self.cfg.VerifyConfig():
print "Config data does not validate, refusing to save."
return False
- self.cfg._WriteConfig()
+ self.cfg._WriteConfig() # pylint: disable=W0212
def do_rm(self, line):
"""Removes an instance or a node.
def do_rm(self, line):
"""Removes an instance or a node.
@@
-295,7
+298,7
@@
class ConfigShell(cmd.Cmd):
"""
pointer = self.parents[-1]
"""
pointer = self.parents[-1]
- data = self.cfg._config_data
+ data = self.cfg._config_data # pylint: disable=W0212
if pointer not in (data.instances, data.nodes):
print "Can only delete instances and nodes"
return False
if pointer not in (data.instances, data.nodes):
print "Can only delete instances and nodes"
return False
@@
-310,14
+313,16
@@
class ConfigShell(cmd.Cmd):
else:
print "Invalid node name"
else:
print "Invalid node name"
- def do_EOF(self, line):
+ @staticmethod
+ def do_EOF(line):
"""Exit the application.
"""
print
return True
"""Exit the application.
"""
print
return True
- def do_quit(self, line):
+ @staticmethod
+ def do_quit(line):
"""Exit the application.
"""
"""Exit the application.
"""
@@
-336,10
+341,9
@@
def ParseOptions():
In case of command line errors, it will show the usage and exit the
program.
In case of command line errors, it will show the usage and exit the
program.
- Returns:
- (options, args), as returned by OptionParser.parse_args
- """
+ @return: a tuple (options, args), as returned by OptionParser.parse_args
+ """
parser = optparse.OptionParser()
options, args = parser.parse_args()
parser = optparse.OptionParser()
options, args = parser.parse_args()
@@
-350,9
+354,8
@@
def ParseOptions():
def main():
"""Application entry point.
def main():
"""Application entry point.
- This is just a wrapper over BootStrap, to handle our own exceptions.
"""
"""
- options, args = ParseOptions()
+ _, args = ParseOptions()
if args:
cfg_file = args[0]
else:
if args:
cfg_file = args[0]
else: