| Salvatore Orlando | d6767d0 | 2012-08-31 04:55:20 -0700 | [diff] [blame] | 1 | # lib/quantum | 
|  | 2 | # functions - funstions specific to quantum | 
|  | 3 |  | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 4 | # Dependencies: | 
|  | 5 | # ``functions`` file | 
|  | 6 | # ``DEST`` must be defined | 
|  | 7 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 8 | # ``stack.sh`` calls the entry points in this order: | 
|  | 9 | # | 
|  | 10 | # install_quantum | 
|  | 11 | # install_quantumclient | 
|  | 12 | # install_quantum_agent_packages | 
|  | 13 | # install_quantum_third_party | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 14 | # configure_quantum | 
|  | 15 | # init_quantum | 
|  | 16 | # configure_quantum_third_party | 
|  | 17 | # init_quantum_third_party | 
|  | 18 | # start_quantum_third_party | 
|  | 19 | # create_nova_conf_quantum | 
|  | 20 | # start_quantum_service_and_check | 
|  | 21 | # create_quantum_initial_network | 
|  | 22 | # setup_quantum_debug | 
|  | 23 | # start_quantum_agents | 
|  | 24 | # | 
|  | 25 | # ``unstack.sh`` calls the entry points in this order: | 
|  | 26 | # | 
|  | 27 | # stop_quantum | 
|  | 28 |  | 
|  | 29 | # Functions in lib/quantum are classified into the following categories: | 
|  | 30 | # | 
|  | 31 | # - entry points (called from stack.sh or unstack.sh) | 
|  | 32 | # - internal functions | 
|  | 33 | # - quantum exercises | 
|  | 34 | # - 3rd party programs | 
|  | 35 |  | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 36 |  | 
|  | 37 | # Quantum Networking | 
|  | 38 | # ------------------ | 
|  | 39 |  | 
|  | 40 | # Make sure that quantum is enabled in ``ENABLED_SERVICES``.  If you want | 
|  | 41 | # to run Quantum on this host, make sure that q-svc is also in | 
|  | 42 | # ``ENABLED_SERVICES``. | 
|  | 43 | # | 
|  | 44 | # If you're planning to use the Quantum openvswitch plugin, set | 
|  | 45 | # ``Q_PLUGIN`` to "openvswitch" and make sure the q-agt service is enabled | 
|  | 46 | # in ``ENABLED_SERVICES``.  If you're planning to use the Quantum | 
|  | 47 | # linuxbridge plugin, set ``Q_PLUGIN`` to "linuxbridge" and make sure the | 
|  | 48 | # q-agt service is enabled in ``ENABLED_SERVICES``. | 
|  | 49 | # | 
|  | 50 | # See "Quantum Network Configuration" below for additional variables | 
|  | 51 | # that must be set in localrc for connectivity across hosts with | 
|  | 52 | # Quantum. | 
|  | 53 | # | 
| Dean Troyer | b323691 | 2013-03-17 15:17:05 -0500 | [diff] [blame] | 54 | # With Quantum networking the NETWORK_MANAGER variable is ignored. | 
| Kyle Mestery | ebfac64 | 2013-05-17 15:20:56 -0500 | [diff] [blame] | 55 | # | 
|  | 56 | # To enable specific configuration options for either the Open vSwitch or | 
|  | 57 | # LinuxBridge plugin, please see the top level README file under the | 
|  | 58 | # Quantum section. | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 59 |  | 
| Salvatore Orlando | d6767d0 | 2012-08-31 04:55:20 -0700 | [diff] [blame] | 60 | # Save trace setting | 
|  | 61 | XTRACE=$(set +o | grep xtrace) | 
|  | 62 | set +o xtrace | 
|  | 63 |  | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 64 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 65 | # Quantum Network Configuration | 
|  | 66 | # ----------------------------- | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 67 |  | 
|  | 68 | # Set up default directories | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 69 | QUANTUM_DIR=$DEST/quantum | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 70 | QUANTUMCLIENT_DIR=$DEST/python-quantumclient | 
| Gary Kotton | 9343df1 | 2012-11-28 10:05:53 +0000 | [diff] [blame] | 71 | QUANTUM_AUTH_CACHE_DIR=${QUANTUM_AUTH_CACHE_DIR:-/var/cache/quantum} | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 72 |  | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 73 | QUANTUM_CONF_DIR=/etc/quantum | 
|  | 74 | QUANTUM_CONF=$QUANTUM_CONF_DIR/quantum.conf | 
|  | 75 | export QUANTUM_TEST_CONFIG_FILE=${QUANTUM_TEST_CONFIG_FILE:-"$QUANTUM_CONF_DIR/debug.ini"} | 
|  | 76 |  | 
|  | 77 | # Default Quantum Plugin | 
|  | 78 | Q_PLUGIN=${Q_PLUGIN:-openvswitch} | 
|  | 79 | # Default Quantum Port | 
|  | 80 | Q_PORT=${Q_PORT:-9696} | 
|  | 81 | # Default Quantum Host | 
| Jian Wen | f28c9c7 | 2013-05-21 14:16:56 +0800 | [diff] [blame] | 82 | Q_HOST=${Q_HOST:-$SERVICE_HOST} | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 83 | # Default admin username | 
|  | 84 | Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum} | 
|  | 85 | # Default auth strategy | 
|  | 86 | Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone} | 
|  | 87 | # Use namespace or not | 
|  | 88 | Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True} | 
| Maru Newby | d7150e9 | 2013-04-23 06:16:11 +0000 | [diff] [blame] | 89 | # RHEL's support for namespaces requires using veths with ovs | 
|  | 90 | Q_OVS_USE_VETH=${Q_OVS_USE_VETH:-False} | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 91 | Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True} | 
|  | 92 | # Meta data IP | 
| Jian Wen | f28c9c7 | 2013-05-21 14:16:56 +0800 | [diff] [blame] | 93 | Q_META_DATA_IP=${Q_META_DATA_IP:-$SERVICE_HOST} | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 94 | # Allow Overlapping IP among subnets | 
| Salvatore Orlando | d1742fe | 2013-03-07 13:34:57 +0100 | [diff] [blame] | 95 | Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True} | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 96 | # Use quantum-debug command | 
|  | 97 | Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False} | 
| Maru Newby | 31c94ab | 2012-12-19 03:59:20 +0000 | [diff] [blame] | 98 | # The name of the default q-l3 router | 
|  | 99 | Q_ROUTER_NAME=${Q_ROUTER_NAME:-router1} | 
| Baodong (Robert) Li | 7a8d852 | 2013-03-21 06:16:55 -0700 | [diff] [blame] | 100 | # List of config file names in addition to the main plugin config file | 
|  | 101 | # See _configure_quantum_common() for details about setting it up | 
|  | 102 | declare -a Q_PLUGIN_EXTRA_CONF_FILES | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 103 |  | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 104 | if is_service_enabled quantum; then | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 105 | Q_RR_CONF_FILE=$QUANTUM_CONF_DIR/rootwrap.conf | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 106 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
|  | 107 | Q_RR_COMMAND="sudo" | 
|  | 108 | else | 
| Nachi Ueno | eb1aa3d | 2012-12-06 11:55:29 -0800 | [diff] [blame] | 109 | QUANTUM_ROOTWRAP=$(get_rootwrap_location quantum) | 
|  | 110 | Q_RR_COMMAND="sudo $QUANTUM_ROOTWRAP $Q_RR_CONF_FILE" | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 111 | fi | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 112 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 113 | # Provider Network Configurations | 
|  | 114 | # -------------------------------- | 
|  | 115 |  | 
|  | 116 | # The following variables control the Quantum openvswitch and | 
|  | 117 | # linuxbridge plugins' allocation of tenant networks and | 
|  | 118 | # availability of provider networks. If these are not configured | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 119 | # in ``localrc``, tenant networks will be local to the host (with no | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 120 | # remote connectivity), and no physical resources will be | 
|  | 121 | # available for the allocation of provider networks. | 
|  | 122 |  | 
|  | 123 | # To use GRE tunnels for tenant networks, set to True in | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 124 | # ``localrc``. GRE tunnels are only supported by the openvswitch | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 125 | # plugin, and currently only on Ubuntu. | 
|  | 126 | ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-False} | 
|  | 127 |  | 
|  | 128 | # If using GRE tunnels for tenant networks, specify the range of | 
|  | 129 | # tunnel IDs from which tenant networks are allocated. Can be | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 130 | # overriden in ``localrc`` in necesssary. | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 131 | TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGE:-1:1000} | 
|  | 132 |  | 
|  | 133 | # To use VLANs for tenant networks, set to True in localrc. VLANs | 
|  | 134 | # are supported by the openvswitch and linuxbridge plugins, each | 
|  | 135 | # requiring additional configuration described below. | 
|  | 136 | ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False} | 
|  | 137 |  | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 138 | # If using VLANs for tenant networks, set in ``localrc`` to specify | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 139 | # the range of VLAN VIDs from which tenant networks are | 
|  | 140 | # allocated. An external network switch must be configured to | 
|  | 141 | # trunk these VLANs between hosts for multi-host connectivity. | 
|  | 142 | # | 
|  | 143 | # Example: ``TENANT_VLAN_RANGE=1000:1999`` | 
|  | 144 | TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-} | 
|  | 145 |  | 
|  | 146 | # If using VLANs for tenant networks, or if using flat or VLAN | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 147 | # provider networks, set in ``localrc`` to the name of the physical | 
|  | 148 | # network, and also configure ``OVS_PHYSICAL_BRIDGE`` for the | 
|  | 149 | # openvswitch agent or ``LB_PHYSICAL_INTERFACE`` for the linuxbridge | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 150 | # agent, as described below. | 
|  | 151 | # | 
|  | 152 | # Example: ``PHYSICAL_NETWORK=default`` | 
|  | 153 | PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-} | 
|  | 154 |  | 
|  | 155 | # With the openvswitch plugin, if using VLANs for tenant networks, | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 156 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 157 | # the name of the OVS bridge to use for the physical network. The | 
|  | 158 | # bridge will be created if it does not already exist, but a | 
|  | 159 | # physical interface must be manually added to the bridge as a | 
|  | 160 | # port for external connectivity. | 
|  | 161 | # | 
|  | 162 | # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1`` | 
|  | 163 | OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-} | 
|  | 164 |  | 
|  | 165 | # With the linuxbridge plugin, if using VLANs for tenant networks, | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 166 | # or if using flat or VLAN provider networks, set in ``localrc`` to | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 167 | # the name of the network interface to use for the physical | 
|  | 168 | # network. | 
|  | 169 | # | 
|  | 170 | # Example: ``LB_PHYSICAL_INTERFACE=eth1`` | 
|  | 171 | LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-} | 
|  | 172 |  | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 173 | # With the openvswitch plugin, set to True in ``localrc`` to enable | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 174 | # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False. | 
|  | 175 | # | 
|  | 176 | # Example: ``OVS_ENABLE_TUNNELING=True`` | 
|  | 177 | OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS} | 
|  | 178 | fi | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 179 |  | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 180 | # Quantum plugin specific functions | 
|  | 181 | # --------------------------------- | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 182 |  | 
|  | 183 | # Please refer to ``lib/quantum_plugins/README.md`` for details. | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 184 | source $TOP_DIR/lib/quantum_plugins/$Q_PLUGIN | 
|  | 185 |  | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 186 | # Agent loadbalancer service plugin functions | 
|  | 187 | # ------------------------------------------- | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 188 |  | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 189 | # Hardcoding for 1 service plugin for now | 
| Akihiro MOTOKI | c07112a | 2013-03-22 16:35:38 +0900 | [diff] [blame] | 190 | source $TOP_DIR/lib/quantum_plugins/services/agent_loadbalancer | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 191 |  | 
| Akihiro MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 192 | # Use security group or not | 
|  | 193 | if has_quantum_plugin_security_group; then | 
|  | 194 | Q_USE_SECGROUP=${Q_USE_SECGROUP:-True} | 
|  | 195 | else | 
|  | 196 | Q_USE_SECGROUP=False | 
|  | 197 | fi | 
|  | 198 |  | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 199 | # Functions | 
|  | 200 | # --------- | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 201 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 202 | # configure_quantum() | 
|  | 203 | # Set common config for all quantum server and agents. | 
|  | 204 | function configure_quantum() { | 
|  | 205 | _configure_quantum_common | 
| Akihiro MOTOKI | b0f1c38 | 2013-01-13 17:58:12 +0900 | [diff] [blame] | 206 | iniset_rpc_backend quantum $QUANTUM_CONF DEFAULT | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 207 |  | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 208 | # goes before q-svc to init Q_SERVICE_PLUGIN_CLASSES | 
|  | 209 | if is_service_enabled q-lbaas; then | 
|  | 210 | _configure_quantum_lbaas | 
|  | 211 | fi | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 212 | if is_service_enabled q-svc; then | 
|  | 213 | _configure_quantum_service | 
|  | 214 | fi | 
|  | 215 | if is_service_enabled q-agt; then | 
|  | 216 | _configure_quantum_plugin_agent | 
|  | 217 | fi | 
|  | 218 | if is_service_enabled q-dhcp; then | 
|  | 219 | _configure_quantum_dhcp_agent | 
|  | 220 | fi | 
|  | 221 | if is_service_enabled q-l3; then | 
|  | 222 | _configure_quantum_l3_agent | 
|  | 223 | fi | 
|  | 224 | if is_service_enabled q-meta; then | 
|  | 225 | _configure_quantum_metadata_agent | 
|  | 226 | fi | 
|  | 227 |  | 
|  | 228 | _configure_quantum_debug_command | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 229 | } | 
|  | 230 |  | 
|  | 231 | function create_nova_conf_quantum() { | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 232 | iniset $NOVA_CONF DEFAULT network_api_class "nova.network.quantumv2.api.API" | 
|  | 233 | iniset $NOVA_CONF DEFAULT quantum_admin_username "$Q_ADMIN_USERNAME" | 
|  | 234 | iniset $NOVA_CONF DEFAULT quantum_admin_password "$SERVICE_PASSWORD" | 
|  | 235 | iniset $NOVA_CONF DEFAULT quantum_admin_auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0" | 
|  | 236 | iniset $NOVA_CONF DEFAULT quantum_auth_strategy "$Q_AUTH_STRATEGY" | 
|  | 237 | iniset $NOVA_CONF DEFAULT quantum_admin_tenant_name "$SERVICE_TENANT_NAME" | 
|  | 238 | iniset $NOVA_CONF DEFAULT quantum_url "http://$Q_HOST:$Q_PORT" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 239 |  | 
| Akihiro MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 240 | if [[ "$Q_USE_SECGROUP" == "True" ]]; then | 
|  | 241 | LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver | 
|  | 242 | iniset $NOVA_CONF DEFAULT security_group_api quantum | 
|  | 243 | fi | 
|  | 244 |  | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 245 | # set NOVA_VIF_DRIVER and optionally set options in nova_conf | 
|  | 246 | quantum_plugin_create_nova_conf | 
|  | 247 |  | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 248 | iniset $NOVA_CONF DEFAULT libvirt_vif_driver "$NOVA_VIF_DRIVER" | 
|  | 249 | iniset $NOVA_CONF DEFAULT linuxnet_interface_driver "$LINUXNET_VIF_DRIVER" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 250 | if is_service_enabled q-meta; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 251 | iniset $NOVA_CONF DEFAULT service_quantum_metadata_proxy "True" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 252 | fi | 
|  | 253 | } | 
|  | 254 |  | 
|  | 255 | # create_quantum_accounts() - Set up common required quantum accounts | 
|  | 256 |  | 
|  | 257 | # Tenant               User       Roles | 
|  | 258 | # ------------------------------------------------------------------ | 
|  | 259 | # service              quantum    admin        # if enabled | 
|  | 260 |  | 
|  | 261 | # Migrated from keystone_data.sh | 
|  | 262 | function create_quantum_accounts() { | 
|  | 263 |  | 
|  | 264 | SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }") | 
|  | 265 | ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }") | 
|  | 266 |  | 
|  | 267 | if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then | 
|  | 268 | QUANTUM_USER=$(keystone user-create \ | 
|  | 269 | --name=quantum \ | 
|  | 270 | --pass="$SERVICE_PASSWORD" \ | 
|  | 271 | --tenant_id $SERVICE_TENANT \ | 
|  | 272 | --email=quantum@example.com \ | 
|  | 273 | | grep " id " | get_field 2) | 
|  | 274 | keystone user-role-add \ | 
|  | 275 | --tenant_id $SERVICE_TENANT \ | 
|  | 276 | --user_id $QUANTUM_USER \ | 
|  | 277 | --role_id $ADMIN_ROLE | 
|  | 278 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then | 
|  | 279 | QUANTUM_SERVICE=$(keystone service-create \ | 
|  | 280 | --name=quantum \ | 
|  | 281 | --type=network \ | 
|  | 282 | --description="Quantum Service" \ | 
|  | 283 | | grep " id " | get_field 2) | 
|  | 284 | keystone endpoint-create \ | 
|  | 285 | --region RegionOne \ | 
|  | 286 | --service_id $QUANTUM_SERVICE \ | 
|  | 287 | --publicurl "http://$SERVICE_HOST:9696/" \ | 
|  | 288 | --adminurl "http://$SERVICE_HOST:9696/" \ | 
|  | 289 | --internalurl "http://$SERVICE_HOST:9696/" | 
|  | 290 | fi | 
|  | 291 | fi | 
|  | 292 | } | 
|  | 293 |  | 
|  | 294 | function create_quantum_initial_network() { | 
|  | 295 | TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1) | 
|  | 296 |  | 
|  | 297 | # Create a small network | 
|  | 298 | # Since quantum command is executed in admin context at this point, | 
|  | 299 | # ``--tenant_id`` needs to be specified. | 
| Devananda van der Veen | 37a8d15 | 2013-01-15 17:27:34 -0800 | [diff] [blame] | 300 | if is_baremetal; then | 
|  | 301 | sudo ovs-vsctl add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE | 
|  | 302 | for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do | 
|  | 303 | sudo ip addr del $IP dev $PUBLIC_INTERFACE | 
|  | 304 | sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE | 
|  | 305 | done | 
|  | 306 | NET_ID=$(quantum net-create $PHYSICAL_NETWORK --tenant_id $TENANT_ID --provider:network_type flat --provider:physical_network "$PHYSICAL_NETWORK" | grep ' id ' | get_field 2) | 
|  | 307 | SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2) | 
|  | 308 | sudo ifconfig $OVS_PHYSICAL_BRIDGE up | 
|  | 309 | else | 
|  | 310 | NET_ID=$(quantum net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2) | 
|  | 311 | SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2) | 
|  | 312 | fi | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 313 |  | 
| Dan Wendlandt | 555ecd0 | 2013-02-23 23:07:07 -0800 | [diff] [blame] | 314 | if [[ "$Q_L3_ENABLED" == "True" ]]; then | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 315 | # Create a router, and add the private subnet as one of its interfaces | 
| Dan Wendlandt | 555ecd0 | 2013-02-23 23:07:07 -0800 | [diff] [blame] | 316 | if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then | 
|  | 317 | # create a tenant-owned router. | 
| Maru Newby | 31c94ab | 2012-12-19 03:59:20 +0000 | [diff] [blame] | 318 | ROUTER_ID=$(quantum router-create --tenant_id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2) | 
|  | 319 | else | 
| Dan Wendlandt | 555ecd0 | 2013-02-23 23:07:07 -0800 | [diff] [blame] | 320 | # Plugin only supports creating a single router, which should be admin owned. | 
| Maru Newby | 31c94ab | 2012-12-19 03:59:20 +0000 | [diff] [blame] | 321 | ROUTER_ID=$(quantum router-create $Q_ROUTER_NAME | grep ' id ' | get_field 2) | 
|  | 322 | fi | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 323 | quantum router-interface-add $ROUTER_ID $SUBNET_ID | 
|  | 324 | # Create an external network, and a subnet. Configure the external network as router gw | 
|  | 325 | EXT_NET_ID=$(quantum net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2) | 
| Stephen Ma | 8396d4f | 2013-02-18 05:32:59 -0800 | [diff] [blame] | 326 | EXT_GW_IP=$(quantum subnet-create --ip_version 4 ${Q_FLOATING_ALLOCATION_POOL:+--allocation-pool $Q_FLOATING_ALLOCATION_POOL} $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2) | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 327 | quantum router-gateway-set $ROUTER_ID $EXT_NET_ID | 
|  | 328 |  | 
| Dan Wendlandt | 555ecd0 | 2013-02-23 23:07:07 -0800 | [diff] [blame] | 329 | if is_service_enabled q-l3; then | 
|  | 330 | # logic is specific to using the l3-agent for l3 | 
|  | 331 | if is_quantum_ovs_base_plugin && [[ "$Q_USE_NAMESPACE" = "True" ]]; then | 
|  | 332 | CIDR_LEN=${FLOATING_RANGE#*/} | 
|  | 333 | sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE | 
|  | 334 | sudo ip link set $PUBLIC_BRIDGE up | 
|  | 335 | ROUTER_GW_IP=`quantum port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'` | 
|  | 336 | sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP | 
|  | 337 | fi | 
|  | 338 | if [[ "$Q_USE_NAMESPACE" == "False" ]]; then | 
|  | 339 | # Explicitly set router id in l3 agent configuration | 
|  | 340 | iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID | 
|  | 341 | fi | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 342 | fi | 
|  | 343 | fi | 
|  | 344 | } | 
|  | 345 |  | 
|  | 346 | # init_quantum() - Initialize databases, etc. | 
|  | 347 | function init_quantum() { | 
|  | 348 | : | 
|  | 349 | } | 
|  | 350 |  | 
|  | 351 | # install_quantum() - Collect source and prepare | 
|  | 352 | function install_quantum() { | 
|  | 353 | git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH | 
| Dean Troyer | fe51a90 | 2013-04-01 15:48:44 -0500 | [diff] [blame] | 354 | setup_develop $QUANTUM_DIR | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 355 | } | 
|  | 356 |  | 
|  | 357 | # install_quantumclient() - Collect source and prepare | 
|  | 358 | function install_quantumclient() { | 
|  | 359 | git_clone $QUANTUMCLIENT_REPO $QUANTUMCLIENT_DIR $QUANTUMCLIENT_BRANCH | 
| Dean Troyer | fe51a90 | 2013-04-01 15:48:44 -0500 | [diff] [blame] | 360 | setup_develop $QUANTUMCLIENT_DIR | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 361 | } | 
|  | 362 |  | 
|  | 363 | # install_quantum_agent_packages() - Collect source and prepare | 
|  | 364 | function install_quantum_agent_packages() { | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 365 | # install packages that is specific to plugin agent | 
|  | 366 | quantum_plugin_install_agent_packages | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 367 | } | 
|  | 368 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 369 | # Start running processes, including screen | 
|  | 370 | function start_quantum_service_and_check() { | 
| Baodong (Robert) Li | 7a8d852 | 2013-03-21 06:16:55 -0700 | [diff] [blame] | 371 | # build config-file options | 
|  | 372 | local cfg_file | 
|  | 373 | local CFG_FILE_OPTIONS="--config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE" | 
|  | 374 | for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do | 
|  | 375 | CFG_FILE_OPTIONS+=" --config-file /$cfg_file" | 
|  | 376 | done | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 377 | # Start the Quantum service | 
| Baodong (Robert) Li | 7a8d852 | 2013-03-21 06:16:55 -0700 | [diff] [blame] | 378 | screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server $CFG_FILE_OPTIONS" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 379 | echo "Waiting for Quantum to start..." | 
| Aaron Rosen | 0ae742c | 2013-02-21 12:10:30 -0800 | [diff] [blame] | 380 | if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$Q_HOST:$Q_PORT; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 381 | die $LINENO "Quantum did not start" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 382 | fi | 
|  | 383 | } | 
|  | 384 |  | 
|  | 385 | # Start running processes, including screen | 
|  | 386 | function start_quantum_agents() { | 
|  | 387 | # Start up the quantum agents if enabled | 
| Dean Troyer | 58ab929 | 2013-03-19 15:39:47 -0500 | [diff] [blame] | 388 | screen_it q-agt "cd $QUANTUM_DIR && python $AGENT_BINARY --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE" | 
|  | 389 | screen_it q-dhcp "cd $QUANTUM_DIR && python $AGENT_DHCP_BINARY --config-file $QUANTUM_CONF --config-file=$Q_DHCP_CONF_FILE" | 
|  | 390 | screen_it q-l3 "cd $QUANTUM_DIR && python $AGENT_L3_BINARY --config-file $QUANTUM_CONF --config-file=$Q_L3_CONF_FILE" | 
|  | 391 | screen_it q-meta "cd $QUANTUM_DIR && python $AGENT_META_BINARY --config-file $QUANTUM_CONF --config-file=$Q_META_CONF_FILE" | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 392 |  | 
| Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 393 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then | 
|  | 394 | # For XenServer, start an agent for the domU openvswitch | 
|  | 395 | screen_it q-domua "cd $QUANTUM_DIR && python $AGENT_BINARY --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE.domU" | 
|  | 396 | fi | 
|  | 397 |  | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 398 | if is_service_enabled q-lbaas; then | 
| Dean Troyer | 58ab929 | 2013-03-19 15:39:47 -0500 | [diff] [blame] | 399 | screen_it q-lbaas "cd $QUANTUM_DIR && python $AGENT_LBAAS_BINARY --config-file $QUANTUM_CONF --config-file=$LBAAS_AGENT_CONF_FILENAME" | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 400 | fi | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 401 | } | 
|  | 402 |  | 
|  | 403 | # stop_quantum() - Stop running processes (non-screen) | 
|  | 404 | function stop_quantum() { | 
|  | 405 | if is_service_enabled q-dhcp; then | 
|  | 406 | pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }') | 
|  | 407 | [ ! -z "$pid" ] && sudo kill -9 $pid | 
|  | 408 | fi | 
| Jordan Pittier | 2ae6acf | 2013-05-08 19:14:29 +0200 | [diff] [blame] | 409 | if is_service_enabled q-meta; then | 
|  | 410 | pid=$(ps aux | awk '/quantum-ns-metadata-proxy/ { print $2 }') | 
|  | 411 | [ ! -z "$pid" ] && sudo kill -9 $pid | 
|  | 412 | fi | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 413 | } | 
|  | 414 |  | 
| Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 415 | # cleanup_quantum() - Remove residual data files, anything left over from previous | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 416 | # runs that a clean run would need to clean up | 
| Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 417 | function cleanup_quantum() { | 
| JordanP | 614202f | 2013-05-16 11:16:13 +0200 | [diff] [blame] | 418 | if is_quantum_ovs_base_plugin; then | 
|  | 419 | quantum_ovs_base_cleanup | 
|  | 420 | fi | 
|  | 421 |  | 
|  | 422 | # delete all namespaces created by quantum | 
|  | 423 | for ns in $(sudo ip netns list | grep -o -e qdhcp-[0-9a-f\-]* -e qrouter-[0-9a-f\-]*); do | 
|  | 424 | sudo ip netns delete ${ns} | 
|  | 425 | done | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 426 | } | 
|  | 427 |  | 
|  | 428 | # _configure_quantum_common() | 
|  | 429 | # Set common config for all quantum server and agents. | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 430 | # This MUST be called before other ``_configure_quantum_*`` functions. | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 431 | function _configure_quantum_common() { | 
|  | 432 | # Put config files in ``QUANTUM_CONF_DIR`` for everyone to find | 
|  | 433 | if [[ ! -d $QUANTUM_CONF_DIR ]]; then | 
|  | 434 | sudo mkdir -p $QUANTUM_CONF_DIR | 
|  | 435 | fi | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 436 | sudo chown $STACK_USER $QUANTUM_CONF_DIR | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 437 |  | 
|  | 438 | cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF | 
|  | 439 |  | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 440 | # Set plugin-specific variables ``Q_DB_NAME``, ``Q_PLUGIN_CLASS``. | 
|  | 441 | # For main plugin config file, set ``Q_PLUGIN_CONF_PATH``, ``Q_PLUGIN_CONF_FILENAME``. | 
|  | 442 | # For addition plugin config files, set ``Q_PLUGIN_EXTRA_CONF_PATH``, | 
|  | 443 | # ``Q_PLUGIN_EXTRA_CONF_FILES``.  For example: | 
|  | 444 | #    ``Q_PLUGIN_EXTRA_CONF_FILES=(file1, file2)`` | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 445 | quantum_plugin_configure_common | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 446 |  | 
|  | 447 | if [[ $Q_PLUGIN_CONF_PATH == '' || $Q_PLUGIN_CONF_FILENAME == '' || $Q_PLUGIN_CLASS == '' ]]; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 448 | die $LINENO "Quantum plugin not set.. exiting" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 449 | fi | 
|  | 450 |  | 
|  | 451 | # If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``QUANTUM_CONF_DIR`` | 
|  | 452 | mkdir -p /$Q_PLUGIN_CONF_PATH | 
|  | 453 | Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME | 
|  | 454 | cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE | 
|  | 455 |  | 
| Attila Fazekas | 7e79d91 | 2013-03-03 12:23:04 +0100 | [diff] [blame] | 456 | iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection `database_connection_url $Q_DB_NAME` | 
| mathieu-rohon | cf9c10d | 2013-03-18 17:34:03 +0100 | [diff] [blame] | 457 | iniset $QUANTUM_CONF DEFAULT state_path $DATA_DIR/quantum | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 458 |  | 
| Baodong (Robert) Li | 7a8d852 | 2013-03-21 06:16:55 -0700 | [diff] [blame] | 459 | # If addition config files are set, make sure their path name is set as well | 
|  | 460 | if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 && $Q_PLUGIN_EXTRA_CONF_PATH == '' ]]; then | 
|  | 461 | die $LINENO "Quantum additional plugin config not set.. exiting" | 
|  | 462 | fi | 
|  | 463 |  | 
|  | 464 | # If additional config files exist, copy them over to quantum configuration | 
|  | 465 | # directory | 
|  | 466 | if [[ $Q_PLUGIN_EXTRA_CONF_PATH != '' ]]; then | 
|  | 467 | mkdir -p /$Q_PLUGIN_EXTRA_CONF_PATH | 
|  | 468 | local f | 
|  | 469 | for (( f=0; $f < ${#Q_PLUGIN_EXTRA_CONF_FILES[@]}; f+=1 )); do | 
|  | 470 | Q_PLUGIN_EXTRA_CONF_FILES[$f]=$Q_PLUGIN_EXTRA_CONF_PATH/${Q_PLUGIN_EXTRA_CONF_FILES[$f]} | 
|  | 471 | cp $QUANTUM_DIR/${Q_PLUGIN_EXTRA_CONF_FILES[$f]} /${Q_PLUGIN_EXTRA_CONF_FILES[$f]} | 
|  | 472 | done | 
|  | 473 | fi | 
|  | 474 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 475 | _quantum_setup_rootwrap | 
|  | 476 | } | 
|  | 477 |  | 
|  | 478 | function _configure_quantum_debug_command() { | 
|  | 479 | if [[ "$Q_USE_DEBUG_COMMAND" != "True" ]]; then | 
|  | 480 | return | 
|  | 481 | fi | 
|  | 482 |  | 
|  | 483 | cp $QUANTUM_DIR/etc/l3_agent.ini $QUANTUM_TEST_CONFIG_FILE | 
|  | 484 |  | 
|  | 485 | iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT verbose False | 
|  | 486 | iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT debug False | 
|  | 487 | iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE | 
|  | 488 | iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT root_helper "$Q_RR_COMMAND" | 
| Gary Kotton | d9ca2b2 | 2013-01-30 13:52:43 +0000 | [diff] [blame] | 489 | # Intermediate fix until Quantum patch lands and then line above will | 
|  | 490 | # be cleaned. | 
|  | 491 | iniset $QUANTUM_TEST_CONFIG_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 492 |  | 
|  | 493 | _quantum_setup_keystone $QUANTUM_TEST_CONFIG_FILE DEFAULT set_auth_url | 
|  | 494 | _quantum_setup_interface_driver $QUANTUM_TEST_CONFIG_FILE | 
|  | 495 |  | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 496 | quantum_plugin_configure_debug_command | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 497 | } | 
|  | 498 |  | 
|  | 499 | function _configure_quantum_dhcp_agent() { | 
|  | 500 | AGENT_DHCP_BINARY="$QUANTUM_DIR/bin/quantum-dhcp-agent" | 
|  | 501 | Q_DHCP_CONF_FILE=$QUANTUM_CONF_DIR/dhcp_agent.ini | 
|  | 502 |  | 
|  | 503 | cp $QUANTUM_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE | 
|  | 504 |  | 
|  | 505 | iniset $Q_DHCP_CONF_FILE DEFAULT verbose True | 
|  | 506 | iniset $Q_DHCP_CONF_FILE DEFAULT debug True | 
|  | 507 | iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 508 | iniset $Q_DHCP_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND" | 
|  | 509 |  | 
|  | 510 | _quantum_setup_keystone $Q_DHCP_CONF_FILE DEFAULT set_auth_url | 
|  | 511 | _quantum_setup_interface_driver $Q_DHCP_CONF_FILE | 
|  | 512 |  | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 513 | quantum_plugin_configure_dhcp_agent | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 514 | } | 
|  | 515 |  | 
|  | 516 | function _configure_quantum_l3_agent() { | 
| Dan Wendlandt | 555ecd0 | 2013-02-23 23:07:07 -0800 | [diff] [blame] | 517 | Q_L3_ENABLED=True | 
|  | 518 | # for l3-agent, only use per tenant router if we have namespaces | 
|  | 519 | Q_L3_ROUTER_PER_TENANT=$Q_USE_NAMESPACE | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 520 | AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 521 | Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini | 
|  | 522 |  | 
|  | 523 | cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE | 
|  | 524 |  | 
|  | 525 | iniset $Q_L3_CONF_FILE DEFAULT verbose True | 
|  | 526 | iniset $Q_L3_CONF_FILE DEFAULT debug True | 
|  | 527 | iniset $Q_L3_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 528 | iniset $Q_L3_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND" | 
|  | 529 |  | 
|  | 530 | _quantum_setup_keystone $Q_L3_CONF_FILE DEFAULT set_auth_url | 
|  | 531 | _quantum_setup_interface_driver $Q_L3_CONF_FILE | 
|  | 532 |  | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 533 | quantum_plugin_configure_l3_agent | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 534 | } | 
|  | 535 |  | 
|  | 536 | function _configure_quantum_metadata_agent() { | 
|  | 537 | AGENT_META_BINARY="$QUANTUM_DIR/bin/quantum-metadata-agent" | 
|  | 538 | Q_META_CONF_FILE=$QUANTUM_CONF_DIR/metadata_agent.ini | 
|  | 539 |  | 
|  | 540 | cp $QUANTUM_DIR/etc/metadata_agent.ini $Q_META_CONF_FILE | 
|  | 541 |  | 
|  | 542 | iniset $Q_META_CONF_FILE DEFAULT verbose True | 
|  | 543 | iniset $Q_META_CONF_FILE DEFAULT debug True | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 544 | iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP | 
|  | 545 | iniset $Q_META_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND" | 
|  | 546 |  | 
|  | 547 | _quantum_setup_keystone $Q_META_CONF_FILE DEFAULT set_auth_url | 
|  | 548 | } | 
|  | 549 |  | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 550 | function _configure_quantum_lbaas() { | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 551 | quantum_agent_lbaas_install_agent_packages | 
|  | 552 | quantum_agent_lbaas_configure_common | 
|  | 553 | quantum_agent_lbaas_configure_agent | 
|  | 554 | } | 
|  | 555 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 556 | # _configure_quantum_plugin_agent() - Set config files for quantum plugin agent | 
|  | 557 | # It is called when q-agt is enabled. | 
|  | 558 | function _configure_quantum_plugin_agent() { | 
| Maru Newby | 2298ca4 | 2012-10-25 23:46:42 +0000 | [diff] [blame] | 559 | # Specify the default root helper prior to agent configuration to | 
| Gary Kotton | 98e18e9 | 2013-01-28 14:26:56 +0000 | [diff] [blame] | 560 | # ensure that an agent's configuration can override the default | 
| Maru Newby | 2298ca4 | 2012-10-25 23:46:42 +0000 | [diff] [blame] | 561 | iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND" | 
| mathieu-rohon | 3ebb01a | 2013-04-09 15:09:07 +0200 | [diff] [blame] | 562 | iniset $QUANTUM_CONF DEFAULT verbose True | 
|  | 563 | iniset $QUANTUM_CONF DEFAULT debug True | 
| Maru Newby | 2298ca4 | 2012-10-25 23:46:42 +0000 | [diff] [blame] | 564 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 565 | # Configure agent for plugin | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 566 | quantum_plugin_configure_plugin_agent | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 567 | } | 
|  | 568 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 569 | # _configure_quantum_service() - Set config files for quantum service | 
|  | 570 | # It is called when q-svc is enabled. | 
|  | 571 | function _configure_quantum_service() { | 
|  | 572 | Q_API_PASTE_FILE=$QUANTUM_CONF_DIR/api-paste.ini | 
|  | 573 | Q_POLICY_FILE=$QUANTUM_CONF_DIR/policy.json | 
|  | 574 |  | 
|  | 575 | cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE | 
|  | 576 | cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE | 
|  | 577 |  | 
|  | 578 | if is_service_enabled $DATABASE_BACKENDS; then | 
|  | 579 | recreate_database $Q_DB_NAME utf8 | 
|  | 580 | else | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 581 | die $LINENO "A database must be enabled in order to use the $Q_PLUGIN Quantum plugin." | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 582 | fi | 
|  | 583 |  | 
|  | 584 | # Update either configuration file with plugin | 
|  | 585 | iniset $QUANTUM_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS | 
|  | 586 |  | 
| Eugene Nikanorov | b7d8284 | 2013-03-06 16:28:33 +0400 | [diff] [blame] | 587 | if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then | 
|  | 588 | iniset $QUANTUM_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES | 
|  | 589 | fi | 
|  | 590 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 591 | iniset $QUANTUM_CONF DEFAULT verbose True | 
|  | 592 | iniset $QUANTUM_CONF DEFAULT debug True | 
| Salvatore Orlando | 3de02e8 | 2013-03-12 15:12:12 +0100 | [diff] [blame] | 593 | iniset $QUANTUM_CONF DEFAULT policy_file $Q_POLICY_FILE | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 594 | iniset $QUANTUM_CONF DEFAULT allow_overlapping_ips $Q_ALLOW_OVERLAPPING_IP | 
|  | 595 |  | 
|  | 596 | iniset $QUANTUM_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY | 
| Akihiro MOTOKI | 712feb6 | 2013-02-11 23:45:19 +0900 | [diff] [blame] | 597 | _quantum_setup_keystone $QUANTUM_CONF keystone_authtoken | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 598 |  | 
|  | 599 | # Configure plugin | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 600 | quantum_plugin_configure_service | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 601 | } | 
|  | 602 |  | 
|  | 603 | # Utility Functions | 
|  | 604 | #------------------ | 
|  | 605 |  | 
|  | 606 | # _quantum_setup_rootwrap() - configure Quantum's rootwrap | 
|  | 607 | function _quantum_setup_rootwrap() { | 
| Nachi Ueno | eb1aa3d | 2012-12-06 11:55:29 -0800 | [diff] [blame] | 608 | if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then | 
|  | 609 | return | 
|  | 610 | fi | 
|  | 611 | # Deploy new rootwrap filters files (owned by root). | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 612 | # Wipe any existing ``rootwrap.d`` files first | 
| Dean Troyer | 60e9c0a | 2012-12-06 15:52:52 -0600 | [diff] [blame] | 613 | Q_CONF_ROOTWRAP_D=$QUANTUM_CONF_DIR/rootwrap.d | 
| Nachi Ueno | eb1aa3d | 2012-12-06 11:55:29 -0800 | [diff] [blame] | 614 | if [[ -d $Q_CONF_ROOTWRAP_D ]]; then | 
|  | 615 | sudo rm -rf $Q_CONF_ROOTWRAP_D | 
|  | 616 | fi | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 617 | # Deploy filters to ``$QUANTUM_CONF_DIR/rootwrap.d`` | 
| Nachi Ueno | eb1aa3d | 2012-12-06 11:55:29 -0800 | [diff] [blame] | 618 | mkdir -p -m 755 $Q_CONF_ROOTWRAP_D | 
|  | 619 | cp -pr $QUANTUM_DIR/etc/quantum/rootwrap.d/* $Q_CONF_ROOTWRAP_D/ | 
|  | 620 | sudo chown -R root:root $Q_CONF_ROOTWRAP_D | 
|  | 621 | sudo chmod 644 $Q_CONF_ROOTWRAP_D/* | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 622 | # Set up ``rootwrap.conf``, pointing to ``$QUANTUM_CONF_DIR/rootwrap.d`` | 
| Dirk Mueller | 13aab25 | 2013-03-18 18:55:09 +0100 | [diff] [blame] | 623 | # location moved in newer versions, prefer new location | 
|  | 624 | if test -r $QUANTUM_DIR/etc/quantum/rootwrap.conf; then | 
|  | 625 | sudo cp -p $QUANTUM_DIR/etc/quantum/rootwrap.conf $Q_RR_CONF_FILE | 
|  | 626 | else | 
|  | 627 | sudo cp -p $QUANTUM_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE | 
|  | 628 | fi | 
| Nachi Ueno | eb1aa3d | 2012-12-06 11:55:29 -0800 | [diff] [blame] | 629 | sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE | 
|  | 630 | sudo chown root:root $Q_RR_CONF_FILE | 
|  | 631 | sudo chmod 0644 $Q_RR_CONF_FILE | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 632 | # Specify ``rootwrap.conf`` as first parameter to quantum-rootwrap | 
| Nachi Ueno | eb1aa3d | 2012-12-06 11:55:29 -0800 | [diff] [blame] | 633 | ROOTWRAP_SUDOER_CMD="$QUANTUM_ROOTWRAP $Q_RR_CONF_FILE *" | 
|  | 634 |  | 
|  | 635 | # Set up the rootwrap sudoers for quantum | 
|  | 636 | TEMPFILE=`mktemp` | 
|  | 637 | echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE | 
|  | 638 | chmod 0440 $TEMPFILE | 
|  | 639 | sudo chown root:root $TEMPFILE | 
|  | 640 | sudo mv $TEMPFILE /etc/sudoers.d/quantum-rootwrap | 
| Gary Kotton | 98e18e9 | 2013-01-28 14:26:56 +0000 | [diff] [blame] | 641 |  | 
|  | 642 | # Update the root_helper | 
|  | 643 | iniset $QUANTUM_CONF AGENT root_helper "$Q_RR_COMMAND" | 
| Nachi Ueno | eb1aa3d | 2012-12-06 11:55:29 -0800 | [diff] [blame] | 644 | } | 
|  | 645 |  | 
| Salvatore Orlando | d6767d0 | 2012-08-31 04:55:20 -0700 | [diff] [blame] | 646 | # Configures keystone integration for quantum service and agents | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 647 | function _quantum_setup_keystone() { | 
| Salvatore Orlando | d6767d0 | 2012-08-31 04:55:20 -0700 | [diff] [blame] | 648 | local conf_file=$1 | 
|  | 649 | local section=$2 | 
|  | 650 | local use_auth_url=$3 | 
|  | 651 | if [[ -n $use_auth_url ]]; then | 
|  | 652 | iniset $conf_file $section auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0" | 
|  | 653 | else | 
|  | 654 | iniset $conf_file $section auth_host $KEYSTONE_SERVICE_HOST | 
|  | 655 | iniset $conf_file $section auth_port $KEYSTONE_AUTH_PORT | 
|  | 656 | iniset $conf_file $section auth_protocol $KEYSTONE_SERVICE_PROTOCOL | 
|  | 657 | fi | 
|  | 658 | iniset $conf_file $section admin_tenant_name $SERVICE_TENANT_NAME | 
|  | 659 | iniset $conf_file $section admin_user $Q_ADMIN_USERNAME | 
|  | 660 | iniset $conf_file $section admin_password $SERVICE_PASSWORD | 
| Akihiro MOTOKI | 5e3deb6 | 2012-12-11 17:09:02 +0900 | [diff] [blame] | 661 | iniset $conf_file $section signing_dir $QUANTUM_AUTH_CACHE_DIR | 
|  | 662 | # Create cache dir | 
|  | 663 | sudo mkdir -p $QUANTUM_AUTH_CACHE_DIR | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 664 | sudo chown $STACK_USER $QUANTUM_AUTH_CACHE_DIR | 
| Vishvananda Ishaya | 23431f3 | 2012-12-12 15:57:33 -0800 | [diff] [blame] | 665 | rm -f $QUANTUM_AUTH_CACHE_DIR/* | 
| Salvatore Orlando | d6767d0 | 2012-08-31 04:55:20 -0700 | [diff] [blame] | 666 | } | 
|  | 667 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 668 | function _quantum_setup_interface_driver() { | 
| Maru Newby | d7150e9 | 2013-04-23 06:16:11 +0000 | [diff] [blame] | 669 |  | 
|  | 670 | # ovs_use_veth needs to be set before the plugin configuration | 
|  | 671 | # occurs to allow plugins to override the setting. | 
|  | 672 | iniset $1 DEFAULT ovs_use_veth $Q_OVS_USE_VETH | 
|  | 673 |  | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 674 | quantum_plugin_setup_interface_driver $1 | 
| Yoshihiro Kaneko | 602cf9b | 2012-07-23 06:27:36 +0000 | [diff] [blame] | 675 | } | 
|  | 676 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 677 | # Functions for Quantum Exercises | 
|  | 678 | #-------------------------------- | 
|  | 679 |  | 
|  | 680 | function delete_probe() { | 
|  | 681 | local from_net="$1" | 
|  | 682 | net_id=`_get_net_id $from_net` | 
|  | 683 | probe_id=`quantum-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-list -c id -c network_id | grep $net_id | awk '{print $2}'` | 
|  | 684 | quantum-debug --os-tenant-name admin --os-username admin probe-delete $probe_id | 
|  | 685 | } | 
|  | 686 |  | 
|  | 687 | function setup_quantum_debug() { | 
|  | 688 | if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then | 
|  | 689 | public_net_id=`_get_net_id $PUBLIC_NETWORK_NAME` | 
| Akihiro MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 690 | quantum-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create --device-owner compute $public_net_id | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 691 | private_net_id=`_get_net_id $PRIVATE_NETWORK_NAME` | 
| Akihiro MOTOKI | 3452f8e | 2013-03-21 14:11:27 +0900 | [diff] [blame] | 692 | quantum-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create --device-owner compute $private_net_id | 
| Yoshihiro Kaneko | 602cf9b | 2012-07-23 06:27:36 +0000 | [diff] [blame] | 693 | fi | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 694 | } | 
|  | 695 |  | 
|  | 696 | function teardown_quantum_debug() { | 
|  | 697 | delete_probe $PUBLIC_NETWORK_NAME | 
|  | 698 | delete_probe $PRIVATE_NETWORK_NAME | 
| Yoshihiro Kaneko | 602cf9b | 2012-07-23 06:27:36 +0000 | [diff] [blame] | 699 | } | 
|  | 700 |  | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 701 | function _get_net_id() { | 
|  | 702 | quantum --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD net-list | grep $1 | awk '{print $2}' | 
|  | 703 | } | 
|  | 704 |  | 
|  | 705 | function _get_probe_cmd_prefix() { | 
|  | 706 | local from_net="$1" | 
|  | 707 | net_id=`_get_net_id $from_net` | 
|  | 708 | probe_id=`quantum-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-list -c id -c network_id | grep $net_id | awk '{print $2}' | head -n 1` | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 709 | echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 710 | } | 
|  | 711 |  | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 712 | function _ping_check_quantum() { | 
|  | 713 | local from_net=$1 | 
|  | 714 | local ip=$2 | 
|  | 715 | local timeout_sec=$3 | 
|  | 716 | local expected=${4:-"True"} | 
|  | 717 | local check_command="" | 
|  | 718 | probe_cmd=`_get_probe_cmd_prefix $from_net` | 
|  | 719 | if [[ "$expected" = "True" ]]; then | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 720 | check_command="while ! $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 721 | else | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 722 | check_command="while $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 723 | fi | 
|  | 724 | if ! timeout $timeout_sec sh -c "$check_command"; then | 
|  | 725 | if [[ "$expected" = "True" ]]; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 726 | die $LINENO "[Fail] Couldn't ping server" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 727 | else | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 728 | die $LINENO "[Fail] Could ping server" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 729 | fi | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 730 | fi | 
|  | 731 | } | 
|  | 732 |  | 
|  | 733 | # ssh check | 
|  | 734 | function _ssh_check_quantum() { | 
|  | 735 | local from_net=$1 | 
|  | 736 | local key_file=$2 | 
|  | 737 | local ip=$3 | 
|  | 738 | local user=$4 | 
|  | 739 | local timeout_sec=$5 | 
|  | 740 | local probe_cmd = "" | 
|  | 741 | probe_cmd=`_get_probe_cmd_prefix $from_net` | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 742 | if ! timeout $timeout_sec sh -c "while ! $probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 743 | die $LINENO "server didn't become ssh-able!" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 744 | fi | 
|  | 745 | } | 
|  | 746 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 747 | # Quantum 3rd party programs | 
|  | 748 | #--------------------------- | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 749 |  | 
|  | 750 | # please refer to ``lib/quantum_thirdparty/README.md`` for details | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 751 | QUANTUM_THIRD_PARTIES="" | 
|  | 752 | for f in $TOP_DIR/lib/quantum_thirdparty/*; do | 
|  | 753 | third_party=$(basename $f) | 
|  | 754 | if is_service_enabled $third_party; then | 
|  | 755 | source $TOP_DIR/lib/quantum_thirdparty/$third_party | 
|  | 756 | QUANTUM_THIRD_PARTIES="$QUANTUM_THIRD_PARTIES,$third_party" | 
|  | 757 | fi | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 758 | done | 
|  | 759 |  | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 760 | function _quantum_third_party_do() { | 
|  | 761 | for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do | 
|  | 762 | ${1}_${third_party} | 
|  | 763 | done | 
|  | 764 | } | 
|  | 765 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 766 | # configure_quantum_third_party() - Set config files, create data dirs, etc | 
|  | 767 | function configure_quantum_third_party() { | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 768 | _quantum_third_party_do configure | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 769 | } | 
|  | 770 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 771 | # init_quantum_third_party() - Initialize databases, etc. | 
|  | 772 | function init_quantum_third_party() { | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 773 | _quantum_third_party_do init | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 774 | } | 
|  | 775 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 776 | # install_quantum_third_party() - Collect source and prepare | 
|  | 777 | function install_quantum_third_party() { | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 778 | _quantum_third_party_do install | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 779 | } | 
|  | 780 |  | 
|  | 781 | # start_quantum_third_party() - Start running processes, including screen | 
|  | 782 | function start_quantum_third_party() { | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 783 | _quantum_third_party_do start | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 784 | } | 
|  | 785 |  | 
|  | 786 | # stop_quantum_third_party - Stop running processes (non-screen) | 
|  | 787 | function stop_quantum_third_party() { | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 788 | _quantum_third_party_do stop | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 789 | } | 
|  | 790 |  | 
|  | 791 |  | 
| Salvatore Orlando | d6767d0 | 2012-08-31 04:55:20 -0700 | [diff] [blame] | 792 | # Restore xtrace | 
|  | 793 | $XTRACE | 
| Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 794 |  | 
|  | 795 | # Local variables: | 
|  | 796 | # mode: shell-script | 
|  | 797 | # End: |