Hello community,

here is the log from the commit of package crmsh for openSUSE:Factory checked 
in at 2015-10-30 13:43:48
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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      2015-10-28 
17:31:17.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.crmsh.new/crmsh.changes 2015-10-30 
13:43:49.000000000 +0100
@@ -1,0 +2,8 @@
+Thu Oct 29 12:29:21 UTC 2015 - kgronl...@suse.com
+
+- Update to version 2.2.0~rc3+git.1446121677.5f4ab3c:
+  + high: scripts: Eval CIB text in correct scope (bsc#952600)
+  + medium: scripts: Check required parameters for optional sub-steps
+  + medium: utils: Fix python 2.6 compatibility
+
+-------------------------------------------------------------------

Old:
----
  crmsh-2.2.0~rc3+git.1446022288.cbb7d77.tar.bz2

New:
----
  crmsh-2.2.0~rc3+git.1446121677.5f4ab3c.tar.bz2

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

Other differences:
------------------
++++++ crmsh.spec ++++++
--- /var/tmp/diff_new_pack.DgGbLm/_old  2015-10-30 13:43:50.000000000 +0100
+++ /var/tmp/diff_new_pack.DgGbLm/_new  2015-10-30 13:43:50.000000000 +0100
@@ -36,7 +36,7 @@
 Summary:        High Availability cluster command-line interface
 License:        GPL-2.0+
 Group:          %{pkg_group}
-Version:        2.2.0~rc3+git.1446022288.cbb7d77
+Version:        2.2.0~rc3+git.1446121677.5f4ab3c
 Release:        0
 Url:            http://crmsh.github.io
 Source0:        %{name}-%{version}.tar.bz2

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.DgGbLm/_old  2015-10-30 13:43:50.000000000 +0100
+++ /var/tmp/diff_new_pack.DgGbLm/_new  2015-10-30 13:43:50.000000000 +0100
@@ -1,4 +1,4 @@
 <servicedata>
 <service name="tar_scm">
             <param name="url">git://github.com/ClusterLabs/crmsh.git</param>
-          <param 
name="changesrevision">cbb7d776f5489f5925d3e243f1d2844c743fe889</param></service></servicedata>
\ No newline at end of file
+          <param 
name="changesrevision">5f4ab3c5cfbc79d4858dc6cefbfa0311a3d0c67d</param></service></servicedata>
\ No newline at end of file

++++++ crmsh-2.2.0~rc3+git.1446022288.cbb7d77.tar.bz2 -> 
crmsh-2.2.0~rc3+git.1446121677.5f4ab3c.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/crmsh-2.2.0~rc3+git.1446022288.cbb7d77/modules/report.py 
new/crmsh-2.2.0~rc3+git.1446121677.5f4ab3c/modules/report.py
--- old/crmsh-2.2.0~rc3+git.1446022288.cbb7d77/modules/report.py        
2015-10-28 09:51:59.000000000 +0100
+++ new/crmsh-2.2.0~rc3+git.1446121677.5f4ab3c/modules/report.py        
2015-10-29 13:29:21.000000000 +0100
@@ -591,7 +591,7 @@
             self.end_ts = syslog_ts(end_msg)
         else:
             common_warn("end of transition %s not found in logs (transition 
not complete yet?)" % self)
-            self.end_ts = (datetime.datetime(2525, 1, 1) - 
datetime.datetime(1970, 1, 1)).total_seconds()
+            self.end_ts = datetime_to_timestamp(datetime.datetime(2525, 1, 1))
 
     def __str__(self):
         return self.get_node_file()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/crmsh-2.2.0~rc3+git.1446022288.cbb7d77/modules/scripts.py 
new/crmsh-2.2.0~rc3+git.1446121677.5f4ab3c/modules/scripts.py
--- old/crmsh-2.2.0~rc3+git.1446022288.cbb7d77/modules/scripts.py       
2015-10-28 09:51:59.000000000 +0100
+++ new/crmsh-2.2.0~rc3+git.1446121677.5f4ab3c/modules/scripts.py       
2015-10-29 13:29:21.000000000 +0100
@@ -185,8 +185,8 @@
                 return ' -> '.join(x.items()[0])
             action['text'] = '\n'.join([arrow(x) for x in value])
         elif name == 'cib' or name == 'crm':
-            action['text'] = Text.cib(script, value)
-            action['value'] = _remove_empty_lines(str(action['text']))
+            action['text'] = str(Text.cib(script, value))
+            action['value'] = _remove_empty_lines(action['text'])
         elif name == 'call':
             action['value'] = Text(script, value)
         elif name == 'copy':
@@ -1422,8 +1422,15 @@
         params[key] = value
 
     def _fill_values(path, into, source, srcreq):
+        """
+        Copy values into into while checking for missing required parameters.
+        If into has content, all required parameters ARE required, even if the
+        whole step is not required (since we're supplying it). This is checked
+        by checking if the step is not required, but there are some parameters
+        set by the user anyway.
+        """
         if 'required' in source:
-            srcreq = source['required'] and srcreq
+            srcreq = (source['required'] and srcreq) or (into and srcreq)
 
         for param in source.get('parameters', []):
             if param['name'] not in into:
@@ -1436,12 +1443,14 @@
             required = step.get('required', True)
             if not required and step['name'] not in into:
                 continue
+            if not required and step['name'] in into and into[step['name']]:
+                required = True
             if 'name' not in step:
-                _fill_values(path, into, step, step.get('required') and srcreq)
+                _fill_values(path, into, step, required and srcreq)
             else:
                 if step['name'] not in into:
                     into[step['name']] = {}
-                _fill_values(path + [step['name']], into[step['name']], step, 
step.get('required') and srcreq)
+                _fill_values(path + [step['name']], into[step['name']], step, 
required and srcreq)
 
     _fill_values([], params, script, True)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/crmsh-2.2.0~rc3+git.1446022288.cbb7d77/modules/utils.py 
new/crmsh-2.2.0~rc3+git.1446121677.5f4ab3c/modules/utils.py
--- old/crmsh-2.2.0~rc3+git.1446022288.cbb7d77/modules/utils.py 2015-10-28 
09:51:59.000000000 +0100
+++ new/crmsh-2.2.0~rc3+git.1446121677.5f4ab3c/modules/utils.py 2015-10-29 
13:29:21.000000000 +0100
@@ -1034,12 +1034,22 @@
     return dt
 
 
+def total_seconds(td):
+    """
+    Backwards compatible implementation of timedelta.total_seconds()
+    """
+    if hasattr(datetime.timedelta, 'total_seconds'):
+        return td.total_seconds()
+    else:
+        return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) 
/ 10**6
+
+
 def datetime_to_timestamp(dt):
     """
     Convert a datetime object into a floating-point second value
     """
     try:
