test, library: improve example and disable STP of bridge

For the early PoC, STP just annoys with testing. Later,
this should become configurable.
This commit is contained in:
Thomas Haller 2016-12-07 13:08:52 +01:00
parent 17c581a1cd
commit 407e3b81af
4 changed files with 10 additions and 5 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.pyc

View file

@ -11,11 +11,11 @@ cd ./ansible-network-role/
cat <<EOF > ./TEST/inventory
[network-test]
v-rhel6-1 ansible_user=root
v-rhel7-b ansible_user=root
v-rhel6 ansible_user=root network_iphost=196 network_mac=52:54:00:44:9f:ba
v-rhel7 ansible_user=root network_iphost=97 network_mac=52:54:00:05:f5:b3
EOF
../ansible/hacking/test-module -m ./library/network_connections.py -a 'provider=nm name=t-eth0 state=present type=ethernet' --check
ansible-playbook -i ./TEST/inventory ./TEST/test-playbook.yml --verbose --check
ansible-playbook -i ./TEST/inventory -l '*rhel*' ./TEST/test-playbook-3.yml --verbose --check
```

View file

@ -14,11 +14,12 @@
autoconnect: no
interface_name: eth0
type: ethernet
mac: "{{ network_mac | default(omit) }}"
ip:
dhcp4: no
gateway4: 192.168.122.1
address:
- 192.168.122.97/24
- "192.168.122.{{ network_iphost }}/24"
- name: p-3-manual

View file

@ -856,12 +856,15 @@ class NMCmd:
s_con.set_property(NM.SETTING_CONNECTION_INTERFACE_NAME, args['interface_name'])
if args['type'] == 'ethernet':
s_con.set_property(NM.SETTING_CONNECTION_TYPE, '802-3-ethernet')
s_wired = NM.SettingWired.new()
connection.add_setting(s_wired)
s_con.set_property(NM.SETTING_CONNECTION_TYPE, '802-3-ethernet')
s_wired.set_property(NM.SETTING_WIRED_MAC_ADDRESS, args['mac'])
elif args['type'] == 'bridge':
s_con.set_property(NM.SETTING_CONNECTION_TYPE, 'bridge')
s_bridge = NM.SettingBridge.new()
connection.add_setting(s_bridge)
s_bridge.set_property(NM.SETTING_BRIDGE_STP, False)
elif args['type'] == 'bond':
s_con.set_property(NM.SETTING_CONNECTION_TYPE, 'bond')
elif args['type'] == 'team':