Merge "Fix spelling mistakes"
diff --git a/files/apts/cinder b/files/apts/cinder
index 5db06ea..c45b97f 100644
--- a/files/apts/cinder
+++ b/files/apts/cinder
@@ -1,2 +1,3 @@
 tgt
 lvm2
+qemu-utils
diff --git a/files/ldap/openstack.ldif b/files/ldap/openstack.ldif
index f810fe8..02caf3f 100644
--- a/files/ldap/openstack.ldif
+++ b/files/ldap/openstack.ldif
@@ -20,10 +20,6 @@
 objectClass: organizationalUnit
 ou: Projects
 
-dn: ou=Domains,dc=openstack,dc=org
-objectClass: organizationalUnit
-ou: Domains
-
 dn: cn=9fe2ff9ee4384b1894a90878d3e92bab,ou=Roles,dc=openstack,dc=org
 objectClass: organizationalRole
 ou: _member_
diff --git a/files/rpms-suse/cinder b/files/rpms-suse/cinder
index e5b4727..61b9f25 100644
--- a/files/rpms-suse/cinder
+++ b/files/rpms-suse/cinder
@@ -1,2 +1,3 @@
 lvm2
 tgt
+qemu-img
diff --git a/files/rpms/cinder b/files/rpms/cinder
index df861aa..19dedff 100644
--- a/files/rpms/cinder
+++ b/files/rpms/cinder
@@ -1,2 +1,3 @@
 lvm2
 scsi-target-utils
+qemu-img
diff --git a/files/rpms/n-cpu b/files/rpms/n-cpu
index 149672a..e4fdaf4 100644
--- a/files/rpms/n-cpu
+++ b/files/rpms/n-cpu
@@ -4,3 +4,4 @@
 genisoimage
 sysfsutils
 sg3_utils
+python-libguestfs
diff --git a/functions b/functions
index c611e00..70ab999 100644
--- a/functions
+++ b/functions
@@ -1410,7 +1410,7 @@
 # Get the path to the direcotry where python executables are installed.
 # get_python_exec_prefix
 function get_python_exec_prefix() {
-    if is_fedora; then
+    if is_fedora || is_suse; then
         echo "/usr/bin"
     else
         echo "/usr/local/bin"
diff --git a/lib/cinder b/lib/cinder
index c572db4..f691b38 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -276,6 +276,19 @@
             echo "$CINDER_GLUSTERFS_SHARES" > $CINDER_CONF_DIR/glusterfs_shares
         fi
     fi
+
+    if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then
+        # Cinder clones are slightly larger due to some extra
+        # metadata.  RHEL6 will not allow auto-extending of LV's
+        # without this, leading to clones giving hard-to-track disk
+        # I/O errors.
+        # see https://bugzilla.redhat.com/show_bug.cgi?id=975052
+        sudo sed -i~ \
+            -e 's/snapshot_autoextend_threshold =.*/snapshot_autoextend_threshold = 80/' \
+            -e 's/snapshot_autoextend_percent =.*/snapshot_autoextend_percent = 20/' \
+            /etc/lvm/lvm.conf
+    fi
+
 }
 
 # create_cinder_accounts() - Set up common required cinder accounts
diff --git a/lib/nova b/lib/nova
index cac6330..afc540e 100644
--- a/lib/nova
+++ b/lib/nova
@@ -77,7 +77,7 @@
 
 # Set defaults according to the virt driver
 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
-    PUBLIC_INTERFACE_DEFAULT=eth3
+    PUBLIC_INTERFACE_DEFAULT=eth2
     GUEST_INTERFACE_DEFAULT=eth1
     # Allow ``build_domU.sh`` to specify the flat network bridge via kernel args
     FLAT_NETWORK_BRIDGE_DEFAULT=$(sed -e 's/.* flat_network_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline)
diff --git a/lib/quantum b/lib/quantum
index 51dd761..afe99c4 100644
--- a/lib/quantum
+++ b/lib/quantum
@@ -65,6 +65,12 @@
 # Quantum Network Configuration
 # -----------------------------
 
+# Gateway and subnet defaults, in case they are not customized in localrc
+NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
+PUBLIC_NETWORK_GATEWAY=${PUBLIC_NETWORK_GATEWAY:-172.24.4.225}
+PRIVATE_SUBNET_NAME=${PRIVATE_SUBNET_NAME:-"private-subnet"}
+PUBLIC_SUBNET_NAME=${PUBLIC_SUBNET_NAME:-"public-subnet"}
+
 # Set up default directories
 QUANTUM_DIR=$DEST/quantum
 QUANTUMCLIENT_DIR=$DEST/python-quantumclient
@@ -304,11 +310,11 @@
             sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE
         done
         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)
-        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)
+        SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
         sudo ifconfig $OVS_PHYSICAL_BRIDGE up
     else
         NET_ID=$(quantum net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
-        SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
+        SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
     fi
 
     if [[ "$Q_L3_ENABLED" == "True" ]]; then
@@ -323,7 +329,7 @@
         quantum router-interface-add $ROUTER_ID $SUBNET_ID
         # Create an external network, and a subnet. Configure the external network as router gw
         EXT_NET_ID=$(quantum net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2)
-        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)
+        EXT_GW_IP=$(quantum subnet-create --ip_version 4 ${Q_FLOATING_ALLOCATION_POOL:+--allocation-pool $Q_FLOATING_ALLOCATION_POOL} --gateway $PUBLIC_NETWORK_GATEWAY --name $PUBLIC_SUBNET_NAME $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
         quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
 
         if is_service_enabled q-l3; then
@@ -459,7 +465,7 @@
     Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
     cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
 
-    iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection `database_connection_url $Q_DB_NAME`
+    iniset /$Q_PLUGIN_CONF_FILE database connection `database_connection_url $Q_DB_NAME`
     iniset $QUANTUM_CONF DEFAULT state_path $DATA_DIR/quantum
 
     # If addition config files are set, make sure their path name is set as well
@@ -494,7 +500,7 @@
     iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT root_helper "$Q_RR_COMMAND"
     # Intermediate fix until Quantum patch lands and then line above will
     # be cleaned.
-    iniset $QUANTUM_TEST_CONFIG_FILE AGENT root_helper "$Q_RR_COMMAND"
+    iniset $QUANTUM_TEST_CONFIG_FILE agent root_helper "$Q_RR_COMMAND"
 
     _quantum_setup_keystone $QUANTUM_TEST_CONFIG_FILE DEFAULT set_auth_url
     _quantum_setup_interface_driver $QUANTUM_TEST_CONFIG_FILE
@@ -563,7 +569,7 @@
 function _configure_quantum_plugin_agent() {
     # Specify the default root helper prior to agent configuration to
     # ensure that an agent's configuration can override the default
-    iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
+    iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_COMMAND"
     iniset $QUANTUM_CONF DEFAULT verbose True
     iniset $QUANTUM_CONF DEFAULT debug True
 
@@ -645,7 +651,7 @@
     sudo mv $TEMPFILE /etc/sudoers.d/quantum-rootwrap
 
     # Update the root_helper
-    iniset $QUANTUM_CONF AGENT root_helper "$Q_RR_COMMAND"
+    iniset $QUANTUM_CONF agent root_helper "$Q_RR_COMMAND"
 }
 
 # Configures keystone integration for quantum service and agents
diff --git a/lib/quantum_plugins/bigswitch_floodlight b/lib/quantum_plugins/bigswitch_floodlight
index edee0eb..1199745 100644
--- a/lib/quantum_plugins/bigswitch_floodlight
+++ b/lib/quantum_plugins/bigswitch_floodlight
@@ -42,8 +42,8 @@
 }
 
 function quantum_plugin_configure_service() {
-    iniset /$Q_PLUGIN_CONF_FILE RESTPROXY servers $BS_FL_CONTROLLERS_PORT
-    iniset /$Q_PLUGIN_CONF_FILE RESTPROXY servertimeout $BS_FL_CONTROLLER_TIMEOUT
+    iniset /$Q_PLUGIN_CONF_FILE restproxy servers $BS_FL_CONTROLLERS_PORT
+    iniset /$Q_PLUGIN_CONF_FILE restproxy servertimeout $BS_FL_CONTROLLER_TIMEOUT
 }
 
 function quantum_plugin_setup_interface_driver() {
diff --git a/lib/quantum_plugins/linuxbridge b/lib/quantum_plugins/linuxbridge
index dffa32b..989b930 100644
--- a/lib/quantum_plugins/linuxbridge
+++ b/lib/quantum_plugins/linuxbridge
@@ -14,7 +14,7 @@
 
 function quantum_plugin_configure_service() {
     if [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE VLANS tenant_network_type vlan
+        iniset /$Q_PLUGIN_CONF_FILE vlans tenant_network_type vlan
     else
         echo "WARNING - The linuxbridge plugin is using local tenant networks, with no connectivity between hosts."
     fi
@@ -28,12 +28,12 @@
         fi
     fi
     if [[ "$LB_VLAN_RANGES" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE VLANS network_vlan_ranges $LB_VLAN_RANGES
+        iniset /$Q_PLUGIN_CONF_FILE vlans network_vlan_ranges $LB_VLAN_RANGES
     fi
     if [[ "$Q_USE_SECGROUP" == "True" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.linux.iptables_firewall.IptablesFirewallDriver
+        iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver quantum.agent.linux.iptables_firewall.IptablesFirewallDriver
     else
-        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
+        iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver quantum.agent.firewall.NoopFirewallDriver
     fi
 
     # Define extra "LINUX_BRIDGE" configuration options when q-svc is configured by defining
@@ -41,7 +41,7 @@
     # For Example: ``Q_SRV_EXTRA_OPTS=(foo=true bar=2)``
     for I in "${Q_SRV_EXTRA_OPTS[@]}"; do
         # Replace the first '=' with ' ' for iniset syntax
-        iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE ${I/=/ }
+        iniset /$Q_PLUGIN_CONF_FILE linux_bridge ${I/=/ }
     done
 }
 
diff --git a/lib/quantum_plugins/linuxbridge_agent b/lib/quantum_plugins/linuxbridge_agent
index 7855cd0..b3ca8b1 100644
--- a/lib/quantum_plugins/linuxbridge_agent
+++ b/lib/quantum_plugins/linuxbridge_agent
@@ -39,12 +39,12 @@
         LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE
     fi
     if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
+        iniset /$Q_PLUGIN_CONF_FILE linux_bridge physical_interface_mappings $LB_INTERFACE_MAPPINGS
     fi
     if [[ "$Q_USE_SECGROUP" == "True" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.linux.iptables_firewall.IptablesFirewallDriver
+        iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver quantum.agent.linux.iptables_firewall.IptablesFirewallDriver
     else
-        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
+        iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver quantum.agent.firewall.NoopFirewallDriver
     fi
     AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
     # Define extra "AGENT" configuration options when q-agt is configured by defining
@@ -52,14 +52,14 @@
     # For Example: ``Q_AGENT_EXTRA_AGENT_OPTS=(foo=true bar=2)``
     for I in "${Q_AGENT_EXTRA_AGENT_OPTS[@]}"; do
         # Replace the first '=' with ' ' for iniset syntax
-        iniset /$Q_PLUGIN_CONF_FILE AGENT ${I/=/ }
+        iniset /$Q_PLUGIN_CONF_FILE agent ${I/=/ }
     done
     # Define extra "LINUX_BRIDGE" configuration options when q-agt is configured by defining
     # the array ``Q_AGENT_EXTRA_SRV_OPTS``.
     # For Example: ``Q_AGENT_EXTRA_SRV_OPTS=(foo=true bar=2)``
     for I in "${Q_AGENT_EXTRA_SRV_OPTS[@]}"; do
         # Replace the first '=' with ' ' for iniset syntax
-        iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE ${I/=/ }
+        iniset /$Q_PLUGIN_CONF_FILE linux_bridge ${I/=/ }
     done
 }
 
diff --git a/lib/quantum_plugins/nec b/lib/quantum_plugins/nec
index 608e267..69bbe0e 100644
--- a/lib/quantum_plugins/nec
+++ b/lib/quantum_plugins/nec
@@ -77,11 +77,11 @@
 
 function quantum_plugin_configure_service() {
     iniset $QUANTUM_CONF DEFAULT api_extensions_path quantum/plugins/nec/extensions/
-    iniset /$Q_PLUGIN_CONF_FILE OFC host $OFC_API_HOST
-    iniset /$Q_PLUGIN_CONF_FILE OFC port $OFC_API_PORT
-    iniset /$Q_PLUGIN_CONF_FILE OFC driver $OFC_DRIVER
-    iniset /$Q_PLUGIN_CONF_FILE OFC api_retry_max OFC_RETRY_MAX
-    iniset /$Q_PLUGIN_CONF_FILE OFC api_retry_interval OFC_RETRY_INTERVAL
+    iniset /$Q_PLUGIN_CONF_FILE ofc host $OFC_API_HOST
+    iniset /$Q_PLUGIN_CONF_FILE ofc port $OFC_API_PORT
+    iniset /$Q_PLUGIN_CONF_FILE ofc driver $OFC_DRIVER
+    iniset /$Q_PLUGIN_CONF_FILE ofc api_retry_max OFC_RETRY_MAX
+    iniset /$Q_PLUGIN_CONF_FILE ofc api_retry_interval OFC_RETRY_INTERVAL
 
     _quantum_ovs_base_configure_firewall_driver
 }
diff --git a/lib/quantum_plugins/nicira b/lib/quantum_plugins/nicira
index c9c6d0e..d4b3e51 100644
--- a/lib/quantum_plugins/nicira
+++ b/lib/quantum_plugins/nicira
@@ -68,16 +68,16 @@
 
 function quantum_plugin_configure_service() {
     if [[ "$MAX_LP_PER_BRIDGED_LS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE NVP max_lp_per_bridged_ls $MAX_LP_PER_BRIDGED_LS
+        iniset /$Q_PLUGIN_CONF_FILE nvp max_lp_per_bridged_ls $MAX_LP_PER_BRIDGED_LS
     fi
     if [[ "$MAX_LP_PER_OVERLAY_LS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE NVP max_lp_per_overlay_ls $MAX_LP_PER_OVERLAY_LS
+        iniset /$Q_PLUGIN_CONF_FILE nvp max_lp_per_overlay_ls $MAX_LP_PER_OVERLAY_LS
     fi
     if [[ "$FAILOVER_TIME" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE NVP failover_time $FAILOVER_TIME
+        iniset /$Q_PLUGIN_CONF_FILE nvp failover_time $FAILOVER_TIME
     fi
     if [[ "$CONCURRENT_CONNECTIONS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE NVP concurrent_connections $CONCURRENT_CONNECTIONS
+        iniset /$Q_PLUGIN_CONF_FILE nvp concurrent_connections $CONCURRENT_CONNECTIONS
     fi
 
     if [[ "$DEFAULT_TZ_UUID" != "" ]]; then
@@ -89,7 +89,7 @@
         iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l3_gw_service_uuid $DEFAULT_L3_GW_SVC_UUID
         Q_L3_ENABLED=True
         Q_L3_ROUTER_PER_TENANT=True
-        iniset /$Q_PLUGIN_CONF_FILE NVP enable_metadata_access_network True
+        iniset /$Q_PLUGIN_CONF_FILE nvp enable_metadata_access_network True
     fi
     if [[ "$DEFAULT_L2_GW_SVC_UUID" != "" ]]; then
         iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l2_gw_service_uuid $DEFAULT_L2_GW_SVC_UUID
diff --git a/lib/quantum_plugins/openvswitch b/lib/quantum_plugins/openvswitch
index e53db8a..4aac9f8 100644
--- a/lib/quantum_plugins/openvswitch
+++ b/lib/quantum_plugins/openvswitch
@@ -16,10 +16,10 @@
 
 function quantum_plugin_configure_service() {
     if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
-        iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES
+        iniset /$Q_PLUGIN_CONF_FILE ovs tenant_network_type gre
+        iniset /$Q_PLUGIN_CONF_FILE ovs tunnel_id_ranges $TENANT_TUNNEL_RANGES
     elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan
+        iniset /$Q_PLUGIN_CONF_FILE ovs tenant_network_type vlan
     else
         echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts."
     fi
@@ -33,12 +33,12 @@
         fi
     fi
     if [[ "$OVS_VLAN_RANGES" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES
+        iniset /$Q_PLUGIN_CONF_FILE ovs network_vlan_ranges $OVS_VLAN_RANGES
     fi
 
     # Enable tunnel networks if selected
     if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
+        iniset /$Q_PLUGIN_CONF_FILE ovs enable_tunneling True
     fi
 
     _quantum_ovs_base_configure_firewall_driver
@@ -48,7 +48,7 @@
     # For Example: ``Q_SRV_EXTRA_OPTS=(foo=true bar=2)``
     for I in "${Q_SRV_EXTRA_OPTS[@]}"; do
         # Replace the first '=' with ' ' for iniset syntax
-        iniset /$Q_PLUGIN_CONF_FILE OVS ${I/=/ }
+        iniset /$Q_PLUGIN_CONF_FILE ovs ${I/=/ }
     done
 }
 
diff --git a/lib/quantum_plugins/openvswitch_agent b/lib/quantum_plugins/openvswitch_agent
index 7e83428..608c3ea 100644
--- a/lib/quantum_plugins/openvswitch_agent
+++ b/lib/quantum_plugins/openvswitch_agent
@@ -47,8 +47,8 @@
         if [ `vercmp_numbers "$OVS_VERSION" "1.4"` -lt "0" ] && ! is_service_enabled q-svc ; then
             die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
         fi
-        iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
-        iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
+        iniset /$Q_PLUGIN_CONF_FILE ovs enable_tunneling True
+        iniset /$Q_PLUGIN_CONF_FILE ovs local_ip $HOST_IP
     fi
 
     # Setup physical network bridge mappings.  Override
@@ -61,7 +61,7 @@
         sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
     fi
     if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
+        iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS
     fi
     AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
 
@@ -73,20 +73,20 @@
         Q_RR_DOM0_COMMAND="$QUANTUM_DIR/bin/quantum-rootwrap-xen-dom0 $Q_RR_CONF_FILE"
 
         # For now, duplicate the xen configuration already found in nova.conf
-        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_url "$XENAPI_CONNECTION_URL"
-        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_username "$XENAPI_USER"
-        iniset $Q_RR_CONF_FILE XENAPI xenapi_connection_password "$XENAPI_PASSWORD"
+        iniset $Q_RR_CONF_FILE xenapi xenapi_connection_url "$XENAPI_CONNECTION_URL"
+        iniset $Q_RR_CONF_FILE xenapi xenapi_connection_username "$XENAPI_USER"
+        iniset $Q_RR_CONF_FILE xenapi xenapi_connection_password "$XENAPI_PASSWORD"
 
         # Under XS/XCP, the ovs agent needs to target the dom0
         # integration bridge.  This is enabled by using a root wrapper
         # that executes commands on dom0 via a XenAPI plugin.
-        iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_DOM0_COMMAND"
+        iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_DOM0_COMMAND"
 
         # Set "physical" mapping
-        iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
+        iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings "physnet1:$FLAT_NETWORK_BRIDGE"
 
         # XEN_INTEGRATION_BRIDGE is the integration bridge in dom0
-        iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $XEN_INTEGRATION_BRIDGE
+        iniset /$Q_PLUGIN_CONF_FILE ovs integration_bridge $XEN_INTEGRATION_BRIDGE
 
         # Set up domU's L2 agent:
 
@@ -96,25 +96,25 @@
         sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT
 
         # Set bridge mappings to "physnet1:br-$GUEST_INTERFACE_DEFAULT"
-        iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT"
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs bridge_mappings "physnet1:br-$GUEST_INTERFACE_DEFAULT"
         # Set integration bridge to domU's
-        iniset "/$Q_PLUGIN_CONF_FILE.domU" OVS integration_bridge $OVS_BRIDGE
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" ovs integration_bridge $OVS_BRIDGE
         # Set root wrap
-        iniset "/$Q_PLUGIN_CONF_FILE.domU" AGENT root_helper "$Q_RR_COMMAND"
+        iniset "/$Q_PLUGIN_CONF_FILE.domU" agent root_helper "$Q_RR_COMMAND"
     fi
     # Define extra "AGENT" configuration options when q-agt is configured by defining
     # defining the array ``Q_AGENT_EXTRA_AGENT_OPTS``.
     # For Example: ``Q_AGENT_EXTRA_AGENT_OPTS=(foo=true bar=2)``
     for I in "${Q_AGENT_EXTRA_AGENT_OPTS[@]}"; do
         # Replace the first '=' with ' ' for iniset syntax
-        iniset /$Q_PLUGIN_CONF_FILE AGENT ${I/=/ }
+        iniset /$Q_PLUGIN_CONF_FILE agent ${I/=/ }
     done
     # Define extra "OVS" configuration options when q-agt is configured by defining
     # defining the array ``Q_AGENT_EXTRA_SRV_OPTS``.
     # For Example: ``Q_AGENT_EXTRA_SRV_OPTS=(foo=true bar=2)``
     for I in "${Q_AGENT_EXTRA_SRV_OPTS[@]}"; do
         # Replace the first '=' with ' ' for iniset syntax
-        iniset /$Q_PLUGIN_CONF_FILE OVS ${I/=/ }
+        iniset /$Q_PLUGIN_CONF_FILE ovs ${I/=/ }
     done
 }
 
diff --git a/lib/quantum_plugins/ovs_base b/lib/quantum_plugins/ovs_base
index a5e03ac..646ff4a 100644
--- a/lib/quantum_plugins/ovs_base
+++ b/lib/quantum_plugins/ovs_base
@@ -56,9 +56,9 @@
 
 function _quantum_ovs_base_configure_firewall_driver() {
     if [[ "$Q_USE_SECGROUP" == "True" ]]; then
-        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
+        iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver quantum.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
     else
-        iniset /$Q_PLUGIN_CONF_FILE SECURITYGROUP firewall_driver quantum.agent.firewall.NoopFirewallDriver
+        iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver quantum.agent.firewall.NoopFirewallDriver
     fi
 }
 
diff --git a/lib/quantum_plugins/plumgrid b/lib/quantum_plugins/plumgrid
index 1456710..dde18c8 100644
--- a/lib/quantum_plugins/plumgrid
+++ b/lib/quantum_plugins/plumgrid
@@ -27,8 +27,8 @@
 function quantum_plugin_configure_service() {
     PLUMGRID_NOS_IP=${PLUMGRID_NOS_IP:-localhost}
     PLUMGRID_NOS_PORT=${PLUMGRID_NOS_PORT:-7766}
-    iniset /$Q_PLUGIN_CONF_FILE PLUMgridNOS nos_server $PLUMGRID_NOS_IP
-    iniset /$Q_PLUGIN_CONF_FILE PLUMgridNOS nos_server_port $PLUMGRID_NOS_PORT
+    iniset /$Q_PLUGIN_CONF_FILE plumgridnos nos_server $PLUMGRID_NOS_IP
+    iniset /$Q_PLUGIN_CONF_FILE plumgridnos nos_server_port $PLUMGRID_NOS_PORT
 }
 
 function quantum_plugin_configure_debug_command() {
diff --git a/lib/quantum_plugins/ryu b/lib/quantum_plugins/ryu
index dcdccb7..53c4f41 100644
--- a/lib/quantum_plugins/ryu
+++ b/lib/quantum_plugins/ryu
@@ -49,14 +49,14 @@
     if [ -n "$RYU_INTERNAL_INTERFACE" ]; then
         sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $RYU_INTERNAL_INTERFACE
     fi
-    iniset /$Q_PLUGIN_CONF_FILE OVS integration_bridge $OVS_BRIDGE
+    iniset /$Q_PLUGIN_CONF_FILE ovs integration_bridge $OVS_BRIDGE
     AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/ryu/agent/ryu_quantum_agent.py"
 
     _quantum_ovs_base_configure_firewall_driver
 }
 
 function quantum_plugin_configure_service() {
-    iniset /$Q_PLUGIN_CONF_FILE OVS openflow_rest_api $RYU_API_HOST:$RYU_API_PORT
+    iniset /$Q_PLUGIN_CONF_FILE ovs openflow_rest_api $RYU_API_HOST:$RYU_API_PORT
 
     _quantum_ovs_base_configure_firewall_driver
 }
diff --git a/lib/tempest b/lib/tempest
index f3dcfbb..8b4ae0e 100644
--- a/lib/tempest
+++ b/lib/tempest
@@ -281,6 +281,9 @@
         iniset $TEMPEST_CONF volume backend2_name "LVM_iSCSI_2"
     fi
 
+    # cli
+    iniset $TEMPEST_CONF cli cli_dir $NOVA_BIN_DIR
+
     echo "Created tempest configuration file:"
     cat $TEMPEST_CONF
 
diff --git a/stack.sh b/stack.sh
index f8d546f..57b8529 100755
--- a/stack.sh
+++ b/stack.sh
@@ -266,7 +266,6 @@
 FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.224/28}
 FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
 FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
-NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
 
 HOST_IP=$(get_default_host_ip $FIXED_RANGE $FLOATING_RANGE "$HOST_IP_IFACE" "$HOST_IP")
 if [ "$HOST_IP" == "" ]; then
@@ -1001,6 +1000,9 @@
 
     if [ "$VIRT_DRIVER" = 'xenserver' ]; then
         echo_summary "Using XenServer virtualization driver"
+        if [ -z "$XENAPI_CONNECTION_URL" ]; then
+            die $LINENO "XENAPI_CONNECTION_URL is not specified"
+        fi
         read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
         iniset $NOVA_CONF DEFAULT compute_driver "xenapi.XenAPIDriver"
         iniset $NOVA_CONF DEFAULT xenapi_connection_url "$XENAPI_CONNECTION_URL"
diff --git a/stackrc b/stackrc
index 23b5bb8..49cf026 100644
--- a/stackrc
+++ b/stackrc
@@ -178,7 +178,6 @@
         ;;
     xenserver)
         # Xen config common to nova and quantum
-        XENAPI_CONNECTION_URL=${XENAPI_CONNECTION_URL:-"http://169.254.0.1"}
         XENAPI_USER=${XENAPI_USER:-"root"}
         ;;
     *)
diff --git a/tools/xen/README.md b/tools/xen/README.md
index 8f0c10d..9f39080 100644
--- a/tools/xen/README.md
+++ b/tools/xen/README.md
@@ -34,6 +34,13 @@
      `eth0`.
    - eth3 - Public interface, connected to `PUB_BRIDGE_OR_NET_NAME` defaults to
    `"OpenStack Public Network"`.
+ - After the Ubuntu install process finished, the network configuration is
+ modified to:
+   - eth0 - Management interface, connected to `MGT_BRIDGE_OR_NET_NAME`
+   - eth1 - VM interface, connected to `VM_BRIDGE_OR_NET_NAME`
+   - eth2 - Public interface, connected to `PUB_BRIDGE_OR_NET_NAME`
+   - (eth3) - Optional network interface if quantum is used, to enforce xapi to
+   create the underlying bridge.
  - Start devstack inside the created OpenStack VM
 
 ## Step 1: Install Xenserver
@@ -92,30 +99,12 @@
     MULTI_HOST=1
     # Give extra time for boot
     ACTIVE_TIMEOUT=45
-    # Host Interface, i.e. the interface on the OpenStack vm you want to expose
-    # the services on. The default is eth3, which means the public network, but
-    # as the public network is going to be virtual, we are setting the services
-    # to listen on the management network, which defaults to 'xenbr0', the
-    # XenServer's network.
-    HOST_IP_IFACE=eth2
-
-    # Use DHCP server to configure the Management IP of OpenStack VM
-    MGT_IP="dhcp"
 
     # Settings for netinstalling Ubuntu
     UBUNTU_INST_RELEASE=precise
 
-    # First time Ubuntu network install params, use the DHCP server on the
-    # management network
-    UBUNTU_INST_IFACE="eth2"
-    UBUNTU_INST_IP="dhcp"
-
     # NOTE: the value of FLAT_NETWORK_BRIDGE will automatically be determined
     # by install_os_domU.sh script.
-
-    # Public IP address is aligned with the devstack defaults (see FLOATING_RANGE)
-    PUB_IP=172.24.4.10
-    PUB_NETMASK=255.255.255.0
     EOF
 
 ## Step 4: Run `./install_os_domU.sh` from the `tools/xen` directory
diff --git a/tools/xen/build_xva.sh b/tools/xen/build_xva.sh
index b0fd003..d0cdf17 100755
--- a/tools/xen/build_xva.sh
+++ b/tools/xen/build_xva.sh
@@ -32,6 +32,41 @@
 #
 GUEST_NAME="$1"
 
+function _print_interface_config() {
+    local device_nr
+    local ip_address
+    local netmask
+
+    device_nr="$1"
+    ip_address="$2"
+    netmask="$3"
+
+    local device
+
+    device="eth${device_nr}"
+
+    echo "auto $device"
+    if [ $ip_address == "dhcp" ]; then
+        echo "iface $device inet dhcp"
+    else
+        echo "iface $device inet static"
+        echo "  address $ip_address"
+        echo "  netmask $netmask"
+    fi
+
+    # Turn off tx checksumming for better performance
+    echo "  post-up ethtool -K $device tx off"
+}
+
+function print_interfaces_config() {
+    echo "auto lo"
+    echo "iface lo inet loopback"
+
+    _print_interface_config $PUB_DEV_NR $PUB_IP $PUB_NETMASK
+    _print_interface_config $VM_DEV_NR $VM_IP $VM_NETMASK
+    _print_interface_config $MGT_DEV_NR $MGT_IP $MGT_NETMASK
+}
+
 #
 # Mount the VDI
 #
@@ -81,42 +116,7 @@
 EOF
 
 # Configure the network
-INTERFACES=$STAGING_DIR/etc/network/interfaces
-TEMPLATES_DIR=$TOP_DIR/templates
-cp $TEMPLATES_DIR/interfaces.in  $INTERFACES
-if [ $VM_IP == "dhcp" ]; then
-    echo 'eth1 on dhcp'
-    sed -e "s,iface eth1 inet static,iface eth1 inet dhcp,g" -i $INTERFACES
-    sed -e '/@ETH1_/d' -i $INTERFACES
-else
-    sed -e "s,@ETH1_IP@,$VM_IP,g" -i $INTERFACES
-    sed -e "s,@ETH1_NETMASK@,$VM_NETMASK,g" -i $INTERFACES
-fi
-
-if [ $MGT_IP == "dhcp" ]; then
-    echo 'eth2 on dhcp'
-    sed -e "s,iface eth2 inet static,iface eth2 inet dhcp,g" -i $INTERFACES
-    sed -e '/@ETH2_/d' -i $INTERFACES
-else
-    sed -e "s,@ETH2_IP@,$MGT_IP,g" -i $INTERFACES
-    sed -e "s,@ETH2_NETMASK@,$MGT_NETMASK,g" -i $INTERFACES
-fi
-
-if [ $PUB_IP == "dhcp" ]; then
-    echo 'eth3 on dhcp'
-    sed -e "s,iface eth3 inet static,iface eth3 inet dhcp,g" -i $INTERFACES
-    sed -e '/@ETH3_/d' -i $INTERFACES
-else
-    sed -e "s,@ETH3_IP@,$PUB_IP,g" -i $INTERFACES
-    sed -e "s,@ETH3_NETMASK@,$PUB_NETMASK,g" -i $INTERFACES
-fi
-
-if [ "$ENABLE_GI" == "true" ]; then
-    cat <<EOF >>$INTERFACES
-auto eth0
-iface eth0 inet dhcp
-EOF
-fi
+print_interfaces_config > $STAGING_DIR/etc/network/interfaces
 
 # Gracefully cp only if source file/dir exists
 function cp_it {
diff --git a/tools/xen/functions b/tools/xen/functions
index ebfd483..4e37554 100644
--- a/tools/xen/functions
+++ b/tools/xen/functions
@@ -24,6 +24,16 @@
     fi
 }
 
+function create_directory_for_images {
+    if [ -d "/images" ]; then
+        echo "INFO: /images directory already exists, using that" >&2
+    else
+        local LOCALPATH="$(get_local_sr_path)/os-images"
+        mkdir -p $LOCALPATH
+        ln -s $LOCALPATH /images
+    fi
+}
+
 function extract_remote_zipball {
     local ZIPBALL_URL=$1
 
@@ -224,3 +234,19 @@
     pv_args=$(xe vm-param-get param-name=PV-args uuid=$vm)
     xe vm-param-set PV-args="$pv_args $kernel_args" uuid=$vm
 }
+
+function destroy_all_vifs_of()
+{
+    local vm_name_label
+
+    vm_name_label="$1"
+
+    local vm
+
+    vm=$(_vm_uuid "$vm_name_label")
+    IFS=,
+    for vif in $(xe vif-list vm-uuid=$vm --minimal); do
+        xe vif-destroy uuid="$vif"
+    done
+    unset IFS
+}
diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh
index be3b540..d74b1ad 100755
--- a/tools/xen/install_os_domU.sh
+++ b/tools/xen/install_os_domU.sh
@@ -63,6 +63,7 @@
 fi
 
 create_directory_for_kernels
+create_directory_for_images
 
 #
 # Configure Networking
@@ -238,6 +239,15 @@
     vm_uuid=$(xe vm-install template="$TNAME" new-name-label="$GUEST_NAME")
 fi
 
+## Setup network cards
+# Wipe out all
+destroy_all_vifs_of "$GUEST_NAME"
+# Tenant network
+add_interface "$GUEST_NAME" "$VM_BRIDGE_OR_NET_NAME" "$VM_DEV_NR"
+# Management network
+add_interface "$GUEST_NAME" "$MGT_BRIDGE_OR_NET_NAME" "$MGT_DEV_NR"
+# Public network
+add_interface "$GUEST_NAME" "$PUB_BRIDGE_OR_NET_NAME" "$PUB_DEV_NR"
 
 #
 # Inject DevStack inside VM disk
@@ -248,7 +258,7 @@
 # is created by XenServer). This is required for Quantum. Also pass that as a
 # kernel parameter for DomU
 if is_service_enabled quantum; then
-    add_interface "$GUEST_NAME" "$XEN_INT_BRIDGE_OR_NET_NAME" "4"
+    add_interface "$GUEST_NAME" "$XEN_INT_BRIDGE_OR_NET_NAME" $XEN_INT_DEV_NR
 
     XEN_INTEGRATION_BRIDGE=$(bridge_for "$XEN_INT_BRIDGE_OR_NET_NAME")
     append_kernel_cmdline \
@@ -288,19 +298,19 @@
 # Get hold of the Management IP of OpenStack VM
 OS_VM_MANAGEMENT_ADDRESS=$MGT_IP
 if [ $OS_VM_MANAGEMENT_ADDRESS == "dhcp" ]; then
-    OS_VM_MANAGEMENT_ADDRESS=$(find_ip_by_name $GUEST_NAME 2)
+    OS_VM_MANAGEMENT_ADDRESS=$(find_ip_by_name $GUEST_NAME $MGT_DEV_NR)
 fi
 
 # Get hold of the Service IP of OpenStack VM
-if [ $HOST_IP_IFACE == "eth2" ]; then
+if [ $HOST_IP_IFACE == "eth${MGT_DEV_NR}" ]; then
     OS_VM_SERVICES_ADDRESS=$MGT_IP
     if [ $MGT_IP == "dhcp" ]; then
-        OS_VM_SERVICES_ADDRESS=$(find_ip_by_name $GUEST_NAME 2)
+        OS_VM_SERVICES_ADDRESS=$(find_ip_by_name $GUEST_NAME $MGT_DEV_NR)
     fi
 else
     OS_VM_SERVICES_ADDRESS=$PUB_IP
     if [ $PUB_IP == "dhcp" ]; then
-        OS_VM_SERVICES_ADDRESS=$(find_ip_by_name $GUEST_NAME 3)
+        OS_VM_SERVICES_ADDRESS=$(find_ip_by_name $GUEST_NAME $PUB_DEV_NR)
     fi
 fi
 
diff --git a/tools/xen/templates/interfaces.in b/tools/xen/templates/interfaces.in
deleted file mode 100644
index 74b41cc..0000000
--- a/tools/xen/templates/interfaces.in
+++ /dev/null
@@ -1,23 +0,0 @@
-auto lo
-iface lo inet loopback
-
-# If eth3 is static, the order should not matter
-# and eth0 will have the default gateway. If not,
-# we probably want the default gateway to be
-# what is on the public interface. Hence changed
-# the order here.
-auto eth3
-iface eth3 inet static
-        address @ETH3_IP@
-        netmask @ETH3_NETMASK@
-
-auto eth1
-iface eth1 inet static
-        address @ETH1_IP@
-        netmask @ETH1_NETMASK@
-post-up ethtool -K eth1 tx off
-
-auto eth2
-iface eth2 inet static
-        address @ETH2_IP@
-        netmask @ETH2_NETMASK@
diff --git a/tools/xen/test_functions.sh b/tools/xen/test_functions.sh
index 62393ca..410df5f 100755
--- a/tools/xen/test_functions.sh
+++ b/tools/xen/test_functions.sh
@@ -138,6 +138,29 @@
 EOF
 }
 
+function test_create_directory_for_images {
+    (
+        . mocks
+        mock_out get_local_sr uuid1
+        create_directory_for_images
+    )
+
+    assert_directory_exists "/var/run/sr-mount/uuid1/os-images"
+    assert_symlink "/images" "/var/run/sr-mount/uuid1/os-images"
+}
+
+function test_create_directory_for_images_existing_dir {
+    (
+        . mocks
+        given_directory_exists "/images"
+        create_directory_for_images
+    )
+
+    diff -u $LIST_OF_ACTIONS - << EOF
+[ -d /images ]
+EOF
+}
+
 function test_extract_remote_zipball {
     local RESULT=$(. mocks && extract_remote_zipball "someurl")
 
diff --git a/tools/xen/xenrc b/tools/xen/xenrc
index 3e23964..c343891 100644
--- a/tools/xen/xenrc
+++ b/tools/xen/xenrc
@@ -30,32 +30,35 @@
 # VM Password
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
 
+# Extracted variables for OpenStack VM network device numbers.
+# Make sure, they form a continous sequence starting from 0
+MGT_DEV_NR=0
+VM_DEV_NR=1
+PUB_DEV_NR=2
+XEN_INT_DEV_NR=3
+
 # Host Interface, i.e. the interface on the nova vm you want to expose the
-# services on. Usually eth2 (management network) or eth3 (public network) and
-# not eth0 (private network with XenServer host) or eth1 (VM traffic network)
-HOST_IP_IFACE=${HOST_IP_IFACE:-eth3}
+# services on. Usually the device connected to the management network or the
+# one connected to the public network is used.
+HOST_IP_IFACE=${HOST_IP_IFACE:-"eth${MGT_DEV_NR}"}
 
 #
 # Our nova host's network info
 #
 
 # Management network
-MGT_IP=${MGT_IP:-172.16.100.55}
-MGT_NETMASK=${MGT_NETMASK:-255.255.255.0}
+MGT_IP=${MGT_IP:-dhcp}
+MGT_NETMASK=${MGT_NETMASK:-ignored}
 
 # VM Network
 VM_IP=${VM_IP:-10.255.255.255}
 VM_NETMASK=${VM_NETMASK:-255.255.255.0}
 
 # Public network
-PUB_IP=${PUB_IP:-192.168.1.55}
+# Aligned with stack.sh - see FLOATING_RANGE
+PUB_IP=${PUB_IP:-172.24.4.10}
 PUB_NETMASK=${PUB_NETMASK:-255.255.255.0}
 
-# Decide if you should enable eth0,
-# the guest installer network
-# You need to disable this on xcp-xapi on Ubuntu 12.04
-ENABLE_GI=true
-
 # Ubuntu install settings
 UBUNTU_INST_RELEASE="oneiric"
 UBUNTU_INST_TEMPLATE_NAME="Ubuntu 11.10 (64-bit) for DevStack"
@@ -69,8 +72,11 @@
 UBUNTU_INST_HTTP_PROXY=""
 UBUNTU_INST_LOCALE="en_US"
 UBUNTU_INST_KEYBOARD="us"
-# network configuration for ubuntu netinstall
-UBUNTU_INST_IFACE="eth3"
+# network configuration for ubuntu netinstall.
+# TODO(matelakat): get rid of legacy network interfaces
+# specify "eth2" to use the management network
+# specify "eth3" to use the public network
+UBUNTU_INST_IFACE="eth2"
 UBUNTU_INST_IP="dhcp"
 UBUNTU_INST_NAMESERVERS=""
 UBUNTU_INST_NETMASK=""