aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config
diff options
context:
space:
mode:
Diffstat (limited to 'os_net_config')
-rw-r--r--os_net_config/objects.py3
-rw-r--r--os_net_config/tests/test_objects.py40
2 files changed, 42 insertions, 1 deletions
diff --git a/os_net_config/objects.py b/os_net_config/objects.py
index 944aecd..e6b2d4d 100644
--- a/os_net_config/objects.py
+++ b/os_net_config/objects.py
@@ -245,7 +245,8 @@ class _BaseOpts(object):
mtu = json.get('mtu', None)
dhclient_args = json.get('dhclient_args')
dns_servers = json.get('dns_servers')
- nm_controlled = json.get('nm_controlled')
+ nm_controlled = strutils.bool_from_string(str(json.get('nm_controlled',
+ False)))
primary = strutils.bool_from_string(str(json.get('primary', False)))
addresses = []
routes = []
diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py
index f5daf31..9e8432d 100644
--- a/os_net_config/tests/test_objects.py
+++ b/os_net_config/tests/test_objects.py
@@ -144,6 +144,46 @@ class TestInterface(base.TestCase):
interface1 = objects.object_from_json(json.loads(data))
self.assertEqual("--foobar", interface1.dhclient_args)
+ def test_from_json_nm_controlled_false(self):
+ data = """{
+"type": "interface",
+"name": "em1",
+"nm_controlled": false
+}
+"""
+ interface1 = objects.object_from_json(json.loads(data))
+ self.assertFalse(interface1.nm_controlled)
+
+ def test_from_json_nm_controlled_true(self):
+ data = """{
+"type": "interface",
+"name": "em1",
+"nm_controlled": true
+}
+"""
+ interface1 = objects.object_from_json(json.loads(data))
+ self.assertTrue(interface1.nm_controlled)
+
+ def test_from_json_nm_controlled_false_boolstr(self):
+ data = """{
+"type": "interface",
+"name": "em1",
+"nm_controlled": "no"
+}
+"""
+ interface1 = objects.object_from_json(json.loads(data))
+ self.assertFalse(interface1.nm_controlled)
+
+ def test_from_json_nm_controlled_true_boolstr(self):
+ data = """{
+"type": "interface",
+"name": "em1",
+"nm_controlled": "yes"
+}
+"""
+ interface1 = objects.object_from_json(json.loads(data))
+ self.assertTrue(interface1.nm_controlled)
+
def test_from_json_dns_servers(self):
data = """{
"type": "interface",