Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
fwdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
97505e28
authored
Oct 12, 2014
by
Bach Dániel
Committed by
Your Name
Oct 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve ovs code
parent
2e48479d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
14 deletions
+9
-14
ovs.py
+9
-14
No files found.
ovs.py
View file @
97505e28
...
@@ -15,15 +15,16 @@ class Interface(object):
...
@@ -15,15 +15,16 @@ class Interface(object):
self
.
is_veth
=
data
.
get
(
'type'
,
'external'
)
==
'internal'
self
.
is_veth
=
data
.
get
(
'type'
,
'external'
)
==
'internal'
try
:
try
:
self
.
untagged
=
int
(
data
[
'tag'
])
except
(
TypeError
,
KeyError
):
self
.
untagged
=
None
try
:
self
.
tagged
=
frozenset
(
int
(
i
)
for
i
in
data
[
'trunks'
])
self
.
tagged
=
frozenset
(
int
(
i
)
for
i
in
data
[
'trunks'
])
except
(
TypeError
,
KeyError
):
except
(
TypeError
,
KeyError
):
self
.
tagged
=
frozenset
()
self
.
tagged
=
frozenset
()
untagged
=
data
.
get
(
'tag'
)
if
(
untagged
and
not
self
.
tagged
and
unicode
(
untagged
)
.
isdecimal
()):
self
.
untagged
=
int
(
untagged
)
else
:
self
.
untagged
=
None
if
with_show
:
if
with_show
:
data
[
'addresses'
]
=
self
.
show
()
data
[
'addresses'
]
=
self
.
show
()
try
:
try
:
...
@@ -41,9 +42,8 @@ class Interface(object):
...
@@ -41,9 +42,8 @@ class Interface(object):
return
self
.
__dict__
==
other
.
__dict__
return
self
.
__dict__
==
other
.
__dict__
def
__hash__
(
self
):
def
__hash__
(
self
):
r
=
reduce
(
lambda
acc
,
x
:
acc
^
hash
(
x
),
return
reduce
(
lambda
acc
,
x
:
acc
^
hash
(
x
),
(
self
.
name
,
self
.
is_veth
,
self
.
untagged
,
self
.
tagged
),
0
)
self
.
__dict__
.
values
(),
0
)
return
r
@property
@property
def
external_name
(
self
):
def
external_name
(
self
):
...
@@ -143,7 +143,7 @@ class Switch(object):
...
@@ -143,7 +143,7 @@ class Switch(object):
def
add_port
(
self
,
interface
):
def
add_port
(
self
,
interface
):
params
=
[
'add-port'
,
self
.
brname
,
interface
.
external_name
]
params
=
[
'add-port'
,
self
.
brname
,
interface
.
external_name
]
if
interface
.
untagged
and
not
interface
.
tagged
:
if
interface
.
untagged
:
params
.
append
(
'tag=
%
d'
%
int
(
interface
.
untagged
))
params
.
append
(
'tag=
%
d'
%
int
(
interface
.
untagged
))
if
interface
.
tagged
:
if
interface
.
tagged
:
params
.
append
(
'trunks=
%
s'
%
list
(
interface
.
tagged
))
params
.
append
(
'trunks=
%
s'
%
list
(
interface
.
tagged
))
...
@@ -171,11 +171,6 @@ class Switch(object):
...
@@ -171,11 +171,6 @@ class Switch(object):
new_interfaces
=
[
Interface
(
port
,
data
)
new_interfaces
=
[
Interface
(
port
,
data
)
for
port
,
data
in
new_ports
.
items
()]
for
port
,
data
in
new_ports
.
items
()]
add
=
[
i
for
i
in
new_interfaces
if
i
not
in
old_interfaces
]
delete
=
[
i
for
i
in
old_interfaces
if
i
not
in
new_interfaces
]
add
=
list
(
set
(
new_interfaces
)
.
difference
(
set
(
old_interfaces
)))
add
=
list
(
set
(
new_interfaces
)
.
difference
(
set
(
old_interfaces
)))
delete
=
list
(
set
(
old_interfaces
)
.
difference
(
set
(
new_interfaces
)))
delete
=
list
(
set
(
old_interfaces
)
.
difference
(
set
(
new_interfaces
)))
...
...
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