diff options
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 a061b68d..d520cc94 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() + + |