本文整理汇总了Python中opserver_util.OpServerUtils.post_url_http方法的典型用法代码示例。如果您正苦于以下问题:Python OpServerUtils.post_url_http方法的具体用法?Python OpServerUtils.post_url_http怎么用?Python OpServerUtils.post_url_http使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opserver_util.OpServerUtils
的用法示例。
在下文中一共展示了OpServerUtils.post_url_http方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [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
示例2: query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [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
示例3: _send_query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [as 别名]
def _send_query(self, query):
"""Post the query to the analytics-api server and returns the
response."""
self._logger.debug('Sending query: %s' % (query))
opserver_url = OpServerUtils.opserver_query_url(self._analytics_api_ip,
str(self._analytics_api_port))
resp = OpServerUtils.post_url_http(opserver_url, query, True)
try:
resp = json.loads(resp)
value = resp['value']
except (TypeError, ValueError, KeyError):
raise _QueryError(query)
self._logger.debug('Query response: %s' % str(value))
return value
示例4: query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [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
示例5: post_db_purge
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [as 别名]
def post_db_purge(self,purge_input):
res = []
json_body = OpServerUtils.get_json_body(purge_input = purge_input)
print json.dumps(json_body)
try:
purge_url = OpServerUtils.opserver_db_purge_url(
self._ip, str(self._port))
print purge_url
resp = OpServerUtils.post_url_http(
purge_url, json.dumps(json_body))
if resp is not None:
resp = json.loads(resp)
res.append(resp)
except Exception as e:
print str(e)
finally:
return res
示例6: post_query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [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
示例7: query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [as 别名]
#.........这里部分代码省略.........
return -1
if self._args.module is None:
print 'Module is required for trace buffer dump'
return -1
trace_buf_match = OpServerUtils.Match(
name=VizConstants.CATEGORY,
value=self._args.trace,
op=OpServerUtils.MatchOp.EQUAL)
where_msg.append(trace_buf_match.__dict__)
where = [where_msg]
select_list = [
VizConstants.TIMESTAMP,
VizConstants.MESSAGE_TYPE,
VizConstants.SEQUENCE_NUM,
VizConstants.DATA,
VizConstants.SANDESH_TYPE
]
sandesh_type_filter = OpServerUtils.Match(
name=VizConstants.SANDESH_TYPE,
value=str(
SandeshType.TRACE),
op=OpServerUtils.MatchOp.EQUAL)
and_filter.append(sandesh_type_filter.__dict__)
else:
# Message Table Query
table = VizConstants.COLLECTOR_GLOBAL_TABLE
if len(where_msg):
where = [where_msg]
else:
where = None
select_list = [
VizConstants.TIMESTAMP,
VizConstants.SOURCE,
VizConstants.MODULE,
VizConstants.CATEGORY,
VizConstants.MESSAGE_TYPE,
VizConstants.SEQUENCE_NUM,
VizConstants.DATA,
VizConstants.SANDESH_TYPE,
VizConstants.LEVEL,
VizConstants.NODE_TYPE,
VizConstants.INSTANCE_ID,
]
filter = None
if len(or_filter):
filter = [and_filter+[filt] for filt in or_filter]
elif len(and_filter):
filter = [and_filter]
if self._args.keywords is not None:
p = re.compile('\s*,\s*|\s+')
if where is None:
where = [[]]
for kwd in p.split(self._args.keywords):
message_type_match = OpServerUtils.Match(
name=VizConstants.KEYWORD,
value=kwd,
op=OpServerUtils.MatchOp.EQUAL)
for wc in where:
wc.append(message_type_match.__dict__)
# Add sort by timestamp for non object value queries
sort_op = None
sort_fields = None
if self._args.object_values is False:
if self._args.reverse:
sort_op = OpServerUtils.SortOp.DESCENDING
else:
sort_op = OpServerUtils.SortOp.ASCENDING
sort_fields = [VizConstants.TIMESTAMP]
if self._args.limit:
limit = int(self._args.limit)
else:
limit = None
messages_query = OpServerUtils.Query(table,
start_time=start_time,
end_time=end_time,
select_fields=select_list,
where=where,
filter=filter,
sort=sort_op,
sort_fields=sort_fields,
limit=limit)
if self._args.verbose:
print 'Performing query: {0}'.format(
json.dumps(messages_query.__dict__))
resp = OpServerUtils.post_url_http(
messages_url, json.dumps(messages_query.__dict__))
result = {}
if resp is not None:
resp = json.loads(resp)
qid = resp['href'].rsplit('/', 1)[1]
result = OpServerUtils.get_query_result(
self._args.analytics_api_ip, self._args.analytics_api_port, qid)
return result
示例8: get_uve
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [as 别名]
#.........这里部分代码省略.........
continue
if typ not in statdict:
statdict[typ] = {}
statdict[typ][attr] = []
statsattr = json.loads(value)
for elem in statsattr:
#import pdb; pdb.set_trace()
edict = {}
if elem["rtype"] == "list":
elist = redish.lrange(elem["href"], 0, -1)
for eelem in elist:
jj = json.loads(eelem).items()
edict[jj[0][0]] = jj[0][1]
elif elem["rtype"] == "zset":
elist = redish.zrange(
elem["href"], 0, -1, withscores=True)
for eelem in elist:
tdict = json.loads(eelem[0])
tval = long(tdict["ts"])
dt = datetime.datetime.utcfromtimestamp(
float(tval) / 1000000)
tms = (tval % 1000000) / 1000
tstr = dt.strftime('%Y %b %d %H:%M:%S')
edict[tstr + "." + str(tms)] = eelem[1]
elif elem["rtype"] == "hash":
elist = redish.hgetall(elem["href"])
edict = elist
elif elem["rtype"] == "query":
if sfilter is None and mfilter is None and not multi:
qdict = {}
qdict["table"] = elem["aggtype"]
qdict["select_fields"] = elem["select"]
qdict["where"] =[[{"name":"name",
"value":key.split(":",1)[1],
"op":1}]]
qmap[elem["aggtype"]] = {"query":qdict,
"type":typ, "attr":attr}
# For the stats query case, defer processing
continue
statdict[typ][attr].append(
{elem["aggtype"]: edict})
continue
# print "Attr %s Value %s" % (attr, snhdict)
if attr not in state[key][typ]:
state[key][typ][attr] = {}
if dsource in state[key][typ][attr]:
print "Found Dup %s:%s:%s:%s:%s = %s" % \
(key, typ, attr, source, mdule, state[
key][typ][attr][dsource])
state[key][typ][attr][dsource] = snhdict[attr]
if len(qmap):
url = OpServerUtils.opserver_query_url(
self._local_redis_uve[0],
str(8081))
for t,q in qmap.iteritems():
try:
q["query"]["end_time"] = OpServerUtils.utc_timestamp_usec()
q["query"]["start_time"] = qdict["end_time"] - (3600 * 1000000)
json_str = json.dumps(q["query"])
resp = OpServerUtils.post_url_http(url, json_str, True)
if resp is not None:
edict = json.loads(resp)
edict = edict['value']
statdict[q["type"]][q["attr"]].append(
{t: edict})
except Exception as e:
print "Stats Query Exception:" + str(e)
if sfilter is None and mfilter is None:
for ptyp in redish.smembers("PTYPES:" + key):
afilter = None
if tfilter is not None:
if ptyp not in tfilter:
continue
afilter = tfilter[ptyp]
existing = redish.hgetall("PREVIOUS:" + key + ":" + ptyp)
nstate = UVEServer.convert_previous(
existing, state, key, ptyp, afilter)
state = copy.deepcopy(nstate)
pa = ParallelAggregator(state)
rsp = pa.aggregate(key, flat)
except redis.exceptions.ConnectionError:
self._logger.error("Failed to connect to redis-uve: %s:%d" \
% (redis_uve[0], redis_uve[1]))
except Exception as e:
self._logger.error("Exception: %s" % e)
return {}
else:
self._logger.debug("Computed %s" % key)
for k, v in statdict.iteritems():
if k in rsp:
mp = dict(v.items() + rsp[k].items())
statdict[k] = mp
return dict(rsp.items() + statdict.items())
示例9: query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [as 别名]
#.........这里部分代码省略.........
if self._args.source_port is not None:
source_port_match = OpServerUtils.Match(
name=self._SOURCE_PORT,
value=self._args.source_port,
op=OpServerUtils.MatchOp.EQUAL)
where.append(source_port_match.__dict__)
if self._args.destination_port is not None:
dest_port_match = OpServerUtils.Match(
name=self._DESTINATION_PORT,
value=self._args.destination_port,
op=OpServerUtils.MatchOp.EQUAL)
where.append(dest_port_match.__dict__)
if self._args.action is not None:
action_match = OpServerUtils.Match(
name=self._ACTION,
value=self._args.action,
op=OpServerUtils.MatchOp.EQUAL)
filter.append(action_match.__dict__)
if self._args.vrouter_ip is not None:
vrouter_ip_match = OpServerUtils.Match(
name=self._VROUTER_IP,
value=self._args.vrouter_ip,
op=OpServerUtils.MatchOp.EQUAL)
filter.append(vrouter_ip_match.__dict__)
if self._args.other_vrouter_ip is not None:
other_vrouter_ip_match = OpServerUtils.Match(
name=self._OTHER_VROUTER_IP,
value=self._args.other_vrouter_ip,
op=OpServerUtils.MatchOp.EQUAL)
filter.append(other_vrouter_ip_match.__dict__)
if self._args.vmi_uuid is not None:
vmi_match = OpServerUtils.Match(
name=self._VMI_UUID,
value=uuid.UUID(self._args.vmi_uuid),
op=OpServerUtils.MatchOp.EQUAL)
filter.append(vmi_match.__dict__)
# Flow Record Table Query
table = VizConstants.FLOW_TABLE
if len(where) == 0:
where = None
else:
where = [where]
select_list = [
VizConstants.FLOW_TABLE_UUID,
self._VROUTER,
self._SETUP_TIME,
self._TEARDOWN_TIME,
self._SOURCE_VN,
self._DESTINATION_VN,
self._SOURCE_IP,
self._DESTINATION_IP,
self._PROTOCOL,
self._SOURCE_PORT,
self._DESTINATION_PORT,
self._ACTION,
self._DIRECTION,
VizConstants.FLOW_TABLE_AGG_BYTES,
VizConstants.FLOW_TABLE_AGG_PKTS,
self._SG_RULE_UUID,
self._NW_ACE_UUID,
self._VROUTER_IP,
self._OTHER_VROUTER_IP,
self._VMI_UUID,
self._DROP_REASON
]
if self._args.tunnel_info:
select_list.append(self._UNDERLAY_PROTO)
select_list.append(self._UNDERLAY_SPORT)
if len(filter) == 0:
filter = None
flow_query = OpServerUtils.Query(table,
start_time=start_time,
end_time=end_time,
select_fields=select_list,
where=where,
filter=filter,
dir=self._args.direction)
if self._args.verbose:
print 'Performing query: {0}'.format(
json.dumps(flow_query.__dict__))
print ''
resp = OpServerUtils.post_url_http(
flow_url, json.dumps(flow_query.__dict__))
result = {}
if resp is not None:
resp = json.loads(resp)
qid = resp['href'].rsplit('/', 1)[1]
result = OpServerUtils.get_query_result(
self._args.analytics_api_ip, self._args.analytics_api_port, qid)
return result
示例10: query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [as 别名]
#.........这里部分代码省略.........
VizConstants.TIMESTAMP,
VizConstants.SOURCE,
VizConstants.MODULE,
VizConstants.MESSAGE_TYPE,
] + obj_sel_field
elif self._args.trace is not None:
table = VizConstants.COLLECTOR_GLOBAL_TABLE
if self._args.source is None:
print 'Source is required for trace buffer dump'
return None
if self._args.module is None:
print 'Module is required for trace buffer dump'
return None
trace_buf_match = OpServerUtils.Match(
name=VizConstants.CATEGORY,
value=self._args.trace,
op=OpServerUtils.MatchOp.EQUAL)
where_msg.append(trace_buf_match.__dict__)
where = [where_msg]
select_list = [
VizConstants.TIMESTAMP,
VizConstants.MESSAGE_TYPE,
VizConstants.SEQUENCE_NUM,
VizConstants.DATA
]
sandesh_type_filter = OpServerUtils.Match(
name=VizConstants.SANDESH_TYPE,
value=str(
SandeshType.TRACE),
op=OpServerUtils.MatchOp.EQUAL)
filter.append(sandesh_type_filter.__dict__)
else:
# Message Table Query
table = VizConstants.COLLECTOR_GLOBAL_TABLE
# Message Table contains both systemlog and objectlog.
# Add a filter to return only systemlogs
if not self._args.all:
sandesh_type_filter = OpServerUtils.Match(
name=VizConstants.SANDESH_TYPE,
value=str(
SandeshType.SYSTEM),
op=OpServerUtils.MatchOp.EQUAL)
filter.append(sandesh_type_filter.__dict__)
if len(where_msg):
where = [where_msg]
else:
where = None
select_list = [
VizConstants.TIMESTAMP,
VizConstants.SOURCE,
VizConstants.MODULE,
VizConstants.CATEGORY,
VizConstants.MESSAGE_TYPE,
VizConstants.SEQUENCE_NUM,
VizConstants.DATA,
VizConstants.SANDESH_TYPE,
VizConstants.LEVEL,
VizConstants.NODE_TYPE,
VizConstants.INSTANCE_ID,
]
if len(filter) == 0:
filter = None
# Add sort by timestamp
if self._args.reverse:
sort_op = OpServerUtils.SortOp.DESCENDING
else:
sort_op = OpServerUtils.SortOp.ASCENDING
sort_fields = [VizConstants.TIMESTAMP]
if self._args.limit:
limit = int(self._args.limit)
else:
limit = None
messages_query = OpServerUtils.Query(table,
start_time=start_time,
end_time=end_time,
select_fields=select_list,
where=where,
filter=filter,
sort=sort_op,
sort_fields=sort_fields,
limit=limit)
if self._args.verbose:
print 'Performing query: {0}'.format(
json.dumps(messages_query.__dict__))
print ''
resp = OpServerUtils.post_url_http(
messages_url, json.dumps(messages_query.__dict__))
result = {}
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)
return result
示例11: query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [as 别名]
#.........这里部分代码省略.........
else:
where = None
elif self._args.trace is not None:
table = VizConstants.COLLECTOR_GLOBAL_TABLE
if self._args.source is None:
print 'Source is required for trace buffer dump'
return -1
if self._args.module is None:
print 'Module is required for trace buffer dump'
return -1
trace_buf_match = OpServerUtils.Match(
name=VizConstants.CATEGORY,
value=self._args.trace,
op=OpServerUtils.MatchOp.EQUAL)
where_msg.append(trace_buf_match.__dict__)
where = [where_msg]
select_list = [
VizConstants.TIMESTAMP,
VizConstants.MESSAGE_TYPE,
VizConstants.SEQUENCE_NUM,
VizConstants.DATA
]
sandesh_type_filter = OpServerUtils.Match(
name=VizConstants.SANDESH_TYPE,
value=str(
SandeshType.TRACE),
op=OpServerUtils.MatchOp.EQUAL)
filter.append(sandesh_type_filter.__dict__)
else:
# Message Table Query
table = VizConstants.COLLECTOR_GLOBAL_TABLE
# Message Table contains both systemlog and objectlog.
# Add a filter to return only systemlogs
if not self._args.all:
sandesh_type_filter = OpServerUtils.Match(
name=VizConstants.SANDESH_TYPE,
value=str(
SandeshType.SYSTEM),
op=OpServerUtils.MatchOp.EQUAL)
filter.append(sandesh_type_filter.__dict__)
if len(where_msg):
where = [where_msg]
else:
where = None
select_list = [
VizConstants.TIMESTAMP,
VizConstants.SOURCE,
VizConstants.MODULE,
VizConstants.CATEGORY,
VizConstants.MESSAGE_TYPE,
VizConstants.SEQUENCE_NUM,
VizConstants.DATA,
VizConstants.SANDESH_TYPE,
VizConstants.LEVEL,
VizConstants.NODE_TYPE,
VizConstants.INSTANCE_ID,
]
if len(filter) == 0:
filter = None
# Add sort by timestamp for non object value queries
sort_op = None
sort_fields = None
if self._args.object_values is False:
if self._args.reverse:
sort_op = OpServerUtils.SortOp.DESCENDING
else:
sort_op = OpServerUtils.SortOp.ASCENDING
sort_fields = [VizConstants.TIMESTAMP]
if self._args.limit:
limit = int(self._args.limit)
else:
limit = None
messages_query = OpServerUtils.Query(table,
start_time=start_time,
end_time=end_time,
select_fields=select_list,
where=where,
filter=filter,
sort=sort_op,
sort_fields=sort_fields,
limit=limit)
if self._args.verbose:
print 'Performing query: {0}'.format(
json.dumps(messages_query.__dict__))
resp = OpServerUtils.post_url_http(
messages_url, json.dumps(messages_query.__dict__))
result = {}
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)
return result
示例12: query
# 需要导入模块: from opserver_util import OpServerUtils [as 别名]
# 或者: from opserver_util.OpServerUtils import post_url_http [as 别名]
#.........这里部分代码省略.........
VizConstants.MODULE,
VizConstants.MESSAGE_TYPE,
] + obj_sel_field
else:
if self._args.object_select_field:
print "Plesae specify either object-id with " + "object-select-field or only object-values"
return None
select_list = [OpServerUtils.OBJECT_ID]
elif self._args.trace is not None:
table = VizConstants.COLLECTOR_GLOBAL_TABLE
if self._args.source is None:
print "Source is required for trace buffer dump"
return None
if self._args.module is None:
print "Module is required for trace buffer dump"
return None
trace_buf_match = OpServerUtils.Match(
name=VizConstants.CATEGORY, value=self._args.trace, op=OpServerUtils.MatchOp.EQUAL
)
where_msg.append(trace_buf_match.__dict__)
where = [where_msg]
select_list = [
VizConstants.TIMESTAMP,
VizConstants.MESSAGE_TYPE,
VizConstants.SEQUENCE_NUM,
VizConstants.DATA,
]
sandesh_type_filter = OpServerUtils.Match(
name=VizConstants.SANDESH_TYPE, value=str(SandeshType.TRACE), op=OpServerUtils.MatchOp.EQUAL
)
filter.append(sandesh_type_filter.__dict__)
else:
# Message Table Query
table = VizConstants.COLLECTOR_GLOBAL_TABLE
# Message Table contains both systemlog and objectlog.
# Add a filter to return only systemlogs
if not self._args.all:
sandesh_type_filter = OpServerUtils.Match(
name=VizConstants.SANDESH_TYPE, value=str(SandeshType.SYSTEM), op=OpServerUtils.MatchOp.EQUAL
)
filter.append(sandesh_type_filter.__dict__)
if len(where_msg):
where = [where_msg]
else:
where = None
select_list = [
VizConstants.TIMESTAMP,
VizConstants.SOURCE,
VizConstants.MODULE,
VizConstants.CATEGORY,
VizConstants.MESSAGE_TYPE,
VizConstants.SEQUENCE_NUM,
VizConstants.DATA,
VizConstants.SANDESH_TYPE,
VizConstants.LEVEL,
VizConstants.NODE_TYPE,
VizConstants.INSTANCE_ID,
]
if len(filter) == 0:
filter = None
# Add sort by timestamp for non object value queries
sort_op = None
sort_fields = None
if self._args.object_values is False:
if self._args.reverse:
sort_op = OpServerUtils.SortOp.DESCENDING
else:
sort_op = OpServerUtils.SortOp.ASCENDING
sort_fields = [VizConstants.TIMESTAMP]
if self._args.limit:
limit = int(self._args.limit)
else:
limit = None
messages_query = OpServerUtils.Query(
table,
start_time=start_time,
end_time=end_time,
select_fields=select_list,
where=where,
filter=filter,
sort=sort_op,
sort_fields=sort_fields,
limit=limit,
)
if self._args.verbose:
print "Performing query: {0}".format(json.dumps(messages_query.__dict__))
print ""
resp = OpServerUtils.post_url_http(messages_url, json.dumps(messages_query.__dict__))
result = {}
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)
return result