a54873e87953c47a1323d9c1002f04fc8782fd35
[integration/test.git] / tools / deployment / openstack_ha / deploy / 06_neutron_setup.robot
1 *** Settings ***
2 Documentation     Suite that Intalls Neutron and Configures Networking ODL
3 Suite Setup       OpenStackInstallUtils.Get All Ssh Connections
4 Suite Teardown    Close All Connections
5 Library           SSHLibrary
6 Library           OperatingSystem
7 Library           RequestsLibrary
8 Resource          ../libraries/OpenStackInstallUtils.robot
9 Resource          ../libraries/OpenStackOperations.robot
10 Resource          ../libraries/SystemUtils.robot
11 Resource          ../libraries/Utils.robot
12
13 *** Test Cases ***
14 Install Neutron
15     Create And Configure Neutron Db    ${OS_CONTROL_1_IP}    root    mysql    ${OS_CONTROL_1_HOSTNAME}
16     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create And Configure Neutron Db Other Nodes    ${OS_CONTROL_2_IP}    root    mysql    ${OS_CONTROL_2_HOSTNAME}
17     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create And Configure Neutron Db Other Nodes    ${OS_CONTROL_3_IP}    root    mysql    ${OS_CONTROL_3_HOSTNAME}
18     Run Keyword If    3 < ${NUM_CONTROL_NODES}    Create And Configure Neutron Db Other Nodes    ${OS_CONTROL_4_IP}    root    mysql    ${OS_CONTROL_4_HOSTNAME}
19     Run Keyword If    4 < ${NUM_CONTROL_NODES}    Create And Configure Neutron Db Other Nodes    ${OS_CONTROL_5_IP}    root    mysql    ${OS_CONTROL_5_HOSTNAME}
20     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Create Openstack Elements    ${HAPROXY_HOSTNAME}
21     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Create Openstack Elements    ${OS_CONTROL_1_HOSTNAME}
22     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Install Configure Neutron    ${OS_CONTROL_1_IP}    ${OS_CONTROL_1_IP}    ${HAPROXY_HOSTNAME}
23     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Install Configure Neutron    ${OS_CONTROL_1_IP}    ${OS_CONTROL_1_IP}    ${OS_CONTROL_1_HOSTNAME}
24     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Install Configure Neutron    ${OS_CONTROL_2_IP}    ${OS_CONTROL_2_IP}    ${HAPROXY_HOSTNAME}
25     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Install Configure Neutron    ${OS_CONTROL_3_IP}    ${OS_CONTROL_3_IP}    ${HAPROXY_HOSTNAME}
26     Run Keyword If    3 < ${NUM_CONTROL_NODES}    Install Configure Neutron    ${OS_CONTROL_4_IP}    ${OS_CONTROL_3_IP}    ${HAPROXY_HOSTNAME}
27     Run Keyword If    4 < ${NUM_CONTROL_NODES}    Install Configure Neutron    ${OS_CONTROL_5_IP}    ${OS_CONTROL_3_IP}    ${HAPROXY_HOSTNAME}
28     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Sync Db    ${OS_CONTROL_1_IP}
29     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Sync Db    ${OS_CONTROL_1_IP}
30     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Sync Db    ${OS_CONTROL_2_IP}
31     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Sync Db    ${OS_CONTROL_3_IP}
32     Run Keyword If    3 < ${NUM_CONTROL_NODES}    Sync Db    ${OS_CONTROL_4_IP}
33     Run Keyword If    4 < ${NUM_CONTROL_NODES}    Sync Db    ${OS_CONTROL_5_IP}
34     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Generic HAProxy Entry    ${HAPROXY_IP}    ${HAPROXY_IP}    9696    neutron_server
35     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Add ODL As Ovs Manager    ${OS_CONTROL_1_IP}
36     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Add ODL As Ovs Manager    ${OS_CONTROL_1_IP}
37     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Add ODL As Ovs Manager    ${OS_CONTROL_2_IP}
38     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Add ODL As Ovs Manager    ${OS_CONTROL_3_IP}
39     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Start Neutron Service    ${OS_CONTROL_1_IP}
40     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Start Neutron Service    ${OS_CONTROL_1_IP}
41     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Start Neutron Service    ${OS_CONTROL_2_IP}
42     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Start Neutron Service    ${OS_CONTROL_3_IP}
43     Run Keyword If    1 > ${NUM_COMPUTE_NODES}    Install Configure Neutron Compute    ${OS_CONTROL_1_IP}    ${OS_CONTROL_1_IP}    ${OS_CONTROL_1_IP}
44     Run Keyword If    0 < ${NUM_COMPUTE_NODES} and 2 < ${NUM_CONTROL_NODES}    Install Configure Neutron Compute    ${OS_COMPUTE_1_IP}    ${OS_COMPUTE_1_IP}    ${HAPROXY_HOSTNAME}
45     Run Keyword If    1 < ${NUM_COMPUTE_NODES} and 2 < ${NUM_CONTROL_NODES}    Install Configure Neutron Compute    ${OS_COMPUTE_2_IP}    ${OS_COMPUTE_2_IP}    ${HAPROXY_HOSTNAME}
46     Run Keyword If    0 < ${NUM_COMPUTE_NODES} and 2 > ${NUM_CONTROL_NODES}    Install Configure Neutron Compute    ${OS_COMPUTE_1_IP}    ${OS_COMPUTE_1_IP}    ${OS_CONTROL_1_HOSTNAME}
47     Run Keyword If    1 < ${NUM_COMPUTE_NODES} and 2 > ${NUM_CONTROL_NODES}    Install Configure Neutron Compute    ${OS_COMPUTE_2_IP}    ${OS_COMPUTE_2_IP}    ${OS_CONTROL_1_HOSTNAME}
48
49 *** Keywords ***
50 Create And Configure Neutron Db
51     [Arguments]    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    ${host_name}
52     Create Database for Mysql    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    neutron
53     Grant Privileges To Mysql Database    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    neutron.*    neutron    ${host_name}
54     ...    neutron
55     Grant Privileges To Mysql Database    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    neutron.*    neutron    localhost
56     ...    neutron
57     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Grant Privileges To Mysql Database    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    neutron.*
58     ...    neutron    ${HAPROXY_HOSTNAME}    neutron
59
60 Create And Configure Neutron Db Other Nodes
61     [Arguments]    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    ${host_name}
62     Grant Privileges To Mysql Database    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    neutron.*    neutron    ${host_name}
63     ...    neutron
64     Grant Privileges To Mysql Database    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    neutron.*    neutron    localhost
65     ...    neutron
66     Grant Privileges To Mysql Database    ${os_node_cxn}    ${mysql_user}    ${mysql_pass}    neutron.*    neutron    ${HAPROXY_HOSTNAME}
67     ...    neutron
68
69 Create Openstack Elements
70     [Arguments]    ${host_name}
71     Create User    neutron    default    neutron    rc_file=/tmp/stackrc
72     Role Add    service    neutron    admin    rc_file=/tmp/stackrc
73     Create Service    neutron    "Networking service"    network    rc_file=/tmp/stackrc
74     Create Endpoint    RegionOne    ${host_name}    network    public    9696    rc_file=/tmp/stackrc
75     Create Endpoint    RegionOne    ${host_name}    network    internal    9696    rc_file=/tmp/stackrc
76     Create Endpoint    RegionOne    ${host_name}    network    admin    9696    rc_file=/tmp/stackrc
77
78 Install Configure Neutron
79     [Arguments]    ${os_node_cxn}    ${host_ip}    ${host_name}
80     Run Keyword If    '${OS_APPS_PRE_INSTALLED}' == 'no'    Install Rpm Package    ${os_node_cxn}    openstack-neutron openstack-neutron-ml2 ebtables
81     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    transport_url
82     ...    "rabbit://openstack:rabbit@${OS_CONTROL_1_HOSTNAME},openstack:rabbit@${OS_CONTROL_2_HOSTNAME},openstack:rabbit@${OS_CONTROL_3_HOSTNAME}"
83     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    transport_url
84     ...    "rabbit://openstack:rabbit@${host_name}"
85     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    core_plugin    ml2
86     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    allow_overlapping_ips    true
87     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    database    connection    "mysql+pymysql://neutron:neutron@${host_name}/neutron"
88     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    auth_strategy    keystone
89     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    notify_nova_on_port_status_changes    true
90     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    notify_nova_on_port_data_changes    true
91     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    dhcp_agents_per_network
92     ...    3
93     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    auth_uri    http://${host_name}:5000
94     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    auth_url    http://${host_name}:35357
95     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    memcached_servers
96     ...    ${OS_CONTROL_1_IP}:11211,${OS_CONTROL_2_IP}:11211,${OS_CONTROL_3_IP}:11211
97     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    memcached_servers
98     ...    ${host_name}:11211
99     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    auth_type    password
100     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    project_domain_name    default
101     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    user_domain_name    default
102     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    project_name    service
103     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    username    neutron
104     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    keystone_authtoken    password    neutron
105     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    auth_uri    http://${host_name}:5000
106     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    auth_url    http://${host_name}:35357
107     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    memcached_servers
108     ...    ${OS_CONTROL_1_IP}:11211,${OS_CONTROL_2_IP}:11211,${OS_CONTROL_3_IP}:11211
109     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    memcached_servers
110     ...    ${host_name}:11211
111     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    auth_type    password
112     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    project_domain_name    default
113     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    user_domain_name    default
114     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    project_name    service
115     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    username    nova
116     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    nova    password    nova
117     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    oslo_concurrency    lock_path    /var/lib/neutron/tmp
118     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    OVS    ovsdb_connection    tcp:127.0.0.1:6641
119     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    oslo_messaging_rabbit    rabbit_max_retries    0
120     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    oslo_messaging_rabbit    rabbit_ha_queues    true
121     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2    type_drivers    "flat,vlan,vxlan"
122     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2    tenant_network_types    vxlan
123     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2_type_vxlan    vni_ranges    1:1000
124     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2_type_vlan    network_vlan_ranges    physnet1:1:4094
125     Crudini Edit    ${os_node_cxn}    /etc/neutron/dhcp_agent.ini    DEFAULT    ovs_use_veth    True
126     Crudini Edit    ${os_node_cxn}    /etc/neutron/dhcp_agent.ini    DEFAULT    interface_driver    openvswitch
127     Crudini Edit    ${os_node_cxn}    /etc/neutron/dhcp_agent.ini    DEFAULT    enable_isolated_metadata    true
128     Crudini Edit    ${os_node_cxn}    /etc/neutron/dhcp_agent.ini    OVS    ovsdb_connection    tcp:127.0.0.1:6641
129     Crudini Edit    ${os_node_cxn}    /etc/neutron/metadata_agent.ini    DEFAULT    nova_metadata_ip    ${host_name}
130     Crudini Edit    ${os_node_cxn}    /etc/neutron/metadata_agent.ini    DEFAULT    metadata_proxy_shared_secret    metadata
131     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    url    http://${host_name}:9696
132     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    auth_url    http://${host_name}:35357
133     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    auth_type    password
134     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    project_domain_name    default
135     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    user_domain_name    default
136     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    region_name    RegionOne
137     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    project_name    service
138     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    username    neutron
139     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    password    neutron
140     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    service_metadata_proxy    true
141     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    metadata_proxy_shared_secret    metadata
142     Run Keyword If    '${OS_APPS_PRE_INSTALLED}' == 'no'    Install Rpm Package    ${os_node_cxn}    python-networking-odl
143     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2    mechanism_drivers    opendaylight_v2
144     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2_odl    url    http://${host_name}:8080/controller/nb/v2/neutron
145     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2_odl    username    admin
146     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2_odl    password    admin
147     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2_odl    port_binding_controller    pseudo-agentdb-binding
148     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    securitygroup    enable_security_group    true
149     Crudini Edit    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    ml2    extension_drivers    port_security
150     Crudini Edit    ${os_node_cxn}    /etc/neutron/neutron.conf    DEFAULT    service_plugins    odl-router_v2
151     Install OVS And Configure    ${os_node_cxn}    ${host_ip}
152
153 Sync Db
154     [Arguments]    ${os_node_cxn}
155     #Unlink File    ${os_node_cxn}    /etc/neutron/plugin.ini
156     Create Softlink    ${os_node_cxn}    /etc/neutron/plugins/ml2/ml2_conf.ini    /etc/neutron/plugin.ini
157     Run Command As User    ${os_node_cxn}    "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head"    neutron
158     Enable Service    ${os_node_cxn}    neutron-server.service neutron-dhcp-agent.service neutron-metadata-agent.service
159
160 Start Neutron Service
161     [Arguments]    ${os_node_cxn}
162     Restart Service    ${os_node_cxn}    openstack-nova-api.service
163     Start Service    ${os_node_cxn}    neutron-server.service neutron-dhcp-agent.service neutron-metadata-agent.service
164
165 Install Configure Neutron Compute
166     [Arguments]    ${os_node_cxn}    ${host_ip}    ${host_name}
167     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    auth_type    password
168     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    auth_url
169     ...    http://${host_name}:35357
170     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    auth_url
171     ...    http://${HAPROXY_HOSTNAME}:35357
172     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    username    neutron
173     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    password    neutron
174     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    user_domain_name    Default
175     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    project_domain_name    Default
176     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    project_name    service
177     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    auth_strategy    keystone
178     Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    region_name    RegionOne
179     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    url
180     ...    http://${host_name}:9696
181     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Crudini Edit    ${os_node_cxn}    /etc/nova/nova.conf    neutron    url
182     ...    http://${HAPROXY_HOSTNAME}:9696
183     Restart Service    ${os_node_cxn}    libvirtd.service openstack-nova-compute.service
184     Install OVS And Configure    ${os_node_cxn}    ${host_ip}
185     Add ODL As Ovs Manager    ${os_node_cxn}
186
187 Install OVS And Configure
188     [Arguments]    ${os_node_cxn}    ${host_ip}
189     Run Keyword If    '${OS_APPS_PRE_INSTALLED}' == 'no'    Install Rpm Package    ${os_node_cxn}    python-networking-odl openvswitch
190     Enable Service    ${os_node_cxn}    openvswitch
191     Restart Service    ${os_node_cxn}    openvswitch
192     Run Command    ${os_node_cxn}    sudo neutron-odl-ovs-hostconfig --config-file=/etc/neutron/neutron.conf --debug --noovs_dpdk --bridge_mappings="flat1:br-flat1,flat2:br-flat2,physnet1:br-physnet1" --local_ip ${host_ip}
193
194 Add ODL As Ovs Manager
195     [Arguments]    ${os_node_cxn}
196     Run Keyword If    2 < ${NUM_CONTROL_NODES}    Run Command    ${os_node_cxn}    sudo ovs-vsctl set-manager tcp:${OS_CONTROL_1_IP}:6640 tcp:${OS_CONTROL_2_IP}:6640 tcp:${OS_CONTROL_3_IP}:6640
197     Run Keyword If    2 > ${NUM_CONTROL_NODES}    Run Command    ${os_node_cxn}    sudo ovs-vsctl set-manager tcp:${OS_CONTROL_1_IP}:6640