Commit f24b8f17 authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Force10.FTOS.get_local_users

parent a525eb00
# -*- coding: utf-8 -*-
##----------------------------------------------------------------------
## Force10.FTOS.get_local_users
##----------------------------------------------------------------------
## Copyright (C) 2007-2009 The NOC Project
## See LICENSE for details
##----------------------------------------------------------------------
"""
"""
import noc.sa.script
from noc.sa.interfaces import IGetLocalUsers
import re,datetime
rx_line=re.compile(r"^username\s+(?P<username>\S+)(?:\s+.*privilege\s+(?P<privilege>\d+))?.*$")
class Script(noc.sa.script.Script):
name="Force10.FTOS.get_local_users"
implements=[IGetLocalUsers]
def execute(self):
data=self.cli("show running-config | no-more | grep ^username")
r=[]
for l in data.split("\n"):
match=rx_line.match(l.strip())
if match:
user_class="operator"
privilege=match.group("privilege")
if privilege:
if privilege=="15":
user_class="superuser"
else:
user_class=privilege
r.append({
"username" : match.group("username"),
"class" : user_class,
"is_active": True
})
return r
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment