When creating the collectd-ceilometer-plugin.conf file, incorrect values were used This commit changes the following variables: - OS_USERNAME "$OS_USERNAME" -> OS_USERNAME "ceilometer" the service username is hardcoded, and OS_USERNAME overrides an existing variable used by OpenStack - OS_PASSWORD "$OS_PASSWORD" -> OS_PASSWORD "$SERVICE_PASSWORD" these are usually identical for devstack, but can be set differently - OS_TENANT_NAME "service" -> OS_TENANT_NAME "$SERVICE_TENANT_NAME" set to service by default. This change also removes the code that overwrote the OS_USERNAME and OS_PASSWORD variables in devstack/settings Change-Id: I9c8435766aa8448210bf06676f4e06d8fbf3a7a8 Closes-Bug: #1605352
		
			
				
	
	
		
			99 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			99 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
#!/bin/bash
 | 
						|
#
 | 
						|
# common functions for collectd ceilometer plugin
 | 
						|
# -----------------------------------------------
 | 
						|
 | 
						|
# start/stop service
 | 
						|
#
 | 
						|
function start_collectd {
 | 
						|
    if [ -e /usr/lib/systemd/system/collectd.service ] || [ -e /etc/init.d/collectd ]; then
 | 
						|
        sudo service collectd restart
 | 
						|
    fi
 | 
						|
}
 | 
						|
 | 
						|
function stop_collectd {
 | 
						|
    if [ -e /usr/lib/systemd/system/collectd.service ] || [ -e /etc/init.d/collectd ]; then
 | 
						|
        sudo service collectd stop
 | 
						|
    fi
 | 
						|
}
 | 
						|
 | 
						|
# install collectd service
 | 
						|
function install_collectd {
 | 
						|
    if [[ "$COLLECTD_INSTALL" == True  ]]; then
 | 
						|
        if is_fedora || is_ubuntu; then
 | 
						|
            install_package collectd
 | 
						|
        else
 | 
						|
            die $LINENO "No support for collectd on this platform"
 | 
						|
        fi
 | 
						|
    fi
 | 
						|
}
 | 
						|
 | 
						|
# Add conf file for plugin
 | 
						|
function adapt_collectd_conf {
 | 
						|
if [ ! -d "$COLLECTD_CONF_DIR" ]; then
 | 
						|
        sudo mkdir "$COLLECTD_CONF_DIR"
 | 
						|
fi
 | 
						|
 | 
						|
cat << EOF | sudo tee $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
 | 
						|
<LoadPlugin python>
 | 
						|
  Globals true
 | 
						|
</LoadPlugin>
 | 
						|
 | 
						|
<Plugin python>
 | 
						|
    ModulePath "$COLLECTD_CEILOMETER_DIR"
 | 
						|
    LogTraces true
 | 
						|
    Interactive false
 | 
						|
    Import "collectd_ceilometer.plugin"
 | 
						|
 | 
						|
    <Module "collectd_ceilometer.plugin">
 | 
						|
 | 
						|
        # Verbosity True|False
 | 
						|
        VERBOSE $COLLECTD_CEILOMETER_VERBOSE
 | 
						|
 | 
						|
        # Batch size
 | 
						|
        BATCH_SIZE "$COLLECTD_BATCH_SIZE"
 | 
						|
 | 
						|
        # Service endpoint addresses
 | 
						|
        OS_AUTH_URL "$OS_AUTH_URL"
 | 
						|
 | 
						|
        # Ceilometer address
 | 
						|
        #CEILOMETER_ENDPOINT
 | 
						|
        CEILOMETER_URL_TYPE "$CEILOMETER_URL_TYPE"
 | 
						|
 | 
						|
        # Ceilometer timeout in ms
 | 
						|
        CEILOMETER_TIMEOUT "$CEILOMETER_TIMEOUT"
 | 
						|
 | 
						|
        # # Ceilometer user creds
 | 
						|
        OS_USERNAME "ceilometer"
 | 
						|
        OS_PASSWORD "$SERVICE_PASSWORD"
 | 
						|
        OS_TENANT_NAME "$SERVICE_TENANT_NAME"
 | 
						|
 | 
						|
    </Module>
 | 
						|
</Plugin>
 | 
						|
EOF
 | 
						|
 | 
						|
# Configure collectd logfile plugin
 | 
						|
if [ -n $COLLECTD_LOG_FILE ]; then
 | 
						|
    touch $COLLECTD_LOG_FILE
 | 
						|
cat << EOF | sudo tee "$COLLECTD_CONF_DIR/logfile.conf"
 | 
						|
LoadPlugin "logfile"
 | 
						|
<Plugin "logfile">
 | 
						|
  LogLevel "$COLLECTD_LOG_LEVEL"
 | 
						|
  File "$COLLECTD_LOG_FILE"
 | 
						|
  Timestamp true
 | 
						|
</Plugin>
 | 
						|
EOF
 | 
						|
fi
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
# remove plugin conf file
 | 
						|
function restore_collectd_conf {
 | 
						|
 | 
						|
    if [ -f '$COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf' ]; then
 | 
						|
        sudo rm -f $COLLECTD_CONF_DIR/collectd-ceilometer-plugin.conf
 | 
						|
    fi
 | 
						|
 | 
						|
}
 |