[Python-apps-commits] r13933 - in packages/bundlewrap/trunk (18 files)

highvoltage-guest at users.alioth.debian.org highvoltage-guest at users.alioth.debian.org
Mon Mar 27 11:30:49 UTC 2017


    Date: Monday, March 27, 2017 @ 11:30:44
  Author: highvoltage-guest
Revision: 13933

Update bundlewrap to new upstream version 2.17.0

Modified:
  packages/bundlewrap/trunk/CHANGELOG.md
  packages/bundlewrap/trunk/bundlewrap/__init__.py
  packages/bundlewrap/trunk/bundlewrap/items/__init__.py
  packages/bundlewrap/trunk/bundlewrap/items/pkg_apt.py
  packages/bundlewrap/trunk/bundlewrap/items/pkg_dnf.py
  packages/bundlewrap/trunk/bundlewrap/items/pkg_pacman.py
  packages/bundlewrap/trunk/bundlewrap/items/pkg_yum.py
  packages/bundlewrap/trunk/bundlewrap/repo.py
  packages/bundlewrap/trunk/debian/changelog
  packages/bundlewrap/trunk/debian/copyright
  packages/bundlewrap/trunk/docs/content/guide/env.md
  packages/bundlewrap/trunk/docs/content/guide/installation.md
  packages/bundlewrap/trunk/docs/content/guide/item_file_templates.md
  packages/bundlewrap/trunk/docs/content/guide/quickstart.md
  packages/bundlewrap/trunk/docs/content/items/pkg_apt.md
  packages/bundlewrap/trunk/docs/mkdocs.yml
  packages/bundlewrap/trunk/requirements.txt
  packages/bundlewrap/trunk/setup.py

Modified: packages/bundlewrap/trunk/CHANGELOG.md
===================================================================
--- packages/bundlewrap/trunk/CHANGELOG.md	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/CHANGELOG.md	2017-03-27 11:30:44 UTC (rev 13933)
@@ -1,3 +1,13 @@
+# 2.17.0
+
+2017-03-26
+
+* pkg_apt: added start_service attribute
+* pkg_apt: added support for multiarch packages
+* improved reporting of exceptions in metadata processors
+* fixed package cache leaking across nodes
+
+
 # 2.16.0
 
 2017-02-23

Modified: packages/bundlewrap/trunk/bundlewrap/__init__.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/__init__.py	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/bundlewrap/__init__.py	2017-03-27 11:30:44 UTC (rev 13933)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-VERSION = (2, 16, 0)
+VERSION = (2, 17, 0)
 VERSION_STRING = ".".join([str(v) for v in VERSION])

Modified: packages/bundlewrap/trunk/bundlewrap/items/__init__.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/items/__init__.py	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/bundlewrap/items/__init__.py	2017-03-27 11:30:44 UTC (rev 13933)
@@ -27,6 +27,7 @@
     'triggered_by': [],
     'triggers': [],
     'unless': "",
+    'when_creating': {},
 }
 
 
@@ -57,7 +58,6 @@
     """
     A single piece of configuration (e.g. a file, a package, a service).
     """
-    BINARY_ATTRIBUTES = []
     BLOCK_CONCURRENT = []
     BUNDLE_ATTRIBUTE_NAME = None
     ITEM_ATTRIBUTES = {}
@@ -68,6 +68,7 @@
     STATUS_FAILED = 3
     STATUS_SKIPPED = 4
     STATUS_ACTION_SUCCEEDED = 5
