Checking cluster status before actions

* add checking if cluster is operational or error state
  when calling an action to run OSTF tests through fuelclient
* add checking of cluster status when running network
  verification in nailgun

Change-Id: I3f40fb0e0b3d589834c242e73e9f8250daf4e05f
Closes-Bug: #1337887
Closes-Bug: #1337884
This commit is contained in:
Sebastian Kalinowski
2014-07-22 16:06:12 +02:00
parent 3a80906df4
commit 613db7beb6
2 changed files with 19 additions and 0 deletions

View File

@@ -26,6 +26,12 @@ class HealthCheckAction(Action):
"""
action_name = "health"
_allowed_statuses = (
'error',
'operational',
'update_error',
)
def __init__(self):
super(HealthCheckAction, self).__init__()
self.args = (
@@ -45,6 +51,15 @@ class HealthCheckAction(Action):
fuel --env 1 health --check smoke,sanity
"""
env = Environment(params.env)
if env.status not in self._allowed_statuses and not params.force:
exit_with_error(
"Environment is not ready to run health check "
"because it is in {0} state. "
"Health check is likely to fail because of "
"this. Use --force flag to proceed anyway.". format(env.status)
)
if env.is_customized and not params.force:
exit_with_error(
"Environment deployment facts were updated. "

View File

@@ -152,6 +152,10 @@ class Environment(BaseObject):
return (serializer or self.serializer).read_from_file(
settings_file_path)
@property
def status(self):
return self.get_fresh_data()['status']
@property
def settings_url(self):
return "clusters/{0}/attributes".format(self.id)