本文整理汇总了Python中Mgmt.get_value方法的典型用法代码示例。如果您正苦于以下问题:Python Mgmt.get_value方法的具体用法?Python Mgmt.get_value怎么用?Python Mgmt.get_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mgmt
的用法示例。
在下文中一共展示了Mgmt.get_value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTACACSAccountingCfged
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def getTACACSAccountingCfged():
"""
@returns true if TACACS+ is configured as an accounting method
and that there is a valid TACACS+ server configured.
"""
acct = [Mgmt.get_value("/aaa/cmd_audit_method/1/name"),
Mgmt.get_value("/aaa/cmd_audit_method/2/name")]
return ('tacacs+' in acct)
示例2: getTACACSAuthorizationCfged
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def getTACACSAuthorizationCfged():
"""
@returns true if TACACS+ is configured as an authorization method
and that there is a valid TACACS+ server configured.
"""
author = [Mgmt.get_value("/aaa/cmd_author_method/1/name"),
Mgmt.get_value("/aaa/cmd_author_method/2/name")]
return ('tacacs+' in author)
示例3: __set_user_password
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [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
示例4: get_pfs_stats
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def get_pfs_stats(self, start_time, end_time, share_name):
"""
get_pfs_stats(auth, start_time, end_time, share_name) ->
[
[share size],
[bytes received],
[bytes sent]
]
Fetch the system's PFS statistics.
Parameters:
start_time (datetime) - start of the stats query period
end_time (datetime) - end of the stats query period
share_name (string) - share whose stats are desired or 'all' for the
sum of all shares
Exceptions:
get_pfs_statsFault - Datetime not in known format
get_pfs_statsFault - Unknown share name
"""
if share_name == 'all':
share_id = 0
else:
share_id = Mgmt.get_value('/rbt/rcu/share/%s/config/id'
% share_name)
if share_id is None:
raise ServiceError, 'Unknown share name: %s' % share_name
return self.get_stats_internal('pfs', 3,
start_time, end_time, share_id)
示例5: getNTPAuthEnabled
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def getNTPAuthEnabled():
"""
@returns true if any enabled NTP server has a valid key configured.
"""
auth_enabled = False
ntp_hosts = Mgmt.get_pattern('/ntp/server/address/*')
for host in ntp_hosts:
key = Mgmt.get_value('/ntp/server/address/%s/key' % host[2])
enable = Mgmt.get_value('/ntp/server/address/%s/enable' % host[2])
if (key != '0') and (enable == 'true'):
if Mgmt.get_value('/ntp/keys/%s' % key):
auth_enabled = True
break
return auth_enabled
示例6: is_memlock_enabled
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def is_memlock_enabled():
"""!
Queries mgmtd to determine if workstation memlock is turned on
"""
memlock_node = "/rbt/vsp/config/memlock/enable"
memlocked = Mgmt.get_value(memlock_node)
if not memlocked or memlocked == "":
Logging.log(Logging.LOG_ERR, "Cannot determine if memlock is enabled")
memlocked = "false"
return memlocked == "true"
示例7: get_node_value
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def get_node_value(node_name):
"""get value of a specified node
takes one argument:
node_name -> name of the node you want the value of
returns:
(value) -> value of the node_name
"""
import Mgmt
value = Mgmt.get_value(node_name)
return value
示例8: is_interceptor_in_cluster
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def is_interceptor_in_cluster():
RSI = '/rbt/sport/intercept'
names = Mgmt.get_children(RSI + '/config/neighbor/name')[0]
for name in names:
is_interceptor = Mgmt.get_value(RSI + '/neighbor/' + \
name + '/is_interceptor') == 'true'
if is_interceptor:
return True
return False;
示例9: __start_sport
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def __start_sport(self):
val = Mgmt.get_value('/pm/monitor/process/sport/state')
if val is None:
raise ServiceError, "Could not determine the service's state"
if val != 'running':
code, msg, bindings = Mgmt.action(
'/rbt/sport/main/action/restart_service')
if code != 0:
raise ServiceError, msg
示例10: get_rios_manage_esxi_ip
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def get_rios_manage_esxi_ip():
"""!
Queries mgmtd for the current RiOS manage ESXi IP address and returns it
Any callers of this function MUST have an open Mgmt GCL session
If failed, the function returns None.
"""
current_rios_mgmt_esxi_ip_node = "/rbt/vsp/state/network/rios_manage_esxi/ip"
current_rios_mgmt_esxi_ip = Mgmt.get_value(current_rios_mgmt_esxi_ip_node)
if not current_rios_mgmt_esxi_ip or current_rios_mgmt_esxi_ip == "0.0.0.0":
Logging.log(Logging.LOG_INFO, "Failed to get RiOS manage ESXi IP address")
current_rios_mgmt_esxi_ip = None
return current_rios_mgmt_esxi_ip
示例11: getAuthenticationCfged
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def getAuthenticationCfged(auth_method):
"""
@params auth_method: The authentication method to look for.
local, radius or tacacs.
@returns bool indicating whether the specified authentication
method is configured. In the case of TACACS+ and RADIUS,
true is only returned if the authentication method is
configured AND a valid RADIUS/TACACS+ server is configured.
"""
auth = [Mgmt.get_value("/aaa/auth_method/1/name"),
Mgmt.get_value("/aaa/auth_method/2/name"),
Mgmt.get_value("/aaa/auth_method/3/name")]
if auth_method == radius:
configured = ('radius' in auth)
elif auth_method == tacacs:
configured = ('tacacs+' in auth)
elif auth_method == local:
configured = ('local' in auth)
else:
configured = False
return configured
示例12: get_debug_option
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def get_debug_option():
"""!
Note: requires an existing Mgmt connection
Returns either "release", "debug", "stats"
"""
node_name = "/rbt/vsp/config/esxi/vmx/debug_option"
ret_option = "release"
option = Mgmt.get_value(node_name)
# If somehow the node does not exist, we'll assume the release binary
if option:
ret_option = option
return ret_option
示例13: get_rsp_vni_stats
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def get_rsp_vni_stats(self, start_time, end_time, opt_vni, side):
"""
get_rsp_vni_stats(auth, start_time, end_time, opt_vni, side) ->
[
[ingress bytes],
[egress bytes],
[ingress packets],
[egress packets]
]
Fetch the system's RSP VNI statistics.
Parameters:
start_time (datetime) - start of the stats query period
end_time (datetime) - end of the stats query period
opt_vni (string) - name of vni whose stats are desired
side (string) - side of the vni whose stats are desired
(lan, wan, or pkg)
Exceptions:
get_rsp_vni_statsFault - Datetime not in known format
get_rsp_vni_statsFault - Invalid optimization VNI side
get_rsp_vni_statsFault - Invalid optimization VNI
"""
offset_dict = {
'lan' : 0,
'wan' : 10,
'pkg' : 20,
}
try:
offset = offset_dict[side]
except KeyError:
raise ServiceError, '%s is not a valid optimization VNI side' % side
id = Mgmt.get_value('/rbt/rsp2/state/vni/opt/%s/stats_id' % opt_vni)
if id is None:
raise ServiceError, '%s is not a valid optimization vni' % opt_vni
vni_id = int(id) + offset
return self.get_stats_internal('rsp', 4, start_time, end_time, vni_id)
示例14: __stop_sport
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [as 别名]
def __stop_sport(self):
val = Mgmt.get_value('/pm/monitor/process/sport/state')
if val is None:
raise ServiceError, "Could not determine the service's state"
if val == 'running':
code, msg, bindings = Mgmt.action(
'/rbt/sport/status/action/unset_restart_needed')
if code != 0:
raise ServiceError, msg
code, msg, bindings = Mgmt.action(
'/pm/actions/terminate_process',
('process_name', 'string', 'sport'))
if code != 0:
raise ServiceError, msg
示例15: get_alarm_status
# 需要导入模块: import Mgmt [as 别名]
# 或者: from Mgmt import get_value [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'