Commit graph

282 commits

Author SHA1 Message Date
Erik Johnson
002aa88a97
Replace yaml usage with a helper to ensure unicode is handled properly
Without allow_unicode=True, unicode characters are processed through the
str representer and on Python 2 are dumped as a Unicode code point (i.e.
a literal \u0414). This commit makes allow_unicode=True the default in
our salt.utils.yamlloader.safe_dump() helper. It also adds a new
salt.utils.yamlloader.dump() helper which wraps yaml.dump() and also
makes allow_unicode=True the default.

To make importing and using our custom yaml loader/dumper easier, a
convenience module called salt.utils.yaml has been added, which does a
wildcard import from both salt.utils.yamldumper and
salt.utils.yamlloader.

Refs to yaml.load/dump and yaml.safe_load/safe_dump have been updated to
salt.utils.yaml, to ensure that unicode is handled properly.
2018-01-03 14:14:21 -06:00
Erik Johnson
877abb89d0
Complete the salt.utils refactor
This moves the remaining 30 functions from salt.utils to new locations.
2017-10-15 09:43:31 -05:00
rallytime
6ca3607770 Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/engines/slack.py
  - salt/modules/win_pkg.py
  - salt/utils/versions.py
2017-08-18 09:28:26 -04:00
rallytime
8a0f948e4a Merge branch '2016.11' into '2017.7'
Conflicts:
  - salt/utils/versions.py
  - tests/unit/modules/test_boto_elb.py
  - tests/unit/modules/test_boto_secgroup.py
  - tests/unit/states/test_boto_vpc.py
2017-08-17 09:10:31 -04:00
Daniel Wallace
253e216a8d fix IP address spelling 2017-08-15 12:30:03 -06:00
Daniel Wallace
bd63074e7a create new ip address before checking list of allocated ips
This will help prevent a race condition of all cloud servers being built in
parallel trying to build with the same floating ip address.
2017-08-15 09:19:05 -06:00
Erik Johnson
3184168365 Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.

A summary of the changes in this PR is as follows:

* Moves the following functions from `salt.utils` to new locations
  (including a deprecation warning if invoked from `salt.utils`):
  `to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
  `dequote`, `is_hex`, `is_bin_str`, `rand_string`,
  `contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
  `which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
  `is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
  `is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
  `is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
  `salt/utils/__init__.py` for better organization, so we can keep the
  deprecated ones separate from the ones yet to be deprecated as we
  continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
  unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
  import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
  accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
  such that it returns a string matching the passed size. Previously
  this function would get `size` bytes from `os.urandom()`,
  base64-encode it, and return the result, which would in most cases not
  be equal to the passed size.
2017-08-08 13:33:43 -05:00
rallytime
ccf790a83f Update all references for moved functions to use "files" util
- fopen
- flopen
- fpopen
- safe_rm
- is_empty
- is_fcntl_available
2017-07-18 10:31:01 -06:00
rallytime
16a2747d7d Merge branch '2016.11' into '2017.7'
Conflicts:
  - pkg/windows/buildenv/salt.bat
  - salt/modules/pillar.py
  - salt/utils/openstack/nova.py
  - tests/unit/cloud/clouds/test_dimensiondata.py
  - tests/unit/cloud/clouds/test_gce.py
2017-06-14 13:31:42 -06:00
Enquier
293bc64158 Removed empty debug log 2017-06-08 22:53:54 -06:00
CEG
3d9871fe11 Cleaning up, removing debugging tests 2017-06-07 13:49:40 -06:00
CEG
c78e5feea9 Fixing error message 2017-06-07 12:46:13 -06:00
CEG
404dffb6b8 Debugging variable format 2017-06-07 12:45:38 -06:00
CEG
6fa3b976a5 removing string call 2017-06-07 12:37:00 -06:00
CEG
005995e1b0 modifying variable calls 2017-06-07 12:35:49 -06:00
CEG
9e5e7a38ec Testing variable changes 2017-06-07 12:32:50 -06:00
CEG
05e240f37f Debugging Format of floating_ip variable 2017-06-07 12:30:19 -06:00
CEG
6f66c9d10c Fixing response of floating_ip_show to align with other floating ip's. Spelling fix 2017-06-07 11:33:56 -06:00
CEG
58459adbe8 Adding ability to set a Floating IP by a specific IP address 2017-06-07 11:25:43 -06:00
rallytime
655e5fa1d3 Pass in a list as final arg to cloud.filter_event utils call
The third argument that is passed to the salt.utils.cloud.filter_event
function is supposed to be a list. Most of the places calling this function
were using `foo.keys()`, which returns a list in PY2. But, in PY3, this
is a dictionary view.

This change updates the places where `filter_event` is using `.keys()` and
instead wraps the dict with list(). It also adds some extra type checking
in the filter_event function in case a list is not passed in.
2017-06-01 12:50:42 -06:00
rallytime
a69cd74f75 Merge branch '2016.11' into 'nitrogen'
Conflicts:
  - salt/cloud/clouds/nova.py
  - salt/spm/__init__.py
