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


Python Mgmt.set方法代码示例

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


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

示例1: set_top_talkers_interval

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def set_top_talkers_interval(self, interval):
        """
        set_top_talkers_interval(auth, interval) -> None

        Set the Top Talkers collection period.

        Parameters:
        interval (integer) - Interval in hours (must be 24 or 48)

        Exceptions:
        set_top_talkers_intervalFault - Interval must be 24 or 48 hours
        """
        if interval != 24 and interval != 48:
            raise ServiceError, 'Top Talkers interval must be 24 or 48 hours'

        # convert collection period to snapshot interval (24->300, 48->600)
        interval = interval / 24 * 300

        code, msg = Mgmt.set(
            ('/rbt/sport/netflow/config/top_talkers/snapshot_interval',
             'duration_sec', interval)
            )

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:27,代码来源:rbt_service.py

示例2: __set_banner

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def __set_banner(self, node_list, motd):
        """Helper function for setting motd/login banner"""
        nodes_to_set = [(x, 'string', motd) for x in node_list]
        code, msg = Mgmt.set(*nodes_to_set)

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:9,代码来源:fwk_service.py

示例3: __set_user_password

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def __set_user_password(self, username, password):
        # XXX/jshilkaitis: lame, should be an action on the mgmtd side

        # XXX/jshilkaitis: why doesn't the framework do validation?

        valid_password = common.lc_password_validate(password)

        if not valid_password:
            # XXX/jshilkaitis: hardcode the reason for now, since we know
            # length is the only criterion, but that may not be true in the
            # future.
            raise ServiceError, 'Password must contain at least 6 characters'

        use_sha512 = Mgmt.get_value('/rbt/support/config/sha_password/enable')

        if use_sha512:
            crypted_password = common.sha_encrypt_password(False, password)
        else:
            crypted_password = common.ltc_encrypt_password(password)

        password_node_name = '/auth/passwd/user/%s/password' % username

        code, msg = Mgmt.set((password_node_name, 'string', crypted_password))

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:28,代码来源:fwk_service.py

示例4: set_bool_node_value

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def set_bool_node_value(node_name,value):
        """Sets value of a bool node to true/false 

        takes two arguments:
            node_name -> name of the node to be set
            value     -> value the 'node_name' needs to be set to
        returns:
            (return code, error message)
            in case of an error it returns a non-zero error code 
            and error message otherwise it returns zero for success
            and an empty error message.
        """

	import Mgmt
        code, msg = Mgmt.set((node_name,'bool', value))
        return code,msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:18,代码来源:easyConfig.py

示例5: set_snmp_community_string

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def set_snmp_community_string(self, community_string):
        """
        set_snmp_community_string(auth, community_string) -> None

        Set the SNMP community string.

        Parameters:
        community_string (string) - SNMP community string to be set

        Exceptions: None
        """
        code, msg = Mgmt.set(
            ('/snmp/access/rocommunity', 'string', community_string))

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:18,代码来源:fwk_service.py

示例6: set_logging_level

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def set_logging_level(self, level):
        """
        set_logging_level(auth, level) -> None

        Set the minimum logging level.

        Parameters:
        level (string) - logging level to set

        Exceptions: None
        """
        level = level.lower()

        code, msg = Mgmt.set(('/logging/syslog/action/file/\/var\/log\/messages/selector/0/priority', 'string', level))

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:19,代码来源:fwk_service.py

示例7: set_node_value

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def set_node_value(node_name, node_type, node_value):
        """Sets value of node_name  of type node_type
           to node_value

        takes 3 arguments:
            node_name  -> name of the node to be set
            node_value -> value the 'node_name' needs to be set to
            node_type  -> type of 'node_name'
        returns:
            (return code, error message)
            in case of an error it returns a non-zero error code 
            and error message otherwise it returns zero for success
            and an empty error message.
        """

	import Mgmt
        code, msg = Mgmt.set((node_name, node_type, node_value))
        return code,msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:20,代码来源:easyConfig.py

示例8: enable_netflow

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def enable_netflow(self, enable):
        """
        enable_netflow(auth, enable) -> None

        Turn NetFlow support on or off.

        Parameters:
        enable (bool) - true to enable NetFlow, false to disable NetFlow

        Exceptions:
        enable_netflow - Top Talkers must be disabled before NetFlow can be disabled
        """
        code, msg = Mgmt.set(
            ('/rbt/sport/netflow/config/enable', 'bool', enable)
            )

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:20,代码来源:rbt_service.py

