Merge lp:~martinarrieta/mysql-fabric/bug72508 into lp:mysql-fabric

Proposed by Martin Arrieta
Status: Needs review
Proposed branch: lp:~martinarrieta/mysql-fabric/bug72508
Merge into: lp:mysql-fabric
Diff against target: 68 lines (+25/-4)
2 files modified
lib/mysql/fabric/command.py (+13/-2)
scripts/mysqlfabric.py (+12/-2)
To merge this branch: bzr merge lp:~martinarrieta/mysql-fabric/bug72508
Reviewer Review Type Date Requested Status
Oracle/MySQL Engineering Pending
Review via email: mp+218226@code.launchpad.net

Description of the change

I have added a bug about the exit code:

http://bugs.mysql.com/bug.php?id=72508

The solution is simple, please check the code.

Here is an example about how is working after the patch:

# mysqlfabric group health test1
Command :
{ success = True
  return = {"12f4a168-d08e-11e3-92cf-08002760fc47": {"status": "FAULTY", "is_alive": false, "threads": {}, "address": "192.168.70.102"}, "1189e6be-d08e-11e3-92cf-08002760fc47": {"status": "FAULTY", "is_alive": false, "threads": {}, "address": "192.168.70.103"}, "0efa44fb-d08e-11e3-92cf-08002760fc47": {"status": "FAULTY", "is_alive": false, "threads": {}, "address": "192.168.70.104"}}
  activities =
}
[root@fabric-store bug72508]# echo $?
0
[root@fabric-store bug72508]# mysqlfabric group health test
Command :
{ success = False
  return = GroupError: Group (test) does not exist.
  activities =
}
[root@fabric-store bug72508]# echo $?
1

Regards,

Martin Arrieta
@martinarrietac

To post a comment you must log in.
225. By Martin Arrieta

Added the exit status to the procedure dispatcher

Unmerged revisions

225. By Martin Arrieta

Added the exit status to the procedure dispatcher

224. By Martin Arrieta

added the exit code to the command

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/mysql/fabric/command.py'
2--- lib/mysql/fabric/command.py 2014-03-07 06:36:46 +0000
3+++ lib/mysql/fabric/command.py 2014-05-05 12:45:56 +0000
4@@ -354,7 +354,13 @@
5 :param args: The arguments for the command dispatch.
6 """
7 status = self.client.dispatch(self, *args)
8- return self.command_status(status)
9+
10+ if isinstance(status[0], bool):
11+ exitstatus = status[0]
12+ else:
13+ exitstatus = False
14+
15+ return (exitstatus, self.command_status(status))
16
17 @staticmethod
18 def command_status(status, details=False):
19@@ -495,7 +501,12 @@
20 :param args: The arguments for the command dispatch.
21 """
22 status = self.client.dispatch(self, *args)
23- return self.procedure_status(status)
24+ if isinstance(status[0], bool):
25+ exitstatus = status[0]
26+ else:
27+ exitstatus = False
28+
29+ return (exitstatus, self.procedure_status(status))
30
31 @staticmethod
32 def wait_for_procedures(procedure_param, synchronous):
33
34=== modified file 'scripts/mysqlfabric.py' (properties changed: -x to +x)
35--- scripts/mysqlfabric.py 2014-03-07 06:36:46 +0000
36+++ scripts/mysqlfabric.py 2014-05-05 12:45:56 +0000
37@@ -17,6 +17,7 @@
38 #
39
40 import os
41+import sys
42 import inspect
43 import textwrap
44 from getpass import getpass
45@@ -337,12 +338,21 @@
46 command.group_name, command.command_name,
47 )
48 )
49-
50+
51+ #Default exit code is 1 (false)
52+ exitcode = 1
53+
54 # Execute command by dispatching it on the client side. Append the
55 #optional arguments passed by the user to the argument list.
56- result = command.dispatch(*(command.append_options_to_args(args)))
57+ exitstatus, result = command.dispatch(*(command.append_options_to_args(args)))
58 if result is not None:
59 print result
60+
61+ if exitstatus:
62+ exitcode = 0
63+
64+ sys.exit(exitcode)
65+
66 except TypeError:
67 PARSER.error(
68 "Wrong number of parameters were provided for command '{group} "

Subscribers

People subscribed via source and target branches