summaryrefslogtreecommitdiffstats
path: root/doctor_tests/installer
diff options
context:
space:
mode:
Diffstat (limited to 'doctor_tests/installer')
-rw-r--r--doctor_tests/installer/common/vitrage.py98
-rw-r--r--doctor_tests/installer/local.py11
2 files changed, 106 insertions, 3 deletions
diff --git a/doctor_tests/installer/common/vitrage.py b/doctor_tests/installer/common/vitrage.py
new file mode 100644
index 00000000..9ea32271
--- /dev/null
+++ b/doctor_tests/installer/common/vitrage.py
@@ -0,0 +1,98 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import os
+
+
+vitrage_template_file = '/etc/vitrage/templates/vitrage_host_down_scenarios.yaml'
+
+template = """
+metadata:
+ name: host_down_scenarios
+ description: scenarios triggered by Doctor monitor 'compute.host.down' alarm
+definitions:
+ entities:
+ - entity:
+ category: ALARM
+ name: compute.host.down
+ template_id: host_down_alarm
+ - entity:
+ category: ALARM
+ type: vitrage
+ name: Instance Down
+ template_id: instance_alarm
+ - entity:
+ category: RESOURCE
+ type: nova.instance
+ template_id: instance
+ - entity:
+ category: RESOURCE
+ type: nova.host
+ template_id: host
+ relationships:
+ - relationship:
+ source: host_down_alarm
+ relationship_type: on
+ target: host
+ template_id : host_down_alarm_on_host
+ - relationship:
+ source: host
+ relationship_type: contains
+ target: instance
+ template_id : host_contains_instance
+ - relationship:
+ source: instance_alarm
+ relationship_type: on
+ target: instance
+ template_id : alarm_on_instance
+scenarios:
+ - scenario:
+ condition: host_down_alarm_on_host
+ actions:
+ - action:
+ action_type: set_state
+ action_target:
+ target: host
+ properties:
+ state: ERROR
+ - action:
+ action_type: mark_down
+ action_target:
+ target: host
+ - scenario:
+ condition: host_down_alarm_on_host and host_contains_instance
+ actions:
+ - action:
+ action_type: raise_alarm
+ action_target:
+ target: instance
+ properties:
+ alarm_name: Instance Down
+ severity: critical
+ - scenario:
+ condition: host_down_alarm_on_host and host_contains_instance and alarm_on_instance
+ actions:
+ - action:
+ action_type: add_causal_relationship
+ action_target:
+ source: host_down_alarm
+ target: instance_alarm
+ - action:
+ action_type: mark_down
+ action_target:
+ target: instance
+"""
+
+
+def set_vitrage_host_down_template():
+ if os.path.isfile(vitrage_template_file):
+ print('Vitrage host_down template file: %s already exists.' % vitrage_template_file)
+ else:
+ print('Create Vitrage host_down template file:%s.' % vitrage_template_file)
+ with open(vitrage_template_file, 'w') as file:
+ file.write(template)
diff --git a/doctor_tests/installer/local.py b/doctor_tests/installer/local.py
index 7d0ae542..453755c2 100644
--- a/doctor_tests/installer/local.py
+++ b/doctor_tests/installer/local.py
@@ -11,6 +11,8 @@ import shutil
import subprocess
from doctor_tests.installer.base import BaseInstaller
+from doctor_tests.installer.common.vitrage import set_vitrage_host_down_template
+from doctor_tests.common.constants import Inspector
from doctor_tests.common.utils import load_json_file
from doctor_tests.common.utils import write_json_file
@@ -43,13 +45,16 @@ class LocalInstaller(BaseInstaller):
cmd = "getent hosts %s | awk '{ print $1 }'" % (hostname)
server = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
stdout, stderr = server.communicate()
- host_ip = stdout.strip()
+ host_ip = stdout.strip().decode("utf-8")
self.log.info('Get host_ip:%s from host_name:%s in local installer' % (host_ip, hostname))
return host_ip
def set_apply_patches(self):
self._set_nova_policy()
+ if self.conf.inspector.type == Inspector.VITRAGE:
+ set_vitrage_host_down_template()
+ os.system('sudo systemctl restart devstack@vitrage-graph.service')
def restore_apply_patches(self):
self._restore_nova_policy()
@@ -94,7 +99,7 @@ class LocalInstaller(BaseInstaller):
if self.policy_modified or self.add_policy_file:
write_json_file(self.nova_policy_file, data)
- os.system('screen -S stack -p n-api -X stuff "^C^M^[[A^M"')
+ os.system('sudo systemctl restart devstack@n-api.service')
def _restore_nova_policy(self):
if self.policy_modified:
@@ -104,6 +109,6 @@ class LocalInstaller(BaseInstaller):
os.remove(self.nova_policy_file)
if self.add_policy_file or self.policy_modified:
- os.system('screen -S stack -p n-api -X stuff "^C^M^[[A^M"')
+ os.system('sudo systemctl restart devstack@n-api.service')
self.add_policy_file = False
self.policy_modified = False