-        return (make_datetime_naive(dt) - datetime.datetime(1970, 1, 
1)).total_seconds()
+        return total_seconds(make_datetime_naive(dt) - datetime.datetime(1970, 
1, 1))
     except Exception as e:
         common_err("datetime_to_timestamp error: %s" % (e))
         return None
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/crmsh-2.2.0~rc3+git.1446022288.cbb7d77/test/unittests/test_scripts.py 
new/crmsh-2.2.0~rc3+git.1446121677.5f4ab3c/test/unittests/test_scripts.py
--- old/crmsh-2.2.0~rc3+git.1446022288.cbb7d77/test/unittests/test_scripts.py   
2015-10-28 09:51:59.000000000 +0100
+++ new/crmsh-2.2.0~rc3+git.1446121677.5f4ab3c/test/unittests/test_scripts.py   
2015-10-29 13:29:21.000000000 +0100
@@ -721,3 +721,94 @@
     def ver():
         return scripts.verify(script_a, {"foo": "one"})
     assert_raises(ValueError, ver)
+
+
+@with_setup(setup_func, teardown_func)
+def test_two_substeps():
+    """
+    There is a scoping bug
+    """
+    a = '''---
+- version: 2.2
+  category: Script
+  include:
+    - agent: test:apache
+      name: apache
+      parameters:
+        - name: id
+          required: true
+'''
+    b = '''---
+- version: 2.2
+  category: Script
+  include:
+    - script: apache
+      name: apache-a
+      required: true
+    - script: apache
+      name: apache-b
+      required: true
+  parameters:
+    - name: wiz
+      required: true
+  actions:
+    - include: apache-a
+    - include: apache-b
+    - cib: "primitive {{wiz}} {{apache-a:id}} {{apache-b:id}}"
+'''
+
+    script_a = scripts.load_script_string('apache', a)
+    script_b = scripts.load_script_string('test-b', b)
+    assert script_a is not None
+    assert script_b is not None
+
+    actions = scripts.verify(script_b,
+                             {'wiz': "head", "apache-a": {"id": "one"}, 
"apache-b": {"id": "two"}})
+    eq_(len(actions), 1)
+    pprint(actions)
+    assert actions[0]['text'] == "primitive one test:apache\n\nprimitive two 
test:apache\n\nprimitive head one two"
+
+
+@with_setup(setup_func, teardown_func)
+def test_required_subscript_params():
+    """
+    If an optional subscript has multiple required parameters,
+    excluding all = ok
+    excluding one = fail
+    """
+
+    a = '''---
+- version: 2.2
+  category: Script
+  parameters:
+    - name: foo
+      required: true
+      type: string
+    - name: bar
+      required: true
+      type: string
+  actions:
+    - cib: "{{foo}} {{bar}}"
+'''
+
+    b = '''---
+- version: 2.2
+  category: Script
+  include:
+    - script: foofoo
+      required: false
+  actions:
+    - include: foofoo
+    - cib: "{{foofoo:foo}} {{foofoo:bar}"
+'''
+
+    script_a = scripts.load_script_string('foofoo', a)
+    script_b = scripts.load_script_string('test-b', b)
+    assert script_a is not None
+    assert script_b is not None
+
+    def ver():
+        actions = scripts.verify(script_b,
+                                 {"foofoo": {"foo": "one"}})
+        pprint(actions)
+    assert_raises(ValueError, ver)


Reply via email to