bin/nova/nova-hypervisor-metrics.py in sensu-plugins-openstack-0.0.3 vs bin/nova/nova-hypervisor-metrics.py in sensu-plugins-openstack-0.0.4

- old
+ new

@@ -5,10 +5,11 @@ # before (as well as Python 3.0) require that you number the placeholders in the format method(). # This way wherever the {} is used, number it starting from 0. e.g., {0}.nova.hypervisor # #RED from argparse import ArgumentParser +from os import getenv import socket import time from novaclient.v3 import Client @@ -29,13 +30,13 @@ def output_metric(name, value): print '{}\t{}\t{}'.format(name, value, int(time.time())) def main(): parser = ArgumentParser() - parser.add_argument('-u', '--user', default='admin') - parser.add_argument('-p', '--password', default='admin') - parser.add_argument('-t', '--tenant', default='admin') - parser.add_argument('-a', '--auth-url', default='http://localhost:5000/v2.0') + parser.add_argument('-u', '--user', default=getenv('OS_USERNAME', 'admin')) + parser.add_argument('-p', '--password', default=getenv('OS_PASSWORD', 'admin')) + parser.add_argument('-t', '--tenant', default=getenv('OS_TENANT_NAME', 'admin')) + parser.add_argument('-a', '--auth-url', default=getenv('OS_AUTH_URL', 'http://localhost:5000/v2.0')) parser.add_argument('-S', '--service-type', default='compute') parser.add_argument('-H', '--host') parser.add_argument('-s', '--scheme', default=DEFAULT_SCHEME) args = parser.parse_args()