當前位置: 首頁>>代碼示例>>Python>>正文


Python Mgmt.bn_name_pattern_match方法代碼示例

本文整理匯總了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'
開發者ID:akkmzack,項目名稱:RIOS-8.5,代碼行數:42,代碼來源:fwk_service.py

示例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))]
開發者ID:akkmzack,項目名稱:RIOS-8.5,代碼行數:24,代碼來源:rbt_service.py


注:本文中的Mgmt.bn_name_pattern_match方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。