Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
R
router_services
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nova
router_services
Commits
97090cd9
Commit
97090cd9
authored
Nov 28, 2013
by
Sigmund Augdal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added script to remove entries for deleted VMs from mac/address binding table in etcd
parent
8fb38e5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
clean_stale.py
clean_stale.py
+38
-0
setup.py
setup.py
+2
-0
No files found.
clean_stale.py
0 → 100644
View file @
97090cd9
import
etcd
from
nova_router
import
neighbors
from
scvmm_client
import
odata
import
logging
def
main
():
key
=
"/home/sigmunda/Devel/nova/etcd_client.key"
cert
=
"/home/sigmunda/Devel/nova/etcd_client.crt"
cacert
=
"/home/sigmunda/Devel/nova/etcd_ca.crt"
vmm_baseurl
=
'https://srv-spf-99.bs.unsi.no:8090/SC2012R2/VMM/Microsoft.Management.Odata.svc'
username
=
'bs-unsi\spfsvc'
password
=
'Laste8il'
logging
.
basicConfig
(
level
=
logging
.
INFO
)
etcd_client
=
etcd
.
Etcd
(
"158.38.213.2"
,
ssl_key
=
key
,
ssl_cert
=
cert
,
verify
=
cacert
)
vmm_client
=
odata
.
VMMClient
(
vmm_baseurl
,
username
,
password
)
nics
=
set
()
for
nic
in
vmm_client
.
query_collection
(
"VirtualNetworkAdapters"
):
mac
=
nic
.
properties
[
"MACAddress"
]
if
mac
is
not
None
:
nics
.
add
(
mac
.
lower
())
for
entry
in
etcd_client
.
list
(
"/nova/iaas/instances"
):
if
not
entry
.
dir
:
next
mac
=
entry
.
key
.
split
(
"/"
)[
-
1
].
lower
()
if
not
mac
in
nics
:
for
addrtype
in
(
neighbors
.
V4
,
neighbors
.
V6_LL
,
neighbors
.
V6_PUB
):
ipaddr
=
neighbors
.
get_ipaddress_from_mac
(
etcd_client
,
mac
,
addrtype
)
if
ipaddr
is
not
None
:
logging
.
info
(
"Removing address {} from mac {}"
.
format
(
ipaddr
,
mac
))
neighbors
.
remove_pair
(
etcd_client
,
mac
,
ipaddr
,
addrtype
)
else
:
logging
.
debug
(
"found owner for mac {}"
.
format
(
mac
))
if
__name__
==
'__main__'
:
main
()
setup.py
View file @
97090cd9
...
...
@@ -10,6 +10,7 @@ requires = [
'daemonize'
,
'pytest'
,
'mock'
,
'scvmm-client-py'
,
'pyroute2'
,
]
...
...
@@ -26,5 +27,6 @@ setup(name='router-services',
tests_require
=
requires
,
dependency_links
=
[
'git+https://github.com/sigmunau/etcd-py.git#egg=etcd-py-0.0.6'
,
'git+https://scm.uninett.no/nova/scvmm_client_py.git#egg=scvmm-client-py-0.1'
,
],
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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