Update Swift Stat collectd plugin for Auth 3

Change-Id: I8efb8495cb07976c5b3dd525633b1cd0ef134365
This commit is contained in:
akrzos 2018-01-15 12:57:25 -05:00
parent c07ac2f838
commit 57cb621f1e
3 changed files with 17 additions and 4 deletions

View File

@ -30,6 +30,7 @@ class CollectdSwiftStat(object):
self.user = None
self.password = None
self.authurl = None
self.authversion = None
self.project = None
self.swift_conn = None
@ -46,6 +47,8 @@ class CollectdSwiftStat(object):
self.password = val
elif node.key == 'AuthURL':
self.authurl = val
elif node.key == 'AuthVersion':
self.authversion = val
elif node.key == 'Project':
self.project = val
else:
@ -66,15 +69,18 @@ class CollectdSwiftStat(object):
if not self.authurl:
collectd.error('collectd-swift-stat: AuthURL Undefined')
read_plugin = False
if not self.authversion:
collectd.error('collectd-swift-stat: AuthVersion Undefined')
read_plugin = False
if not self.project:
collectd.error('collectd-swift-stat: Project Undefined')
read_plugin = False
if read_plugin:
collectd.info(
'swift_stat: Connecting with user={}, password={}, tenant={},'
' auth_url={}'.format(
self.user, self.password, self.project, self.authurl))
'swift_stat: Connecting with user={}, password={}, tenant={}, auth_url={},'
' auth_version={}'.format(
self.user, self.password, self.project, self.authurl, self.authversion))
self.swift_conn = self.create_swift_session()
collectd.register_read(self.read_swift_stat, self.interval)
@ -108,7 +114,7 @@ class CollectdSwiftStat(object):
def create_swift_session(self):
return Connection(
authurl=self.authurl, user=self.user, key=self.password,
tenant_name=self.project, auth_version='2.0')
tenant_name=self.project, auth_version=self.authversion)
collectd_swift_stat = CollectdSwiftStat()

View File

@ -291,6 +291,12 @@
become: true
when: "'controller' in group_names and swift_stat_controller_collectd_plugin == true and inventory_hostname == groups['controller'][0]"
- name: Get Gnocchi Swift Auth Version
command: hiera -c /etc/puppet/hiera.yaml gnocchi::storage::swift::swift_auth_version
register: controller0_gnocchi_swift_authversion
become: true
when: "'controller' in group_names and swift_stat_controller_collectd_plugin == true and inventory_hostname == groups['controller'][0]"
- name: Get Gnocchi Swift User
shell: hiera -c /etc/puppet/hiera.yaml gnocchi::storage::swift::swift_user | sed 's/service://'
register: controller0_gnocchi_swift_user

View File

@ -416,6 +416,7 @@ PreCacheChain "PreCache"
Interval {{swift_stat_controller_collectd_interval}}
Prefix "gnocchi"
AuthURL "{{controller0_gnocchi_swift_authurl.stdout}}"
AuthVersion "{{controller0_gnocchi_swift_authversion.stdout}}"
User "{{controller0_gnocchi_swift_user.stdout}}"
Password "{{controller0_gnocchi_swift_auth_key.stdout}}"
Project "service"