コード例 #1
0
ファイル: ceilometer.py プロジェクト: wathsalav/xos
    def get_meter(self, meter, obj, pk, keystone=None):
        if (not keystone):
                keystone={}
                keystone['os_username']=env['OS_USERNAME']
                keystone['os_password']=env['OS_PASSWORD']
                keystone['os_auth_url']=env['OS_AUTH_URL']
                keystone['os_tenant_name']=env['OS_TENANT_NAME']
                keystone['os_cacert']=env['OS_CACERT']
                keystone['os_region_name']=env['OS_REGION_NAME']

                keystone['username']=env['OS_USERNAME']
                keystone['password']=env['OS_PASSWORD']
                keystone['auth_url']=env['OS_AUTH_URL']
                keystone['tenant_name']=env['OS_TENANT_NAME']
                keystone['cacert']=env['OS_CACERT']
                keystone['region_name']=env['OS_REGION_NAME']

        keystone['auth_plugin']=client.AuthPlugin(**keystone)

        ceilometer = client.get_client(2,**keystone)
        
        cur_ts = datetime.datetime.fromtimestamp(time.time()-86400)
        str_ts = cur_ts.strftime('%Y-%m-%dT%H:%M:%S')

        object_filter = object_to_filter(obj, pk)
        filter=';'.join([object_filter,'timestamp>%s'%str_ts])
        #query = cli_to_array("project_id=124de34266b24f57957345cdb43cc9ff;timestamp>2014-12-11T00:00:00")
        query = cli_to_array(filter)

        meters = ceilometer.statistics.list(meter,q=query,period=3600)

        stats = meters_to_stats(meters)
        return stats
コード例 #2
0
ファイル: utils.py プロジェクト: juliovp01/ops_tools
 def __init__(self):
     from ceilometerclient import shell
     self.ceilometer = shell.CeilometerShell()
     self.base_argv = copy.deepcopy(sys.argv[1:])
     # NOTE(gordc): workaround for bug1434264
     if not hasattr(self.ceilometer, 'auth_plugin'):
         from ceilometerclient import client
         if hasattr(client, 'AuthPlugin'):
             self.ceilometer.auth_plugin = client.AuthPlugin()
     self.ceilometer.parser = self.ceilometer.get_base_parser()
     self.add_argument = self.ceilometer.parser.add_argument
コード例 #3
0
    def parse_args(self, argv):
        # Parse args once to find version
        self.auth_plugin = ceiloclient.AuthPlugin()
        parser = self.get_base_parser()
        (options, args) = parser.parse_known_args(argv)
        self.auth_plugin.parse_opts(options)
        self._setup_logging(options.debug)

        # build available subcommands based on version
        api_version = options.ceilometer_api_version
        subcommand_parser = self.get_subcommand_parser(api_version)
        self.parser = subcommand_parser

        # Handle top-level --help/-h before attempting to parse
        # a command off the command line
        if options.help or not argv:
            self.do_help(options)
            return 0

        # Return parsed args
        return api_version, subcommand_parser.parse_args(argv)
コード例 #4
0
 def __init__(self):
     self.auth_plugin = ceiloclient.AuthPlugin()