summaryrefslogtreecommitdiffstats
path: root/doctor_tests
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2018-09-17 10:42:07 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2018-09-18 14:01:18 +0800
commit835c9aeb7822aee8334400c15496932feeea18ae (patch)
treef74cb9a63bc7e59d3a534c072b8e17c198a37d29 /doctor_tests
parentda25598a6a31abe0579ffed12d1719e5ff75f9a7 (diff)
delete doctor datasource in congress when cleanup
If we delete doctor driver in congress configuration when cleanup, the doctor datasource still existed, it will be raise an exeption in congress server and the service can't be started. Change-Id: Icefde9964229ef3d55af09cc2e81680cb8d19813 Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
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,