Merge branch '2016.11' into 'nitrogen'

Conflicts:
  - tests/integration/__init__.py
  - tests/integration/modules/test_state.py
This commit is contained in:
rallytime 2017-06-06 12:57:44 -06:00
commit 1a40e105e5
8 changed files with 71 additions and 44 deletions

1
pkg/rpm/salt-proxy@.service Symbolic link
View file

@ -0,0 +1 @@
../salt-proxy@.service

View file

@ -25,7 +25,7 @@ __virtual_name__ = 'network_settings'
ATTRS = ['family', 'txqlen', 'ipdb_scope', 'index', 'operstate', 'group',
'carrier_changes', 'ipaddr', 'neighbours', 'ifname', 'promiscuity',
'linkmode', 'broadcast', 'address', 'num_tx_queues', 'ipdb_priority',
'change', 'kind', 'qdisc', 'mtu', 'num_rx_queues', 'carrier', 'flags',
'kind', 'qdisc', 'mtu', 'num_rx_queues', 'carrier', 'flags',
'ifi_type', 'ports']
LAST_STATS = {}

View file

@ -6,6 +6,7 @@ A module to wrap (non-Windows) archive calls
'''
from __future__ import absolute_import
import contextlib # For < 2.7 compat
import copy
import errno
import glob
import logging
@ -249,13 +250,16 @@ def list_(name,
else:
files.append(path)
for path in files:
_files = copy.deepcopy(files)
for path in _files:
# ZIP files created on Windows do not add entries
# to the archive for directories. So, we'll need to
# manually add them.
dirname = ''.join(path.rpartition('/')[:2])
if dirname:
dirs.add(dirname)
if dirname in files:
files.remove(dirname)
return list(dirs), files, links
except zipfile.BadZipfile:
raise CommandExecutionError('{0} is not a ZIP file'.format(name))
@ -1055,7 +1059,15 @@ def unzip(zip_file,
continue
zfile.extract(target, dest, password)
if extract_perms:
os.chmod(os.path.join(dest, target), zfile.getinfo(target).external_attr >> 16)
perm = zfile.getinfo(target).external_attr >> 16
if perm == 0:
umask_ = os.umask(0)
os.umask(umask_)
if target.endswith('/'):
perm = 0o777 & ~umask_
else:
perm = 0o666 & ~umask_
os.chmod(os.path.join(dest, target), perm)
except Exception as exc:
if runas:
os.seteuid(euid)

View file

@ -816,7 +816,7 @@ def create_floatingip(floating_network, port=None, profile=None):
return conn.create_floatingip(floating_network, port)
def update_floatingip(floatingip_id, port, profile=None):
def update_floatingip(floatingip_id, port=None, profile=None):
'''
Updates a floatingIP
@ -827,7 +827,8 @@ def update_floatingip(floatingip_id, port, profile=None):
salt '*' neutron.update_floatingip network-name port-name
:param floatingip_id: ID of floatingIP
:param port: ID or name of port
:param port: ID or name of port, to associate floatingip to
`None` or do not specify to disassociate the floatingip (Optional)
:param profile: Profile to build on (Optional)
:return: Value of updated floating IP information
'''

View file

@ -68,7 +68,10 @@ def import_cert(name, cert_format=_DEFAULT_FORMAT, context=_DEFAULT_CONTEXT, sto
cached_source_path = __salt__['cp.cache_file'](name, saltenv)
current_certs = __salt__['win_pki.get_certs'](context=context, store=store)
cert_props = __salt__['win_pki.get_cert_file'](name=cached_source_path)
if password:
cert_props = __salt__['win_pki.get_cert_file'](name=cached_source_path, cert_format=cert_format, password=password)
else:
cert_props = __salt__['win_pki.get_cert_file'](name=cached_source_path, cert_format=cert_format)
if cert_props['thumbprint'] in current_certs:
ret['comment'] = ("Certificate '{0}' already contained in store:"

View file

@ -537,12 +537,16 @@ class SaltNeutron(NeutronShell):
return self.network_conn.create_floatingip(body={'floatingip': body})
def update_floatingip(self, floatingip_id, port):
def update_floatingip(self, floatingip_id, port=None):
'''
Updates a floatingip
Updates a floatingip, disassociates the floating ip if
port is set to `None`
'''
port_id = self._find_port_id(port)
body = {'floatingip': {'port_id': port_id}}
if port is None:
body = {'floatingip': {}}
else:
port_id = self._find_port_id(port)
body = {'floatingip': {'port_id': port_id}}
return self.network_conn.update_floatingip(
floatingip=floatingip_id, body=body)

View file

@ -728,40 +728,6 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
#ret = self.run_function('state.sls', mods='requisites.fullsls_prereq')
#self.assertEqual(['sls command can only be used with require requisite'], ret)
def test_requisites_full_sls_require_in(self):
'''
Test require_in when including an entire sls
'''
expected_result = {
'cmd_|-A_|-echo A_|-run': {
'__run_num__': 0,
'comment': 'Command "echo A" run',
'result': True,
'changes': True},
'cmd_|-B_|-echo B_|-run': {
'__run_num__': 1,
'comment': 'Command "echo B" run',
'result': True,
'changes': True},
'cmd_|-C_|-echo C_|-run': {
'__run_num__': 2,
'comment': 'Command "echo C" run',
'result': True,
'changes': True},
}
ret = self.run_function('state.sls',
mods='requisites.fullsls_require_in')
self.assertReturnNonEmptySaltType(ret)
result = self.normalize_ret(ret)
self.assertEqual(expected_result, result)
def test_requisites_full_sls_import(self):
'''
Test full sls requisite with nothing but an import
'''
ret = self.run_function('state.sls', mods='requisites.fullsls_require_import')
self.assertSaltTrueReturn(ret)
def test_requisites_prereq_simple_ordering_and_errors(self):
'''
Call sls file containing several prereq_in and prereq.

View file

@ -0,0 +1,40 @@
# -*- coding: UTF-8 -*-
# Import Python libs
from __future__ import absolute_import
# Import Salt Testing libs
from salttesting import skipIf, TestCase
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import Salt libs
from salt.beacons.network_settings import ATTRS
# Import Third Party libs
try:
from pyroute2 import IPDB
HAS_PYROUTE2 = True
except ImportError:
HAS_PYROUTE2 = False
@skipIf(not HAS_PYROUTE2, 'no pyroute2 installed, skipping')
class Pyroute2TestCase(TestCase):
def test_interface_dict_fields(self):
with IPDB() as ipdb:
for attr in ATTRS:
# ipdb.interfaces is a dict-like object, that
# contains interface definitions. Interfaces can
# be referenced both with indices and names.
#
# ipdb.interfaces[1] is an interface with index 1,
# that is the loopback interface.
self.assertIn(attr, ipdb.interfaces[1])
if __name__ == '__main__':
from integration import run_tests
run_tests(Pyroute2TestCase, needs_daemon=False)