summaryrefslogtreecommitdiffstats
path: root/doctor_tests
diff options
context:
space:
mode:
Diffstat (limited to 'doctor_tests')
-rw-r--r--doctor_tests/inspector/congress.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/doctor_tests/inspector/congress.py b/doctor_tests/inspector/congress.py
index fb747ec5..7f918fb2 100644
--- a/doctor_tests/inspector/congress.py
+++ b/doctor_tests/inspector/congress.py
@@ -31,6 +31,8 @@ class CongressInspector(BaseInspector):
def __init__(self, conf, log):
super(CongressInspector, self).__init__(conf, log)
+ self.is_create_doctor_datasource = False
+ self.doctor_datasource_id = None
self.auth = get_identity_auth()
self.congress = congress_client(get_session(auth=self.auth))
self._init_driver_and_ds()
@@ -48,12 +50,6 @@ class CongressInspector(BaseInspector):
'version < nova_api_min_version(%s)'
% self.nova_api_min_version)
- # create doctor datasource if it's not exist
- if self.doctor_datasource not in datasources:
- self.congress.create_datasource(
- body={'driver': self.doctor_driver,
- 'name': self.doctor_datasource})
-
# check whether doctor driver exist
drivers = \
{driver['id']: driver for driver in
@@ -61,6 +57,14 @@ class CongressInspector(BaseInspector):
if self.doctor_driver not in drivers:
raise Exception('Do not support doctor driver in congress')
+ # create doctor datasource if it's not exist
+ if self.doctor_datasource not in datasources:
+ response = self.congress.create_datasource(
+ body={'driver': self.doctor_driver,
+ 'name': self.doctor_datasource})
+ self.doctor_datasource_id = response['id']
+ self.is_create_doctor_datasource = True
+
self.policy_rules = \
{rule['name']: rule for rule in
self.congress.list_policy_rules(self.policy)['results']}
@@ -86,6 +90,9 @@ class CongressInspector(BaseInspector):
for rule_name in self.rules.keys():
self._del_rule(rule_name)
+ if self.is_create_doctor_datasource:
+ self.congress.delete_datasource(self.doctor_datasource_id)
+
def _add_rule(self, rule_name, rule):
if rule_name not in self.policy_rules:
self.congress.create_policy_rule(self.policy,