Ubuntu Pastebin

Paste from smoser at Fri, 8 Sep 2017 18:23:27 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
diff --git a/cloudinit/config/cc_ntp.py b/cloudinit/config/cc_ntp.py
index a02b4bf1..25accc59 100644
--- a/cloudinit/config/cc_ntp.py
+++ b/cloudinit/config/cc_ntp.py
@@ -76,10 +76,10 @@ schema = {
         ``{0-3}.{distro}.pool.ntp.org``."""),
     'distros': distros,
     'examples': [
-        {'ntp': {'pools': ['0.company.pool.ntp.org', '1.company.pool.ntp.org',
-                           'ntp.myorg.org'],
-                 'servers': ['my.ntp.server.local', 'ntp.ubuntu.com',
-                             '192.168.23.2']}}],
+        dedent("""\
+        ntp:
+          pools: ['0.int.pool.ntp.org', '1.int.pool.ntp.org', 'ntp.myorg.org']
+          servers: ['ntp.server.local', 'ntp.ubuntu.com', '192.168.23.2']""")],
     'frequency': PER_INSTANCE,
     'type': 'object',
     'properties': {
diff --git a/cloudinit/config/schema.py b/cloudinit/config/schema.py
index 16a290e2..44aeb7a6 100644
--- a/cloudinit/config/schema.py
+++ b/cloudinit/config/schema.py
@@ -14,6 +14,7 @@ import re
 import sys
 import yaml
 
+_YAML_MAP = {True: 'true', False: 'false', None: 'null'}
 SCHEMA_UNDEFINED = b'UNDEFINED'
 CLOUD_CONFIG_HEADER = b'#cloud-config'
 SCHEMA_DOC_TMPL = """
@@ -213,8 +214,7 @@ def _get_property_type(property_dict):
     """Return a string representing a property type from a given jsonschema."""
     property_type = property_dict.get('type', SCHEMA_UNDEFINED)
     if property_type == SCHEMA_UNDEFINED and property_dict.get('enum'):
-        yaml_string = yaml.dump(property_dict.get('enum')).strip()
-        property_type = yaml_string[1:-1].replace(', ', '/')
+        property_type = [str(_YAML_MAP.get(k, k)) for k in property_dict['enum']]
     if isinstance(property_type, list):
         property_type = '/'.join(property_type)
     items = property_dict.get('items', {})
@@ -257,7 +257,7 @@ def _get_schema_examples(schema, prefix=''):
         if isinstance(example, str):
             example_content = example
         else:
-            example_content = yaml.dump(example, default_flow_style=False)
+            example_content = '\n'.join([e + "\n" for e in example])
         # Python2.6 is missing textwrapper.indent
         lines = example_content.split('\n')
         indented_lines = ['    {0}'.format(line) for line in lines]
Download as text