From 36bbd898e9b8bef508b5d185dc1e52af0f13cfd0 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 20 Jul 2013 05:56:30 -0700 Subject: Add usage of '#json-patch' --- cloudinit/handlers/__init__.py | 1 + cloudinit/handlers/cloud_config.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'cloudinit/handlers') diff --git a/cloudinit/handlers/__init__.py b/cloudinit/handlers/__init__.py index 497d68c5..297e7451 100644 --- a/cloudinit/handlers/__init__.py +++ b/cloudinit/handlers/__init__.py @@ -62,6 +62,7 @@ INCLUSION_TYPES_MAP = { '#part-handler': 'text/part-handler', '#cloud-boothook': 'text/cloud-boothook', '#cloud-config-archive': 'text/cloud-config-archive', + '#json-patch': 'application/json-patch+json', } # Sorted longest first diff --git a/cloudinit/handlers/cloud_config.py b/cloudinit/handlers/cloud_config.py index 8d1ba37f..84653375 100644 --- a/cloudinit/handlers/cloud_config.py +++ b/cloudinit/handlers/cloud_config.py @@ -66,22 +66,21 @@ class CloudConfigPartHandler(handlers.Handler): def list_types(self): ctypes_handled = [ handlers.type_from_starts_with("#cloud-config"), - JSON_PATCH_CTYPE, + handlers.type_from_starts_with("#json-patch"), ] return ctypes_handled def _write_cloud_config(self): - if not self.cloud_fn: + if not self.cloud_fn or not len(self.file_names): return # Capture which files we merged from... file_lines = [] - if self.file_names: - file_lines.append("# from %s files" % (len(self.file_names))) - for fn in self.file_names: - if not fn: - fn = '?' - file_lines.append("# %s" % (fn)) - file_lines.append("") + file_lines.append("# from %s files" % (len(self.file_names))) + for fn in self.file_names: + if not fn: + fn = '?' + file_lines.append("# %s" % (fn)) + file_lines.append("") if self.cloud_buf is not None: # Something was actually gathered.... lines = [ -- cgit v1.2.3