From 3d8c95a27679d29ca790c0c6a8802e09dde9ec35 Mon Sep 17 00:00:00 2001 From: tengqm Date: Thu, 5 Mar 2015 17:57:10 +0800 Subject: [PATCH] Make update always do a node retrieval first The reason is the the param might be the name of the node, while the name could be changed. So without a persistent ID, we cannot guarantee that the node could be retrieved again successfully. --- senlinclient/v1/shell.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/senlinclient/v1/shell.py b/senlinclient/v1/shell.py index 84844013..16aede58 100644 --- a/senlinclient/v1/shell.py +++ b/senlinclient/v1/shell.py @@ -993,8 +993,14 @@ def do_node_delete(sc, args): help=_('Name or ID of node to update.')) def do_node_update(sc, args): '''Update the node.''' + # Find the node first, we need its UUID + try: + node = sc.get(models.Node, {'id': args.id}) + except exc.HTTPNotFound: + raise exc.CommandError(_('Node not found: %s') % args.id) + params = { - 'id': args.id, + 'id': node.id, 'name': args.name, 'role': args.role, 'profile': args.profile, @@ -1002,7 +1008,7 @@ def do_node_update(sc, args): } sc.update(models.Node, params) - _show_node(sc, args.id) + _show_node(sc, node.id) @utils.arg('-c', '--cluster', required=True,