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