Commit 4de02e84 authored by Robert Ricci's avatar Robert Ricci
Browse files

Move sshdport from the nodes table to the port_reservation table.

I haven't removed the sshdport column from the nodes table yet, in
case I need to go back quickly.
parent e3fd12fa
...@@ -2465,8 +2465,9 @@ foreach my $vnode (keys(%v2pmap)) { ...@@ -2465,8 +2465,9 @@ foreach my $vnode (keys(%v2pmap)) {
printdb("sshdport: $vnode $pnode $vvnode $sshdport\n"); printdb("sshdport: $vnode $pnode $vvnode $sshdport\n");
DBQueryFatal("update nodes set sshdport=$sshdport ". DBQueryFatal("replace into port_registration set pid='$pid', " .
"where node_id='$vvnode'"); "eid='$eid', exptidx='$experiment_idx', service='sshd', ".
"node_id='$vvnode', port=$sshdport");
} }
} }
......
...@@ -856,13 +856,19 @@ class Plab: ...@@ -856,13 +856,19 @@ class Plab:
" (node_id, type, phys_nodeid, role, priority," " (node_id, type, phys_nodeid, role, priority,"
" op_mode, def_boot_osid, update_accounts," " op_mode, def_boot_osid, update_accounts,"
" allocstate, allocstate_timestamp," " allocstate, allocstate_timestamp,"
" eventstate, state_timestamp, sshdport)" " eventstate, state_timestamp)"
" values (%s, %s, %s, %s, %s," " values (%s, %s, %s, %s, %s,"
" %s, %s, %s, %s, now(), %s, now(), %s)", " %s, %s, %s, %s, now(), %s, now(), %s)",
(vnodeid, vnodetype, nodeid, 'virtnode', vprio, (vnodeid, vnodetype, nodeid, 'virtnode', vprio,
'PCVM', defosid, 1, 'PCVM', defosid, 1,
'FREE_CLEAN', 'FREE_CLEAN',
'SHUTDOWN', sshdport)) 'SHUTDOWN'))
DBQueryFatal("insert into port_registration"
" (pid, eid, exptidx, service, node_id, port)"
" values (%s, %s, %s, %s, %s, %s)",
(MONITOR_PID, MONITOR_EID, mon_exptidx,
'sshd', vnodeid, sshdport ))
DBQueryFatal("insert into node_hostkeys" DBQueryFatal("insert into node_hostkeys"
" (node_id)" " (node_id)"
......
...@@ -162,12 +162,14 @@ print "\n"; ...@@ -162,12 +162,14 @@ print "\n";
if ($state eq EXPTSTATE_ACTIVE) { if ($state eq EXPTSTATE_ACTIVE) {
my $query_result = my $query_result =
DBQueryFatal("select r.vname,r.node_id,n.type,n.phys_nodeid,o.osname,". DBQueryFatal("select r.vname,r.node_id,n.type,n.phys_nodeid,o.osname,".
" n.sshdport,n.jailflag,nt.isremotenode,". " p.port,n.jailflag,nt.isremotenode,".
" nt.isplabdslice ". " nt.isplabdslice ".
" from reserved as r ". " from reserved as r ".
"left join nodes as n on r.node_id=n.node_id ". "left join nodes as n on r.node_id=n.node_id ".
"left join os_info as o on o.osid=n.def_boot_osid ". "left join os_info as o on o.osid=n.def_boot_osid ".
"left join node_types as nt on nt.type=n.type ". "left join node_types as nt on nt.type=n.type ".
"left join port_registration as p on ".
" (n.node_id = p.node_id and p.service='sshd')".
"where r.pid='$pid' and r.eid='$eid' order by vname"); "where r.pid='$pid' and r.eid='$eid' order by vname");
while (($v,$p,$t,$m,$o,$s,$j,$r,$d) = $query_result->fetchrow_array()) { while (($v,$p,$t,$m,$o,$s,$j,$r,$d) = $query_result->fetchrow_array()) {
......
...@@ -4915,8 +4915,10 @@ COMMAND_PROTOTYPE(dojailconfig) ...@@ -4915,8 +4915,10 @@ COMMAND_PROTOTYPE(dojailconfig)
/* /*
* Now need the sshdport and jailip for this node. * Now need the sshdport and jailip for this node.
*/ */
res = mydb_query("select sshdport,jailip from nodes " res = mydb_query("select port, jailip from nodes as n "
"where node_id='%s'", "left join port_registration as p on "
" (n.node_id = p.node_id and p.service='sshd') "
"where node_id='%s'",
2, reqp->nodeid); 2, reqp->nodeid);
if (!res) { if (!res) {
...@@ -5031,7 +5033,7 @@ COMMAND_PROTOTYPE(doplabconfig) ...@@ -5031,7 +5033,7 @@ COMMAND_PROTOTYPE(doplabconfig)
/* /*
* Now need the sshdport for this node. * Now need the sshdport for this node.
*/ */
res = mydb_query("select n.sshdport, ps.admin, i.IP " res = mydb_query("select p.port, ps.admin, i.IP "
" from reserved as r " " from reserved as r "
" left join nodes as n " " left join nodes as n "
" on n.node_id=r.node_id " " on n.node_id=r.node_id "
...@@ -5039,6 +5041,8 @@ COMMAND_PROTOTYPE(doplabconfig) ...@@ -5039,6 +5041,8 @@ COMMAND_PROTOTYPE(doplabconfig)
" on n.phys_nodeid=i.node_id " " on n.phys_nodeid=i.node_id "
" left join plab_slices as ps " " left join plab_slices as ps "
" on r.pid=ps.pid and r.eid=ps.eid " " on r.pid=ps.pid and r.eid=ps.eid "
" left join port_registration as p on "
" (n.node_id = p.node_id and p.service='sshd') "
" where i.role='ctrl' and r.node_id='%s'", " where i.role='ctrl' and r.node_id='%s'",
3, reqp->nodeid); 3, reqp->nodeid);
...@@ -7196,7 +7200,7 @@ COMMAND_PROTOTYPE(domotelog) ...@@ -7196,7 +7200,7 @@ COMMAND_PROTOTYPE(domotelog)
} }
/* /*
* Return motelog info for this node. * Lookup or record the port number that is being used for a particular service
*/ */
COMMAND_PROTOTYPE(doportregister) COMMAND_PROTOTYPE(doportregister)
{ {
......
...@@ -403,7 +403,7 @@ class Node ...@@ -403,7 +403,7 @@ class Node
"last_ext_act) as last_act, ". "last_ext_act) as last_act, ".
" t.isvirtnode,t.isremotenode,t.isplabdslice, ". " t.isvirtnode,t.isremotenode,t.isplabdslice, ".
" r.erole as rsrvrole, pi.IP as phys_IP, loc.*, ". " r.erole as rsrvrole, pi.IP as phys_IP, loc.*, ".
" util.* ". " util.*, p.port ".
" from nodes as n ". " from nodes as n ".
"left join reserved as r on n.node_id=r.node_id ". "left join reserved as r on n.node_id=r.node_id ".
"left join node_activity as na on ". "left join node_activity as na on ".
...@@ -419,6 +419,8 @@ class Node ...@@ -419,6 +419,8 @@ class Node
" loc.node_id=n.node_id ". " loc.node_id=n.node_id ".
"left join node_utilization as util on ". "left join node_utilization as util on ".
" util.node_id=n.node_id ". " util.node_id=n.node_id ".
"left join port_registration as p on ".
" (n.node_id = p.node_id and p.service='sshd') ".
"where n.node_id='$node_id'"); "where n.node_id='$node_id'");
if (mysql_num_rows($query_result) == 0) { if (mysql_num_rows($query_result) == 0) {
...@@ -454,7 +456,7 @@ class Node ...@@ -454,7 +456,7 @@ class Node
$ipport_low = $row["ipport_low"]; $ipport_low = $row["ipport_low"];
$ipport_next = $row["ipport_next"]; $ipport_next = $row["ipport_next"];
$ipport_high = $row["ipport_high"]; $ipport_high = $row["ipport_high"];
$sshdport = $row["sshdport"]; $sshdport = $row["port"];
$last_act = $row["last_act"]; $last_act = $row["last_act"];
$last_tty_act = $row["last_tty_act"]; $last_tty_act = $row["last_tty_act"];
$last_net_act = $row["last_net_act"]; $last_net_act = $row["last_net_act"];
......
...@@ -43,12 +43,14 @@ else { ...@@ -43,12 +43,14 @@ else {
} }
$query_result = $query_result =
DBQueryFatal("select n.jailflag,n.jailip,n.sshdport, ". DBQueryFatal("select n.jailflag,n.jailip,p.port, ".
" r.vname,r.pid,r.eid, ". " r.vname,r.pid,r.eid, ".
" t.isvirtnode,t.isremotenode,t.isplabdslice ". " t.isvirtnode,t.isremotenode,t.isplabdslice ".
" from nodes as n ". " from nodes as n ".
"left join reserved as r on n.node_id=r.node_id ". "left join reserved as r on n.node_id=r.node_id ".
"left join node_types as t on t.type=n.type ". "left join node_types as t on t.type=n.type ".
"left join port_registration as p on ".
" (n.node_id = p.node_id and p.service='sshd') ".
"where n.node_id='$node_id'"); "where n.node_id='$node_id'");
if (mysql_num_rows($query_result) == 0) { if (mysql_num_rows($query_result) == 0) {
...@@ -58,7 +60,7 @@ if (mysql_num_rows($query_result) == 0) { ...@@ -58,7 +60,7 @@ if (mysql_num_rows($query_result) == 0) {
$row = mysql_fetch_array($query_result); $row = mysql_fetch_array($query_result);
$jailflag = $row["jailflag"]; $jailflag = $row["jailflag"];
$jailip = $row["jailip"]; $jailip = $row["jailip"];
$sshdport = $row["sshdport"]; $sshdport = $row["port"];
$vname = $row["vname"]; $vname = $row["vname"];
$pid = $row["pid"]; $pid = $row["pid"];
$eid = $row["eid"]; $eid = $row["eid"];
......
...@@ -28,7 +28,7 @@ $reqargs = RequiredPageArguments("node", PAGEARG_NODE); ...@@ -28,7 +28,7 @@ $reqargs = RequiredPageArguments("node", PAGEARG_NODE);
$node_id = $node->node_id(); $node_id = $node->node_id();
$query_result = $query_result =
DBQueryFatal("select n.jailflag,n.jailip,n.sshdport, ". DBQueryFatal("select n.jailflag,n.jailip,p.port, ".
" r.vname,r.pid,r.eid, ". " r.vname,r.pid,r.eid, ".
" t.isvirtnode,t.isremotenode,t.isplabdslice, ". " t.isvirtnode,t.isremotenode,t.isplabdslice, ".
" t.issubnode,t.class ". " t.issubnode,t.class ".
...@@ -36,6 +36,8 @@ $query_result = ...@@ -36,6 +36,8 @@ $query_result =
"left join reserved as r on n.node_id=r.node_id ". "left join reserved as r on n.node_id=r.node_id ".
"left join node_types as t on t.type=n.type ". "left join node_types as t on t.type=n.type ".
"left join os_info as oi on n.def_boot_osid=oi.osid ". "left join os_info as oi on n.def_boot_osid=oi.osid ".
"left join port_registration as p on ".
" (n.node_id = p.node_id and p.service='sshd')".
"where n.node_id='$node_id'"); "where n.node_id='$node_id'");
if (mysql_num_rows($query_result) == 0) { if (mysql_num_rows($query_result) == 0) {
...@@ -45,7 +47,7 @@ if (mysql_num_rows($query_result) == 0) { ...@@ -45,7 +47,7 @@ if (mysql_num_rows($query_result) == 0) {
$row = mysql_fetch_array($query_result); $row = mysql_fetch_array($query_result);
$jailflag = $row["jailflag"]; $jailflag = $row["jailflag"];
$jailip = $row["jailip"]; $jailip = $row["jailip"];
$sshdport = $row["sshdport"]; $sshdport = $row["port"];
$vname = $row["vname"]; $vname = $row["vname"];
$pid = $row["pid"]; $pid = $row["pid"];
$eid = $row["eid"]; $eid = $row["eid"];
......
...@@ -3555,12 +3555,14 @@ class node: ...@@ -3555,12 +3555,14 @@ class node:
output=("You do not have permission to access: " output=("You do not have permission to access: "
+ argdict["node"])) + argdict["node"]))
res = DBQueryFatal("select n.node_id,n.jailflag,n.sshdport, " res = DBQueryFatal("select n.node_id,n.jailflag,n.port, "
" r.vname,r.pid,r.eid, " " r.vname,r.pid,r.eid, "
" t.isvirtnode,t.isremotenode,t.isplabdslice " " t.isvirtnode,t.isremotenode,t.isplabdslice "
" from nodes as n " " from nodes as n "
"left join reserved as r on n.node_id=r.node_id " "left join reserved as r on n.node_id=r.node_id "
"left join node_types as t on t.type=n.type " "left join node_types as t on t.type=n.type "
"left join port_registration as p on "
" (n.node_id = p.node_id and p.service='sshd')"
"where " + clause, "where " + clause,
clause_args) clause_args)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment