

@extensions.expected_errors((400, 404, 501))
@validation.schema(hosts.update)
def update(self, req, id, body):
    "Return booleanized version of body dict.\n\n        :param Request req: The request object (containing 'nova-context'\n                            env var).\n        :param str id: The host name.\n        :param dict body: example format {'host': {'status': 'enable',\n                          'maintenance_mode': 'enable'}}\n        :return: Same dict as body but 'enable' strings for 'status' and\n                 'maintenance_mode' are converted into True, else False.\n        :rtype: dict\n        "

    def read_enabled(orig_val):
        val = orig_val.strip().lower()
        return (val == 'enable')
    context = req.environ['nova.context']
    authorize(context)
    status = body.get('status')
    maint_mode = body.get('maintenance_mode')
    if (status is not None):
        status = read_enabled(status)
    if (maint_mode is not None):
        maint_mode = read_enabled(maint_mode)
    result = {
        'host': id,
    }
    if (status is not None):
        result['status'] = self._set_enabled_status(context, id, status)
    if (maint_mode is not None):
        result['maintenance_mode'] = self._set_host_maintenance(context, id, maint_mode)
    return result

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/hosts.py HostController.update/original