mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Allow possibility to show tenant name instead of tenant id in graph
This commit is contained in:
parent
017ad1f8bb
commit
775bf84215
1 changed files with 38 additions and 5 deletions
|
@ -10,26 +10,55 @@
|
|||
# [glance_*]
|
||||
# user glance
|
||||
#
|
||||
# To show tenant name plugin must run as root
|
||||
#
|
||||
# Magic markers
|
||||
#%# capabilities=autoconf suggest
|
||||
#%# family=auto
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
try:
|
||||
from sqlalchemy.orm import exc, joinedload
|
||||
from sqlalchemy.orm import joinedload
|
||||
import sqlalchemy.exc
|
||||
|
||||
from glance.common.cfg import CommonConfigOpts
|
||||
from glance.registry.db import models
|
||||
from glance.registry.db.api import get_session, configure_db
|
||||
|
||||
from keystone.common import utils
|
||||
from keystone import config
|
||||
from keystone import exception
|
||||
from keystone import identity
|
||||
|
||||
except ImportError:
|
||||
succesful_import = False
|
||||
else:
|
||||
succesful_import = True
|
||||
|
||||
|
||||
def get_name_from_tenant(tenant):
|
||||
try:
|
||||
KEYSTONE_CONF = config.CONF(config_files=[utils.find_config('keystone.conf')])
|
||||
except:
|
||||
# keystone configuration can not be loaded, use id as name"
|
||||
return tenant
|
||||
|
||||
identity_api = identity.Manager()
|
||||
|
||||
try:
|
||||
tenant_info = identity_api.get_tenant(None, tenant)
|
||||
except sqlalchemy.exc.OperationalError:
|
||||
# keystone database can not be connected, use id as name"
|
||||
return tenant
|
||||
|
||||
if not tenant_info:
|
||||
return tenant
|
||||
else:
|
||||
return tenant_info["name"]
|
||||
|
||||
|
||||
def load_conf():
|
||||
CONF = CommonConfigOpts(project="glance", prog="glance-registry")
|
||||
CONF()
|
||||
|
@ -41,12 +70,16 @@ def load_conf():
|
|||
|
||||
|
||||
def print_config(tenant):
|
||||
print 'graph_title Glance used size for tenant %s' % tenant
|
||||
if tenant == "Global":
|
||||
print 'graph_title Glance used size for all tenants'
|
||||
print 'graph_info This graph shows the used size in glance for all tenants'
|
||||
else:
|
||||
print 'graph_title Glance used size for tenant %s' % get_name_from_tenant(tenant)
|
||||
print 'graph_info This graph shows the used size in glance for tenant %s' % tenant
|
||||
print 'graph_vlabel Bytes'
|
||||
print 'graph_args --base 1024 --lower-limit 0'
|
||||
print 'graph_category glance'
|
||||
print 'graph_info This graph shows the used size in glance for tenant %s' % tenant
|
||||
print '%s.label %s' % (tenant, tenant)
|
||||
print '%s.label %s' % (tenant, get_name_from_tenant(tenant))
|
||||
print '%s.draw LINE2' % tenant
|
||||
print '%s.info %s MBytes' % (tenant, tenant)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue