当前位置: 首页>>代码示例>>Python>>正文


Python OpServerUtils.get_query_dict方法代码示例

本文整理汇总了Python中opserver_util.OpServerUtils.get_query_dict方法的典型用法代码示例。如果您正苦于以下问题:Python OpServerUtils.get_query_dict方法的具体用法?Python OpServerUtils.get_query_dict怎么用?Python OpServerUtils.get_query_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opserver_util.OpServerUtils的用法示例。


在下文中一共展示了OpServerUtils.get_query_dict方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_query

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import get_query_dict [as 别名]
    def post_query(self, table, start_time=None, end_time=None,
                   select_fields=None,
                   where_clause='',
                   sort_fields=None, sort=None, limit=None, filter=None, dir=None):
        res = None
        try:
            flows_url = OpServerUtils.opserver_query_url(
                self._ip, str(self._port))
            print flows_url
            query_dict = OpServerUtils.get_query_dict(
                table, start_time, end_time,
                select_fields,
                where_clause,
                sort_fields, sort, limit, filter, dir)

            print json.dumps(query_dict)
            res = []
            resp = OpServerUtils.post_url_http(
                flows_url, json.dumps(query_dict))
            if resp is not None:
                resp = json.loads(resp)
                qid = resp['href'].rsplit('/', 1)[1]
                result = OpServerUtils.get_query_result(
                    self._ip, str(self._port), qid)
                for item in result:
                    res.append(item)
        except Exception as e:
            print str(e)
        finally:
            return res
开发者ID:ganeshahv,项目名称:contrail-test,代码行数:32,代码来源:opserver_introspect_utils.py

示例2: query

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import get_query_dict [as 别名]
    def query(self):
        query_url = OpServerUtils.opserver_query_url(
            self._args.analytics_api_ip,
            self._args.analytics_api_port)

        if self._args.dtable is not None:
            rtable = self._args.dtable
        else:
            rtable = self._args.table
 
        query_dict = OpServerUtils.get_query_dict(
                "StatTable." + rtable, str(self._start_time), str(self._end_time),
                select_fields = self._args.select,
                where_clause = "AND".join(self._args.where),
                sort_fields = self._args.sort)
        
        print json.dumps(query_dict)
        resp = OpServerUtils.post_url_http(
            query_url, json.dumps(query_dict), sync = True)

        res = None
        if resp is not None:
            res = json.loads(resp)
            res = res['value']

        return res
开发者ID:Pojen-Huang,项目名称:contrail-controller,代码行数:28,代码来源:stats.py

示例3: post_query

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import get_query_dict [as 别名]
    def post_query(self, table, start_time=None, end_time=None,
                   select_fields=None,
                   where_clause='',
                   sort_fields=None, sort=None, limit=None, filter=None, dir=None,
                   session_type=None):
        res = None
        try:
            query_dict = OpServerUtils.get_query_dict(
                table, start_time, end_time,
                select_fields,
                where_clause,
                sort_fields, sort, limit, filter, dir,
                session_type)

            res = []
            resp = self.post(path='analytics/query', payload=query_dict)
            if resp is not None:
                try:
                    qid = resp['href'].rsplit('/', 1)[1]
                    result = self.get_query_result(qid)
                    for item in result:
                        res.append(item)
                except Exception as e:
                    if 'value' in resp:
                        for item in resp['value']:
                            res.append(item)
        except Exception as e:
            self.log.debug("Got exception %s"%e)
        finally:
            return res
开发者ID:Juniper,项目名称:contrail-test,代码行数:32,代码来源:opserver_introspect_utils.py

示例4: query

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import get_query_dict [as 别名]
    def query(self, table, start_time=None, end_time=None,
              select_fields=None,
              where_clause="",
              sort_fields=None, sort=None, limit=None, filter=None):
        """
        This function takes in the query parameters,
        format appropriately and calls
        ReST API to the :mod:`opserver` to get data

        :param table: table to do the query on
        :type table: str
        :param start_time: start_time of the query's timeperiod
        :type start_time: int
        :param end_time: end_time of the query's timeperiod
        :type end_time: int
        :param select_fields: list of columns to be returned in the
         final result
        :type select_fields: list of str
        :param where_clause: list of match conditions for the query
        :type where_clause: list of match, which is a pair of str ANDed
        :returns: str -- json formatted result
        :raises: Error

        """

        flows_url = OpServerUtils.opserver_query_url(self._args.opserver_ip,
                                                     self._args.opserver_port)
        print flows_url

        query_dict = OpServerUtils.get_query_dict(table, start_time, end_time,
                                                  select_fields, where_clause,
                                                  sort_fields, sort, limit,
                                                  filter)

        print json.dumps(query_dict)
        resp = OpServerUtils.post_url_http(flows_url, json.dumps(query_dict))
        if resp is not None:
            resp = json.loads(resp)
            qid = resp['href'].rsplit('/', 1)[1]
            result = OpServerUtils.get_query_result(self._args.opserver_ip,
                                                    self._args.opserver_port,
                                                    qid)
            for item in result:
                print item

        return
开发者ID:Doude,项目名称:contrail-controller,代码行数:48,代码来源:opserver_client.py

示例5: post_query

# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import get_query_dict [as 别名]
    def post_query(self, table, start_time=None, end_time=None,
                   select_fields=None,
                   where_clause='',
                   sort_fields=None, sort=None, limit=None, filter=None, dir=None,
                   session_type=None):
        res = None
        try:
            self._drv._auth()
            headers = self._drv._headers
        except Exception as e:
            headers = None #vcenter case where openstack not available

        try:
            flows_url = OpServerUtils.opserver_query_url(
                self._ip, str(self._port))
            print flows_url
            query_dict = OpServerUtils.get_query_dict(
                table, start_time, end_time,
                select_fields,
                where_clause,
                sort_fields, sort, limit, filter, dir,
                session_type)

            print json.dumps(query_dict)
            res = []
            resp = OpServerUtils.post_url_http(
                flows_url, json.dumps(query_dict), headers)
            if resp is not None:
                resp = json.loads(resp)
                try:
                    qid = resp['href'].rsplit('/', 1)[1]
                    result = OpServerUtils.get_query_result(
                        self._ip, str(self._port), qid, headers)
                    for item in result:
                        res.append(item)
                except Exception as e:
                    if 'value' in resp:
                        for item in resp['value']:
                            res.append(item)
        except Exception as e:
            print str(e)
        finally:
            return res
开发者ID:Ankitja,项目名称:contrail-test,代码行数:45,代码来源:opserver_introspect_utils.py


注:本文中的opserver_util.OpServerUtils.get_query_dict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。