2 Documentation Netvirt library. This library is useful for tests to create network, subnet, router and vm instances
5 Variables ../variables/Variables.py
9 [Arguments] ${network_name}
10 [Documentation] Create Network with neutron request.
11 ${output}= Write Commands Until Prompt cd /opt/stack/new/devstack && cat localrc
13 ${output}= Write Commands Until Prompt source openrc admin admin
15 ${output}= Write Commands Until Prompt neutron -v net-create ${network_name}
17 Should Contain ${output} Created a new network
20 [Arguments] ${network_name}
21 [Documentation] Delete Network with neutron request.
22 ${output}= Write Commands Until Prompt neutron -v net-delete ${network_name}
24 Should Contain ${output} Deleted network: ${network_name}
27 [Arguments] ${network_name}
28 [Documentation] Create SubNet for the Network with neutron request.
29 ${subnet}= Set Variable If "${network_name}"=="net1_network" subnet1 subnet2
30 ${range_ip}= Set Variable If "${network_name}"=="net1_network" 10.0.0.0/24 20.0.0.0/24
31 ${output}= Write Commands Until Prompt neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet}
33 Should Contain ${output} Created a new subnet
36 [Documentation] Verifies the Gateway Ips with dump flow.
37 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
39 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
40 \ Should Contain ${output} ${GatewayIpElement}
43 [Documentation] Verifies the Dhcp Ips with dump flow.
44 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
46 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
47 \ Should Contain ${output} ${DhcpIpElement}
50 [Documentation] Verifies the Dhcp Ips with dump flow.
51 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
53 : FOR ${DhcpIpElement} IN @{DHCP_IPS}
54 \ Should Not Contain ${output} ${DhcpIpElement}
57 [Arguments] ${network_name}
58 [Documentation] Delete SubNet for the Network with neutron request.
59 ${subnet}= Set Variable If "${network_name}"=="net1_network" subnet1 subnet2
60 ${output}= Write Commands Until Prompt neutron -v subnet-delete ${subnet}
62 Should Contain ${output} Deleted subnet: ${subnet}
65 [Documentation] Verifies the Gateway Ips removed with dump flow.
66 ${output}= Write Commands Until Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
68 : FOR ${GatewayIpElement} IN @{GATEWAY_IPS}
69 \ Should Not Contain ${output} ${GatewayIpElement}
72 [Arguments] ${net_id} ${network_name}
73 [Documentation] Create Vm Instance with the net id of the Netowrk.
74 ${VmElement}= Set Variable If "${network_name}"=="net1_network" MyFirstInstance MySecondInstance
75 ${output}= Write Commands Until Prompt nova boot --image cirros-0.3.4-x86_64-uec --flavor m1.tiny --nic net-id=${net_id} ${VmElement}
79 [Arguments] ${vm_name}
80 [Documentation] Delete Vm instances using instance names.
81 ${output}= Write Commands Until Prompt nova delete ${vm_name}
85 [Arguments] ${network_name}
86 [Documentation] Retrieve the net id for the given network name to create specific vm instance
87 ${output}= Write Commands Until Prompt neutron net-list | grep "${network_name}" | get_field 1
89 ${splitted_output}= Split String ${output} \
90 ${net_id}= Get from List ${splitted_output} 0
95 [Documentation] Create Router and Add Interface to the subnets.
96 ${output}= Write Commands Until Prompt neutron -v router-create router_1
98 : FOR ${SubnetElement} IN @{SUBNETS_NAME}
99 \ ${output}= Write Commands Until Prompt neutron -v router-interface-add router_1 ${SubnetElement}
103 [Documentation] Remove Interface to the subnets.
104 : FOR ${SubnetElement} IN @{SUBNETS_NAME}
105 \ ${output}= Write Commands Until Prompt neutron -v router-interface-delete router_1 ${SubnetElement}
109 [Documentation] Delete Router and Interface to the subnets.
110 ${output}= Write Commands Until Prompt neutron -v router-delete router_1