def collect(self, config): log.debug("Collect for OpenStack") ds0 = config.datasources[0] client = APIClient( ds0.zCommandUsername, ds0.zCommandPassword, ds0.zOpenStackAuthUrl, ds0.zOpenStackProjectId, ) results = [] for ds in config.datasources: query = dict( field='resource_id', op='eq', value=ds.resourceId, type='string' ) result = yield client.ceilometer_statistics( meter_name=ds.params['metric'], queries=[query] ) results.append((ds, result)) defer.returnValue(results)
def getRegions(self, username, api_key, project_id, auth_url): """Get a list of available regions, given a keystone endpoint and credentials.""" client = APIClient( username=username, password=api_key, project_id=project_id, auth_url=auth_url, ) serviceCatalog = yield client.serviceCatalog() ep = [] [ep.extend(x['endpoints']) for x in serviceCatalog] regions = set([x['region'] for x in ep]) returnValue([{'key': c, 'label': c} for c in sorted(regions)])
def collect(self, config): log.debug("Collect for OpenStack Neutron Agent Status (%s)" % config.id) ds0 = config.datasources[0] client = APIClient( ds0.zCommandUsername, ds0.zCommandPassword, ds0.zOpenStackAuthUrl, ds0.zOpenStackProjectId) results = {} log.debug('Requesting agent-list') result = yield client.neutron_agents() results['agents'] = result['agents'] defer.returnValue(results)
def collect(self, config): log.debug("Collect for OpenStack Nova Service Status (%s)" % config.id) ds0 = config.datasources[0] client = APIClient( ds0.zCommandUsername, ds0.zCommandPassword, ds0.zOpenStackAuthUrl, ds0.zOpenStackProjectId) results = {} log.debug('Requesting services') result = yield client.nova_services() results['services'] = result['services'] yield self.preprocess_hosts(config, results) defer.returnValue(results)
def getCeilometerUrl(self, username, api_key, project_id, auth_url, region_name): """Return the first defined ceilometer URL, given a keystone endpoint, credentials, and a region. May return an empty string if none is found.""" client = APIClient( username=username, password=api_key, project_id=project_id, auth_url=auth_url, ) serviceCatalog = yield client.serviceCatalog() for sc in serviceCatalog: if sc['type'] == 'metering': for endpoint in sc['endpoints']: if endpoint['region'] == region_name: returnValue(str(endpoint['publicURL'])) return # never found one. returnValue("")