| Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 | # | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 3 | # Neutron VMware NSX plugin | 
|  | 4 | # ------------------------- | 
|  | 5 |  | 
|  | 6 | # Save trace setting | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 7 | NSX_XTRACE=$(set +o | grep xtrace) | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 8 | set +o xtrace | 
|  | 9 |  | 
|  | 10 | source $TOP_DIR/lib/neutron_plugins/ovs_base | 
|  | 11 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 12 | function setup_integration_bridge { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 13 | _neutron_ovs_base_setup_bridge $OVS_BRIDGE | 
|  | 14 | # Set manager to NSX controller (1st of list) | 
|  | 15 | if [[ "$NSX_CONTROLLERS" != "" ]]; then | 
|  | 16 | # Get the first controller | 
|  | 17 | controllers=(${NSX_CONTROLLERS//,/ }) | 
|  | 18 | OVS_MGR_IP=${controllers[0]} | 
|  | 19 | else | 
|  | 20 | die $LINENO "Error - No controller specified. Unable to set a manager for OVS" | 
|  | 21 | fi | 
|  | 22 | sudo ovs-vsctl set-manager ssl:$OVS_MGR_IP | 
|  | 23 | } | 
|  | 24 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 25 | function is_neutron_ovs_base_plugin { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 26 | # NSX uses OVS, but not the l3-agent | 
|  | 27 | return 0 | 
|  | 28 | } | 
|  | 29 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 30 | function neutron_plugin_create_nova_conf { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 31 | # if n-cpu is enabled, then setup integration bridge | 
|  | 32 | if is_service_enabled n-cpu; then | 
|  | 33 | setup_integration_bridge | 
|  | 34 | fi | 
|  | 35 | } | 
|  | 36 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 37 | function neutron_plugin_install_agent_packages { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 38 | # VMware NSX Plugin does not run q-agt, but it currently needs dhcp and metadata agents | 
|  | 39 | _neutron_ovs_base_install_agent_packages | 
|  | 40 | } | 
|  | 41 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 42 | function neutron_plugin_configure_common { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 43 | Q_PLUGIN_CONF_PATH=etc/neutron/plugins/vmware | 
|  | 44 | Q_PLUGIN_CONF_FILENAME=nsx.ini | 
| armando-migliaccio | 41e36d6 | 2014-02-04 13:39:32 -0800 | [diff] [blame] | 45 | Q_PLUGIN_CLASS="neutron.plugins.vmware.plugin.NsxPlugin" | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 46 | } | 
|  | 47 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 48 | function neutron_plugin_configure_debug_command { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 49 | sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE | 
|  | 50 | iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT external_network_bridge "$PUBLIC_BRIDGE" | 
|  | 51 | } | 
|  | 52 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 53 | function neutron_plugin_configure_dhcp_agent { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 54 | setup_integration_bridge | 
|  | 55 | iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata True | 
|  | 56 | iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network True | 
|  | 57 | iniset $Q_DHCP_CONF_FILE DEFAULT ovs_use_veth True | 
|  | 58 | } | 
|  | 59 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 60 | function neutron_plugin_configure_l3_agent { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 61 | # VMware NSX plugin does not run L3 agent | 
| Gary Kotton | b405256 | 2014-06-11 04:16:57 -0700 | [diff] [blame] | 62 | die $LINENO "q-l3 should not be executed with VMware NSX plugin!" | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 63 | } | 
|  | 64 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 65 | function neutron_plugin_configure_plugin_agent { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 66 | # VMware NSX plugin does not run L2 agent | 
|  | 67 | die $LINENO "q-agt must not be executed with VMware NSX plugin!" | 
|  | 68 | } | 
|  | 69 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 70 | function neutron_plugin_configure_service { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 71 | if [[ "$MAX_LP_PER_BRIDGED_LS" != "" ]]; then | 
|  | 72 | iniset /$Q_PLUGIN_CONF_FILE nsx max_lp_per_bridged_ls $MAX_LP_PER_BRIDGED_LS | 
|  | 73 | fi | 
|  | 74 | if [[ "$MAX_LP_PER_OVERLAY_LS" != "" ]]; then | 
|  | 75 | iniset /$Q_PLUGIN_CONF_FILE nsx max_lp_per_overlay_ls $MAX_LP_PER_OVERLAY_LS | 
|  | 76 | fi | 
|  | 77 | if [[ "$FAILOVER_TIME" != "" ]]; then | 
|  | 78 | iniset /$Q_PLUGIN_CONF_FILE nsx failover_time $FAILOVER_TIME | 
|  | 79 | fi | 
|  | 80 | if [[ "$CONCURRENT_CONNECTIONS" != "" ]]; then | 
|  | 81 | iniset /$Q_PLUGIN_CONF_FILE nsx concurrent_connections $CONCURRENT_CONNECTIONS | 
|  | 82 | fi | 
|  | 83 |  | 
|  | 84 | if [[ "$DEFAULT_TZ_UUID" != "" ]]; then | 
|  | 85 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_tz_uuid $DEFAULT_TZ_UUID | 
|  | 86 | else | 
|  | 87 | die $LINENO "The VMware NSX plugin won't work without a default transport zone." | 
|  | 88 | fi | 
|  | 89 | if [[ "$DEFAULT_L3_GW_SVC_UUID" != "" ]]; then | 
|  | 90 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l3_gw_service_uuid $DEFAULT_L3_GW_SVC_UUID | 
|  | 91 | Q_L3_ENABLED=True | 
|  | 92 | Q_L3_ROUTER_PER_TENANT=True | 
|  | 93 | iniset /$Q_PLUGIN_CONF_FILE nsx metadata_mode access_network | 
|  | 94 | fi | 
|  | 95 | if [[ "$DEFAULT_L2_GW_SVC_UUID" != "" ]]; then | 
|  | 96 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l2_gw_service_uuid $DEFAULT_L2_GW_SVC_UUID | 
|  | 97 | fi | 
|  | 98 | # NSX_CONTROLLERS must be a comma separated string | 
|  | 99 | if [[ "$NSX_CONTROLLERS" != "" ]]; then | 
|  | 100 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_controllers $NSX_CONTROLLERS | 
|  | 101 | else | 
|  | 102 | die $LINENO "The VMware NSX plugin needs at least an NSX controller." | 
|  | 103 | fi | 
|  | 104 | if [[ "$NSX_USER" != "" ]]; then | 
|  | 105 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_user $NSX_USER | 
|  | 106 | fi | 
|  | 107 | if [[ "$NSX_PASSWORD" != "" ]]; then | 
|  | 108 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_password $NSX_PASSWORD | 
|  | 109 | fi | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 110 | if [[ "$NSX_HTTP_TIMEOUT" != "" ]]; then | 
|  | 111 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT http_timeout $NSX_HTTP_TIMEOUT | 
|  | 112 | fi | 
|  | 113 | if [[ "$NSX_RETRIES" != "" ]]; then | 
|  | 114 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT retries $NSX_RETRIES | 
|  | 115 | fi | 
|  | 116 | if [[ "$NSX_REDIRECTS" != "" ]]; then | 
|  | 117 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT redirects $NSX_REDIRECTS | 
|  | 118 | fi | 
|  | 119 | if [[ "$AGENT_MODE" != "" ]]; then | 
|  | 120 | iniset /$Q_PLUGIN_CONF_FILE nsx agent_mode $AGENT_MODE | 
|  | 121 | if [[ "$AGENT_MODE" == "agentless" ]]; then | 
|  | 122 | if [[ "$DEFAULT_SERVICE_CLUSTER_UUID" != "" ]]; then | 
|  | 123 | iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_service_cluster_uuid $DEFAULT_SERVICE_CLUSTER_UUID | 
|  | 124 | else | 
|  | 125 | die $LINENO "Agentless mode requires a service cluster." | 
|  | 126 | fi | 
|  | 127 | iniset /$Q_PLUGIN_CONF_FILE nsx_metadata metadata_server_address $Q_META_DATA_IP | 
|  | 128 | fi | 
|  | 129 | fi | 
|  | 130 | } | 
|  | 131 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 132 | function neutron_plugin_setup_interface_driver { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 133 | local conf_file=$1 | 
|  | 134 | iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver | 
|  | 135 | } | 
|  | 136 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 137 | function has_neutron_plugin_security_group { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 138 | # 0 means True here | 
|  | 139 | return 0 | 
|  | 140 | } | 
|  | 141 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 142 | function neutron_plugin_check_adv_test_requirements { | 
| armando-migliaccio | 05952e3 | 2014-01-05 07:59:06 -0800 | [diff] [blame] | 143 | is_service_enabled q-dhcp && return 0 | 
|  | 144 | } | 
|  | 145 |  | 
|  | 146 | # Restore xtrace | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 147 | $NSX_XTRACE |