From 97b19f3b1992e56ef8e1a055fbe64a19d1eacfbf Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 24 Jul 2013 11:07:55 -0400 Subject: rename CC_JSONP_PRE again (JSONP_PREFIX) and use CLOUD_PREFIX --- cloudinit/handlers/cloud_config.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'cloudinit/handlers') diff --git a/cloudinit/handlers/cloud_config.py b/cloudinit/handlers/cloud_config.py index 8bbc904d..7edae13d 100644 --- a/cloudinit/handlers/cloud_config.py +++ b/cloudinit/handlers/cloud_config.py @@ -52,12 +52,12 @@ MERGE_HEADER = 'Merge-Type' # This gets loaded into yaml with final result {'a': 22} DEF_MERGERS = mergers.string_extract_mergers('dict(replace)+list()+str()') CLOUD_PREFIX = "#cloud-config" +JSONP_PREFIX = "#cloud-config-jsonp" # The file header -> content types this module will handle. -CC_JSONP_PRE = "#cloud-config-jsonp" CC_TYPES = { - CC_JSONP_PRE: handlers.type_from_starts_with(CC_JSONP_PRE), - '#cloud-config': handlers.type_from_starts_with("#cloud-config"), + JSONP_PREFIX: handlers.type_from_starts_with(JSONP_PREFIX), + CLOUD_PREFIX: handlers.type_from_starts_with(CLOUD_PREFIX), } @@ -117,12 +117,12 @@ class CloudConfigPartHandler(handlers.Handler): def _merge_patch(self, payload): payload = payload.lstrip() - if payload.lower().startswith(CC_JSONP_PRE): + if payload.lower().startswith(JSONP_PREFIX): # JSON doesn't handle comments in this manner, so ensure that # if we started with this 'type' that we remove it before # attempting to load it as json (which the jsonpatch library will # attempt to do). - payload = payload[CC_JSONP_PRE:] + payload = payload[JSONP_PREFIX:] patch = jsonpatch.JsonPatch.from_string(payload) LOG.debug("Merging by applying json patch %s", patch) self.cloud_buf = patch.apply(self.cloud_buf, in_place=False) @@ -150,7 +150,7 @@ class CloudConfigPartHandler(handlers.Handler): # First time through, merge with an empty dict... if self.cloud_buf is None or not self.file_names: self.cloud_buf = {} - if ctype == CC_TYPES[CC_JSONP_PRE]: + if ctype == CC_TYPES[JSONP_PREFIX]: self._merge_patch(payload) else: self._merge_part(payload, headers) -- cgit v1.2.3