MCPcopy Create free account
hub / github.com/canonical/cloud-init / _attach_launch_index

Method _attach_launch_index

cloudinit/user_data.py:170–192  ·  view source on GitHub ↗
(self, msg)

Source from the content-addressed store, hash-verified

168 self._attach_part(append_msg, part)
169
170 def _attach_launch_index(self, msg):
171 header_idx = msg.get("Launch-Index", None)
172 payload_idx = None
173 if msg.get_content_type() in EXAMINE_FOR_LAUNCH_INDEX:
174 try:
175 # See if it has a launch-index field
176 # that might affect the final header
177 payload = util.load_yaml(msg.get_payload(decode=True))
178 if payload:
179 payload_idx = payload.get("launch-index")
180 except Exception:
181 pass
182 # Header overrides contents, for now (?) or the other way around?
183 if header_idx is not None:
184 payload_idx = header_idx
185 # Nothing found in payload, use header (if anything there)
186 if payload_idx is None:
187 payload_idx = header_idx
188 if payload_idx is not None:
189 try:
190 msg.add_header("Launch-Index", str(int(payload_idx)))
191 except (ValueError, TypeError):
192 pass
193
194 def _get_include_once_filename(self, entry):
195 entry_fn = util.hash_blob(entry, "md5", 64)

Callers 1

Calls 2

add_headerMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected