Commit Graph

24 Commits

Author SHA1 Message Date
Mike Place
1aab1bde56 Fix loader call in pyobjects 2015-06-17 10:17:47 -06:00
Grischa Meyer
c0c25e83b5 fixing other test 2015-06-16 11:11:04 +10:00
Grischa Meyer
2739be2059 fixing text for virtual support in pyobjects 2015-06-16 11:09:16 +10:00
Colton Myers
124ad51c40 Merge remote-tracking branch 'upstream/2015.2' into merge-forward-develop
Conflicts:
    doc/ref/index.rst
    doc/topics/eauth/index.rst
    salt/beacons/__init__.py
    salt/beacons/service.py
    salt/loader.py
    salt/minion.py
    salt/output/nested.py
2015-03-30 15:10:17 -06:00
Evan Borgstrom
181df2e489 Fix a bug with the implicit list handling in pyobjects requisites
When specifying a requisite and you only need to list a single item you
can specify it without being wraped in a list and we will handle it
automatically.  This was being handled when we built our attrs to output
the final data, but this failed when you extended a require requisite
inside of a context manager.
2015-03-27 21:04:00 -07:00
Colton Myers
b0fe5cc955 Merge remote-tracking branch 'upstream/2015.2' into merge-forward-develop
Conflicts:
    salt/fileclient.py
    salt/minion.py
    tests/unit/pyobjects_test.py
2015-03-25 12:04:30 -06:00
Evan Borgstrom
247d38d1da This fixes #21796
From the Python docs on the exec statement:

> Remember that at module level, globals and locals are the same dictionary.
> If two separate objects are given as globals and locals, the code will be
> executed as if it were embedded in a class definition.

We were providing a specific object for locals and in the specific case
reported in #21796 this caused a very strange name error when used in a
specific way. By removing the explicit locals dictionary and just having the
globals dictionary be shared fixes the issue, and we weren't using the
specific locals anyway.
2015-03-21 08:03:12 -07:00
Evan Borgstrom
3223a15f83 This fixes #21796
From the Python docs on the exec statement:

> Remember that at module level, globals and locals are the same dictionary.
> If two separate objects are given as globals and locals, the code will be
> executed as if it were embedded in a class definition.

We were providing a specific object for locals and in the specific case
reported in #21796 this caused a very strange name error when used in a
specific way. By removing the explicit locals dictionary and just having the
globals dictionary be shared fixes the issue, and we weren't using the
specific locals anyway.
2015-03-21 07:58:14 -07:00
Evan Borgstrom
a43920bffc Update documentation & tests following #18911
Thanks for the contribution @tomashavlas!  Please make sure you update
the tests & documentation in the future.
2015-02-04 21:27:24 -08:00
Pedro Algarvio
60f215f191 Add from __future__ import absolute_import 2015-01-30 22:25:04 +00:00
Pedro Algarvio
a964a2161e Switch imports and revert the assert to what it was. 2014-12-02 23:18:54 +00:00
Pedro Algarvio
6a259dc229 Proper minion config initialization. Fix test. 2014-12-02 07:55:52 +00:00
Pedro Algarvio
9f60901597 Switch open() for salt.utils.fopen() 2014-11-26 18:29:21 +00:00
Pedro Algarvio
e9fbd9910d Set the cachedir to a relative path 2014-10-12 02:16:23 +01:00
Evan Borgstrom
d54be1b2f2 Allow for "imports" within pyobjects files
This allows for pyobject state files to import objects from other state
files by specifying a salt:// URL in the import statement.
2014-04-14 11:26:16 -04:00
Pedro Algarvio
60d77f6d32 Allow standalone test execution 2014-03-31 03:03:00 +01:00
Evan Borgstrom
4aec18b1e0 Refactor and modularize of the loader interface, adding Map to pyobjects
The problem with using the loaded states (see commit cc8539f) is that
you can end up in situations where a particular state doesn't exist for
whatever reason. This prevents you from building states freely (see
ticket #10918).

The refactor focuses on breaking out the `gen_functions` function into a
number of smaller reusable functions so that pyobjects can load all of
the states and still process `__virtual__()` and `__virtualname__` in a
way that makes sense for building states. After all pyobjects is just
compiling a high state data structure, if a state is available or not
during application time is up to the minion.

As part of this refactor I have also updated all of the inline comments
in the loader to be more consistent with the way things are actually
working now (such as `__virtual__()` returning a string being
deprecated).

There are also some pep8 fixes to the loader file.

Fix #10918

----

This also adds a new feature to pyobjects named `Map`, which allows for
definition of grain dependent data in a pythonic way -- using inner
classes.

----

Lastly this ditches the instance based registry and instead uses a class
based approach like a singleton.
2014-03-12 22:23:32 -04:00
Evan Borgstrom
cc8e25e316 Rebuild StateRegistry storage so IDs across modules work
As it stands the following will fail as we didn't allow duplicate IDs
under any circumstances:

    with Pkg.installed("nginx"):
    	Service.running("nginx")

This commit changes the way the StateRegistry stores states to allow the
above example to work properly.

Now it behaves much more closely to the YAML + Jinja renderer.
2014-02-27 15:52:14 -05:00
Evan Borgstrom
2e6371f65b Add test for duplicates, now to fix it 2014-02-27 15:04:27 -05:00
Evan Borgstrom
796efac44f Update tests to use new syntax 2014-02-20 15:19:42 -05:00
Evan Borgstrom
7ed0eb576e Switch double to single quotes, fix pylint warning 2014-02-20 10:23:57 -05:00
Evan Borgstrom
adae60f44a Adding a object interface to the __salt__ dictionary
This is another suggestion from @mgwilliams. It adds an object to the
sls file scope named Salt, which dispatches its attributes to the
__salt__ dictionary.

For example, the following two lines are functionally the same:

    ret = Salt.cmd.run(bar)
    ret = salt['cmd.run'](bar)
2014-02-19 20:38:02 -05:00
Evan Borgstrom
e80e39032e Support including & extending 2014-02-17 21:31:06 -05:00
Evan Borgstrom
72cb2ab35b Add pyobjects tests 2014-02-17 19:54:56 -05:00