本文整理汇总了Python中Mgmt.bn_name_pattern_match方法的典型用法代码示例。如果您正苦于以下问题:Python Mgmt.bn_name_pattern_match方法的具体用法?Python Mgmt.bn_name_pattern_match怎么用?Python Mgmt.bn_name_pattern_match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mgmt
的用法示例。
在下文中一共展示了Mgmt.bn_name_pattern_match方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_alarm_status
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import bn_name_pattern_match [as 别名]
def get_alarm_status(self, alarm):
"""
get_alarm_status(auth, alarm) -> string
Get an alarm's status.
Parameters:
alarm (string) - name of the alarm whose status will be returned
Exceptions:
get_alarm_statusFault - Alarm does not exist
get_alarm_statusFault - Server Error. Contact Support.
"""
alarm = alarm.lower()
alarm_enabled = Mgmt.get_value('/stats/config/alarm/%s/enable'
% alarm)
if alarm_enabled is None:
raise ServiceError, 'Alarm %s does not exist' % alarm
elif alarm_enabled == 'false':
return 'disabled'
elif alarm_enabled == 'true':
# XXX/jshilkaitis: use mdc_iterate_binding_pattern one day, but
# need to expose it first, and since it's non-trivial, I'm
# punting on that for now.
alarm_pfx = '/stats/state/alarm/' + alarm
alarm_nodes = Mgmt.iterate(alarm_pfx, subtree=True)
for node in alarm_nodes:
if ((Mgmt.bn_name_pattern_match(
node[0], alarm_pfx + '/node/*/rising/error') or
Mgmt.bn_name_pattern_match(
node[0], alarm_pfx + '/node/*/falling/error')) and
node[2] == 'true'):
return 'ERROR'
else:
raise ServiceError, 'Server error. Contact Support.'
return 'ok'
示例2: __get_top_talkers_list
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import bn_name_pattern_match [as 别名]
def __get_top_talkers_list(self, node_path, value_type):
"""
Internal function to support top talkers queries.
Iterate subtree on node_path and use the results to generate
a result list of value_type instances.
"""
temp_result = {}
bindings = Mgmt.iterate(node_path, subtree=True)
for b in bindings:
if Mgmt.bn_name_pattern_match(b[0], node_path + '/*/*'):
parts = Mgmt.bn_name_to_parts(b[0])
idx = int(parts[3]) - 1 # iterate results are 1-based
attr_name = parts[4]
curr_val = temp_result.setdefault(idx, value_type())
setattr(curr_val, attr_name, b[2])
return [temp_result[i] for i in xrange(len(temp_result))]