From 2fb61b9c9fad9fdace6cfc3b0b827a225341f352 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Fri, 16 Sep 2016 00:32:01 +0900 Subject: [PATCH 01/12] SaltStack's code of conduct --- CONDUCT.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 CONDUCT.md diff --git a/CONDUCT.md b/CONDUCT.md new file mode 100644 index 000000000000..fc14ecd4f465 --- /dev/null +++ b/CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at conduct@saltstack.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From b815c985770fbd58c4b158ea37c85dd3e5006508 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 15 Sep 2016 15:30:07 -0500 Subject: [PATCH 02/12] Add note about yumpkg.check_db removal in Boron Resolves #36292. --- doc/topics/releases/2016.3.0.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/topics/releases/2016.3.0.rst b/doc/topics/releases/2016.3.0.rst index 6150cddfd2c4..c39844e12222 100644 --- a/doc/topics/releases/2016.3.0.rst +++ b/doc/topics/releases/2016.3.0.rst @@ -37,6 +37,8 @@ Backwards-incompatible Changes fileserver under ``salt://_runners``, ``salt://_output``, etc. and sync them using the functions in the new :mod:`saltutil runner `. +- The :py:func:`pkg.check_db ` function has been + removed for yum/dnf. Core Changes From a4bbd5e3d716651ec617b9551b0e33450802b623 Mon Sep 17 00:00:00 2001 From: Nicole Thomas Date: Thu, 15 Sep 2016 14:37:53 -0600 Subject: [PATCH 03/12] Add resize2fs unit test from blockdev_test to disk_test (#36346) The blockdev module is being slowly deprecated and its functions moved to to the disk module instead. There is a test for resize2fs in the blockdev_test file in the 2015.8 branch (which matches the resize2fs function in the blockdev module), but this function was moved to the disk file in 2016.3. The test was never moved over. I discovered this during a merge forward in #36344. This PR adds the test from 2015.8 blockdev_test to the 2016.3 disk_test.py, and is adjusted to work with the disk module accordingly. --- tests/unit/modules/disk_test.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/unit/modules/disk_test.py b/tests/unit/modules/disk_test.py index 8cf4d3613d19..097b24831337 100644 --- a/tests/unit/modules/disk_test.py +++ b/tests/unit/modules/disk_test.py @@ -7,13 +7,14 @@ from __future__ import absolute_import # Import Salt Testing libs -from salttesting import TestCase +from salttesting import skipIf, TestCase from salttesting.helpers import ensure_in_syspath from salttesting.mock import MagicMock, patch ensure_in_syspath('../../') +# Import Salt libs from salt.modules import disk -#usage_size = {'filesystem': None,'1K-blocks':10000,'used':10000,'available':10000,'capacity':10000} +import salt.utils STUB_DISK_USAGE = { '/': {'filesystem': None, '1K-blocks': 10000, 'used': 10000, 'available': 10000, 'capacity': 10000}, @@ -130,6 +131,17 @@ def test_tune(self): python_shell=False ) + @skipIf(not salt.utils.which('resize2fs'), 'resize2fs not found') + def test_resize2fs(self): + ''' + unit tests for disk.resize2fs + ''' + device = '/dev/sdX1' + mock = MagicMock() + with patch.dict(disk.__salt__, {'cmd.run_all': mock}): + disk.resize2fs(device) + mock.assert_called_once_with('resize2fs {0}'.format(device), python_shell=False) + if __name__ == '__main__': from integration import run_tests From 19eb84860e759c62521db9882613ab809807d1d1 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Thu, 15 Sep 2016 15:38:42 -0500 Subject: [PATCH 04/12] remove help message from glance module (#36345) --- salt/modules/glance.py | 1 - 1 file changed, 1 deletion(-) diff --git a/salt/modules/glance.py b/salt/modules/glance.py index c7e3e4bef295..7ae3730d5c2e 100644 --- a/salt/modules/glance.py +++ b/salt/modules/glance.py @@ -162,7 +162,6 @@ def get(key, default=None): log.debug('Calling keystoneclient.v2_0.client.Client(' + '{0}, **{1})'.format(ks_endpoint, kwargs)) keystone = kstone.Client(**kwargs) - log.debug(help(keystone.get_token)) kwargs['token'] = keystone.get_token(keystone.session) # This doesn't realy prevent the password to show up # in the minion log as keystoneclient.session is From ef128ad0b0b02b8de91db4274564ee039f6a1ede Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 15 Sep 2016 15:39:46 -0500 Subject: [PATCH 05/12] Return None when find_file identifies the path as a directory (#36342) This fixes a traceback in the LocalClient when you try to use cp.cache_file on a directory instead of a file. --- salt/utils/gitfs.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index cefd3d964dda..112e971c49ba 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -874,6 +874,9 @@ def find_file(self, path, tgt_env): path = salt.utils.path_join(os.path.dirname(path), link_tgt) else: blob = file_blob + if isinstance(blob, git.Tree): + # Path is a directory, not a file. + blob = None break except KeyError: # File not found or repo_path points to a directory @@ -1417,6 +1420,9 @@ def find_file(self, path, tgt_env): else: oid = tree[path].oid blob = self.repo[oid] + if isinstance(blob, pygit2.Tree): + # Path is a directory, not a file. + blob = None break except KeyError: blob = None @@ -1792,6 +1798,9 @@ def find_file(self, path, tgt_env): path = salt.utils.path_join(os.path.dirname(path), link_tgt) else: blob = self.repo.get_object(oid) + if isinstance(blob, dulwich.objects.Tree): + # Path is a directory, not a file. + blob = None break except KeyError: blob = None From fee3be4d261e8b6d44536f544868b59b8c11fe09 Mon Sep 17 00:00:00 2001 From: Julien BONACHERA Date: Thu, 15 Sep 2016 22:42:02 +0200 Subject: [PATCH 06/12] Use infoblox_* values if present in arguments (#36339) --- salt/states/infoblox.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/states/infoblox.py b/salt/states/infoblox.py index 38e9e59f21ca..6065a42d7eeb 100644 --- a/salt/states/infoblox.py +++ b/salt/states/infoblox.py @@ -138,9 +138,9 @@ def present(name, value, record_type, dns_view, - infoblox_server=None, - infoblox_user=None, - infoblox_password=None, + infoblox_server=infoblox_server, + infoblox_user=infoblox_user, + infoblox_password=infoblox_password, infoblox_api_version='v1.4.2', sslVerify=sslVerify) if retval: From 9451141b3f7c6bbd97979c16c8126d422da89df5 Mon Sep 17 00:00:00 2001 From: Julien Cigar Date: Thu, 15 Sep 2016 22:53:09 +0200 Subject: [PATCH 07/12] set __virtualname__ to 'service' (#36330) --- salt/modules/daemontools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/salt/modules/daemontools.py b/salt/modules/daemontools.py index bb34043cdec8..1887ce8ffc1a 100644 --- a/salt/modules/daemontools.py +++ b/salt/modules/daemontools.py @@ -31,6 +31,8 @@ log = logging.getLogger(__name__) +__virtualname__ = 'service' + VALID_SERVICE_DIRS = [ '/service', '/var/service', @@ -46,7 +48,7 @@ def __virtual__(): # Ensure that daemontools is installed properly. BINS = frozenset(('svc', 'supervise', 'svok')) - return all(salt.utils.which(b) for b in BINS) + return __virtualname__ if all(salt.utils.which(b) for b in BINS) else False def _service_path(name): From fbbe9ec571b87a2791d148d38c9e0719c1050a5a Mon Sep 17 00:00:00 2001 From: Michael Stella Date: Thu, 15 Sep 2016 17:12:41 -0400 Subject: [PATCH 08/12] Quote postgres privilege target names (#36249) * Quote postgres privilege target names Postgres lets you put characters in table/database names which you then must quote. So we should always quote. * Updating unit tests * Also quote role names. Role names can also have dashes (or others) in them, so we must also quote them. --- salt/modules/postgres.py | 12 ++++++------ tests/unit/modules/postgres_test.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/salt/modules/postgres.py b/salt/modules/postgres.py index dd2068b08604..0e863d4ca61b 100644 --- a/salt/modules/postgres.py +++ b/salt/modules/postgres.py @@ -2865,22 +2865,22 @@ def privileges_grant(name, _grants = ','.join(_privs) if object_type in ['table', 'sequence']: - on_part = '{0}.{1}'.format(prepend, object_name) + on_part = '{0}."{1}"'.format(prepend, object_name) else: - on_part = object_name + on_part = '"{0}"'.format(object_name) if grant_option: if object_type == 'group': - query = 'GRANT {0} TO {1} WITH ADMIN OPTION'.format( + query = 'GRANT {0} TO "{1}" WITH ADMIN OPTION'.format( object_name, name) else: - query = 'GRANT {0} ON {1} {2} TO {3} WITH GRANT OPTION'.format( + query = 'GRANT {0} ON {1} {2} TO "{3}" WITH GRANT OPTION'.format( _grants, object_type.upper(), on_part, name) else: if object_type == 'group': - query = 'GRANT {0} TO {1}'.format(object_name, name) + query = 'GRANT {0} TO "{1}"'.format(object_name, name) else: - query = 'GRANT {0} ON {1} {2} TO {3}'.format( + query = 'GRANT {0} ON {1} {2} TO "{3}"'.format( _grants, object_type.upper(), on_part, name) ret = _psql_prepare_and_run(['-c', query], diff --git a/tests/unit/modules/postgres_test.py b/tests/unit/modules/postgres_test.py index a74f27f5c44e..14f8d3d6ab28 100644 --- a/tests/unit/modules/postgres_test.py +++ b/tests/unit/modules/postgres_test.py @@ -1240,7 +1240,7 @@ def test_privileges_grant_table(self): password='testpassword' ) - query = 'GRANT ALL ON TABLE public.awl TO baruwa WITH GRANT OPTION' + query = 'GRANT ALL ON TABLE public."awl" TO "baruwa" WITH GRANT OPTION' postgres._run_psql.assert_called_once_with( ['/usr/bin/pgsql', '--no-align', '--no-readline', @@ -1267,7 +1267,7 @@ def test_privileges_grant_table(self): password='testpassword' ) - query = 'GRANT ALL ON TABLE public.awl TO baruwa' + query = 'GRANT ALL ON TABLE public."awl" TO "baruwa"' postgres._run_psql.assert_called_once_with( ['/usr/bin/pgsql', '--no-align', '--no-readline', @@ -1298,7 +1298,7 @@ def test_privileges_grant_group(self): password='testpassword' ) - query = 'GRANT admins TO baruwa WITH ADMIN OPTION' + query = 'GRANT admins TO "baruwa" WITH ADMIN OPTION' postgres._run_psql.assert_called_once_with( ['/usr/bin/pgsql', '--no-align', '--no-readline', @@ -1324,7 +1324,7 @@ def test_privileges_grant_group(self): password='testpassword' ) - query = 'GRANT admins TO baruwa' + query = 'GRANT admins TO "baruwa"' postgres._run_psql.assert_called_once_with( ['/usr/bin/pgsql', '--no-align', '--no-readline', From 275319193a5d173fe4b14f7ef8f663450e4d2c2a Mon Sep 17 00:00:00 2001 From: rallytime Date: Thu, 15 Sep 2016 16:34:05 -0600 Subject: [PATCH 09/12] Check for Ign/Hit membership instead of == in aptpkg.refresh_db --- salt/modules/aptpkg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py index d3db2b1a3e05..cd27a2f5cd3f 100644 --- a/salt/modules/aptpkg.py +++ b/salt/modules/aptpkg.py @@ -361,9 +361,9 @@ def refresh_db(): # Strip filesize from end of line ident = re.sub(r' \[.+B\]$', '', ident) ret[ident] = True - elif cols[0] == 'Ign': + elif 'Ign' in cols[0]: ret[ident] = False - elif cols[0] == 'Hit': + elif 'Hit' in cols[0]: ret[ident] = None return ret From 70ffdafbf0c2283a959a08babb3e41cea5388584 Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 14 Sep 2016 19:03:13 +0900 Subject: [PATCH 10/12] Schema test requires jsonschema 2.5.0 or above --- tests/unit/utils/config_test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/utils/config_test.py b/tests/unit/utils/config_test.py index 7ea8d2d4598a..66a6cb008423 100644 --- a/tests/unit/utils/config_test.py +++ b/tests/unit/utils/config_test.py @@ -6,6 +6,8 @@ # Import python libs from __future__ import absolute_import +from distutils.version import LooseVersion + # Import Salt Testing Libs from salttesting import TestCase, skipIf from salttesting.helpers import ensure_in_syspath @@ -20,7 +22,9 @@ import jsonschema import jsonschema.exceptions HAS_JSONSCHEMA = True + JSONSCHEMA_VERSION = jsonschema.__version__ except ImportError: + JSONSCHEMA_VERSION = '' HAS_JSONSCHEMA = False @@ -746,6 +750,7 @@ def test_ipv4_config(self): ) @skipIf(HAS_JSONSCHEMA is False, 'The \'jsonschema\' library is missing') + @skipIf(HAS_JSONSCHEMA and LooseVersion(jsonschema.__version__) <= LooseVersion('2.5.0'), 'Requires jsonschema 2.5.0 or greater') def test_ipv4_config_validation(self): class TestConf(schema.Schema): item = schema.IPv4Item(title='Item', description='Item description') From 3f308d7694819e1a52cd56b0e6ce0a015b7660a2 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Fri, 16 Sep 2016 17:23:20 +0300 Subject: [PATCH 11/12] postgres_extension: report changes when an extension was installed (#36335) * postgres_extension: report changes when extension was installed or upgraded * postgres_extension state: fix unit tests --- salt/states/postgres_extension.py | 16 ++++++++-------- tests/unit/states/postgres_test.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/salt/states/postgres_extension.py b/salt/states/postgres_extension.py index 16bfb55f96f7..22ba34c911fe 100644 --- a/salt/states/postgres_extension.py +++ b/salt/states/postgres_extension.py @@ -51,13 +51,13 @@ def present(name, The name of the extension to manage if_not_exists - Add a if_not_exists switch to the ddl statement + Add an `IF NOT EXISTS` parameter to the DDL statement schema Schema to install the extension into ext_version - version to install + Version to install from_version Old extension version if already installed @@ -69,10 +69,10 @@ def present(name, Database to act on db_user - database username if different from config or default + Database username if different from config or default db_password - user password if any password for a specified user + User password if any password for a specified user db_host Database host if different from config or default @@ -87,10 +87,10 @@ def present(name, db_args = { 'maintenance_db': maintenance_db, 'runas': user, - 'host': db_host, 'user': db_user, - 'port': db_port, 'password': db_password, + 'host': db_host, + 'port': db_port, } # check if extension exists mode = 'create' @@ -134,11 +134,11 @@ def present(name, else: suffix = 'ed' ret['comment'] = 'The extension {0} has been {1}{2}'.format(name, mode, suffix) + ret['changes'][name] = '{0}{1}'.format(mode.capitalize(), suffix) elif cret is not None: ret['comment'] = 'Failed to {1} extension {0}'.format(name, mode) ret['result'] = False - else: - ret['result'] = True + return ret diff --git a/tests/unit/states/postgres_test.py b/tests/unit/states/postgres_test.py index 1c327d96fca9..0ffc186378e1 100644 --- a/tests/unit/states/postgres_test.py +++ b/tests/unit/states/postgres_test.py @@ -370,7 +370,7 @@ def test_present(self): self.assertEqual( ret, {'comment': 'The extension foo has been installed', - 'changes': {}, 'name': 'foo', 'result': True} + 'changes': {'foo': 'Installed'}, 'name': 'foo', 'result': True} ) ret = postgres_extension.present('foo') self.assertEqual( @@ -382,7 +382,7 @@ def test_present(self): self.assertEqual( ret, {'comment': 'The extension foo has been upgraded', - 'changes': {}, 'name': 'foo', 'result': True} + 'changes': {'foo': 'Upgraded'}, 'name': 'foo', 'result': True} ) @patch.dict(OPTS, {'test': True}) From 0db2b67ed4ee136922b536a80d34121bc6e8c2ee Mon Sep 17 00:00:00 2001 From: rallytime Date: Fri, 16 Sep 2016 13:25:08 -0600 Subject: [PATCH 12/12] Whitespace fix --- tests/unit/modules/disk_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/modules/disk_test.py b/tests/unit/modules/disk_test.py index 4b7384a56e31..ec162f74597f 100644 --- a/tests/unit/modules/disk_test.py +++ b/tests/unit/modules/disk_test.py @@ -151,7 +151,7 @@ def test_fstype(self): mock = MagicMock(return_value='FSTYPE\n{0}'.format(fs_type)) with patch.dict(disk.__salt__, {'cmd.run': mock}): self.assertEqual(disk.fstype(device), fs_type) - + @skipIf(not salt.utils.which('resize2fs'), 'resize2fs not found') def test_resize2fs(self): '''