def update_nodes(params): """Update the nodes of a cluster host""" host_name = params['host_name'] body = params['body'] nodes = body['nodes'] host: watolib.CREHost = watolib.Host.host(host_name) constructors.require_etag(constructors.etag_of_obj(host)) host.edit(host.attributes(), nodes) return constructors.serve_json( constructors.object_sub_property( domain_type='host_config', ident=host_name, name='nodes', value=host.cluster_nodes(), ))
def update_nodes(params): """Update the nodes of a cluster host""" host_name = params["host_name"] body = params["body"] nodes = body["nodes"] host: watolib.CREHost = watolib.Host.load_host(host_name) _require_host_etag(host) host.edit(host.attributes(), nodes) return constructors.serve_json( constructors.object_sub_property( domain_type="host_config", ident=host_name, name="nodes", value=host.cluster_nodes(), ))
def update_nodes(params): """Update the nodes of a cluster host""" host_name = params['host_name'] body = params['body'] nodes = body['nodes'] check_hostname(host_name, should_exist=True) for node in nodes: check_hostname(node, should_exist=True) host: watolib.CREHost = watolib.Host.host(host_name) if not host.is_cluster(): return problem(status=400, title="Trying to change nodes of a regular host.", detail="nodes can only be changed on cluster hosts.") constructors.require_etag(constructors.etag_of_obj(host)) host.edit(host.attributes(), nodes) return constructors.serve_json( constructors.object_sub_property( domain_type='host_config', ident=host_name, name='nodes', value=host.cluster_nodes(), ))