mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
grains module: yaml representer for OrderedDict
This commit is contained in:
parent
2c9c8d4073
commit
c92326f5ea
1 changed files with 3 additions and 0 deletions
|
@ -15,6 +15,7 @@ import collections
|
|||
from functools import reduce
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.utils.odict import OrderedDict
|
||||
import yaml
|
||||
import salt.ext.six as six
|
||||
from salt.ext.six.moves import range # pylint: disable=import-error,no-name-in-module,redefined-builtin
|
||||
|
@ -239,6 +240,8 @@ def setvals(grains, destructive=False):
|
|||
# Cast defaultdict to dict; is there a more central place to put this?
|
||||
yaml.representer.SafeRepresenter.add_representer(collections.defaultdict,
|
||||
yaml.representer.SafeRepresenter.represent_dict)
|
||||
yaml.representer.SafeRepresenter.add_representer(OrderedDict,
|
||||
yaml.representer.SafeRepresenter.represent_dict)
|
||||
cstr = yaml.safe_dump(grains, default_flow_style=False)
|
||||
try:
|
||||
with salt.utils.fopen(gfn, 'w+') as fp_:
|
||||
|
|
Loading…
Add table
Reference in a new issue