diff options
author | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-07-26 18:09:21 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-07-26 18:09:21 -0400 |
commit | 31a8dfef9c42b77a17ba09d92651cf222b525a00 (patch) | |
tree | 33e837ab38ea6798d5aa133c735fc8ff3f045862 /cobbler/api.py | |
parent | c4474d526d288d866fce3b58fd2b853cd983df14 (diff) | |
download | third_party-cobbler-31a8dfef9c42b77a17ba09d92651cf222b525a00.tar.gz third_party-cobbler-31a8dfef9c42b77a17ba09d92651cf222b525a00.tar.xz third_party-cobbler-31a8dfef9c42b77a17ba09d92651cf222b525a00.zip |
Added -v/--version
Diffstat (limited to 'cobbler/api.py')
-rw-r--r-- | cobbler/api.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cobbler/api.py b/cobbler/api.py index a061b68..d520cc9 100644 --- a/cobbler/api.py +++ b/cobbler/api.py @@ -23,6 +23,7 @@ import action_import import action_reposync import action_status import action_validate +import sub_process class BootAPI: @@ -42,6 +43,19 @@ class BootAPI: self.__settings = self._config.settings() self.sync_flag = self.__settings.minimize_syncs + def version(self): + """ + What version is cobbler? + Currently checks the RPM DB, which is not perfect. + Will return "?" if not installed. + """ + cmd = sub_process.Popen("/bin/rpm -q cobbler", stdout=sub_process.PIPE, shell=True) + result = cmd.communicate()[0].replace("cobbler-","") + if result.find("not installed") != -1: + return "?" + return result[:result.rfind(".")] + + def clear(self): """ Forget about current list of profiles, distros, and systems @@ -182,4 +196,9 @@ class BootAPI: """ return self._config.deserialize() +if __name__ == "__main__": + api = BootAPI() + print api.version() + + |