Révision 33cff547
Add autoconf and enhance graphs
| plugins/keystone/keystone_stats | ||
|---|---|---|
| 8 | 8 |
# |
| 9 | 9 |
# Magic markers |
| 10 | 10 |
#%# capabilities=autoconf |
| 11 |
#%# family=keystone
|
|
| 11 |
#%# family=auto
|
|
| 12 | 12 |
|
| 13 | 13 |
import sys |
| 14 |
import traceback |
|
| 15 |
|
|
| 16 |
try: |
|
| 17 |
from keystone.common import utils |
|
| 18 |
from keystone import config |
|
| 19 |
from keystone import exception |
|
| 20 |
from keystone import identity |
|
| 21 |
except ImportError: |
|
| 22 |
succesful_import = False |
|
| 23 |
else: |
|
| 24 |
succesful_import = True |
|
| 14 | 25 |
|
| 15 |
from keystone.common import utils |
|
| 16 |
from keystone import config |
|
| 17 |
from keystone import exception |
|
| 18 |
from keystone import identity |
|
| 19 | 26 |
|
| 20 | 27 |
CONF = config.CONF |
| 21 | 28 |
|
| ... | ... | |
| 78 | 85 |
for (field, value) in stats[state].iteritems(): |
| 79 | 86 |
print "%s_%s.value %s" % (field, state, value) |
| 80 | 87 |
|
| 88 |
def load_conf(): |
|
| 89 |
CONF(config_files=[utils.find_config('keystone.conf')])
|
|
| 81 | 90 |
|
| 82 | 91 |
if __name__ == '__main__': |
| 83 | 92 |
if len(sys.argv) > 1: |
| 84 | 93 |
if sys.argv[1] == "config": |
| 85 | 94 |
print_config() |
| 86 | 95 |
elif sys.argv[1] == "autoconf": |
| 87 |
print "yes" |
|
| 88 |
else: |
|
| 89 |
CONF(config_files=[utils.find_config('keystone.conf')])
|
|
| 96 |
if not succesful_import: |
|
| 97 |
print 'no (failed import keystone module)' |
|
| 98 |
sys.exit(0) |
|
| 99 |
try: |
|
| 100 |
load_conf() |
|
| 101 |
identity.Manager() |
|
| 102 |
except: |
|
| 103 |
print 'no (failed to connect keystone backend: %s'%traceback.format_exc() |
|
| 104 |
sys.exit(0) |
|
| 105 |
print 'yes' |
|
| 106 |
|
|
| 107 |
elif succesful_import: |
|
| 108 |
load_conf() |
|
| 90 | 109 |
print_values() |
| 91 | 110 |
|
Formats disponibles : Unified diff