|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
+import cStringIO
|
|
|
import os
|
|
|
import unittest
|
|
|
import tempfile
|
|
@@ -9,6 +10,7 @@ import shutil
|
|
|
import yaml
|
|
|
|
|
|
from ooinstall.oo_config import OOConfig, Host, OOConfigInvalidHostError
|
|
|
+import ooinstall.openshift_ansible
|
|
|
|
|
|
SAMPLE_CONFIG = """
|
|
|
variant: openshift-enterprise
|
|
@@ -224,3 +226,81 @@ class HostTests(OOInstallFixture):
|
|
|
'public_hostname': 'a.example.com',
|
|
|
}
|
|
|
self.assertRaises(OOConfigInvalidHostError, Host, **yaml_props)
|
|
|
+
|
|
|
+ def test_inventory_file_quotes_node_labels(self):
|
|
|
+ """Verify a host entry wraps openshift_node_labels value in double quotes"""
|
|
|
+ yaml_props = {
|
|
|
+ 'ip': '192.168.0.1',
|
|
|
+ 'hostname': 'a.example.com',
|
|
|
+ 'connect_to': 'a-private.example.com',
|
|
|
+ 'public_ip': '192.168.0.1',
|
|
|
+ 'public_hostname': 'a.example.com',
|
|
|
+ 'new_host': True,
|
|
|
+ 'roles': ['node'],
|
|
|
+ 'node_labels': {
|
|
|
+ 'region': 'infra'
|
|
|
+ },
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ new_node = Host(**yaml_props)
|
|
|
+ inventory = cStringIO.StringIO()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ooinstall.openshift_ansible.write_host(
|
|
|
+ new_node,
|
|
|
+ 'node',
|
|
|
+ inventory,
|
|
|
+ schedulable=True)
|
|
|
+
|
|
|
+ legacy_inventory_line = inventory.getvalue()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ node_labels_expected = '''openshift_node_labels="{'region': 'infra'}"'''
|
|
|
+ node_labels_bad = '''openshift_node_labels={'region': 'infra'}'''
|
|
|
+
|
|
|
+
|
|
|
+ self.assertIn(node_labels_expected, legacy_inventory_line)
|
|
|
+
|
|
|
+ self.assertNotIn(node_labels_bad, legacy_inventory_line)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|