+    WHEN_CREATING_ATTRIBUTES = {}
 
     def __init__(
         self,
@@ -85,6 +86,7 @@
         self.item_data_dir = join(bundle.bundle_data_dir, self.BUNDLE_ATTRIBUTE_NAME)
         self.name = name
         self.node = bundle.node
+        self.when_creating = {}
         self._faults_missing_for_attributes = set()
         self._precedes_items = []
 
@@ -101,15 +103,13 @@
         except FaultUnavailable:
             self._faults_missing_for_attributes.add(_("unknown"))
 
-        for attribute_name, attribute_default in \
-                BUILTIN_ITEM_ATTRIBUTES.items():
+        for attribute_name, attribute_default in BUILTIN_ITEM_ATTRIBUTES.items():
             setattr(self, attribute_name, force_text(attributes.get(
                 attribute_name,
                 copy(attribute_default),
             )))
 
-        for attribute_name, attribute_default in \
-                self.ITEM_ATTRIBUTES.items():
+        for attribute_name, attribute_default in self.ITEM_ATTRIBUTES.items():
             if attribute_name not in BUILTIN_ITEM_ATTRIBUTES:
                 try:
                     self.attributes[attribute_name] = force_text(attributes.get(
@@ -119,6 +119,10 @@
                 except FaultUnavailable:
                     self._faults_missing_for_attributes.add(attribute_name)
 
+        for attribute_name, attribute_default in self.WHEN_CREATING_ATTRIBUTES.items():
+            self.when_creating[attribute_name] = \
+                attributes.get('when_creating', {}).get(attribute_name, attribute_default)
+
         if self.cascade_skip is None:
             self.cascade_skip = not (self.unless or self.triggered)
 
@@ -299,14 +303,26 @@
             ),
         )
         if invalid_attributes:
-            raise BundleError(
-                _("invalid attribute(s) for '{item}' in bundle '{bundle}': {attrs}").format(
-                    item=item_id,
-                    bundle=bundle.name,
-                    attrs=", ".join(invalid_attributes),
-                )
-            )
+            raise BundleError(_(
+                "invalid attribute(s) for '{item}' in bundle '{bundle}': {attrs}"
+            ).format(
+                item=item_id,
+                bundle=bundle.name,
+                attrs=", ".join(invalid_attributes),
+            ))
 
+        invalid_attributes = set(attributes.get('when_creating', {}).keys()).difference(
+            set(cls.WHEN_CREATING_ATTRIBUTES.keys())
+        )
+        if invalid_attributes:
+            raise BundleError(_(
+                "invalid when_creating attribute(s) for '{item}' in bundle '{bundle}': {attrs}"
+            ).format(
+                item=item_id,
+                bundle=bundle.name,
+                attrs=", ".join(invalid_attributes),
+            ))
+
     @classmethod
     def _validate_name(cls, bundle, name):
         if ":" in name:

Modified: packages/bundlewrap/trunk/bundlewrap/items/pkg_apt.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/items/pkg_apt.py	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/bundlewrap/items/pkg_apt.py	2017-03-27 11:30:44 UTC (rev 13933)
@@ -3,7 +3,9 @@
 
 from pipes import quote
 
+from bundlewrap.exceptions import BundleError
 from bundlewrap.items.pkg import Pkg
+from bundlewrap.utils.text import mark_for_translation as _
 
 
 class AptPkg(Pkg):
@@ -13,28 +15,59 @@
     BLOCK_CONCURRENT = ["pkg_apt"]
     BUNDLE_ATTRIBUTE_NAME = "pkg_apt"
     ITEM_TYPE_NAME = "pkg_apt"
+    WHEN_CREATING_ATTRIBUTES = {
+        'start_service': True,
+    }
 
     def pkg_all_installed(self):
         result = self.node.run("dpkg -l | grep '^ii'")
         for line in result.stdout.decode('utf-8').strip().split("\n"):
-            yield line[4:].split()[0].split(":")[0]
+            pkg_name = line[4:].split()[0].replace(":", "_")
+            yield "{}:{}".format(self.ITEM_TYPE_NAME, pkg_name)
 
     def pkg_install(self):
+        runlevel = "" if self.when_creating['start_service'] else "RUNLEVEL=1 "
         self.node.run(
+            runlevel +
             "DEBIAN_FRONTEND=noninteractive "
             "apt-get -qy -o Dpkg::Options::=--force-confold --no-install-recommends "
-            "install {}".format(quote(self.name))
+            "install {}".format(quote(self.name.replace("_", ":")))
         )
 
     def pkg_installed(self):
         result = self.node.run(
-            "dpkg -s {} | grep '^Status: '".format(quote(self.name)),
+            "dpkg -s {} | grep '^Status: '".format(quote(self.name.replace("_", ":"))),
             may_fail=True,
         )
         return result.return_code == 0 and " installed" in result.stdout_text
 
+    @staticmethod
+    def pkg_in_cache(pkgid, cache):
+        pkgtype, pkgname = pkgid.split(":")
+        if "_" in pkgname:
+            return pkgid in cache
+        else:
+            for cached_pkgid in cache:
+                if cached_pkgid is None:
+                    continue
+                if cached_pkgid == pkgid or cached_pkgid.startswith(pkgid + ":"):
+                    return True
+            return False
+
     def pkg_remove(self):
         self.node.run(
             "DEBIAN_FRONTEND=noninteractive "
-            "apt-get -qy purge {}".format(quote(self.name))
+            "apt-get -qy purge {}".format(quote(self.name.replace("_", ":")))
         )
+
+    @classmethod
+    def validate_attributes(cls, bundle, item_id, attributes):
+        super(AptPkg, cls).validate_attributes(bundle, item_id, attributes)
+
+        if not isinstance(attributes.get('when_creating', {}).get('start_service', True), bool):
+            raise BundleError(_(
+                "expected boolean for 'start_service' on {item} in bundle '{bundle}'"
+            ).format(
+                bundle=bundle.name,
+                item=item_id,
+            ))

Modified: packages/bundlewrap/trunk/bundlewrap/items/pkg_dnf.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/items/pkg_dnf.py	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/bundlewrap/items/pkg_dnf.py	2017-03-27 11:30:44 UTC (rev 13933)
@@ -17,7 +17,7 @@
     def pkg_all_installed(self):
         result = self.node.run("dnf -d0 -e0 list installed")
         for line in result.stdout.decode('utf-8').strip().split("\n"):
-            yield line.split()[0].split(".")[0]
+            yield "{}:{}".format(self.ITEM_TYPE_NAME, line.split()[0].split(".")[0])
 
     def pkg_install(self):
         self.node.run("dnf -d0 -e0 -y install {}".format(quote(self.name)))

Modified: packages/bundlewrap/trunk/bundlewrap/items/pkg_pacman.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/items/pkg_pacman.py	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/bundlewrap/items/pkg_pacman.py	2017-03-27 11:30:44 UTC (rev 13933)
@@ -28,7 +28,7 @@
     def pkg_all_installed(self):
         pkgs = self.node.run("pacman -Qq").stdout.decode('utf-8')
         for line in pkgs.splitlines():
-            yield line.strip()
+            yield "{}:{}".format(self.ITEM_TYPE_NAME, line.split())
 
     def pkg_install(self):
         if self.attributes['tarball']:

Modified: packages/bundlewrap/trunk/bundlewrap/items/pkg_yum.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/items/pkg_yum.py	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/bundlewrap/items/pkg_yum.py	2017-03-27 11:30:44 UTC (rev 13933)
@@ -17,7 +17,7 @@
     def pkg_all_installed(self):
         result = self.node.run("yum -d0 -e0 list installed")
         for line in result.stdout.decode('utf-8').strip().split("\n"):
-            yield line.split()[0].split(".")[0]
+            yield "{}:{}".format(self.ITEM_TYPE_NAME, line.split()[0].split(".")[0])
 
     def pkg_install(self):
         self.node.run("yum -d0 -e0 -y install {}".format(quote(self.name)))

Modified: packages/bundlewrap/trunk/bundlewrap/repo.py
===================================================================
--- packages/bundlewrap/trunk/bundlewrap/repo.py	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/bundlewrap/repo.py	2017-03-27 11:30:44 UTC (rev 13933)
@@ -514,9 +514,20 @@
                             node=node.name,
                             i=iterations[(node.name, metadata_processor_name)],
                         ))
-                        processed = metadata_processor(
-                            deepcopy_metadata(self._node_metadata_partial[node.name]),
-                        )
+                        try:
+                            processed = metadata_processor(
+                                deepcopy_metadata(self._node_metadata_partial[node.name]),
+                            )
+                        except Exception as exc:
+                            io.stderr(_(
+                                "{x} Exception while executing metadata processor "
+                                "{metaproc} for node {node}:"
+                            ).format(
+                                x=red("!!!"),
+                                metaproc=metadata_processor_name,
+                                node=node.name,
+                            ))
+                            raise exc
                         iterations[(node.name, metadata_processor_name)] += 1
                         if isinstance(processed, tuple) and len(processed) == 2:
                             if processed[1] is True:

Modified: packages/bundlewrap/trunk/debian/changelog
===================================================================
--- packages/bundlewrap/trunk/debian/changelog	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/debian/changelog	2017-03-27 11:30:44 UTC (rev 13933)
@@ -1,6 +1,13 @@
-bundlewrap (2.16.0-1) UNRELEASED; urgency=medium
+bundlewrap (2.17.0-1) unstable; urgency=medium
 
   * New upstream release
+  * List new authors in debian/copyright
+
+ -- Jonathan Carter <jcarter at linux.com>  Mon, 27 Mar 2017 13:07:35 +0200
+
+bundlewrap (2.16.0-1) unstable; urgency=medium
+
+  * New upstream release
   * Use dh-python
 
  -- Jonathan Carter <jcarter at linux.com>  Mon, 20 Mar 2017 12:37:12 +0200

Modified: packages/bundlewrap/trunk/debian/copyright
===================================================================
--- packages/bundlewrap/trunk/debian/copyright	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/debian/copyright	2017-03-27 11:30:44 UTC (rev 13933)
@@ -7,6 +7,8 @@
 Comment: Copyrights are assigned to Torsten Rehn (see: CAA.md)
  Additional author: Peter Hofmann <scm at uninformativ.de>
  Additional author: Tim Buchwaldt <tim at buchwaldt.ws>
+ Additional author: Torsten Rehn <torsten at rehn.email>
+ Additional author: Rico Ullmann <rico at erinnerungsfragmente.de>
 License: GPL-3
 
 Files: debian/*

Modified: packages/bundlewrap/trunk/docs/content/guide/env.md
===================================================================
--- packages/bundlewrap/trunk/docs/content/guide/env.md	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/docs/content/guide/env.md	2017-03-27 11:30:44 UTC (rev 13933)
@@ -6,11 +6,13 @@
 
 You can also use `bw -a ...` to achieve the same effect.
 
+<br>
 
 ## `BW_COLORS`
 
 Colors are enabled by default. Setting this variable to `0` tells BundleWrap to never use any ANSI color escape sequences.
 
+<br>
 
 ## `BW_DEBUG_LOG_DIR`
 
@@ -18,16 +20,19 @@
 
 <div class="alert alert-info">Debug logs are verbose and BundleWrap does not rotate them for you. Putting them on a tmpfs or ramdisk will save your SSD and get rid of old logs every time you reboot your machine.</div>
 
+<br>
 
 ## `BW_HARDLOCK_EXPIRY`
 
 [Hard locks](locks.md) are automatically ignored after some time. By default, it's `"8h"`. You can use this variable to override that default.
 
+<br>
 
 ## `BW_IDENTITY`
 
 When BundleWrap [locks](locks.md) a node, it stores a short description about "you". By default, this is the string `$USER@$HOSTNAME`, e.g. `john at mymachine`. You can use `BW_IDENTITY` to specify a custom string. (No variables will be evaluated in user supplied strings.)
 
+<br>
 
 ## `BW_ITEM_WORKERS` and `BW_NODE_WORKERS`
 
@@ -39,21 +44,25 @@
 
 Note that you should not set these variables to very high values. First, it can cause high memory consumption on your machine. Second, not all SSH servers can handle massive parallelism. Please refer to your OpenSSH documentation on how to tune your servers for these situations.
 
+<br>
 
 ## `BW_REPO_PATH`
 
 Set this to a path pointing to your BundleWrap repository. If unset, the current working directory is used. Can be overridden with `bw --repository PATH`. Keep in mind that `bw` will also look for a repository in all parent directories until it finds one.
 
+<br>
 
 ## `BW_SOFTLOCK_EXPIRY`
 
 [Soft locks](locks.md) are automatically removed from nodes after some time. By default, it's `"8h"`. You can use this variable to override that default.
 
+<br>
 
 ## `BW_SSH_ARGS`
 
 Extra arguments to include in every call to `ssh` BundleWrap makes. Set this to "-F ~/.ssh/otherconf" to use a different SSH config with BundleWrap.
 
+<br>
 
 ## `BW_TABLE_STYLE`
 
@@ -64,6 +73,7 @@
 <tr><td><code>grep</code></td><td>make output more <code>grep</code>- and <code>cut</code>-friendly</td></tr>
 </table>
 
+<br>
 
 ## `BW_VAULT_DUMMY_MODE`
 

Modified: packages/bundlewrap/trunk/docs/content/guide/installation.md
===================================================================
--- packages/bundlewrap/trunk/docs/content/guide/installation.md	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/docs/content/guide/installation.md	2017-03-27 11:30:44 UTC (rev 13933)
@@ -38,7 +38,7 @@
 
 <pre><code class="nohighlight">pip install -e /opt/bundlewrap</code></pre>
 
-You can now try running the `bw` command line utility::
+You can now try running the `bw` command line utility:
 
 <pre><code class="nohighlight">bw --help</code></pre>
 

Modified: packages/bundlewrap/trunk/docs/content/guide/item_file_templates.md
===================================================================
--- packages/bundlewrap/trunk/docs/content/guide/item_file_templates.md	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/docs/content/guide/item_file_templates.md	2017-03-27 11:30:44 UTC (rev 13933)
@@ -6,7 +6,7 @@
 
 <pre><code class="nohighlight">Hello, this is ${node.name}!</code></pre>
 
-After template rendering, it would look like this::
+After template rendering, it would look like this:
 
 <pre><code class="nohighlight">Hello, this is myexamplenodename!</code></pre>
 

Modified: packages/bundlewrap/trunk/docs/content/guide/quickstart.md
===================================================================
--- packages/bundlewrap/trunk/docs/content/guide/quickstart.md	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/docs/content/guide/quickstart.md	2017-03-27 11:30:44 UTC (rev 13933)
@@ -85,14 +85,14 @@
 
 	files = {
 	    '/etc/motd': {
-	        'source': "etc/motd",
+	        'content_type': 'mako',  # use the Mako template engine for this file
+	        'source': "mymotd",  # filename of the template
 	    },
 	}
 
-Then write the file template::
+Then write the file template:
 
-<pre><code class="nohighlight">mkdir bundles/mybundle/files/etc
-vim bundles/mybundle/files/etc/motd</code></pre>
+<pre><code class="nohighlight">vim bundles/mybundle/files/mymotd</code></pre>
 
 You can use this for example content:
 

Modified: packages/bundlewrap/trunk/docs/content/items/pkg_apt.md
===================================================================
--- packages/bundlewrap/trunk/docs/content/items/pkg_apt.md	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/docs/content/items/pkg_apt.md	2017-03-27 11:30:44 UTC (rev 13933)
@@ -6,9 +6,14 @@
         "foopkg": {
             "installed": True,  # default
         },
-        "bar": {
+        "bar_i386": {  # i386 multiarch variant of the "bar" package
             "installed": False,
         },
+        "awesome-daemon": {
+            "when_creating": {
+                "start_service": False,
+            },
+        },
     }
 
 <br>
@@ -22,3 +27,11 @@
 ### installed
 
 `True` when the package is expected to be present on the system; `False` if it should be purged.
+
+### when\_creating
+
+These attributes are only enforced during the creation of the item on the node (in this case this means when a package is installed). They are ignored in subsequent runs of `bw apply`.
+
+#### start\_service
+
+By default, daemons will be auto-started on systems like Debian or Ubuntu. This happens right after the package has been installed. You might want to set `start_service` to `False` to avoid this. This might be necessary if BundleWrap must place some more config files on the node before a daemon can actually be started.

Modified: packages/bundlewrap/trunk/docs/mkdocs.yml
===================================================================
--- packages/bundlewrap/trunk/docs/mkdocs.yml	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/docs/mkdocs.yml	2017-03-27 11:30:44 UTC (rev 13933)
@@ -1,10 +1,9 @@
 site_name: BundleWrap
 docs_dir: content
 site_dir: build
-theme: cinder
 repo_url: "https://github.com/bundlewrap/bundlewrap"
 remote_name: github
-copyright: "BundleWrap is published under the <a href='https://github.com/bundlewrap/bundlewrap/blob/master/LICENSE'>GPL license</a>"
+copyright: "BundleWrap is published under the <a href='https://github.com/bundlewrap/bundlewrap/blob/master/LICENSE'>GPL license</a>."
 google_analytics: ['UA-33891245-2', 'docs.bundlewrap.org']
 pages:
 - <i class="fa fa-home"></i>: index.md

Modified: packages/bundlewrap/trunk/requirements.txt
===================================================================
--- packages/bundlewrap/trunk/requirements.txt	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/requirements.txt	2017-03-27 11:30:44 UTC (rev 13933)
@@ -1,5 +1,4 @@
 # deps in this file are for local dev purposes only
 mkdocs
-mkdocs-cinder
 pytest
 wheel

Modified: packages/bundlewrap/trunk/setup.py
===================================================================
--- packages/bundlewrap/trunk/setup.py	2017-03-27 07:53:25 UTC (rev 13932)
+++ packages/bundlewrap/trunk/setup.py	2017-03-27 11:30:44 UTC (rev 13933)
@@ -16,7 +16,7 @@
 
 setup(
     name="bundlewrap",
-    version="2.16.0",
+    version="2.17.0",
     description="Config management with Python",
     long_description=(
         "By allowing for easy and low-overhead config management, BundleWrap fills the gap between complex deployments using Chef or Puppet and old school system administration over SSH.\n"




More information about the Python-apps-commits mailing list