def test_openvswitch_port_present_idempotent(self): set_module_args(dict(state='present', bridge='test-br', port='eth2', tag=10, external_ids={'foo': 'bar'})) self.execute_module(test_name='test_openvswitch_port_present_idempotent')
def test_openvswitch_bridge_updates_vlan(self): set_module_args({'state': 'present', 'bridge': 'test-br2', 'parent': 'test-br', 'vlan': 300}) commands = [ '/usr/bin/ovs-vsctl -t 5 set port test-br2 tag=300' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_bridge_updates_vlan')
def test_openvswitch_bridge_absent_removes_bridge(self): set_module_args(dict(state="absent", bridge="test-br")) commands = ["/usr/bin/ovs-vsctl -t 5 del-br test-br"] self.execute_module( changed=True, commands=commands, test_name="test_openvswitch_bridge_absent_removes_bridge", )
def test_openvswitch_bond_absent_removes_bond(self): set_module_args(dict(state="absent", bridge="bond-br", port="bond0")) commands = ["/usr/bin/ovs-vsctl -t 5 del-port bond-br bond0"] self.execute_module( changed=True, commands=commands, test_name="test_openvswitch_bond_absent_removes_bond", )
def test_openvswitch_port_absent_removes_port(self): set_module_args(dict(state="absent", bridge="test-br", port="eth2")) commands = ["/usr/bin/ovs-vsctl -t 5 del-port test-br eth2"] self.execute_module( changed=True, commands=commands, test_name="test_openvswitch_port_absent_removes_port", )
def test_openvswitch_db_present_stp_enable(self): set_module_args( dict(state='present', table='Bridge', record='test-br', col='stp_enable', value='true')) self.execute_module(changed=True, test_name='test_openvswitch_db_present_stp_enable')
def test_openvswitch_port_absent_removes_port(self): set_module_args(dict(state='absent', bridge='test-br', port='eth2')) commands = [ '/usr/bin/ovs-vsctl -t 5 del-port test-br eth2', ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_port_absent_removes_port')
def test_openvswitch_db_absent_idempotent(self): set_module_args( dict(state='absent', table='Bridge', record='test-br', col='other_config', key='disable-in-band', value='true')) self.execute_module(test_name='test_openvswitch_db_absent_idempotent')
def test_openvswitch_bridge_present_creates_fake_bridge(self): set_module_args( dict(state="present", bridge="test-br2", parent="test-br", vlan=10) ) commands = ["/usr/bin/ovs-vsctl -t 5 add-br test-br2 test-br 10"] self.execute_module( changed=True, commands=commands, test_name="test_openvswitch_bridge_present_creates_fake_bridge", )
def test_openvswitch_bridge_present_creates_fake_bridge(self): set_module_args(dict(state='present', bridge='test-br2', parent='test-br', vlan=10)) commands = [ '/usr/bin/ovs-vsctl -t 5 add-br test-br2 test-br 10', ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_bridge_present_creates_fake_bridge')
def test_openvswitch_bridge_present_idempotent(self): set_module_args( dict( state="present", bridge="test-br", fail_mode="secure", external_ids={"foo": "bar"}, )) self.execute_module( test_name="test_openvswitch_bridge_present_idempotent")
def test_openvswitch_bridge_present_changes_fail_mode(self): set_module_args(dict(state='present', bridge='test-br', fail_mode='standalone', external_ids={'foo': 'bar'})) commands = [ '/usr/bin/ovs-vsctl -t 5 set-fail-mode test-br standalone' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_bridge_present_changes_fail_mode')
def test_openvswitch_db_present_missing_key_on_map(self): set_module_args( dict(state='present', table='Bridge', record='test-br', col='other_config', value='false')) self.execute_module( failed=True, test_name='test_openvswitch_db_present_missing_key_on_map')
def test_openvswitch_bridge_present_clears_external_id(self): set_module_args(dict(state='present', bridge='test-br', fail_mode='secure', external_ids={'foo': ''})) commands = [ '/usr/bin/ovs-vsctl -t 5 br-set-external-id test-br foo ' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_bridge_present_clears_external_id')
def test_openvswitch_db_present_idempotent_value(self): set_module_args({ "col": "other_config", "key": "pmd-cpu-mask", "record": ".", "table": "open_vswitch", "value": "0xaaa00000000", }) self.execute_module( test_name="test_openvswitch_db_present_idempotent_value")
def test_openvswitch_port_present_idempotent(self): set_module_args( dict( state="present", bridge="test-br", port="eth2", tag=10, external_ids={"foo": "bar"}, )) self.execute_module( test_name="test_openvswitch_port_present_idempotent")
def test_openvswitch_db_present_stp_enable(self): set_module_args( dict( state="present", table="Bridge", record="test-br", col="stp_enable", value="true", )) self.execute_module(changed=True, test_name="test_openvswitch_db_present_stp_enable")
def test_openvswitch_db_present_idempotent(self): set_module_args( dict( state="present", table="Bridge", record="test-br", col="other_config", key="disable-in-band", value="true", )) self.execute_module(test_name="test_openvswitch_db_present_idempotent")
def test_openvswitch_bond_present_idempotent(self): set_module_args( dict( state="present", bridge="bond-br", port="bond0", external_ids={"foo": "bar"}, other_config={"bond-detect-mode": "miimon"}, )) self.execute_module( commands=[], test_name="test_openvswitch_bond_present_idempotent")
def test_openvswitch_port_present_changes_tag(self): set_module_args(dict(state='present', bridge='test-br', port='eth2', tag=20, external_ids={'foo': 'bar'})) commands = [ '/usr/bin/ovs-vsctl -t 5 set port eth2 tag=20' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_port_present_changes_tag')
def test_openvswitch_bridge_present_creates_bridge(self): set_module_args(dict(state='present', bridge='test-br', fail_mode='secure', external_ids={'foo': 'bar'})) commands = [ '/usr/bin/ovs-vsctl -t 5 add-br test-br', '/usr/bin/ovs-vsctl -t 5 set-fail-mode test-br secure', '/usr/bin/ovs-vsctl -t 5 br-set-external-id test-br foo bar' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_bridge_present_creates_bridge')
def test_openvswitch_port_present_clears_external_id(self): set_module_args(dict(state='present', bridge='test-br', port='eth2', tag=10, external_ids={'foo': None})) commands = [ '/usr/bin/ovs-vsctl -t 5 remove port eth2 external_ids foo' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_port_present_clears_external_id')
def test_openvswitch_port_present_adds_external_id(self): set_module_args(dict(state='present', bridge='test-br', port='eth2', tag=10, external_ids={'foo2': 'bar2'})) commands = [ '/usr/bin/ovs-vsctl -t 5 set port eth2 external_ids:foo2=bar2' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_port_present_adds_external_id')
def test_openvswitch_db_present_missing_key_on_map(self): set_module_args( dict( state="present", table="Bridge", record="test-br", col="other_config", value="false", )) self.execute_module( failed=True, test_name="test_openvswitch_db_present_missing_key_on_map", )
def test_openvswitch_bridge_updates_vlan(self): set_module_args({ "state": "present", "bridge": "test-br2", "parent": "test-br", "vlan": 300, }) commands = ["/usr/bin/ovs-vsctl -t 5 set port test-br2 tag=300"] self.execute_module( changed=True, commands=commands, test_name="test_openvswitch_bridge_updates_vlan", )
def test_openvswitch_bridge_present_runs_set_mode(self): set_module_args(dict(state='present', bridge='test-br', fail_mode='secure', external_ids={'foo': 'bar'}, set="bridge test-br datapath_type=netdev")) commands = [ '/usr/bin/ovs-vsctl -t 5 add-br test-br -- set bridge test-br' ' datapath_type=netdev', '/usr/bin/ovs-vsctl -t 5 set-fail-mode test-br secure', '/usr/bin/ovs-vsctl -t 5 br-set-external-id test-br foo bar' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_bridge_present_runs_set_mode')
def test_openvswitch_bridge_present_clears_external_id(self): set_module_args( dict( state="present", bridge="test-br", fail_mode="secure", external_ids={"foo": ""}, )) commands = ["/usr/bin/ovs-vsctl -t 5 br-set-external-id test-br foo "] self.execute_module( changed=True, commands=commands, test_name="test_openvswitch_bridge_present_clears_external_id", )
def test_openvswitch_bridge_present_changes_fail_mode(self): set_module_args( dict( state="present", bridge="test-br", fail_mode="standalone", external_ids={"foo": "bar"}, )) commands = ["/usr/bin/ovs-vsctl -t 5 set-fail-mode test-br standalone"] self.execute_module( changed=True, commands=commands, test_name="test_openvswitch_bridge_present_changes_fail_mode", )
def test_openvswitch_port_present_runs_set_mode(self): set_module_args(dict(state='present', bridge='test-br', port='eth2', tag=10, external_ids={'foo': 'bar'}, set="port eth2 other_config:stp-path-cost=10")) commands = [ '/usr/bin/ovs-vsctl -t 5 add-port test-br eth2 tag=10 -- set' ' port eth2 other_config:stp-path-cost=10', '/usr/bin/ovs-vsctl -t 5 set port eth2 external_ids:foo=bar' ] self.execute_module(changed=True, commands=commands, test_name='test_openvswitch_port_present_runs_set_mode')
def test_openvswitch_db_present_updates_key(self): set_module_args( dict(state='present', table='Bridge', record='test-br', col='other_config', key='disable-in-band', value='false')) self.execute_module( changed=True, commands=[ '/usr/bin/ovs-vsctl -t 5 set Bridge test-br other_config' ':disable-in-band=false' ], test_name='test_openvswitch_db_present_updates_key')