From 74678923b88a45c0dca36e42a69588b0929221e9 Mon Sep 17 00:00:00 2001 From: Nicole Thomas Date: Mon, 22 Aug 2016 13:04:33 -0600 Subject: [PATCH 1/2] Fixup doc formatting for the sqs_events engine (#35663) Fixes #35509 --- salt/engines/sqs_events.py | 82 ++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/salt/engines/sqs_events.py b/salt/engines/sqs_events.py index ed4b9b207e..13dcdc2d1b 100644 --- a/salt/engines/sqs_events.py +++ b/salt/engines/sqs_events.py @@ -6,42 +6,54 @@ Note that long polling is utilized to avoid excessive CPU usage. .. versionadded:: 2015.8.0 -:configuration: - This engine can be run on the master or on a minion. - - Example Config: - engines: - - sqs_events: - queue: test - profile: my-sqs-profile #optional - - Explicit sqs credentials are accepted but this engine can also utilize - IAM roles assigned to the instance through Instance Profiles. Dynamic - credentials are then automatically obtained from AWS API and no further - configuration is necessary. More Information available at:: - - http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html - - If IAM roles are not used you need to specify them either in a pillar or - in the config file of the master or minion, as appropriate:: - - sqs.keyid: GKTADJGHEIQSXMKKRBJ08H - sqs.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs - - A region may also be specified in the configuration:: - - sqs.region: us-east-1 - - If a region is not specified, the default is us-east-1. - - It's also possible to specify key, keyid and region via a profile: - - myprofile: - keyid: GKTADJGHEIQSXMKKRBJ08H - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs - region: us-east-1 - :depends: boto + +Configuration +============= + +This engine can be run on the master or on a minion. + +Example Config: + +.. code-block:: yaml + + engines: + - sqs_events: + queue: test + profile: my-sqs-profile #optional + +Explicit sqs credentials are accepted but this engine can also utilize +IAM roles assigned to the instance through Instance Profiles. Dynamic +credentials are then automatically obtained from AWS API and no further +configuration is necessary. More Information available at:: + + http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html + +If IAM roles are not used you need to specify them either in a pillar or +in the config file of the master or minion, as appropriate: + +.. code-block:: yaml + + sqs.keyid: GKTADJGHEIQSXMKKRBJ08H + sqs.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs + +A region may also be specified in the configuration: + +.. code-block:: yaml + + sqs.region: us-east-1 + +If a region is not specified, the default is us-east-1. + +It's also possible to specify key, keyid and region via a profile: + +.. code-block:: yaml + + myprofile: + keyid: GKTADJGHEIQSXMKKRBJ08H + key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs + region: us-east-1 + ''' # Import python libs From d76659a63a187bad32922f74b84d82c2e35b5acc Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Mon, 22 Aug 2016 20:21:32 -0500 Subject: [PATCH 2/2] Don't use six.text_type() in salt.utils.gitfs For Python 2, Pygit2 (as well as others) store unicode strings as bytes (e.g. ``'\xd0\x94'``), not as unicode strings. This can result in a ``UnicodeDecodeError`` being raised when ``os.path.join()`` is invoked and Python attempts to decode the bytestring. This commit fixes the issue by using ``str()`` to force config values to be strings, rather than ``six.text_type()``. Resolves #35630. --- salt/utils/gitfs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index 7d0a7390cc..368247a3dc 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -153,7 +153,7 @@ class GitProvider(object): self.id = next(iter(remote)) self.get_url() per_remote_conf = dict( - [(key, six.text_type(val)) for key, val in + [(key, str(val)) for key, val in six.iteritems(salt.utils.repack_dictlist(remote[self.id]))] ) if not per_remote_conf: @@ -2016,7 +2016,7 @@ class GitBase(object): 'a bug, please report it.'.format(key) ) failhard(self.role) - per_remote_defaults[param] = six.text_type(self.opts[key]) + per_remote_defaults[param] = str(self.opts[key]) self.remotes = [] for remote in remotes: @@ -2132,7 +2132,7 @@ class GitBase(object): continue except TypeError: # remote was non-string, try again - if not fnmatch.fnmatch(repo.url, six.text_type(remote)): + if not fnmatch.fnmatch(repo.url, str(remote)): continue success, failed = repo.clear_lock(lock_type=lock_type) cleared.extend(success) @@ -2177,7 +2177,7 @@ class GitBase(object): continue except TypeError: # remote was non-string, try again - if not fnmatch.fnmatch(repo.url, six.text_type(remote)): + if not fnmatch.fnmatch(repo.url, str(remote)): continue success, failed = repo.lock() locked.extend(success)