Handle SHELVED_OFFLOADED and VERIFY_RESIZE states

This change adds support for the SHELVED_OFFLOADED and (partly)
VERIFY_RESIZE states.  Shelved-offloaded instances don't have a
hypervisor associated with them.  VERIFY_RESIZE instances should still
be running on their associated hypervisor.  They are also present, but
"shut off", on another hypervisor.  Even with this change, the code
still generates a warning about the instance being present on multiple
hypervisors.  Personally I find the warning quite useful, and I don't
really know what to do about it.  Maybe we should suppress the warning
if the instance hasn't been in this state for long.

Change-Id: I3a56500bd350a070c96f719e702a5334ec8c8558
This commit is contained in:
Simon Leinen 2017-02-20 09:44:04 +01:00
parent 6d676efe83
commit a7e8010598
1 changed files with 15 additions and 5 deletions

View File

@ -211,6 +211,14 @@ def collect_server_information(nova, verbose=False):
search_opts={'all_tenants': True})
return srv
def instance_state_needs_hypervisor(state):
"""Return true if an instance in this state should have a hypervisor.
"""
if state == 'SHELVED_OFFLOADED':
return False
else:
return True
def report_server_hypervisor_inconsistencies(srv, hyp, verbose=False, note_incomplete=True):
"""Detect and report discrepancies between Nova and hypervisor views
@ -229,16 +237,18 @@ def report_server_hypervisor_inconsistencies(srv, hyp, verbose=False, note_incom
* an instance has incompatible states between Nova and the hypervisor
"""
state_mapping = {
'ACTIVE': 'running',
'SUSPENDED': 'shut off',
'SHUTOFF': 'shut off',
'PAUSED': 'paused',
'ACTIVE': 'running',
'VERIFY_RESIZE': 'running',
'SUSPENDED': 'shut off',
'SHUTOFF': 'shut off',
'SHELVED': 'shut off',
'PAUSED': 'paused',
}
for uuid, s in srv.iteritems():
nova_status = s.nova_info.status
hypervisor_name = s.nova_info._info['OS-EXT-SRV-ATTR:hypervisor_hostname']
if hypervisor_name is None:
if note_incomplete:
if instance_state_needs_hypervisor(nova_status) and note_incomplete:
print(u"Instance {} (Nova status {}) has no hypervisor".
format(uuid, nova_status))
elif hypervisor_name not in hyp: