'Start/Stop host maintenance window. On start, it triggers
guest VMs evacuation.'

def _set_host_maintenance(self, context, host_name, mode=True):

    LOG.info('Putting    host    %(host_name)s    in    maintenance    mode    %(mode)s.', {'host_name': host_name, 'mode': mode})
    try:
        result = self.api.set_host_maintenance(context, host_name, mode)
    except NotImplementedError:
        common.raise_feature_not_supported()
    except (exception.HostNotFound, exception.HostMappingNotFound) as e:
        raise webob.exc.HTTPNotFound(explanation=e.format_message())
    except exception.ComputeServiceUnavailable as e:
        raise webob.exc.HTTPBadRequest(explanation=e.format_message())
    if (result not in ('on_maintenance', 'off_maintenance')):
        raise webob.exc.HTTPBadRequest(explanation=result)
    return result
