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
b5f078eb
Commit
b5f078eb
authored
Jun 23, 2014
by
Leigh B Stoller
Browse files
Add lookup by vlan id
parent
0e1679a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
protogeni/scripts/maptoslice.in
View file @
b5f078eb
...
...
@@ -36,7 +36,7 @@ use Getopt::Std;
#
sub
usage
()
{
print
"
Usage: maptoslice <urn> | <ip> | <mac>
\n
";
print
"
Usage: maptoslice <urn> | <ip> | <mac>
| vlan
\n
";
exit
(
1
);
}
sub
fatal
($);
...
...
@@ -89,7 +89,11 @@ my ($type, $id);
# Connect to the proper DB.
DBSetDefault
(
DBConnect
(
GENICM_DBNAME
()));
if
(
$token
=~
/^[\w]+$/
)
{
if
(
$token
=~
/^\d+$/
&&
$token
<=
4096
)
{
$type
=
"
vlan
";
$id
=
$token
;
}
elsif
(
$token
=~
/^[\w]+$/
)
{
$type
=
"
mac
";
$id
=
$token
;
}
...
...
@@ -147,6 +151,27 @@ elsif ($type eq "ip" || $type eq "mac") {
GeniDB::
DBQueryFatal
("
select slice_uuid from geni_slivers
"
.
"
where resource_id='
$nodeid
'
");
}
elsif
(
$type
eq
"
vlan
")
{
$query_result
=
emdb::
DBQueryFatal
("
(select s.slice_uuid
"
.
"
from reserved_vlantags as v
"
.
"
left join experiment_stats as s on
"
.
"
s.exptidx=v.exptidx
"
.
"
where v.tag='
$id
' and s.slice_uuid is not null)
"
.
"
union
"
.
"
(select s.slice_uuid
"
.
"
from reserved_vlantags as v
"
.
"
left join lan_member_attributes as a on
"
.
"
a.lanid=v.lanid and
"
.
"
a.attrkey='portlan_exptidx'
"
.
"
left join experiments as e on
"
.
"
e.idx=a.attrvalue
"
.
"
left join experiment_stats as s on
"
.
"
s.exptidx=a.attrvalue
"
.
"
where v.tag='
$id
' and
"
.
"
e.idx is not null and
"
.
"
s.slice_uuid is not null)
");
}
else
{
fatal
("
Do not know how to map token to a slice!
");
}
...
...
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