示例9: enable_top_talkers

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def enable_top_talkers(self, enable):
        """
        enable_top_talkers(auth, enable) -> None

        Turn Top Talkers on or off.

        Parameters:
        enable (bool) - true to enable Top Talkers, false to disable Top Talkers

        Exceptions:
        enable_top_talkersFault - NetFlow must be enabled before Top Talkers can be enabled
        """
        code, msg = Mgmt.set(
            ('/rbt/sport/netflow/config/top_talkers/enable', 'bool', enable)
            )

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:20,代码来源:rbt_service.py

示例10: __set_alarm_threshold

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def __set_alarm_threshold(self, alarm, rising_or_falling,
                              error_or_clear, val):
        alarm = alarm.lower()
        rising_or_falling = rising_or_falling.lower()
        error_or_clear = error_or_clear.lower()

        self.__assert_alarm_exists(alarm)

        node_name = '/stats/config/alarm/%s/%s/%s_threshold' % \
                    (alarm, rising_or_falling, error_or_clear)

        # should never fail because we ensure that the alarm exists
        node_type = Mgmt.query(node_name)[0][1]

        code, msg = Mgmt.set((node_name, node_type, val))

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:20,代码来源:fwk_service.py

示例11: set_snmp_password

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def set_snmp_password(self, username, password, auth_protocol):
        """
        set_snmp_password(auth, username, password, auth_protocol) -> None

        Configure a SNMP user.

        Parameters:
        username - username of user to configure
        password - user's new password
        auth_protocol - protocol used to encrypt the password

        Exceptions:
        set_snmp_passwordFault - password must contain at least 8 characters
        set_snmp_passwordFault - XXX/BUG 47861/48172 for bad auth_protocol value
        """
        # XXX/jshilkaitis: lame, should be an action on the mgmtd side

        # 8 is USM_LENGTH_P_MIN from net-snmp
        if len(password) < 8:
            raise ServiceError, "password must contain at least 8 characters"

        auth_protocol = auth_protocol.upper()

        code, msg, bindings = Mgmt.action(
            '/snmp/usm/actions/generate_auth_key',
            ('password', 'string', password),
            ('hash_function', 'string', auth_protocol)
            )

        if code != 0:
            raise ServiceError, msg

        auth_key = bindings['auth_key']

        snmp_user_pfx = '/snmp/usm/users/%s' % username
        code, msg = Mgmt.set(
            (snmp_user_pfx, 'string', username),
            (snmp_user_pfx + '/auth_key', 'string', auth_key),
            (snmp_user_pfx + '/hash_function', 'string', auth_protocol)
            )

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:45,代码来源:fwk_service.py

示例12: enable_rsp

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def enable_rsp(self, enable):
        """
        enable_rsp(auth, enable) -> None

        Turn RSP on and off.

        Parameters:
        enable (bool) - true to turn on RSP, false to turn off RSP

        Exceptions:
        enable_rspFault - RSP not supported
        enable_rspFault - RSP not installed
        enable_rspFault - installed RSP release is not supported
        enable_rspFault - RSP not fully shut down
        """
        code, msg = Mgmt.set(
            ('/rbt/rsp2/config/enable', 'bool', enable)
            )

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:23,代码来源:rbt_service.py

示例13: enable_alarm

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def enable_alarm(self, alarm, enable):
        """
        enable_alarm(auth, alarm, enable) -> None

        Turn an alarm on or off.

        Parameters:
        alarm (string) - name of the alarm to change
        enable (bool) - true to enable alarm, false to disable alarm

        Exceptions:
        enable_alarmFault - Alarm does not exist
        """
        alarm = alarm.lower()

        self.__assert_alarm_exists(alarm)

        code, msg = Mgmt.set(
            ('/stats/config/alarm/%s/enable' % alarm, 'bool', enable))

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:24,代码来源:fwk_service.py

示例14: set_snmp_password_preencrypted

# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import set [as 别名]
    def set_snmp_password_preencrypted(self, username, digest, auth_protocol):
        """
        set_snmp_password_preencrypted(auth, username, digest, auth_protocol) -> None

        Configure a SNMP user using a pre-encrypted password.

        Parameters:
        username - username of user to configure
        digest - user's pre-encrypted password
        auth_protocol - protocol used to encrypt the password

        Exceptions:
        set_snmp_passwordFault - XXX/BUG 47861/48172 for bad auth_protocol value
        """
        snmp_user_pfx = '/snmp/usm/users/%s' % username
        code, msg = Mgmt.set(
            (snmp_user_pfx, 'string', username),
            (snmp_user_pfx + '/auth_key', 'string', digest),
            (snmp_user_pfx + '/hash_function', 'string', auth_protocol)
            )

        if code != 0:
            raise ServiceError, msg
开发者ID:akkmzack,项目名称:RIOS-8.5,代码行数:25,代码来源:fwk_service.py


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