Skip to content

Commit

Permalink
Merge pull request #26765 from basepi/merge-forward-2015.8
Browse files Browse the repository at this point in the history
[2015.8] Merge forward from 2015.5 to 2015.8
  • Loading branch information
basepi committed Aug 29, 2015
2 parents eb82c89 + 3b696d9 commit 203cf7a
Show file tree
Hide file tree
Showing 19 changed files with 581 additions and 336 deletions.
7 changes: 4 additions & 3 deletions salt/cloud/clouds/gce.py
Expand Up @@ -99,7 +99,6 @@
from salt import syspaths
from salt.cloud.libcloudfuncs import * # pylint: disable=redefined-builtin,wildcard-import,unused-wildcard-import
from salt.exceptions import (
SaltCloudException,
SaltCloudSystemExit,
)

Expand Down Expand Up @@ -142,27 +141,29 @@ def __virtual__():
pathname = os.path.expanduser(parameters['service_account_private_key'])

if not os.path.exists(pathname):
raise SaltCloudException(
log.error(
'The GCE service account private key {0!r} used in '
'the {1!r} provider configuration does not exist\n'.format(
parameters['service_account_private_key'],
provider
)
)
return False

key_mode = str(
oct(stat.S_IMODE(os.stat(pathname).st_mode))
)

if key_mode not in ('0400', '0600'):
raise SaltCloudException(
log.error(
'The GCE service account private key {0!r} used in '
'the {1!r} provider configuration needs to be set to '
'mode 0400 or 0600\n'.format(
parameters['service_account_private_key'],
provider
)
)
return False

return __virtualname__

Expand Down
34 changes: 32 additions & 2 deletions salt/cloud/clouds/linode.py
Expand Up @@ -39,6 +39,7 @@
from __future__ import absolute_import
import logging
import pprint
import re
import time

# Import Salt Libs
Expand Down Expand Up @@ -1276,8 +1277,8 @@ def update_linode(linode_id, update_args=None):
update_args
The args to update the Linode with. Must be in dictionary form.
'''
if update_args is None:
update_args = {}
if _validate_name(linode_id) is False:
return False

update_args.update({'LinodeID': linode_id})

Expand Down Expand Up @@ -1508,3 +1509,32 @@ def _get_status_id_by_name(status_name):
internal linode VM status name
'''
return LINODE_STATUS.get(status_name, {}).get('code', None)


def _validate_name(name):
'''
Checks if the provided name fits Linode's labeling parameters.
.. versionadded:: 2015.5.6
name
The VM name to validate
'''
name_length = len(name)
regex = re.compile(r'^[a-zA-Z0-9][A-Za-z0-9_-]*[a-zA-Z0-9]$')

if name_length < 3 or name_length > 48:
ret = False
elif not re.match(regex, name):
ret = False
else:
ret = True

if ret is False:
log.warning(
'A Linode label may only contain ASCII letters or numbers, dashes, and '
'underscores, must begin and end with letters or numbers, and be at least '
'three characters in length.'
)

return ret
2 changes: 1 addition & 1 deletion salt/modules/ilo.py
Expand Up @@ -6,7 +6,7 @@
'''
from __future__ import absolute_import

import xml.etree.cElementTree as ET
from salt._compat import ElementTree as ET
import salt.utils
import os
import tempfile
Expand Down
6 changes: 3 additions & 3 deletions salt/modules/openbsdpkg.py
Expand Up @@ -105,9 +105,9 @@ def latest_version(*names, **kwargs):
continue
pkgname += '--{0}'.format(flavor) if flavor else ''
cur = pkgs.get(pkgname, '')
if not cur or __salt__['pkg_resource.compare'](pkg1=cur,
oper='<',
pkg2=pkgver):
if not cur or salt.utils.compare_versions(ver1=cur,
oper='<',
ver2=pkgver):
ret[pkgname] = pkgver

# Return a string if only one package name passed
Expand Down

0 comments on commit 203cf7a

Please sign in to comment.