MCPcopy
hub / github.com/saltstack/salt / render_state

Method render_state

salt/state.py:4228–4444  ·  view source on GitHub ↗

Render a state file and retrieve all of the include states

(self, sls, saltenv, mods, matches, local=False, context=None)

Source from the content-addressed store, hash-verified

4226 self.state.module_refresh()
4227
4228 def render_state(self, sls, saltenv, mods, matches, local=False, context=None):
4229 """
4230 Render a state file and retrieve all of the include states
4231 """
4232 errors = []
4233 if not local:
4234 state_data = self.client.get_state(sls, saltenv)
4235 fn_ = state_data.get("dest", False)
4236 else:
4237 fn_ = sls
4238 if not os.path.isfile(fn_):
4239 errors.append(
4240 f"Specified SLS {sls} on local filesystem cannot be found."
4241 )
4242 state = None
4243 if not fn_:
4244 errors.append(
4245 "Specified SLS {} in saltenv {} is not "
4246 "available on the salt master or through a configured "
4247 "fileserver".format(sls, saltenv)
4248 )
4249 else:
4250 try:
4251 state = compile_template(
4252 fn_,
4253 self.state.rend,
4254 self.state.opts["renderer"],
4255 self.state.opts["renderer_blacklist"],
4256 self.state.opts["renderer_whitelist"],
4257 saltenv,
4258 sls,
4259 rendered_sls=mods,
4260 context=context,
4261 )
4262 except SaltRenderError as exc:
4263 msg = f"Rendering SLS '{saltenv}:{sls}' failed: {exc}"
4264 log.critical(msg)
4265 errors.append(msg)
4266 except Exception as exc: # pylint: disable=broad-except
4267 msg = f"Rendering SLS {sls} failed, render error: {exc}"
4268 log.critical(
4269 msg,
4270 # Show the traceback if the debug logging level is enabled
4271 exc_info_on_loglevel=logging.DEBUG,
4272 )
4273 errors.append(f"{msg}\n{traceback.format_exc()}")
4274 try:
4275 mods.add(f"{saltenv}:{sls}")
4276 except AttributeError:
4277 pass
4278
4279 # Track SLS files that were rendered, even if they produce no
4280 # output (empty state), so they can satisfy requisites
4281 # (Issue #30971)
4282 if hasattr(self.state, "_processed_sls_files"):
4283 self.state._processed_sls_files.add(sls)
4284
4285 if state:

Callers 2

render_highstateMethod · 0.95
includeMethod · 0.45

Calls 15

_handle_extendMethod · 0.95
_handle_excludeMethod · 0.95
_handle_state_declsMethod · 0.95
merge_included_statesMethod · 0.95
_handle_iorderMethod · 0.95
compile_templateFunction · 0.90
formatMethod · 0.80
filterMethod · 0.80
get_stateMethod · 0.45
getMethod · 0.45
appendMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected