Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
02305526
Commit
02305526
authored
May 15, 2006
by
Mike Hibler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'eplabconfig' (Emulatated PlanetLab Config) command
parent
78503406
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
+90
-0
tmcd/tmcd.c
tmcd/tmcd.c
+90
-0
No files found.
tmcd/tmcd.c
View file @
02305526
...
...
@@ -232,6 +232,7 @@ COMMAND_PROTOTYPE(dotmcctest);
COMMAND_PROTOTYPE
(
dofwinfo
);
COMMAND_PROTOTYPE
(
dohostinfo
);
COMMAND_PROTOTYPE
(
doemulabconfig
);
COMMAND_PROTOTYPE
(
doeplabconfig
);
COMMAND_PROTOTYPE
(
dolocalize
);
COMMAND_PROTOTYPE
(
dobooterrno
);
COMMAND_PROTOTYPE
(
dobootlog
);
...
...
@@ -323,6 +324,7 @@ struct command {
{
"firewallinfo"
,
FULLCONFIG_ALL
,
0
,
dofwinfo
},
{
"hostinfo"
,
FULLCONFIG_NONE
,
0
,
dohostinfo
},
{
"emulabconfig"
,
FULLCONFIG_NONE
,
F_ALLOCATED
,
doemulabconfig
},
{
"eplabconfig"
,
FULLCONFIG_NONE
,
F_ALLOCATED
,
doeplabconfig
},
{
"localization"
,
FULLCONFIG_PHYS
,
0
,
dolocalize
},
{
"booterrno"
,
FULLCONFIG_NONE
,
0
,
dobooterrno
},
{
"bootlog"
,
FULLCONFIG_NONE
,
0
,
dobootlog
},
...
...
@@ -5752,6 +5754,94 @@ COMMAND_PROTOTYPE(doemulabconfig)
return
0
;
}
/*
* Return the config for an emulated ("inner") planetlab
*/
COMMAND_PROTOTYPE
(
doeplabconfig
)
{
MYSQL_RES
*
res
;
MYSQL_ROW
row
;
char
buf
[
MYBUFSIZE
];
char
*
bufp
=
buf
,
*
ebufp
=
&
buf
[
sizeof
(
buf
)];
int
nrows
;
/*
* We only respond if we are a PLC node
*/
res
=
mydb_query
(
"select node_id from reserved "
"where pid='%s' and eid='%s' and plab_role='plc'"
,
1
,
reqp
->
pid
,
reqp
->
eid
);
if
(
!
res
)
{
error
(
"EPLABCONFIG: %s: DB Error getting plab_role
\n
"
,
reqp
->
nodeid
);
return
1
;
}
if
(
!
mysql_num_rows
(
res
))
{
mysql_free_result
(
res
);
return
0
;
}
row
=
mysql_fetch_row
(
res
);
if
(
!
row
[
0
]
||
strcmp
(
row
[
0
],
reqp
->
nodeid
)
!=
0
)
{
mysql_free_result
(
res
);
return
0
;
}
mysql_free_result
(
res
);
/*
* NAME=<name> ROLE=<role> IP=<IP> MAC=<MAC>
*/
res
=
mydb_query
(
"select r.vname,r.plab_role,i.IP,i.mac "
" from reserved as r join interfaces as i "
" where r.node_id=i.node_id and "
" i.role='ctrl' and r.pid='%s' and r.eid='%s'"
,
4
,
reqp
->
pid
,
reqp
->
eid
);
if
(
!
res
||
mysql_num_rows
(
res
)
==
0
)
{
error
(
"EMULABCONFIG: %s: DB Error getting plab_in_elab info
\n
"
,
reqp
->
nodeid
);
if
(
res
)
mysql_free_result
(
res
);
return
1
;
}
nrows
=
(
int
)
mysql_num_rows
(
res
);
/*
* Spit out the PLC node first just cuz
*/
bzero
(
buf
,
sizeof
(
buf
));
while
(
nrows
--
)
{
row
=
mysql_fetch_row
(
res
);
if
(
!
strcmp
(
row
[
1
],
"plc"
))
{
bufp
+=
OUTPUT
(
bufp
,
ebufp
-
bufp
,
"NAME=%s ROLE=%s IP=%s MAC=%s
\n
"
,
row
[
0
],
row
[
1
],
row
[
2
],
row
[
3
]);
break
;
}
}
/*
* Then all the nodes
*/
mysql_data_seek
(
res
,
0
);
nrows
=
(
int
)
mysql_num_rows
(
res
);
while
(
nrows
--
)
{
row
=
mysql_fetch_row
(
res
);
if
(
!
strcmp
(
row
[
1
],
"plc"
))
continue
;
bufp
+=
OUTPUT
(
bufp
,
ebufp
-
bufp
,
"NAME=%s ROLE=%s IP=%s MAC=%s
\n
"
,
row
[
0
],
row
[
1
],
row
[
2
],
row
[
3
]);
}
mysql_free_result
(
res
);
client_writeback
(
sock
,
buf
,
strlen
(
buf
),
tcp
);
return
0
;
}
/*
* Hack to test timeouts and other anomolous situations for tmcc
*/
...
...
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