def test_del(): _execCmd([EXT_OVS_VSCTL, 'show']) json_input = { 'request': { 'networks': { 'ovs-test-net': { 'remove': True } }, 'bondings': { 'bond1515': { 'remove': True } } } } print("\nexecuting hook with fake json input:") print(json_input) hooks.before_network_setup(json_input) print("hook finished\n") _execCmd([EXT_OVS_VSCTL, 'show']) _execCmd(['cat', '/var/run/vdsm/netconf/nets/ovs-test-net'], exit=False) _execCmd(['cat', '/var/run/vdsm/netconf/bonds/bond1515'], exit=False) _execCmd([EXT_IP, 'link', 'del', 'dummy_1']) _execCmd([EXT_IP, 'link', 'del', 'dummy_2'])
def test_add(): _execCmd([EXT_OVS_VSCTL, 'show']) json_input = { 'request': { 'networks': { 'ovs-test-net': { 'bonding': 'bond1515', 'bridged': True, 'vlan': 122, 'custom': { 'ovs': True } } }, 'bondings': { 'bond1515': { 'nics': ['dummy_1', 'dummy_2'], 'custom': { 'ovs': True, 'ovs_bond_mode': 'active-backup' } } } } } _execCmd([EXT_IP, 'link', 'add', 'dummy_1', 'type', 'dummy']) _execCmd([EXT_IP, 'link', 'add', 'dummy_2', 'type', 'dummy']) print("> executing hook with fake json input: " + str(json_input)) hooks.before_network_setup(json_input) print("hook finished") _execCmd([EXT_OVS_VSCTL, 'show']) _execCmd(['cat', '/var/run/vdsm/netconf/nets/ovs-test-net']) _execCmd(['cat', '/var/run/vdsm/netconf/bonds/bond1515'])
def test_del(): _execCmd([EXT_OVS_VSCTL, 'show']) json_input = {'request': {'networks': {'ovs-test-net': {'remove': True}}, 'bondings': {'bond1515': {'remove': True}}}} print("\nexecuting hook with fake json input:") print(json_input) hooks.before_network_setup(json_input) print("hook finished\n") _execCmd([EXT_OVS_VSCTL, 'show']) _execCmd(['cat', '/var/run/vdsm/netconf/nets/ovs-test-net'], exit=False) _execCmd(['cat', '/var/run/vdsm/netconf/bonds/bond1515'], exit=False) _execCmd([EXT_IP, 'link', 'del', 'dummy_1']) _execCmd([EXT_IP, 'link', 'del', 'dummy_2'])
def _apply_hook(bondings, networks, options): results = hooks.before_network_setup(_build_setup_hook_dict(networks, bondings, options)) # gather any changes that could have been done by the hook scripts networks = results["request"]["networks"] bondings = results["request"]["bondings"] options = results["request"]["options"] return bondings, networks, options
def _apply_hook(bondings, networks, options): results = hooks.before_network_setup( _build_setup_hook_dict(networks, bondings, options)) # gather any changes that could have been done by the hook scripts networks = results['request']['networks'] bondings = results['request']['bondings'] options = results['request']['options'] return bondings, networks, options
def test_add(): _execCmd([EXT_OVS_VSCTL, 'show']) json_input = { 'request': { 'networks': { 'ovs-test-net': {'bonding': 'bond1515', 'bridged': True, 'vlan': 122, 'custom': {'ovs': True}}}, 'bondings': { 'bond1515': {'nics': ['dummy_1', 'dummy_2'], 'custom': {'ovs': True, 'ovs_bond_mode': 'active-backup'}}}}} _execCmd([EXT_IP, 'link', 'add', 'dummy_1', 'type', 'dummy']) _execCmd([EXT_IP, 'link', 'add', 'dummy_2', 'type', 'dummy']) print("> executing hook with fake json input: " + str(json_input)) hooks.before_network_setup(json_input) print("hook finished") _execCmd([EXT_OVS_VSCTL, 'show']) _execCmd(['cat', '/var/run/vdsm/netconf/nets/ovs-test-net']) _execCmd(['cat', '/var/run/vdsm/netconf/bonds/bond1515'])