From 40546f79e0e504d2d1470019a61a24da217e14fc Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 24 Sep 2013 15:10:25 +0200 Subject: [PATCH] Add Neutron Metering Agent support In Havana, Neutron has now a Metering Agent which gets meters from virtual routers. This patchs aims to allow devstack using this new service. Change-Id: I17ad83799d60384247b98cc8a93ac032f641c721 Signed-off-by: Emilien Macchi --- README.md | 1 + lib/neutron | 18 ++++++++++++++++ lib/neutron_plugins/services/metering | 30 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 lib/neutron_plugins/services/metering diff --git a/README.md b/README.md index 99e983887e..c94d8bd23a 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ following settings in your `localrc` : enable_service q-dhcp enable_service q-l3 enable_service q-meta + enable_service q-metering enable_service neutron # Optional, to enable tempest configuration as part of devstack enable_service tempest diff --git a/lib/neutron b/lib/neutron index 4a3d1b06a6..5334be613b 100644 --- a/lib/neutron +++ b/lib/neutron @@ -202,6 +202,12 @@ source $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN # Hardcoding for 1 service plugin for now source $TOP_DIR/lib/neutron_plugins/services/loadbalancer +# Agent metering service plugin functions +# ------------------------------------------- + +# Hardcoding for 1 service plugin for now +source $TOP_DIR/lib/neutron_plugins/services/metering + # VPN service plugin functions # ------------------------------------------- # Hardcoding for 1 service plugin for now @@ -231,6 +237,9 @@ function configure_neutron() { if is_service_enabled q-lbaas; then _configure_neutron_lbaas fi + if is_service_enabled q-metering; then + _configure_neutron_metering + fi if is_service_enabled q-vpn; then _configure_neutron_vpn fi @@ -451,6 +460,10 @@ function start_neutron_agents() { if is_service_enabled q-lbaas; then screen_it q-lbaas "cd $NEUTRON_DIR && python $AGENT_LBAAS_BINARY --config-file $NEUTRON_CONF --config-file=$LBAAS_AGENT_CONF_FILENAME" fi + + if is_service_enabled q-metering; then + screen_it q-metering "cd $NEUTRON_DIR && python $AGENT_METERING_BINARY --config-file $NEUTRON_CONF --config-file $METERING_AGENT_CONF_FILENAME" + fi } # stop_neutron() - Stop running processes (non-screen) @@ -630,6 +643,11 @@ function _configure_neutron_lbaas() { neutron_agent_lbaas_configure_agent } +function _configure_neutron_metering() { + neutron_agent_metering_configure_common + neutron_agent_metering_configure_agent +} + function _configure_neutron_fwaas() { neutron_fwaas_configure_common neutron_fwaas_configure_driver diff --git a/lib/neutron_plugins/services/metering b/lib/neutron_plugins/services/metering new file mode 100644 index 0000000000..629f3b788a --- /dev/null +++ b/lib/neutron_plugins/services/metering @@ -0,0 +1,30 @@ +# Neutron metering plugin +# --------------------------- + +# Save trace setting +MY_XTRACE=$(set +o | grep xtrace) +set +o xtrace + + +AGENT_METERING_BINARY="$NEUTRON_BIN_DIR/neutron-metering-agent" +METERING_PLUGIN="neutron.services.metering.metering_plugin.MeteringPlugin" + +function neutron_agent_metering_configure_common() { + if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then + Q_SERVICE_PLUGIN_CLASSES=$METERING_PLUGIN + else + Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$METERING_PLUGIN" + fi +} + +function neutron_agent_metering_configure_agent() { + METERING_AGENT_CONF_PATH=/etc/neutron/services/metering + mkdir -p $METERING_AGENT_CONF_PATH + + METERING_AGENT_CONF_FILENAME="$METERING_AGENT_CONF_PATH/metering_agent.ini" + + cp $NEUTRON_DIR/etc/metering_agent.ini $METERING_AGENT_CONF_FILENAME +} + +# Restore xtrace +$MY_XTRACE