Пример #1
0
    def test_duplicates(self):
        def add_dup():
            self.File.managed("dup", name="/dup")

        add_dup()
        self.assertRaises(DuplicateState, add_dup)
        Service = StateFactory("service")
        Service.running("dup", name="dup-service")

        self.assertEqual(
            Registry.states,
            OrderedDict(
                [
                    (
                        "dup",
                        OrderedDict(
                            [
                                ("file.managed", [{"name": "/dup"}]),
                                ("service.running", [{"name": "dup-service"}]),
                            ]
                        ),
                    )
                ]
            ),
        )
Пример #2
0
    def setUpClass(cls):
        cls.recursive_map_template = textwrap.dedent("""\
        #!pyobjects
        from salt://map.sls import Samba

        class CustomSamba(Samba):
            pass
        """)
        cls.recursive_import_template = textwrap.dedent("""\
        #!pyobjects
        from salt://recursive_map.sls import CustomSamba

        Pkg.removed("samba-imported", names=[CustomSamba.server, CustomSamba.client])"""
                                                        )
        cls.File = StateFactory("file")
Пример #3
0
# Import Salt Testing libs
from tests.support.unit import TestCase

# Import Salt libs
import tests.integration as integration
import salt.config
import salt.state
import salt.utils
from salt.template import compile_template
from salt.utils.odict import OrderedDict
from salt.utils.pyobjects import (StateFactory, State, Registry, SaltObject,
                                  InvalidFunction, DuplicateState)

log = logging.getLogger(__name__)

File = StateFactory('file')
Service = StateFactory('service')

pydmesg_expected = {
    'file.managed': [
        {
            'group': 'root'
        },
        {
            'mode': '0755'
        },
        {
            'require': [{
                'file': '/usr/local/bin'
            }]
        },
Пример #4
0
 def setUpClass(cls):
     cls.File = StateFactory("file")
Пример #5
0
from salttesting import TestCase
from salttesting.helpers import ensure_in_syspath

ensure_in_syspath('../')

from salt.config import minion_config
from salt.loader import states
from salt.minion import SMinion
from salt.renderers.pyobjects import render as pyobjects_render
from salt.utils.odict import OrderedDict
from salt.utils.pyobjects import (StateFactory, State, StateRegistry,
                                  InvalidFunction, SaltObject)

test_registry = StateRegistry()
File = StateFactory('file', registry=test_registry)

pydmesg_expected = {
    'file.managed': [
        {
            'group': 'root'
        },
        {
            'mode': '0755'
        },
        {
            'require': [{
                'file': '/usr/local/bin'
            }]
        },
        {
Пример #6
0
from salt.utils.pyobjects import (
    DuplicateState,
    InvalidFunction,
    Registry,
    SaltObject,
    State,
    StateFactory,
)
from tests.support.runtests import RUNTIME_VARS

# Import Salt Testing libs
from tests.support.unit import TestCase, skipIf

log = logging.getLogger(__name__)

File = StateFactory("file")
Service = StateFactory("service")

pydmesg_expected = {
    "file.managed": [
        {
            "group": "root"
        },
        {
            "mode": "0755"
        },
        {
            "require": [{
                "file": "/usr/local/bin"
            }]
        },
Пример #7
0
from salttesting import TestCase
from salttesting.helpers import ensure_in_syspath

ensure_in_syspath('../')

from salt.config import minion_config
from salt.loader import states
from salt.minion import SMinion
from salt.renderers.pyobjects import render as pyobjects_render
from salt.utils.odict import OrderedDict
from salt.utils.pyobjects import (StateFactory, State, StateRegistry,
                                  SaltObject, InvalidFunction, DuplicateState)

test_registry = StateRegistry()
File = StateFactory('file', registry=test_registry)
Service = StateFactory('service', registry=test_registry)

pydmesg_expected = {
    'file.managed': [
        {'group': 'root'},
        {'mode': '0755'},
        {'require': [{'file': '/usr/local/bin'}]},
        {'source': 'salt://debian/files/pydmesg.py'},
        {'user': '******'},
    ]
}
pydmesg_salt_expected = OrderedDict([('/usr/local/bin/pydmesg', pydmesg_expected)])
pydmesg_kwargs = dict(user='******', group='root', mode='0755',
                      source='salt://debian/files/pydmesg.py')