Hello community,

here is the log from the commit of package crmsh for openSUSE:Factory checked 
in at 2014-05-23 07:51:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/crmsh (Old)
 and      /work/SRC/openSUSE:Factory/.crmsh.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "crmsh"

Changes:
--------
--- /work/SRC/openSUSE:Factory/crmsh/crmsh.changes      2014-05-17 
21:43:25.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.crmsh.new/crmsh.changes 2014-05-23 
07:51:35.000000000 +0200
@@ -1,0 +2,7 @@
+Thu May 22 17:05:53 UTC 2014 - kgronl...@suse.com
+
+- medium: xmlutil: Limit xpath search to children (bnc#879419)
+- medium: ui: Fix argument check in resource commands (gh#crmsh/crmsh#29)
+- upstream: 2.0.0-88-g598dfd4
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ crmsh.spec ++++++
--- /var/tmp/diff_new_pack.1XvZmQ/_old  2014-05-23 07:51:36.000000000 +0200
+++ /var/tmp/diff_new_pack.1XvZmQ/_new  2014-05-23 07:51:36.000000000 +0200
@@ -41,7 +41,7 @@
 Summary:        High Availability cluster command-line interface
 License:        GPL-2.0+
 Group:          %{pkg_group}
-Version:        2.0+git85
+Version:        2.0+git88
 Release:        %{?crmsh_release}%{?dist}
 Url:            http://crmsh.github.io
 Source0:        crmsh.tar.bz2

++++++ crmsh.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/crmsh/modules/ui_node.py new/crmsh/modules/ui_node.py
--- old/crmsh/modules/ui_node.py        2014-05-16 13:20:50.000000000 +0200
+++ new/crmsh/modules/ui_node.py        2014-05-22 19:04:46.000000000 +0200
@@ -168,10 +168,9 @@
         if not argl:
             node = utils.this_node()
         elif len(argl) == 1:
-            if xmlutil.is_our_node(args[0]):
-                node = args[0]
-            else:
-                common_err("%s: node name not recognized" % args[0])
+            node = args[0]
+            if not xmlutil.is_our_node(node):
+                common_err("%s: node name not recognized" % node)
                 return False
         else:
             syntax_err(args, context=context.get_command_name())
@@ -289,31 +288,34 @@
 
     @command.wait
     @command.completers(compl.nodes, compl.choice(['set', 'delete', 'show']), 
compl.resources)
-    def do_attribute(self, context, *args):
+    def do_attribute(self, context, node, cmd, rsc, value=None):
         """usage:
         attribute <node> set <rsc> <value>
         attribute <node> delete <rsc>
         attribute <node> show <rsc>"""
-        return ui_utils.manage_attr(context.get_command_name(), 
self.node_attr, args)
+        return ui_utils.manage_attr(context.get_command_name(), self.node_attr,
+                                    node, cmd, rsc, value)
 
     @command.wait
     @command.completers(compl.nodes, compl.choice(['set', 'delete', 'show']), 
compl.resources)
-    def do_utilization(self, context, *args):
+    def do_utilization(self, context, node, cmd, rsc, value=None):
         """usage:
         utilization <node> set <rsc> <value>
         utilization <node> delete <rsc>
         utilization <node> show <rsc>"""
-        return ui_utils.manage_attr(context.get_command_name(), 
self.node_utilization, args)
+        return ui_utils.manage_attr(context.get_command_name(), 
self.node_utilization,
+                                    node, cmd, rsc, value)
 
     @command.wait
     @command.name('status-attr')
     @command.completers(compl.nodes, compl.choice(['set', 'delete', 'show']), 
compl.resources)
-    def do_status_attr(self, context, *args):
+    def do_status_attr(self, context, node, cmd, rsc, value=None):
         """usage:
         status-attr <node> set <rsc> <value>
         status-attr <node> delete <rsc>
         status-attr <node> show <rsc>"""
-        return ui_utils.manage_attr(context.get_command_name(), 
self.node_status, args)
+        return ui_utils.manage_attr(context.get_command_name(), 
self.node_status,
+                                    node, cmd, rsc, value)
 
 
 # vim:ts=4:sw=4:et:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/crmsh/modules/ui_resource.py 
new/crmsh/modules/ui_resource.py
--- old/crmsh/modules/ui_resource.py    2014-05-16 13:20:50.000000000 +0200
+++ new/crmsh/modules/ui_resource.py    2014-05-22 19:04:46.000000000 +0200
@@ -312,28 +312,25 @@
     @command.alias('move')
     @command.skill_level('administrator')
     @command.completers_repeating(compl.resources, compl.nodes,
-                                  compl.choice(['lifetime', 'force']))
-    def do_migrate(self, context, *args):
+                                  compl.choice(['reboot', 'forever', 'force']))
+    def do_migrate(self, context, rsc, *args):
         """usage: migrate <rsc> [<node>] [<lifetime>] [force]"""
-        argl = list(args)
-        rsc = argl[0]
         if not utils.is_name_sane(rsc):
             return False
-        del argl[0]
         node = None
-        opt_l = utils.fetch_opts(argl, ["force"])
+        argl = list(args)
+        force = "force" in utils.fetch_opts(argl, ["force"])
         lifetime = utils.fetch_lifetime_opt(argl)
-        if len(argl) == 1:
-            if xmlutil.is_our_node(argl[0]):
-                node = argl[0]
-            else:
-                context.fatal_error("Not our node: " + argl[0])
+        if len(argl) > 0:
+            node = argl[0]
+            if not xmlutil.is_our_node(node):
+                context.fatal_error("Not our node: " + node)
         opts = ''
         if node:
             opts = "--node='%s'" % node
         if lifetime:
             opts = "%s --lifetime='%s'" % (opts, lifetime)
-        if "force" in opt_l or config.core.force:
+        if force or config.core.force:
             opts = "%s --force" % opts
         return utils.ext_cmd(self.rsc_migrate % (rsc, opts)) == 0
 
@@ -356,28 +353,30 @@
         return cleanup_resource(resource, node)
 
     @command.completers(compl.resources, _attrcmds, compl.nodes)
-    def do_failcount(self, context, *args):
+    def do_failcount(self, context, rsc, cmd, node, value=None):
         """usage:
         failcount <rsc> set <node> <value>
         failcount <rsc> delete <node>
         failcount <rsc> show <node>"""
-        return ui_utils.manage_attr(context.get_command_name(), 
self.rsc_failcount, args)
+        return ui_utils.manage_attr(context.get_command_name(), 
self.rsc_failcount,
+                                    rsc, cmd, node, value)
 
     @command.skill_level('administrator')
     @command.wait
     @command.completers(compl.resources, _attrcmds)
-    def do_param(self, context, *args):
+    def do_param(self, context, rsc, cmd, param, value=None):
         """usage:
         param <rsc> set <param> <value>
         param <rsc> delete <param>
         param <rsc> show <param>"""
-        return ui_utils.manage_attr(context.get_command_name(), 
self.rsc_param, args)
+        return ui_utils.manage_attr(context.get_command_name(), self.rsc_param,
+                                    rsc, cmd, param, value)
 
     @command.skill_level('administrator')
     @command.wait
     @command.completers(compl.resources,
                         compl.choice(['set', 'stash', 'unstash', 'delete', 
'show', 'check']))
-    def do_secret(self, context, *args):
+    def do_secret(self, context, rsc, cmd, param, value=None):
         """usage:
         secret <rsc> set <param> <value>
         secret <rsc> stash <param>
@@ -385,27 +384,30 @@
         secret <rsc> delete <param>
         secret <rsc> show <param>
         secret <rsc> check <param>"""
-        return ui_utils.manage_attr(context.get_command_name(), 
self.rsc_secret, args)
+        return ui_utils.manage_attr(context.get_command_name(), 
self.rsc_secret,
+                                    rsc, cmd, param, value)
 
     @command.skill_level('administrator')
     @command.wait
     @command.completers(compl.resources, _attrcmds)
-    def do_meta(self, context, *args):
+    def do_meta(self, context, rsc, cmd, attr, value=None):
         """usage:
         meta <rsc> set <attr> <value>
         meta <rsc> delete <attr>
         meta <rsc> show <attr>"""
-        return ui_utils.manage_attr(context.get_command_name(), self.rsc_meta, 
args)
+        return ui_utils.manage_attr(context.get_command_name(), self.rsc_meta,
+                                    rsc, cmd, attr, value)
 
     @command.skill_level('administrator')
     @command.wait
     @command.completers(compl.resources, _attrcmds)
-    def do_utilization(self, context, *args):
+    def do_utilization(self, context, rsc, cmd, attr, value=None):
         """usage:
         utilization <rsc> set <attr> <value>
         utilization <rsc> delete <attr>
         utilization <rsc> show <attr>"""
-        return ui_utils.manage_attr(context.get_command_name(), 
self.rsc_utilization, args)
+        return ui_utils.manage_attr(context.get_command_name(), 
self.rsc_utilization,
+                                    rsc, cmd, attr, value)
 
     @command.completers(compl.nodes)
     def do_refresh(self, context, *args):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/crmsh/modules/ui_utils.py 
new/crmsh/modules/ui_utils.py
--- old/crmsh/modules/ui_utils.py       2014-05-16 13:20:50.000000000 +0200
+++ new/crmsh/modules/ui_utils.py       2014-05-22 19:04:46.000000000 +0200
@@ -22,9 +22,10 @@
 import utils
 
 
-def _get_attr_cmd(attr_ext_commands, args):
+def _get_attr_cmd(attr_ext_commands, subcmd):
+    attr_ext_commands
     try:
-        attr_cmd = attr_ext_commands[args[1]]
+        attr_cmd = attr_ext_commands[subcmd]
         if attr_cmd:
             return attr_cmd
     except KeyError, msg:
@@ -32,38 +33,39 @@
     raise ValueError("Bad attr_cmd " + repr(attr_ext_commands))
 
 
-def _dispatch_attr_cmd(cmd, attr_cmd, args):
-    if args[1] == 'set':
-        if len(args) != 4:
-            raise ValueError("Expected 4 arguments to 'set'")
-        if not utils.is_name_sane(args[0]) \
-                or not utils.is_name_sane(args[2]) \
-                or not utils.is_value_sane(args[3]):
-            raise ValueError("Argument failed sanity check")
-        return utils.ext_cmd(attr_cmd % (args[0], args[2], args[3])) == 0
-    elif args[1] in ('delete', 'show') or \
-            (cmd == "secret" and args[1] in ('stash', 'unstash', 'check')):
-        if len(args) != 3:
-            raise ValueError("Expected 3 arguments to " + args[1])
-        if not utils.is_name_sane(args[0]) \
-                or not utils.is_name_sane(args[2]):
-            raise ValueError("Argument failed sanity check")
-        return utils.ext_cmd(attr_cmd % (args[0], args[2])) == 0
-    raise ValueError("Unknown command " + repr(args[1]))
+def _dispatch_attr_cmd(cmd, attr_cmd, rsc, subcmd, attr, value):
+    def sanity_check(arg):
+        if not utils.is_name_sane(arg):
+            raise ValueError("Expected valid name, got '%s'" % (arg))
+    if subcmd == 'set':
+        if value is None:
+            raise ValueError("Missing value argument to set")
+        sanity_check(rsc)
+        sanity_check(attr)
+        sanity_check(value)
+        return utils.ext_cmd(attr_cmd % (rsc, attr, value)) == 0
+    elif subcmd in ('delete', 'show') or \
+            (cmd == "secret" and subcmd in ('stash', 'unstash', 'check')):
+        if value is not None:
+            raise ValueError("Too many arguments to %s" % (subcmd))
+        sanity_check(rsc)
+        sanity_check(attr)
+        return utils.ext_cmd(attr_cmd % (rsc, attr)) == 0
+    raise ValueError("Unknown command " + repr(subcmd))
 
 
-def manage_attr(cmd, attr_ext_commands, args):
+def manage_attr(cmd, attr_ext_commands, rsc, subcmd, attr, value):
     '''
     TODO: describe.
     '''
-    if len(args) < 3:
-        bad_usage(cmd, ' '.join(args), "Too few arguments")
-        return False
     try:
-        attr_cmd = _get_attr_cmd(attr_ext_commands, args)
-        return _dispatch_attr_cmd(cmd, attr_cmd, args)
+        attr_cmd = _get_attr_cmd(attr_ext_commands, subcmd)
+        return _dispatch_attr_cmd(cmd, attr_cmd, rsc, subcmd, attr, value)
     except ValueError, msg:
-        bad_usage(cmd, ' '.join(args), msg)
+        cmdline = [rsc, subcmd, attr]
+        if value is not None:
+            cmdline.append(value)
+        bad_usage(cmd, ' '.join(cmdline), msg)
         return False
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/crmsh/modules/xmlutil.py new/crmsh/modules/xmlutil.py
--- old/crmsh/modules/xmlutil.py        2014-05-16 13:20:50.000000000 +0200
+++ new/crmsh/modules/xmlutil.py        2014-05-22 19:04:46.000000000 +0200
@@ -777,7 +777,7 @@
 
 
 def get_rsc_operations(rsc_node):
-    actions = [op2list(op) for op in rsc_node.xpath('//operations/op')]
+    actions = [op2list(op) for op in rsc_node.xpath('.//operations/op')]
     actions = [[op, pl] for op, pl in actions if op]
     return actions
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/crmsh/test/testcases/confbasic.exp 
new/crmsh/test/testcases/confbasic.exp
--- old/crmsh/test/testcases/confbasic.exp      2014-05-16 13:20:50.000000000 
+0200
+++ new/crmsh/test/testcases/confbasic.exp      2014-05-22 19:04:46.000000000 
+0200
@@ -59,8 +59,6 @@
 .EXT crm_resource --show-metadata ocf:pacemaker:Stateful
 .EXT crm_resource --show-metadata ocf:heartbeat:Dummy
 .EXT pengine metadata
-WARNING: 50: s5: action monitor not advertised in meta-data, it may not be 
supported by the RA
-WARNING: 50: s6: action monitor not advertised in meta-data, it may not be 
supported by the RA
 .EXT crmd metadata
 .EXT cib metadata
 .INP: show
@@ -136,5 +134,3 @@
        record-pending=true
 tag t1: m5 m6
 .INP: commit
-WARNING: 52: s5: action monitor not advertised in meta-data, it may not be 
supported by the RA
-WARNING: 52: s6: action monitor not advertised in meta-data, it may not be 
supported by the RA

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to