%PDF- %PDF-
| Direktori : /proc/self/root/proc/thread-self/root/lib/python2.7/site-packages/salt/utils/ |
| Current File : //proc/self/root/proc/thread-self/root/lib/python2.7/site-packages/salt/utils/aggregation.pyc |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l m Z d d l m
Z
d d d d d
g Z e j e
� Z d e f d � � YZ d
e e f d � � YZ d e e f d � � YZ d � Z d � Z e e d � Z e e e d � Z d S( u/
salt.utils.aggregation
~~~~~~~~~~~~~~~~~~~~~~
This library makes it possible to introspect dataset and aggregate nodes
when it is instructed.
.. note::
The following examples with be expressed in YAML for convenience's sake:
- !aggr-scalar will refer to Scalar python function
- !aggr-map will refer to Map python object
- !aggr-seq will refer for Sequence python object
How to instructs merging
------------------------
This yaml document has duplicate keys:
.. code-block:: yaml
foo: !aggr-scalar first
foo: !aggr-scalar second
bar: !aggr-map {first: foo}
bar: !aggr-map {second: bar}
baz: !aggr-scalar 42
but tagged values instruct Salt that overlapping values they can be merged
together:
.. code-block:: yaml
foo: !aggr-seq [first, second]
bar: !aggr-map {first: foo, second: bar}
baz: !aggr-seq [42]
Default merge strategy is keep untouched
----------------------------------------
For example, this yaml document still has duplicate keys, but does not
instruct aggregation:
.. code-block:: yaml
foo: first
foo: second
bar: {first: foo}
bar: {second: bar}
baz: 42
So the late found values prevail:
.. code-block:: yaml
foo: second
bar: {second: bar}
baz: 42
Limitations
-----------
Aggregation is permitted between tagged objects that share the same type.
If not, the default merge strategy prevails.
For example, these examples:
.. code-block:: yaml
foo: {first: value}
foo: !aggr-map {second: value}
bar: !aggr-map {first: value}
bar: 42
baz: !aggr-seq [42]
baz: [fail]
qux: 42
qux: !aggr-scalar fail
are interpreted like this:
.. code-block:: yaml
foo: !aggr-map{second: value}
bar: 42
baz: [fail]
qux: !aggr-seq [fail]
Introspection
-------------
TODO: write this part
i ( t absolute_importt print_functiont unicode_literalsN( t OrderedDict( t sixu aggregateu Aggregateu Mapu Scalaru Sequencet Aggregatec B@ s e Z d Z RS( u
Aggregation base.
( t __name__t
__module__t __doc__( ( ( s: /usr/lib/python2.7/site-packages/salt/utils/aggregation.pyR z s t Mapc B@ s e Z d Z RS( u
Map aggregation.
( R R R ( ( ( s: /usr/lib/python2.7/site-packages/salt/utils/aggregation.pyR � s t Sequencec B@ s e Z d Z RS( u
Sequence aggregation.
( R R R ( ( ( s: /usr/lib/python2.7/site-packages/salt/utils/aggregation.pyR
� s c C@ s
t | g � S( u]
Shortcut for Sequence creation
>>> Scalar('foo') == Sequence(['foo'])
True
( R
( t obj( ( s: /usr/lib/python2.7/site-packages/salt/utils/aggregation.pyt Scalar� s c C@ s� | s t t f S| t k r&