Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Vladimir
noc
Commits
b033878b
Commit
b033878b
authored
Sep 01, 2009
by
Dmitry Volodin
Browse files
Cisco.IOS.get_dhcp_binding
parent
746fbc88
Changes
1
Hide whitespace changes
Inline
Side-by-side
sa/profiles/Cisco/IOS/get_dhcp_binding.py
0 → 100644
View file @
b033878b
# -*- coding: utf-8 -*-
##----------------------------------------------------------------------
## Cisco.IOS.get_dhcp_binding
##----------------------------------------------------------------------
## Copyright (C) 2007-2009 The NOC Project
## See LICENSE for details
##----------------------------------------------------------------------
"""
"""
import
noc.sa.script
from
noc.sa.interfaces
import
IGetDHCPBinding
import
re
,
datetime
rx_line
=
re
.
compile
(
r
"^(?P<ip>\d+\.\d+\.\d+\.\d+)\s+(?P<mac>\S+)\s+(?P<expire>.+?)\s+(?P<type>Automatic|Manual)$"
,
re
.
IGNORECASE
)
class
Script
(
noc
.
sa
.
script
.
Script
):
name
=
"Cisco.IOS.get_dhcp_binding"
implements
=
[
IGetDHCPBinding
]
def
execute
(
self
):
self
.
cli
(
"terminal length 0"
)
vlans
=
self
.
cli
(
"show ip dhcp binding"
)
r
=
[]
for
l
in
vlans
.
split
(
"
\n
"
):
match
=
rx_line
.
match
(
l
.
strip
().
lower
())
if
match
:
d
=
match
.
group
(
"expire"
)
if
d
==
"infinite"
:
expire
=
d
else
:
expire
=
datetime
.
datetime
.
strptime
(
d
,
"%b %d %Y %I:%M %p"
)
r
.
append
({
"ip"
:
match
.
group
(
"ip"
),
"mac"
:
match
.
group
(
"mac"
),
"expiration"
:
expire
,
"type"
:
match
.
group
(
"type"
)[
0
].
upper
(),
})
return
r
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment