Merge "Set debug to True in cinder.conf"
diff --git a/files/apts/ceilometer-collector b/files/apts/ceilometer-collector
index c67ade3..71007ba 100644
--- a/files/apts/ceilometer-collector
+++ b/files/apts/ceilometer-collector
@@ -1,2 +1,6 @@
 python-pymongo
 mongodb-server
+libnspr4-dev
+pkg-config
+libxml2-dev
+libxslt-dev
\ No newline at end of file
diff --git a/files/apts/general b/files/apts/general
index 0264066..a1fcf3c 100644
--- a/files/apts/general
+++ b/files/apts/general
@@ -9,6 +9,7 @@
 git
 lsof # useful when debugging
 openssh-server
+openssl
 vim-nox
 locate # useful when debugging
 python-virtualenv
diff --git a/files/keystone_data.sh b/files/keystone_data.sh
index 4c76c9b..a6fab09 100755
--- a/files/keystone_data.sh
+++ b/files/keystone_data.sh
@@ -167,9 +167,9 @@
         keystone endpoint-create \
             --region RegionOne \
             --service_id $CEILOMETER_SERVICE \
-            --publicurl "http://$SERVICE_HOST:8777/" \
-            --adminurl "http://$SERVICE_HOST:8777/" \
-            --internalurl "http://$SERVICE_HOST:8777/"
+            --publicurl "http://$SERVICE_HOST:8777" \
+            --adminurl "http://$SERVICE_HOST:8777" \
+            --internalurl "http://$SERVICE_HOST:8777"
     fi
 fi
 
diff --git a/files/ldap/openstack.ldif b/files/ldap/openstack.ldif
index 00c9861..2b76372 100644
--- a/files/ldap/openstack.ldif
+++ b/files/ldap/openstack.ldif
@@ -20,6 +20,10 @@
 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/general b/files/rpms-suse/general
index 8ed74ec..b8ceeb7 100644
--- a/files/rpms-suse/general
+++ b/files/rpms-suse/general
@@ -4,6 +4,7 @@
 git-core
 iputils
 openssh
+openssl
 psmisc
 python-cmd2 # dist:opensuse-12.3
 python-netaddr
diff --git a/files/rpms/ceilometer-collector b/files/rpms/ceilometer-collector
index c5c855c..d7b7ea8 100644
--- a/files/rpms/ceilometer-collector
+++ b/files/rpms/ceilometer-collector
@@ -1,2 +1,3 @@
+selinux-policy-targeted
 mongodb-server
 pymongo
diff --git a/files/rpms/general b/files/rpms/general
index e4f143d..fc3412b 100644
--- a/files/rpms/general
+++ b/files/rpms/general
@@ -3,6 +3,7 @@
 euca2ools # only for testing client
 git-core
 openssh-server
+openssl
 psmisc
 pylint
 python-netaddr
diff --git a/lib/baremetal b/lib/baremetal
index 2659386..57048a1 100644
--- a/lib/baremetal
+++ b/lib/baremetal
@@ -63,7 +63,7 @@
 
 # sub-driver to use for remote power management
 # - nova.virt.baremetal.fake.FakePowerManager, for manual power control
-# - nova.virt.baremetal.ipmi.Ipmi, for remote IPMI
+# - nova.virt.baremetal.ipmi.IPMI, for remote IPMI
 # - nova.virt.baremetal.tilera_pdu.Pdu, for TilePro hardware
 BM_POWER_MANAGER=${BM_POWER_MANAGER:-nova.virt.baremetal.fake.FakePowerManager}
 
@@ -258,9 +258,10 @@
     nova flavor-create $BM_FLAVOR_NAME $BM_FLAVOR_ID \
             $BM_FLAVOR_RAM $BM_FLAVOR_ROOT_DISK $BM_FLAVOR_CPU
     nova flavor-key $BM_FLAVOR_NAME set \
-            cpu_arch=$BM_FLAVOR_ARCH \
-            deploy_kernel_id=$aki \
-            deploy_ramdisk_id=$ari
+            "cpu_arch"="$BM_FLAVOR_ARCH" \
+            "baremetal:deploy_kernel_id"="$aki" \
+            "baremetal:deploy_ramdisk_id"="$ari"
+
 }
 
 # pull run-time kernel/ramdisk out of disk image and load into glance
diff --git a/lib/ceilometer b/lib/ceilometer
index 8772867..c04371d 100644
--- a/lib/ceilometer
+++ b/lib/ceilometer
@@ -88,9 +88,20 @@
     iniset $CEILOMETER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME
     iniset $CEILOMETER_CONF keystone_authtoken signing_dir $CEILOMETER_AUTH_CACHE_DIR
 
+    configure_mongodb
+
     cleanup_ceilometer
 }
 
+function configure_mongodb() {
+    if is_fedora ; then
+        # ensure smallfiles selected to minimize freespace requirements
+        sudo sed -i '/--smallfiles/!s/OPTIONS=\"/OPTIONS=\"--smallfiles /' /etc/sysconfig/mongod
+
+        restart_service mongod
+    fi
+}
+
 # init_ceilometer() - Initialize etc.
 function init_ceilometer() {
     # Create cache dir
diff --git a/lib/quantum b/lib/quantum
index 3e41d8d..eebbabf 100644
--- a/lib/quantum
+++ b/lib/quantum
@@ -89,7 +89,7 @@
 # Meta data IP
 Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
 # Allow Overlapping IP among subnets
-Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-False}
+Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True}
 # Use quantum-debug command
 Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False}
 # The name of the default q-l3 router
@@ -176,6 +176,11 @@
 # Please refer to lib/quantum_plugins/README.md for details.
 source $TOP_DIR/lib/quantum_plugins/$Q_PLUGIN
 
+# Agent loadbalancer service plugin functions
+# -------------------------------------------
+# Hardcoding for 1 service plugin for now
+source $TOP_DIR/lib/quantum_plugins/agent_loadbalancer
+
 # Entry Points
 # ------------
 
@@ -185,6 +190,10 @@
     _configure_quantum_common
     iniset_rpc_backend quantum $QUANTUM_CONF DEFAULT
 
+    # goes before q-svc to init Q_SERVICE_PLUGIN_CLASSES
+    if is_service_enabled q-lbaas; then
+        _configure_quantum_lbaas
+    fi
     if is_service_enabled q-svc; then
         _configure_quantum_service
     fi
@@ -362,6 +371,10 @@
     screen_it q-dhcp "python $AGENT_DHCP_BINARY --config-file $QUANTUM_CONF --config-file=$Q_DHCP_CONF_FILE"
     screen_it q-meta "python $AGENT_META_BINARY --config-file $QUANTUM_CONF --config-file=$Q_META_CONF_FILE"
     screen_it q-l3 "python $AGENT_L3_BINARY --config-file $QUANTUM_CONF --config-file=$Q_L3_CONF_FILE"
+
+    if is_service_enabled q-lbaas; then
+        screen_it q-lbaas "python $AGENT_LBAAS_BINARY --config-file $QUANTUM_CONF --config-file=$LBAAS_AGENT_CONF_FILENAME"
+    fi
 }
 
 # stop_quantum() - Stop running processes (non-screen)
@@ -483,6 +496,13 @@
     _quantum_setup_keystone $Q_META_CONF_FILE DEFAULT set_auth_url
 }
 
+function _configure_quantum_lbaas()
+{
+    quantum_agent_lbaas_install_agent_packages
+    quantum_agent_lbaas_configure_common
+    quantum_agent_lbaas_configure_agent
+}
+
 # _configure_quantum_plugin_agent() - Set config files for quantum plugin agent
 # It is called when q-agt is enabled.
 function _configure_quantum_plugin_agent() {
@@ -512,6 +532,10 @@
     # Update either configuration file with plugin
     iniset $QUANTUM_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
 
+    if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then
+        iniset $QUANTUM_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES
+    fi
+
     iniset $QUANTUM_CONF DEFAULT verbose True
     iniset $QUANTUM_CONF DEFAULT debug True
     iniset $QUANTUM_CONF DEFAULT state_path $DATA_DIR/quantum
diff --git a/lib/quantum_plugins/agent_loadbalancer b/lib/quantum_plugins/agent_loadbalancer
new file mode 100644
index 0000000..a4d6dff
--- /dev/null
+++ b/lib/quantum_plugins/agent_loadbalancer
@@ -0,0 +1,45 @@
+# Quantum loadbalancer plugin
+# ---------------------------
+
+# Save trace setting
+MY_XTRACE=$(set +o | grep xtrace)
+set +o xtrace
+
+
+AGENT_LBAAS_BINARY="$QUANTUM_DIR/bin/quantum-lbaas-agent"
+
+function quantum_agent_lbaas_install_agent_packages() {
+    if is_ubuntu || is_fedora; then
+        install_package haproxy
+    fi
+}
+
+function quantum_agent_lbaas_configure_common() {
+    if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
+        Q_SERVICE_PLUGIN_CLASSES="quantum.plugins.services.agent_loadbalancer.plugin.LoadBalancerPlugin"
+    else
+        Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,quantum.plugins.services.agent_loadbalancer.plugin.LoadBalancerPlugin"
+    fi
+}
+
+function quantum_agent_lbaas_configure_agent() {
+    LBAAS_AGENT_CONF_PATH=/etc/quantum/plugins/services/agent_loadbalancer
+    mkdir -p $LBAAS_AGENT_CONF_PATH
+
+    LBAAS_AGENT_CONF_FILENAME="$LBAAS_AGENT_CONF_PATH/lbaas_agent.ini"
+
+    cp $QUANTUM_DIR/etc/lbaas_agent.ini /$LBAAS_AGENT_CONF_FILENAME
+
+    if [[ $Q_PLUGIN == 'linuxbridge' || $Q_PLUGIN == 'brocade' ]]; then
+        iniset $LBAAS_AGENT_CONF_FILENAME DEFAULT interface_driver "quantum.agent.linux.interface.BridgeInterfaceDriver"
+    else
+        iniset $LBAAS_AGENT_CONF_FILENAME DEFAULT interface_driver "quantum.agent.linux.interface.OVSInterfaceDriver"
+    fi
+
+    if is_fedora; then
+        iniset $LBAAS_AGENT_CONF_FILENAME DEFAULT user_group "nobody"
+    fi
+}
+
+# Restore xtrace
+$MY_XTRACE
diff --git a/stack.sh b/stack.sh
index 6952fba..0f5401a 100755
--- a/stack.sh
+++ b/stack.sh
@@ -1076,9 +1076,8 @@
         iniset $NOVA_CONF DEFAULT compute_driver nova.virt.baremetal.driver.BareMetalDriver
         iniset $NOVA_CONF DEFAULT firewall_driver $LIBVIRT_FIREWALL_DRIVER
         iniset $NOVA_CONF DEFAULT scheduler_host_manager nova.scheduler.baremetal_host_manager.BaremetalHostManager
-        # NOTE(deva): ComputeCapabilitiesFilter does not currently work with Baremetal. See bug # 1129485
-        #             As a work around, we disable CCFilter by explicitly enabling all the other default filters.
-        iniset $NOVA_CONF DEFAULT scheduler_default_filters ComputeFilter,RetryFilter,AvailabilityZoneFilter,ImagePropertiesFilter
+        iniset $NOVA_CONF DEFAULT ram_allocation_ratio 1.0
+        iniset $NOVA_CONF DEFAULT reserved_host_memory_mb 0
         iniset $NOVA_CONF baremetal instance_type_extra_specs cpu_arch:$BM_CPU_ARCH
         iniset $NOVA_CONF baremetal driver $BM_DRIVER
         iniset $NOVA_CONF baremetal power_manager $BM_POWER_MANAGER