Anastasia Kuznetsova | 6823b06 | 2018-03-23 15:52:17 +0400 | [diff] [blame] | 1 | |
| 2 | {%- macro MACRO_CONFIGURE_VSWITCH(NODE_NAME, IP) %} |
| 3 | {#################################################} |
| 4 | |
| 5 | - description: 'Install openvswitch-vtep package and configure it' |
| 6 | cmd: | |
| 7 | ip addr add {{ IP }}/24 dev ens4 |
| 8 | ifconfig ens4 up |
| 9 | |
| 10 | apt-get update |
| 11 | apt-get -y install openvswitch-switch |
| 12 | service openvswitch-switch stop |
| 13 | apt-get -y install openvswitch-vtep bridge-utils |
| 14 | |
| 15 | ovsdb-tool create /etc/openvswitch/vtep.db /usr/share/openvswitch/vtep.ovsschema |
| 16 | ovsdb-tool create /etc/openvswitch/vswitch.db /usr/share/openvswitch/vswitch.ovsschema |
| 17 | ovsdb-server --pidfile --detach --log-file --remote ptcp:6632:{{ IP }} --remote punix:/var/run/openvswitch/db.sock --remote=db:hardware_vtep,Global,managers /etc/openvswitch/vswitch.db /etc/openvswitch/vtep.db |
| 18 | ovs-vswitchd --log-file --detach --pidfile unix:/var/run/openvswitch/db.sock |
| 19 | ovs-vsctl add-br v-switch |
| 20 | vtep-ctl add-ps v-switch |
| 21 | vtep-ctl set Physical_Switch v-switch tunnel_ips={{ IP }} |
| 22 | ovs-vsctl add-port v-switch port0 -- set interface port0 type=internal |
| 23 | vtep-ctl add-port v-switch port0 |
| 24 | /usr/share/openvswitch/scripts/ovs-vtep --log-file=/var/log/openvswitch/ovs-vtep.log --pidfile=/var/run/openvswitch/ovs-vtep.pid --detach v-switch |
| 25 | node_name: {{ NODE_NAME }} |
| 26 | retry: {count: 1, delay: 5} |
| 27 | skip_fail: false |
| 28 | |
| 29 | {%- endmacro %} |
| 30 | |
| 31 | {%- macro MACRO_CHECK_BGPVPN_ENABLED_BY_DEFAULT() %} |
| 32 | {#####################################################} |
| 33 | |
| 34 | - description: 'Check BGPVPN extension is enabled by default' |
| 35 | cmd: salt 'cmp*' pillar.get neutron:compute:bgp_vpn:enabled | grep True |
| 36 | node_name: {{ HOSTNAME_CFG01 }} |
| 37 | retry: {count: 1, delay: 5} |
| 38 | skip_fail: false |
| 39 | |
| 40 | {%- endmacro %} |
| 41 | |
| 42 | {%- macro MACRO_ENABLE_L2GW(CLUSTER_NAME, VSWITCH_IP) %} |
| 43 | {#####################################################} |
| 44 | |
| 45 | - description: 'Check L2GW is disabled by default' |
| 46 | cmd: salt 'gtw01*' pillar.get neutron:gateway:l2gw:enabled | grep False |
| 47 | node_name: {{ HOSTNAME_CFG01 }} |
| 48 | retry: {count: 1, delay: 5} |
| 49 | skip_fail: false |
| 50 | |
| 51 | - description: 'Enable L2GW' |
| 52 | cmd: | |
| 53 | set -e; |
| 54 | set -x; |
| 55 | {%- set CLUSTER_PATH = '/srv/salt/reclass/classes/cluster/' + CLUSTER_NAME %} |
| 56 | |
| 57 | echo "Setting 'enable: true' for L2gw feature to gateway.yml file" |
| 58 | L2GW_LINE=$(sed -n '/l2gw/=' {{ CLUSTER_PATH }}/openstack/gateway.yml) |
| 59 | L2GW_ENABLE_LINE=$((L2GW_LINE + 1)) |
| 60 | sed -i "${L2GW_ENABLE_LINE}s/enabled: false/enabled: true/1" {{ CLUSTER_PATH }}/openstack/gateway.yml |
| 61 | |
| 62 | echo "Setting 'ovsdb_hosts' ips for L2gw feature to gateway.yml file" |
| 63 | sed -i "s/ovsdbx: 127.0.0.1:6632/ovsdbx: {{VSWITCH_IP}}:6632/1" {{ CLUSTER_PATH }}/openstack/gateway.yml |
| 64 | |
| 65 | node_name: {{ HOSTNAME_CFG01 }} |
| 66 | retry: {count: 1, delay: 5} |
| 67 | skip_fail: false |
| 68 | |
| 69 | - description: 'Refresh pillar data after L2GW enablement' |
| 70 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar |
| 71 | node_name: {{ HOSTNAME_CFG01 }} |
| 72 | retry: {count: 1, delay: 5} |
| 73 | skip_fail: false |
| 74 | |
| 75 | - description: 'Check L2GW is enabled' |
| 76 | cmd: salt 'gtw01*' pillar.get neutron:gateway:l2gw:enabled | grep True |
| 77 | node_name: {{ HOSTNAME_CFG01 }} |
| 78 | retry: {count: 1, delay: 5} |
| 79 | skip_fail: false |
| 80 | |
| 81 | {%- endmacro %} |