Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
fwdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b316aa59
authored
Oct 14, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename Interface.is_veth
parent
97505e28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
ovs.py
+7
-7
No files found.
ovs.py
View file @
b316aa59
...
@@ -12,7 +12,7 @@ class Interface(object):
...
@@ -12,7 +12,7 @@ class Interface(object):
# {"interfaces": ["eth1"], "tag": 2, "trunks": [1, 2, 3],
# {"interfaces": ["eth1"], "tag": 2, "trunks": [1, 2, 3],
# "type": "internal", "addresses": ["193.006.003.130/24", "None"]}
# "type": "internal", "addresses": ["193.006.003.130/24", "None"]}
self
.
name
=
name
self
.
name
=
name
self
.
is_
veth
=
data
.
get
(
'type'
,
'external'
)
==
'internal'
self
.
is_
internal
=
data
.
get
(
'type'
,
'external'
)
==
'internal'
try
:
try
:
self
.
tagged
=
frozenset
(
int
(
i
)
for
i
in
data
[
'trunks'
])
self
.
tagged
=
frozenset
(
int
(
i
)
for
i
in
data
[
'trunks'
])
...
@@ -35,7 +35,7 @@ class Interface(object):
...
@@ -35,7 +35,7 @@ class Interface(object):
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<Interface:
%
s veth=
%
s| untagged=
%
s tagged=
%
s addrs=
%
s>'
%
(
return
'<Interface:
%
s veth=
%
s| untagged=
%
s tagged=
%
s addrs=
%
s>'
%
(
self
.
name
,
self
.
is_
veth
,
self
.
untagged
,
self
.
tagged
,
self
.
name
,
self
.
is_
internal
,
self
.
untagged
,
self
.
tagged
,
self
.
addresses
)
self
.
addresses
)
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
...
@@ -47,7 +47,7 @@ class Interface(object):
...
@@ -47,7 +47,7 @@ class Interface(object):
@property
@property
def
external_name
(
self
):
def
external_name
(
self
):
if
self
.
is_
veth
:
if
self
.
is_
internal
:
return
'
%
s-EXT'
%
self
.
name
return
'
%
s-EXT'
%
self
.
name
else
:
else
:
return
self
.
name
return
self
.
name
...
@@ -77,7 +77,7 @@ class Interface(object):
...
@@ -77,7 +77,7 @@ class Interface(object):
self
.
_run
(
'add'
,
str
(
address
),
'dev'
,
self
.
name
)
self
.
_run
(
'add'
,
str
(
address
),
'dev'
,
self
.
name
)
def
up
(
self
):
def
up
(
self
):
if
self
.
is_
veth
:
if
self
.
is_
internal
:
ns_exec
((
'ip'
,
'link'
,
'set'
,
'up'
,
self
.
name
))
ns_exec
((
'ip'
,
'link'
,
'set'
,
'up'
,
self
.
name
))
sudo
((
'ip'
,
'link'
,
'set'
,
'up'
,
self
.
external_name
))
sudo
((
'ip'
,
'link'
,
'set'
,
'up'
,
self
.
external_name
))
...
@@ -150,7 +150,7 @@ class Switch(object):
...
@@ -150,7 +150,7 @@ class Switch(object):
# move interface into namespace
# move interface into namespace
try
:
try
:
if
interface
.
is_
veth
:
if
interface
.
is_
internal
:
sudo
((
'ip'
,
'link'
,
'add'
,
interface
.
external_name
,
sudo
((
'ip'
,
'link'
,
'add'
,
interface
.
external_name
,
'type'
,
'veth'
,
'peer'
,
'name'
,
interface
.
name
))
'type'
,
'veth'
,
'peer'
,
'name'
,
interface
.
name
))
self
.
_setns
(
interface
.
name
)
self
.
_setns
(
interface
.
name
)
...
@@ -160,7 +160,7 @@ class Switch(object):
...
@@ -160,7 +160,7 @@ class Switch(object):
def
delete_port
(
self
,
interface
):
def
delete_port
(
self
,
interface
):
self
.
_run
(
'del-port'
,
self
.
brname
,
interface
.
external_name
)
self
.
_run
(
'del-port'
,
self
.
brname
,
interface
.
external_name
)
if
interface
.
is_
veth
:
if
interface
.
is_
internal
:
try
:
try
:
sudo
((
'ip'
,
'link'
,
'del'
,
interface
.
external_name
))
sudo
((
'ip'
,
'link'
,
'del'
,
interface
.
external_name
))
except
CalledProcessError
:
except
CalledProcessError
:
...
@@ -185,7 +185,7 @@ class Switch(object):
...
@@ -185,7 +185,7 @@ class Switch(object):
for
interface
in
new_interfaces
:
for
interface
in
new_interfaces
:
try
:
try
:
if
interface
.
is_
veth
or
not
HA
:
if
interface
.
is_
internal
or
not
HA
:
interface
.
up
()
interface
.
up
()
except
CalledProcessError
as
e
:
except
CalledProcessError
as
e
:
logger
.
warning
(
e
)
logger
.
warning
(
e
)
...
...
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