コード例 #1
0
ファイル: clientmanager.py プロジェクト: carriercomm/oiopy
 def setup(self):
     if not self.setup_done:
         if not self._options.get('namespace', None):
             msg = 'Set a namespace with --oio-ns, OIO_NS\n'
             raise exceptions.CommandError('Missing parameter: \n%s' % msg)
         self.namespace = self._options['namespace']
         sds_conf = load_sds_conf(self.namespace) or {}
         if not self._options.get('proxyd_url') and 'proxy' in sds_conf:
             proxyd_url = 'http://%s' % sds_conf.get('proxy')
             self._options['proxyd_url'] = proxyd_url
         validate_options(self._options)
         LOG.info('Using parameters %s' % self._options)
         self.session = requests.Session()
         self.setup_done = True
コード例 #2
0
    def collect(self):
        namespaces = self.namespaces

        # Convert a string config value to be an array
        if isinstance(namespaces, basestring):
            namespaces = [namespaces]

        http = urllib3.PoolManager()
        for ns in namespaces:
            config = utils.load_sds_conf(ns)
            if not config:
                self.log.error('No configuration found for namespace ' + ns)
                continue
            proxy = config['proxy']
            self.get_stats(http, ns, proxy)