__init__.py (salt-3002.1) | : | __init__.py (salt-3002.2) | ||
---|---|---|---|---|
""" | """ | |||
Render the pillar data | Render the pillar data | |||
""" | """ | |||
# Import python libs | ||||
import collections | import collections | |||
import copy | import copy | |||
import fnmatch | import fnmatch | |||
import inspect | import inspect | |||
import logging | import logging | |||
import os | import os | |||
import sys | import sys | |||
import traceback | import traceback | |||
import salt.ext.tornado.gen | import salt.ext.tornado.gen | |||
import salt.fileclient | import salt.fileclient | |||
# Import salt libs | ||||
import salt.loader | import salt.loader | |||
import salt.minion | import salt.minion | |||
import salt.transport.client | import salt.transport.client | |||
import salt.utils.args | import salt.utils.args | |||
import salt.utils.cache | import salt.utils.cache | |||
import salt.utils.crypt | import salt.utils.crypt | |||
import salt.utils.data | import salt.utils.data | |||
import salt.utils.dictupdate | import salt.utils.dictupdate | |||
import salt.utils.url | import salt.utils.url | |||
from salt.exceptions import SaltClientError | from salt.exceptions import SaltClientError | |||
# Import 3rd-party libs | ||||
from salt.ext import six | from salt.ext import six | |||
from salt.template import compile_template | from salt.template import compile_template | |||
# Even though dictupdate is imported, invoking salt.utils.dictupdate.merge here | # Even though dictupdate is imported, invoking salt.utils.dictupdate.merge here | |||
# causes an UnboundLocalError. This should be investigated and fixed, but until | # causes an UnboundLocalError. This should be investigated and fixed, but until | |||
# then, leave the import directly below this comment intact. | # then, leave the import directly below this comment intact. | |||
from salt.utils.dictupdate import merge | from salt.utils.dictupdate import merge | |||
from salt.utils.odict import OrderedDict | from salt.utils.odict import OrderedDict | |||
from salt.version import __version__ | from salt.version import __version__ | |||
skipping to change at line 439 | skipping to change at line 433 | |||
pillarenv=self.pillarenv, | pillarenv=self.pillarenv, | |||
) | ) | |||
return fresh_pillar.compile_pillar() | return fresh_pillar.compile_pillar() | |||
def compile_pillar(self, *args, **kwargs): # Will likely just be pillar_dir s | def compile_pillar(self, *args, **kwargs): # Will likely just be pillar_dir s | |||
log.debug( | log.debug( | |||
"Scanning pillar cache for information about minion %s and pillarenv %s", | "Scanning pillar cache for information about minion %s and pillarenv %s", | |||
self.minion_id, | self.minion_id, | |||
self.pillarenv, | self.pillarenv, | |||
) | ) | |||
log.debug("Scanning cache: %s", self.cache._dict) | if self.opts["pillar_cache_backend"] == "memory": | |||
cache_dict = self.cache | ||||
else: | ||||
cache_dict = self.cache._dict | ||||
log.debug("Scanning cache: %s", cache_dict) | ||||
# Check the cache! | # Check the cache! | |||
if self.minion_id in self.cache: # Keyed by minion_id | if self.minion_id in self.cache: # Keyed by minion_id | |||
# TODO Compare grains, etc? | # TODO Compare grains, etc? | |||
if self.pillarenv in self.cache[self.minion_id]: | if self.pillarenv in self.cache[self.minion_id]: | |||
# We have a cache hit! Send it back. | # We have a cache hit! Send it back. | |||
log.debug( | log.debug( | |||
"Pillar cache hit for minion %s and pillarenv %s", | "Pillar cache hit for minion %s and pillarenv %s", | |||
self.minion_id, | self.minion_id, | |||
self.pillarenv, | self.pillarenv, | |||
) | ) | |||
skipping to change at line 470 | skipping to change at line 469 | |||
"Pillar cache miss for pillarenv %s for minion %s", | "Pillar cache miss for pillarenv %s for minion %s", | |||
self.pillarenv, | self.pillarenv, | |||
self.minion_id, | self.minion_id, | |||
) | ) | |||
return fresh_pillar | return fresh_pillar | |||
else: | else: | |||
# We haven't seen this minion yet in the cache. Store it. | # We haven't seen this minion yet in the cache. Store it. | |||
fresh_pillar = self.fetch_pillar() | fresh_pillar = self.fetch_pillar() | |||
self.cache[self.minion_id] = {self.pillarenv: fresh_pillar} | self.cache[self.minion_id] = {self.pillarenv: fresh_pillar} | |||
log.debug("Pillar cache miss for minion %s", self.minion_id) | log.debug("Pillar cache miss for minion %s", self.minion_id) | |||
log.debug("Current pillar cache: %s", self.cache._dict) # FIXME hac k! | log.debug("Current pillar cache: %s", cache_dict) # FIXME hack! | |||
return fresh_pillar | return fresh_pillar | |||
class Pillar: | class Pillar: | |||
""" | """ | |||
Read over the pillar top files and render the pillar data | Read over the pillar top files and render the pillar data | |||
""" | """ | |||
def __init__( | def __init__( | |||
self, | self, | |||
opts, | opts, | |||
End of changes. 5 change blocks. | ||||
8 lines changed or deleted | 7 lines changed or added |