Change in vdsm[master]: Fix multiple commands with same name in different vdsm-tool ...

fsimonce at redhat.com fsimonce at redhat.com
Tue May 29 08:01:10 UTC 2012


Federico Simoncelli has posted comments on this change.

Change subject: Fix multiple commands with same name in different vdsm-tool modules
......................................................................


Patch Set 3: I would prefer that you didn't submit this

(4 inline comments)

....................................................
File vdsm-tool/vdsm-tool
Line 74:                 sys.stdout.write('\nWarning: the command \'%s\' in module '
The format of the string is confusing for me. We could define an error message (at the moment just as a global variable in this file, we'll do it in a fancier way later), and use it here. It's also better for localization (in the future).

 ERROR_SAME_COMMAND = """\
 Warning: the command '%s' in module '%s' is being ignored, because a command \
 with the same name has already been registered by module '%s'.\
 """

And then here you can use:

 print textwrap.fill(ERROR_SAME_COMMAND % (cmd_name, mod_name,
                     tool_command[cmd_name]["module"].__name__))

Line 81:             tool_command[cmd_name] = cmd
Let's cache the module name here:

 tool_command[cmd_name] = {"module": module, "command": cmd}

(You need to modify all the parts that are using  tool_command)

Line 87: def _get_module_name(command):
We can get rid of this since we cache the module in load_modules.

Line 140:     tool_command[cmd](*args[1:])
Here:

 tool_command[cmd]["command"](*args[1:])

--
To view, visit http://gerrit.ovirt.org/4645
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I6a289a202e0efcb7f2948b6200ea39552164f5b6
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Wenyi Gao <wenyi at linux.vnet.ibm.com>
Gerrit-Reviewer: Adam Litke <agl at us.ibm.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: Ryan Harper <ryanh at us.ibm.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Wenyi Gao <wenyi at linux.vnet.ibm.com>


More information about the vdsm-patches mailing list