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:
@@ -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. "
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user