allow node update api receive node name and id prefix

Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
allencloud 2016-10-21 18:16:47 +08:00
parent ff2de8dace
commit d075b83dd6
4 changed files with 17 additions and 11 deletions

View File

@ -1369,7 +1369,7 @@ func (c *Cluster) GetNode(input string) (types.Node, error) {
}
// UpdateNode updates existing nodes properties.
func (c *Cluster) UpdateNode(nodeID string, version uint64, spec types.NodeSpec) error {
func (c *Cluster) UpdateNode(input string, version uint64, spec types.NodeSpec) error {
c.RLock()
defer c.RUnlock()
@ -1385,10 +1385,15 @@ func (c *Cluster) UpdateNode(nodeID string, version uint64, spec types.NodeSpec)
ctx, cancel := c.getRequestContext()
defer cancel()
currentNode, err := getNode(ctx, c.client, input)
if err != nil {
return err
}
_, err = c.client.UpdateNode(
ctx,
&swarmapi.UpdateNodeRequest{
NodeID: nodeID,
NodeID: currentNode.ID,
Spec: &nodeSpec,
NodeVersion: &swarmapi.Version{
Index: version,

View File

@ -193,6 +193,7 @@ This section lists each version from latest to oldest. Each listing includes a
* `POST /plugins/(plugin name)/push` push a plugin.
* `POST /plugins/create?name=(plugin name)` create a plugin.
* `DELETE /plugins/(plugin name)` delete a plugin.
* `POST /node/(id or name)/update` now accepts both `id` or `name` to identify the node to update.
### v1.24 API changes

View File

@ -3965,7 +3965,7 @@ List nodes
### Inspect a node
`GET /nodes/<id>`
`GET /nodes/(id or name)`
Return low-level information on the node `id`
@ -4047,9 +4047,9 @@ Return low-level information on the node `id`
### Remove a node
`DELETE /nodes/(id)`
`DELETE /nodes/(id or name)`
Remove a node [`id`] from the swarm.
Remove a node from the swarm.
**Example request**:
@ -4077,7 +4077,7 @@ Remove a node [`id`] from the swarm.
`POST /nodes/(id)/update`
Update the node `id`.
Update a node.
The payload of the `POST` request is the new `NodeSpec` and
overrides the current `NodeSpec` for the specified node.

View File

@ -4564,7 +4564,7 @@ List nodes
### Inspect a node
`GET /nodes/<id>`
`GET /nodes/(id or name)`
Return low-level information on the node `id`
@ -4647,9 +4647,9 @@ Return low-level information on the node `id`
### Remove a node
`DELETE /nodes/(id)`
`DELETE /nodes/(id or name)`
Remove a node [`id`] from the swarm.
Remove a node from the swarm.
**Example request**:
@ -4675,9 +4675,9 @@ Remove a node [`id`] from the swarm.
### Update a node
`POST /nodes/(id)/update`
`POST /nodes/(id or name)/update`
Update the node `id`.
Update a node.
The payload of the `POST` request is the new `NodeSpec` and
overrides the current `NodeSpec` for the specified node.