summaryrefslogtreecommitdiffstats
path: root/doctor_tests/inspector
diff options
context:
space:
mode:
authorwenjuan dong <dong.wenjuan@zte.com.cn>2018-09-18 08:50:10 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-09-18 08:50:10 +0000
commit825a0a0dd5e8028129b782ed21c549586257b1c5 (patch)
tree98ef1398d4a3aad5fd971e1927498bc4a54bd193 /doctor_tests/inspector
parentfcf53129ab2b18b84571faff13d7cb118b3a41b3 (diff)
parent835c9aeb7822aee8334400c15496932feeea18ae (diff)
Merge "delete doctor datasource in congress when cleanup"
Diffstat (limited to 'doctor_tests/inspector')
-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,