Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
056dfa36
Commit
056dfa36
authored
Jul 09, 2008
by
Leigh B. Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add lookup by UUID() for protogeni. Might not really be needed, but
lets checkpoint.
parent
a3da0300
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
1 deletion
+46
-1
db/Interface.pm.in
db/Interface.pm.in
+46
-1
No files found.
db/Interface.pm.in
View file @
056dfa36
#
!/usr/bin/perl -wT
#
#
EMULAB
-
COPYRIGHT
#
Copyright
(
c
)
2005
,
200
6
University
of
Utah
and
the
Flux
Group
.
#
Copyright
(
c
)
2005
-
200
8
University
of
Utah
and
the
Flux
Group
.
#
All
rights
reserved
.
#
package
Interface
;
...
...
@@ -49,6 +49,9 @@ sub LookupAll($$)
{
my
($
class
,
$
nodeid
)
=
@
_
;
$
nodeid
=
$
nodeid
->
node_id
()
if
(
ref
($
nodeid
));
#
Look
in
cache
first
return
@{
$
node_interfaces
{$
nodeid
}
}
if
(
exists
($
node_interfaces
{$
nodeid
}));
...
...
@@ -105,6 +108,14 @@ sub IP($) { return field($_[0], 'IP'); }
sub
role
($)
{
return
field
($
_
[
0
],
'role'
);
}
sub
type
($)
{
return
field
($
_
[
0
],
'interface_type'
);
}
sub
mask
($)
{
return
field
($
_
[
0
],
'mask'
);
}
sub
uuid
($)
{
return
field
($
_
[
0
],
'uuid'
);
}
sub
IsExperimental
($)
{
my
($
self
)
=
@
_
;
return
$
self
->
role
()
eq
TBDB_IFACEROLE_EXPERIMENT
();
}
#
#
Lookup
by
card
,
port
...
...
@@ -113,6 +124,9 @@ sub Lookup($$$$)
{
my
($
class
,
$
nodeid
,
$
card
,
$
port
)
=
@
_
;
$
nodeid
=
$
nodeid
->
node_id
()
if
(
ref
($
nodeid
));
#
Look
in
cache
first
return
$
all_interfaces
{
"$nodeid:$card:$port"
}
if
(
exists
($
all_interfaces
{
"$nodeid:$card:$port"
}));
...
...
@@ -148,6 +162,9 @@ sub LookupByIface($$$)
{
my
($
class
,
$
nodeid
,
$
iface
)
=
@
_
;
$
nodeid
=
$
nodeid
->
node_id
()
if
(
ref
($
nodeid
));
#
Look
in
cache
first
return
$
all_interfaces
{
"$nodeid:$iface"
}
if
(
exists
($
all_interfaces
{
"$nodeid:$iface"
}));
...
...
@@ -176,6 +193,31 @@ sub LookupByIface($$$)
return
$
interface
;
}
#
#
Lookup
by
uuid
#
sub
LookupByUUID
($$)
{
my
($
class
,
$
uuid
)
=
@
_
;
if
(
! ($uuid =~ /^\w+\-\w+\-\w+\-\w+\-\w+$/)) {
return
undef
;
}
my
$
query_result
=
DBQueryWarn
(
"select node_id,iface from interfaces "
.
"where uuid='$uuid'"
);
return
undef
if
(
!$query_result);
return
undef
if
(
!$query_result->numrows);
my
($
node_id
,
$
iface
)
=
$
query_result
->
fetchrow_array
();
return
Interface
->
LookupByIface
($
node_id
,
$
iface
);
}
#
#
Lookup
the
control
interface
for
a
node
,
which
is
something
we
do
a
lot
.
#
...
...
@@ -183,6 +225,9 @@ sub LookupControl($)
{
my
($
class
,
$
nodeid
)
=
@
_
;
$
nodeid
=
$
nodeid
->
node_id
()
if
(
ref
($
nodeid
));
my
$
query_result
=
DBQueryWarn
(
"select * from interfaces "
.
"where node_id='$nodeid' and "
.
...
...
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