Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
6bdac7ca
Commit
6bdac7ca
authored
Jun 10, 2010
by
Robert Ricci
Browse files
Merge branch 'ofmerge'
parents
dc0db4de
29c597cd
Changes
6
Hide whitespace changes
Inline
Side-by-side
db/Lan.pm.in
View file @
6bdac7ca
...
...
@@ -48,6 +48,93 @@ my %LanTables = ("lans" => ["lanid"],
"lan_member_attributes"
=>
[
"lanid"
,
"memberid"
,
"attrkey"
],
"ifaces"
=>
[
"lanid"
,
"ifaceid"
]);
#
#
Initialize
Openflow
attributes
in
lan_attributes
table
.
#
sub
InitOpenflowAttributes
($$$)
{
my
($
exptidx
,
$
vname
,
$
lanid
)
=
@
_
;
my
$
ofenabled
=
0
;
my
$
ofcontroller
=
""
;
my
$
safe_val
;
#
Add
openflow
arrtibutes
:
my
$
query_result
=
DBQueryWarn
(
"select ofenabled, ofcontroller from virt_lans "
.
"where exptidx='$exptidx' and vname='$vname'"
);
return
0
if
(
!$query_result);
($
ofenabled
,
$
ofcontroller
)
=
$
query_result
->
fetchrow_array
()
if
($
query_result
->
numrows
);
#
#
Firstly
check
if
the
attribuets
are
there
,
if
no
values
,
#
insert
them
.
This
is
because
the
vlan
may
be
created
#
by
Lookup
many
times
.
The
values
can
be
overwritten
by
#
the
later
creation
.
#
#
Process
'ofenabled'
:
$
query_result
=
DBQueryWarn
(
"select attrvalue from lan_attributes "
.
"where lanid='$lanid' and attrkey='ofenabled'"
);
return
0
if
(
!$query_result);
if
(
!$query_result->numrows)
{
$
safe_val
=
DBQuoteSpecial
($
ofenabled
);
$
query_result
=
DBQueryWarn
(
"replace into lan_attributes set "
.
" lanid='$lanid', "
.
" attrkey='ofenabled', "
.
" attrvalue=$safe_val, "
.
" attrtype='integer'"
);
return
0
if
(
!defined($query_result));
}
#
Process
'ofcontroller'
:
$
query_result
=
DBQueryWarn
(
"select attrvalue from lan_attributes "
.
"where lanid='$lanid' and attrkey='ofcontroller'"
);
return
0
if
(
!$query_result);
if
(
!$query_result->numrows)
{
$
safe_val
=
DBQuoteSpecial
($
ofcontroller
);
$
query_result
=
DBQueryWarn
(
"replace into lan_attributes set "
.
" lanid='$lanid', "
.
" attrkey='ofcontroller', "
.
" attrvalue=$safe_val, "
.
" attrtype='string'"
);
return
0
if
(
!defined($query_result));
}
#
Process
'oflistener'
:
$
query_result
=
DBQueryWarn
(
"select attrvalue from lan_attributes "
.
"where lanid='$lanid' and attrkey='oflistener'"
);
return
0
if
(
!$query_result);
if
(
!$query_result->numrows)
{
$
safe_val
=
DBQuoteSpecial
(
""
);
$
query_result
=
DBQueryWarn
(
"replace into lan_attributes set "
.
" lanid='$lanid', "
.
" attrkey='oflistener', "
.
" attrvalue=$safe_val, "
.
" attrtype='string'"
);
return
0
if
(
!defined($query_result));
}
return
1
;
}
#
#
Lookup
and
create
a
class
instance
to
return
.
#
...
...
@@ -107,6 +194,9 @@ sub Lookup($$;$$)
$
self
->{
"ATTRS"
}
=
{};
$
self
->{
"EXPT"
}
=
$
experiment
;
return
undef
if
(
!Lan->InitOpenflowAttributes($self->{'LAN'}->{'exptidx'}, $self->{'LAN'}->{'vname'}, $lanid));
#
#
Grab
the
attributes
for
this
lan
now
.
#
...
...
@@ -188,7 +278,7 @@ sub Create($$$;$$$)
#
Need
the
newly
minted
ID
my
$
lanid
=
$
query_result
->
insertid
();
my
$
lan
=
Lan
->
Lookup
($
lanid
);
print
"Created lan: $lan
\n
"
if
($
debug
&&
$
lan
);
return
$
lan
;
...
...
sql/database-create.sql
View file @
6bdac7ca
...
...
@@ -3831,6 +3831,8 @@ CREATE TABLE `virt_lans` (
`layer`
tinyint
(
4
)
NOT
NULL
default
'2'
,
`implemented_by_path`
tinytext
,
`implemented_by_link`
tinytext
,
`ofenabled`
tinyint
(
1
)
default
'0'
,
`ofcontroller`
tinytext
,
PRIMARY
KEY
(
`exptidx`
,
`vname`
,
`vnode`
,
`vport`
),
UNIQUE
KEY
`vport`
(
`pid`
,
`eid`
,
`vname`
,
`vnode`
,
`vport`
),
KEY
`pid`
(
`pid`
,
`eid`
,
`vname`
),
...
...
sql/database-fill.sql
View file @
6bdac7ca
...
...
@@ -684,6 +684,9 @@ REPLACE INTO table_regex VALUES ('virt_lans','fixed_iface','text','redirect','de
REPLACE
INTO
table_regex
VALUES
(
'virt_lans'
,
'modbase'
,
'int'
,
'redirect'
,
'default:boolean'
,
0
,
0
,
NULL
);
REPLACE
INTO
table_regex
VALUES
(
'virt_lans'
,
'compat'
,
'int'
,
'redirect'
,
'default:boolean'
,
0
,
0
,
NULL
);
REPLACE
INTO
table_regex
VALUES
(
'virt_lans'
,
'layer'
,
'int'
,
'redirect'
,
'default:tinyint'
,
1
,
2
,
NULL
);
REPLACE
INTO
table_regex
VALUES
(
'virt_lans'
,
'ofenabled'
,
'int'
,
'redirect'
,
'default:boolean'
,
0
,
0
,
NULL
);
REPLACE
INTO
table_regex
VALUES
(
'virt_lans'
,
'ofcontroller'
,
'text'
,
'redirect'
,
'default:tinytext'
,
0
,
0
,
NULL
);
REPLACE
INTO
table_regex
VALUES
(
'virt_node_desires'
,
'pid'
,
'text'
,
'redirect'
,
'projects:pid'
,
0
,
0
,
NULL
);
REPLACE
INTO
table_regex
VALUES
(
'virt_node_desires'
,
'eid'
,
'text'
,
'redirect'
,
'experiments:eid'
,
0
,
0
,
NULL
);
REPLACE
INTO
table_regex
VALUES
(
'virt_node_desires'
,
'vname'
,
'text'
,
'redirect'
,
'virt_nodes:vname'
,
0
,
0
,
NULL
);
...
...
sql/updates/4/211
0 → 100644
View file @
6bdac7ca
#
# Add virt_paths
#
use strict;
use libdb;
sub DoUpdate($$$)
{
if (!DBSlotExists("virt_lans", "ofenabled")) {
DBQueryFatal("ALTER TABLE virt_lans ADD ".
" `ofenabled` tinyint(1) default '0'");
}
if (!DBSlotExists("virt_lans", "ofcontroller")) {
DBQueryFatal("ALTER TABLE virt_lans ADD ".
" `ofcontroller` tinytext");
}
DBQueryFatal("REPLACE INTO table_regex VALUES" .
" ('virt_lans', 'ofenabled', 'int', 'redirect', ".
" 'default:boolean', 0,0,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES" .
" ('virt_lans', 'ofcontroller', 'int', 'redirect', ".
" 'default:tinytext', 0,0,NULL)");
}
1;
tbsetup/ns2ir/lanlink.tcl
View file @
6bdac7ca
...
...
@@ -273,6 +273,11 @@ LanLink instproc init {s nodes bw d type} {
$self instvar iscloud
$self set iscloud 0
$self instvar ofenabled
$self instvar ofcontroller
#$self instvar oflistener # this is not needed
$self set ofenabled 0
foreach node $nodes
{
set nodepair
[
list $node
[
$node
add_lanlink $self
]]
set bandwidth
(
$nodepair
)
$bw
...
...
@@ -296,6 +301,16 @@ LanLink instproc init {s nodes bw d type} {
}
}
#
# Enable Openflow on lan/link and set controller
#
LanLink instproc enable_openflow
{
ofcontrollerstr
}
{
$self instvar ofenabled
$self instvar ofcontroller
set ofenabled 1
set ofcontroller $ofcontrollerstr
}
#
# Set the mustdelay flag.
#
...
...
@@ -753,6 +768,8 @@ Link instproc updatedb {DB} {
$self instvar fixed_iface
$self instvar layer
$self instvar implemented_by
$self instvar ofenabled
$self instvar ofcontroller
$sim spitxml_data
"virt_lan_lans"
[
list
"vname"
]
[
list $self
]
...
...
@@ -882,6 +899,22 @@ Link instproc updatedb {DB} {
if
{
$implemented_by !=
{}
}
{
lappend values $implemented_by
}
# openflow
#
# table: virt_lans
# columns: ofenabled = 0/1
# ofcontroller =
""
/
"controller connection string"
#
lappend fields
"ofenabled"
lappend fields
"ofcontroller"
lappend values $ofenabled
if
{
$ofenabled
== 1
}
{
lappend values $ofcontroller
}
else
{
lappend values
""
}
$sim
spitxml_data
"virt_lans"
$fields
$values
}
...
...
@@ -919,6 +952,8 @@ Lan instproc updatedb {DB} {
$self instvar member_settings
$self instvar mustdelay
$self instvar fixed_iface
$self instvar ofenabled
$self instvar ofcontroller
if
{
$modelnet
_cores > 0 || $modelnet_edges > 0
}
{
perror
"Lans are not allowed when using modelnet; just duplex links."
...
...
@@ -1047,6 +1082,22 @@ Lan instproc updatedb {DB} {
lappend values $fixed_iface
(
$nodeport
)
}
# openflow
#
# table: virt_lans
# columns: ofenabled = 0/1
# ofcontroller =
""
/
"controller connection string"
#
lappend fields
"ofenabled"
lappend fields
"ofcontroller"
lappend values $ofenabled
if
{
$ofenabled
== 1
}
{
lappend values $ofcontroller
}
else
{
lappend values
""
}
$sim
spitxml_data
"virt_lans"
$fields
$values
foreach setting_key
[
array names member_settings
]
{
...
...
tbsetup/snmpit.in
View file @
6bdac7ca
...
...
@@ -1547,6 +1547,36 @@ sub doVlansFromTables($$@) {
}
delete
(
$trunkedPorts
{
$port
});
}
#
# Set openflow
#
# A much more right place for the openflow settings is CreateOneVlan,
# however, it is called by sync vlan function and others, which don't destroy
# the existing vlan_arrtibutes rows.
#
# TODO: Move this part to CreateOneVlan and Make sure the existed
# vlan_attributes rows are deleted
#
my
$ofenabled
;
$vlan
->
GetAttribute
("
ofenabled
",
\
$ofenabled
);
if
(
defined
(
$ofenabled
)
&&
$ofenabled
==
1
)
{
$errors
+=
doOpenflowEnable
(
$stacks
,
$vlanid
);
my
$ofcontroller
;
$vlan
->
GetAttribute
("
ofcontroller
",
\
$ofcontroller
);
if
(
defined
(
$ofcontroller
)
&&
$ofcontroller
ne
"")
{
$errors
+=
doSetOpenflowController
(
$stacks
,
$vlanid
,
$ofcontroller
);
}
$errors
+=
doEnableOpenflowListener
(
$stacks
,
$vlanid
);
# doEnableOpenflowListener updates the lan_arrtibutes table, so vlan
# should refresh itself. But here vlan will not be used any more, so
# maybe we can comment this refresh.
$vlan
->
Refresh
();
}
# Delete this vlan from the list that will be created below.
delete
(
$vlans
{"
$vlanid
"});
}
...
...
@@ -1586,6 +1616,35 @@ sub doVlansFromTables($$@) {
my
@ports
=
getVlanPorts
(
$vlanid
);
$errors
+=
CreateOneVlan
(
$stack
,
$vlanid
,
@ports
);
#
# Set openflow
#
# A much more right place for the openflow settings is CreateOneVlan,
# however, it is called by sync vlan function and others, which don't destroy
# the existing vlan_arrtibutes rows.
#
# TODO: Move this part to CreateOneVlan and Make sure the existed
# vlan_attributes rows are deleted
#
my
$ofenabled
;
$vlan
->
GetAttribute
("
ofenabled
",
\
$ofenabled
);
if
(
defined
(
$ofenabled
)
&&
$ofenabled
==
1
)
{
$errors
+=
doOpenflowEnable
(
$stacks
,
$vlanid
);
my
$ofcontroller
;
$vlan
->
GetAttribute
("
ofcontroller
",
\
$ofcontroller
);
if
(
defined
(
$ofcontroller
)
&&
$ofcontroller
ne
"")
{
$errors
+=
doSetOpenflowController
(
$stacks
,
$vlanid
,
$ofcontroller
);
}
$errors
+=
doEnableOpenflowListener
(
$stacks
,
$vlanid
);
# doEnableOpenflowListener updates the lan_arrtibutes table, so vlan
# should refresh itself. But here vlan will not be used any more, so
# maybe we can comment this refresh.
$vlan
->
Refresh
();
}
}
return
$errors
;
}
...
...
@@ -2688,6 +2747,13 @@ sub doEnableOpenflowListener($$) {
}
ofunlock
();
#
# update the vlan object with the new listener string
# other openflow functions may also need this, especially doOpenflowEnable/doOpenflowDisable
#
my
$vlaninst
=
VLan
->
Lookup
(
$vlan
);
$vlaninst
->
SetAttribute
('
oflistener
',
$listenerConnStr
,
'
string
');
return
$errors
;
}
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