[Kimchi-devel] [PATCH 3/4] Expose repo_mngt_tool to /config/capabilities
Aline Manera
alinefm at linux.vnet.ibm.com
Tue Mar 11 20:34:20 UTC 2014
From: Aline Manera <alinefm at br.ibm.com>
Probably, in some cases Kimchi can not be able to identify which repository
management tool to use so expose this information to properly update the
UI
Also update the API.md and test case to reflect this change
Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
docs/API.md | 2 ++
src/kimchi/mockmodel.py | 4 +++-
src/kimchi/model/config.py | 11 ++++++++++-
tests/test_rest.py | 2 ++
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/docs/API.md b/docs/API.md
index b3b6c49..698fc66 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -579,6 +579,8 @@ creation.
the system; False, otherwise.
* update_tool: True if there is a compatible package manager for the
system; False, otherwise
+ * repo_mngt_tool: True if there is a compatible repository management tool
+ for the system; False, otherwise
* **POST**: *See Configuration Actions*
**Actions (POST):**
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index b842b6c..72764b0 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -67,7 +67,9 @@ class MockModel(object):
['http', 'https', 'ftp', 'ftps', 'tftp'],
'qemu_stream': True,
'screenshot': True,
- 'system_report_tool': True}
+ 'system_report_tool': True,
+ 'update_tool': True,
+ 'repo_mngt_tool': True}
def reset(self):
self._mock_vms = {}
diff --git a/src/kimchi/model/config.py b/src/kimchi/model/config.py
index 3580ad3..5b27188 100644
--- a/src/kimchi/model/config.py
+++ b/src/kimchi/model/config.py
@@ -27,6 +27,7 @@ from kimchi.distroloader import DistroLoader
from kimchi.exception import NotFoundError
from kimchi.featuretests import FeatureTests
from kimchi.model.debugreports import DebugReportsModel
+from kimchi.repositories import Repositories
from kimchi.screenshot import VMScreenshot
from kimchi.swupdate import SoftwareUpdate
from kimchi.utils import check_url_path, kimchi_log
@@ -80,11 +81,19 @@ class CapabilitiesModel(object):
else:
update_tool = True
+ try:
+ Repositories()
+ except Exception:
+ repo_mngt_tool = False
+ else:
+ repo_mngt_tool = True
+
return {'libvirt_stream_protocols': self.libvirt_stream_protocols,
'qemu_stream': self.qemu_stream,
'screenshot': VMScreenshot.get_stream_test_result(),
'system_report_tool': bool(report_tool),
- 'update_tool': update_tool}
+ 'update_tool': update_tool,
+ 'repo_mngt_tool': repo_mngt_tool}
class DistrosModel(object):
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 65d50e0..92c1a83 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1340,6 +1340,8 @@ class RestTests(unittest.TestCase):
self.assertIn('qemu_stream', conf)
self.assertIn('screenshot', conf)
self.assertIn('system_report_tool', conf)
+ self.assertIn('update_tool', conf)
+ self.assertIn('repo_mngt_tool', conf)
def test_auth_unprotected(self):
hdrs = {'AUTHORIZATION': ''}
--
1.7.10.4
More information about the Kimchi-devel
mailing list