2017-04-28 09:23:42 -06:00
Nicole Thomas
a622518ad2 Merge pull request #40929 from rallytime/bp-37696
Back-port #37696 to 2016.11
2017-04-27 11:43:25 -06:00
Nicole Thomas
26be306b5c Merge pull request #40752 from Enquier/nova_ssl_2
Add ability to specify a custom SSL certificate or disable SSL verification in KeystoneAuth v3
2017-04-27 11:29:08 -06:00
Nicole Thomas
1a28722c5a Pylint fix 2017-04-27 10:33:15 -06:00
yangang
8e0a9864c5 if vm state is not ACTIVE, associate floating ip to it will fail.So we should wait for state of vm is ACTIVE,then associate the assigned floating ip to it 2017-04-27 10:33:15 -06:00
CEG
817f49296e fixing lint errors in keystone auth error 2017-04-26 11:05:53 -06:00
CEG
f683636c61 fix trailing whitespace 2017-04-26 11:05:07 -06:00
rallytime
5372f25fde Merge branch '2016.11' into 'nitrogen'
Conflicts:
  - salt/cloud/clouds/rackspace.py
  - tests/unit/cloud/clouds/test_dimensiondata.py
2017-04-24 15:35:28 -06:00
Bo Maryniuk
b2e85de85d Fix lint, typos and readability 2017-04-22 10:19:05 +02:00
Bo Maryniuk
61558f08e7 Lintfix E0602 2017-04-22 10:08:20 +02:00
Bo Maryniuk
181d0780d0 Lintfix 2017-04-22 10:08:19 +02:00
Bo Maryniuk
8e9ce1a68d Move out nested function to be unit-testable 2017-04-22 10:08:19 +02:00
CEG
4a70b8c0cc fixing minor error in security_groups
security groups parser had incorrect split action which caused errors
2017-04-18 15:00:35 -06:00
CEG
c9d6f8e5ed adding note in documentation 2017-04-18 14:47:29 -06:00
CEG
c24dfe3fba adding support for cacert verification 2017-04-18 14:13:11 -06:00
rallytime
71f3c73150 Merge branch '2016.11' into 'develop'
Conflicts:
  - salt/template.py
  - salt/utils/pycrypto.py
  - tests/integration/modules/test_state.py
  - tests/unit/states/test_artifactory.py
  - tests/unit/test_template.py
2017-04-05 13:02:14 -06:00
Erik Johnson
84ee693006 Nova and openstack don't accept base64-encoded userdata
This fixes my bad copypasta.
2017-04-04 15:41:43 -05:00
Erik Johnson
6a6ef0adf8 Move userdata templating to salt.utils.cloud 2017-04-04 15:41:43 -05:00
Erik Johnson
04f02df5fe Try to read compiled template as StringIO
The fact that PyYAML was the last renderer in the render pipe initially,
masked the fact that template renderers return StringIO instances and
not strings. This commit makes sure that we try reading from the
StringIO first and then fallback to just trying to base64 encode the
userdata value as returned by compile_template().
2017-04-04 15:41:43 -05:00
Erik Johnson
79cc253bbf Only template the userdata_file if explicitly configured to do so 2017-04-04 15:41:43 -05:00
Erik Johnson
cc2186f35a Add templating support for other cloud drivers that support userdata_file 2017-04-04 15:41:43 -05:00
rallytime
52edbffc85 Merge branch '2016.11' into 'develop'
Conflicts:
  - doc/ref/cache/all/index.rst
  - doc/topics/cache/index.rst
  - salt/cache/localfs.py
  - salt/modules/boto_rds.py
  - salt/roster/cloud.py
  - salt/states/virtualenv_mod.py
  - tests/integration/states/test_archive.py
  - tests/unit/modules/test_dockermod.py
  - tests/unit/states/dockerng_test.py
2017-03-28 17:09:30 -06:00
rallytime
77415369cc Merge branch '2016.3' into '2016.11'
Conflicts:
  - salt/states/pkg.py
2017-03-23 16:47:52 -06:00
David Boucha
9f0c9802c2 remove reference to auth_minion.
Support for this option was removed years ago and is no longer needed.
2017-03-23 13:08:51 -06:00
Joseph Hall
dde48b3650 Add event_filter to salt cloud 2017-03-13 15:36:13 -06:00
Pedro Algarvio
7dc6b64689
No need to call .keys() when iterating a dictionary 2017-03-06 14:42:31 +00:00
rallytime
2595ac383d Merge branch '2016.11' into 'develop'
Conflicts:
  - salt/config/__init__.py
  - salt/modules/docker.py
  - salt/states/docker.py
2017-02-22 16:24:36 -07:00
rallytime
c613d19e76 Merge branch '2016.3' into '2016.11'
Conflicts:
  - salt/modules/dockerng.py
  - salt/states/dockerng.py
2017-02-21 13:59:14 -07:00
Daniel Wallace
f829d6f9fc skip false values from preferred_ip 2017-02-16 15:11:08 -06:00
Mike Place
8a4d210959 Merge pull request #39079 from gtmanfred/2016.3
use_keystoneauth should default to False if not specified
2017-01-31 13:12:46 -07:00