Commit Graph

10 Commits

Author SHA1 Message Date
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