diff options
author | panageo2 <panageo@intracom-telecom.com> | 2017-07-18 09:55:37 +0000 |
---|---|---|
committer | panageo2 <panageo@intracom-telecom.com> | 2017-07-18 14:46:43 +0000 |
commit | 99bae44820c3acb77933dbdd8d1296e5f28878df (patch) | |
tree | db1b642aadedad5199eda6e7677cc0db3ddbe268 /sdnvpn/lib/utils.py | |
parent | 38d1895faf9aaeefa6b64df6f4d149a00884b09b (diff) |
Add test case 9
Development of a new test that checks all
nodes and succeeds if all OVS br-int interfaces
have fail_mode=secure
JIRA: SDNVPN-168
Change-Id: Iff14f60e2d25c1769cdec7cec126425937780eb7
Signed-off-by: panageo2 <panageo@intracom-telecom.com>
Diffstat (limited to 'sdnvpn/lib/utils.py')
-rw-r--r-- | sdnvpn/lib/utils.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index e22e455..a7aa991 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -649,3 +649,37 @@ def create_router_association(neutron_client, bgpvpn_id, router_id): def create_network_association(neutron_client, bgpvpn_id, neutron_network_id): json_body = {"network_association": {"network_id": neutron_network_id}} return neutron_client.create_network_association(bgpvpn_id, json_body) + + +def is_fail_mode_secure(): + """ + Checks the value of the attribute fail_mode, + if it is set to secure. This check is performed + on all OVS br-int interfaces, for all OpenStack nodes. + """ + is_secure = {} + openstack_nodes = get_nodes() + get_ovs_int_cmd = ("sudo ovs-vsctl show | " + "grep -i bridge | " + "awk '{print $2}'") + # Define OVS get fail_mode command + get_ovs_fail_mode_cmd = ("sudo ovs-vsctl get-fail-mode br-int") + for openstack_node in openstack_nodes: + if not openstack_node.is_active(): + continue + + ovs_int_list = (openstack_node.run_cmd(get_ovs_int_cmd). + strip().split('\n')) + if 'br-int' in ovs_int_list: + # Execute get fail_mode command + br_int_fail_mode = (openstack_node. + run_cmd(get_ovs_fail_mode_cmd).strip()) + if br_int_fail_mode == 'secure': + # success + is_secure[openstack_node.name] = True + else: + # failure + logging.error('The fail_mode for br-int was not secure ' + 'in {} node'.format(openstack_node.name)) + is_secure[openstack_node.name] = False + return is_secure |