diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2008-11-18 12:22:06 -0500 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2008-11-18 12:22:06 -0500 |
commit | 3fa049a27ddf44e72e1a457d4b01e4c395765638 (patch) | |
tree | 8d287392dba8aef3678da9b7b571c34c9408b8a7 /cobbler/modules/cli_misc.py | |
parent | 26bc2ae9a72922e54a40fd12f1cb1020dc0e7fcf (diff) | |
download | cobbler-3fa049a27ddf44e72e1a457d4b01e4c395765638.tar.gz cobbler-3fa049a27ddf44e72e1a457d4b01e4c395765638.tar.xz cobbler-3fa049a27ddf44e72e1a457d4b01e4c395765638.zip |
Add a --version command to cobbler which works by writing the file for /var/lib/cobbler/version
at build time, including git hash info since the version during development may not be as definitive
as the package version
Diffstat (limited to 'cobbler/modules/cli_misc.py')
-rw-r--r-- | cobbler/modules/cli_misc.py | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/cobbler/modules/cli_misc.py b/cobbler/modules/cli_misc.py index a293474c..503b6c70 100644 --- a/cobbler/modules/cli_misc.py +++ b/cobbler/modules/cli_misc.py @@ -67,7 +67,7 @@ class CheckFunction(commands.CobblerFunction): class ImportFunction(commands.CobblerFunction): def help_me(self): - return HELP_FORMAT % ("cobbler import","[ARGS|--help]") + return HELP_FORMAT % ("cobbler import","[ARGS]") def command_name(self): return "import" @@ -120,7 +120,7 @@ class ReserializeFunction(commands.CobblerFunction): class ListFunction(commands.CobblerFunction): def help_me(self): - return HELP_FORMAT % ("cobbler list","[ARGS|--help]") + return HELP_FORMAT % ("cobbler list","[ARGS]") def command_name(self): return "list" @@ -151,7 +151,7 @@ class ListFunction(commands.CobblerFunction): class StatusFunction(commands.CobblerFunction): def help_me(self): - return HELP_FORMAT % ("cobbler status","[ARGS|--help]") + return HELP_FORMAT % ("cobbler status","[ARGS]") def command_name(self): return "status" @@ -177,7 +177,7 @@ class SyncFunction(commands.CobblerFunction): class RepoSyncFunction(commands.CobblerFunction): def help_me(self): - return HELP_FORMAT % ("cobbler reposync","[ARGS|--help]") + return HELP_FORMAT % ("cobbler reposync","[ARGS]") def command_name(self): return "reposync" @@ -214,7 +214,7 @@ class BuildIsoFunction(commands.CobblerFunction): p.add_option("--tempdir", dest="tempdir", help="(OPTIONAL) working directory") def help_me(self): - return HELP_FORMAT % ("cobbler buildiso","") + return HELP_FORMAT % ("cobbler buildiso","[ARGS]") def command_name(self): return "buildiso" @@ -232,7 +232,7 @@ class BuildIsoFunction(commands.CobblerFunction): class ReplicateFunction(commands.CobblerFunction): def help_me(self): - return HELP_FORMAT % ("cobbler replicate","[ARGS|--help]") + return HELP_FORMAT % ("cobbler replicate","[ARGS]") def command_name(self): return "replicate" @@ -262,7 +262,7 @@ class ReplicateFunction(commands.CobblerFunction): class AclFunction(commands.CobblerFunction): def help_me(self): - return HELP_FORMAT % ("cobbler aclsetup","[ARGS|--help]") + return HELP_FORMAT % ("cobbler aclsetup","[ARGS]") def command_name(self): return "aclsetup" @@ -281,6 +281,48 @@ class AclFunction(commands.CobblerFunction): self.options.removegroup ) +######################################################## + +class VersionFunction(commands.CobblerFunction): + + def help_me(self): + return HELP_FORMAT % ("cobbler version","") + + def command_name(self): + return "version" + + def add_options(self, p, args): + pass + + def run(self): + + # --version output format borrowed from ls, so it must be right :) + + versions = self.api.version(extended=True) + + print "cobbler %s" % versions["version"] + print "" + + # print extended info if available, which is useful for devel branch testing + print "build date : %s" % versions["builddate"] + if versions.get("gitstamp","?") != "?": + print "git hash : %s" % versions["gitstamp"] + if versions.get("gitdate", "?") != "?": + print "git date : %s" % versions["gitdate"] + + print "" + + print "Copyright (C) 2006-2008 Red Hat, Inc." + print "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>" + print "This is free software: you are free to change and redistribute it." + print "There is NO WARRANTY, to the extent permitted by law." + + print "" + + print "Written by Michael DeHaan." + + return True + ######################################################## # MODULE HOOKS @@ -297,7 +339,8 @@ def cli_functions(api): CheckFunction(api), ImportFunction(api), ReserializeFunction(api), ListFunction(api), StatusFunction(api), SyncFunction(api), RepoSyncFunction(api), ValidateKsFunction(api), - ReplicateFunction(api), AclFunction(api) + ReplicateFunction(api), AclFunction(api), + VersionFunction(api) ] return [] |