From 9c3b2ad42292a2f7b141b2be3cf70a06e1691a33 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 6 Dec 2016 16:47:03 +0100 Subject: [PATCH] test,library: add example playbooks and bug fixes --- TEST/test-playbook-3.yml | 38 ++++++++++++++++++++++++++++++++++ library/network_connections.py | 6 +++--- 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 TEST/test-playbook-3.yml diff --git a/TEST/test-playbook-3.yml b/TEST/test-playbook-3.yml new file mode 100644 index 0000000..0dd2141 --- /dev/null +++ b/TEST/test-playbook-3.yml @@ -0,0 +1,38 @@ +--- +- hosts: network-test + vars: + network: + connections: + - name: p-3-auto + autoconnect: no + interface_name: eth0 + type: ethernet + - name: p-3-auto + + + - name: p-3-manual + autoconnect: no + interface_name: eth0 + type: ethernet + ip: + dhcp4: no + gateway4: 192.168.122.1 + address: + - 192.168.122.97/24 + - name: p-3-manual + + + - name: p-3-br0 + autoconnect: no + interface_name: br0 + type: bridge + - name: p-3-br0-eth0 + autoconnect: no + interface_name: eth0 + type: ethernet + slave_type: bridge + master: p-3-br0 + - name: p-3-br0-eth0 + + roles: + - network diff --git a/library/network_connections.py b/library/network_connections.py index a33664c..a089a6e 100755 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -771,8 +771,8 @@ class NMCmd: if len(cons) != 1: raise Exception('a unique %s connection "%s" was not found, instead there are [ %s ]' % (field, args[field], ' '.join([c.get_uuid() for c in cons]))) con = cons[0] - if expected_type is not None and con.get_type() != expected_type: - raise Exception('the %s connection "%s" is expected to be of type %s but is %s (%s)' % (field, args[field], expected_type, con.get_type(), con.get_uuid())) + if expected_type is not None and con.get_connection_type() != expected_type: + raise Exception('the %s connection "%s" is expected to be of type %s but is %s (%s)' % (field, args[field], expected_type, con.get_connection_type(), con.get_uuid())) return con def connection_find_master(self, args, field, check_mode = False, expected_type = None): @@ -872,7 +872,7 @@ class NMCmd: if 'slave_type' in args: s_con.set_property(NM.SETTING_CONNECTION_SLAVE_TYPE, args['slave_type']) - m = self.connection_find_master(args, 'master', check_mode) + m = self.connection_find_master(args, 'master', check_mode, args['slave_type']) if m is None: dirty = True else: