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
848d3e5c
Commit
848d3e5c
authored
Nov 02, 2000
by
Mac Newbold
Browse files
Now returns error code if any non-fatal errors occured.
parent
ab488519
Changes
2
Hide whitespace changes
Inline
Side-by-side
db/nalloc
View file @
848d3e5c
...
...
@@ -5,6 +5,7 @@ my $dbh = Mysql->connect("localhost","tbdb","script","none");
if
(
$#ARGV
<
1
)
{
die
("
Usage: nalloc <pid> <eid> <node> <node> <...>
\n
");}
my
$error
=
0
;
my
$pid
=
shift
;
my
$eid
=
shift
;
my
@node_names
=
@ARGV
;
...
...
@@ -28,19 +29,25 @@ foreach my $n (@node_names) {
$sth
=
$dbh
->
query
(
$cmd
);
if
(
$sth
->
numrows
>
0
)
{
print
"
You have already reserved node '
$n
'.
\n
";
$error
++
;
}
else
{
print
"
Someone else has already reserved node '
$n
'.
\n
";
$error
++
;
}
next
;
}
else
{
$sth
=
$dbh
->
query
("
select * from nodes where node_id='
$n
'
");
if
(
$sth
->
numrows
<
1
)
{
print
"
Node '
$n
' does not exist.
\n
";
$error
++
;
next
;
}
}
print
"
Reserving node '
$n
'...
";
$cmd
=
"
insert into reserved (node_id,pid,eid) values ('
$n
','
$pid
','
$eid
')
";
$sth
=
$dbh
->
query
(
$cmd
)
&&
print
"
Succeeded.
\n
"
||
print
"
Failed Command:
\n
$cmd
\n
Error string is:
"
.
$dbh
->
errstr
.
"
\n
";
||
(
print
"
Failed Command:
\n
$cmd
\n
Error string is:
"
.
$dbh
->
errstr
.
"
\n
"
&&
$error
++
);
}
exit
(
$error
);
db/nfree
View file @
848d3e5c
...
...
@@ -9,6 +9,7 @@ if ($#ARGV < 1) {
"
nfree releases only the listed nodes.
\n
");
}
my
$error
=
0
;
my
$pid
=
shift
;
my
$eid
=
shift
;
my
@node_names
=
@ARGV
;
...
...
@@ -40,11 +41,14 @@ foreach my $n (@node_names) {
"
and eid='
$eid
'
");
if
(
$sth
->
numrows
==
0
)
{
print
"
Node '
$n
' is not reserved by your experiment.
\n
";
$error
++
;
next
;
}
print
"
Releasing node '
$n
'...
";
$cmd
=
"
delete from reserved where node_id='
$n
' and eid='
$eid
'
";
$sth
=
$dbh
->
query
(
$cmd
)
&&
print
"
Succeeded.
\n
"
||
print
"
Failed Command:
\n
$cmd
\n
Error string is:
"
.
$dbh
->
errstr
.
"
\n
";
||
(
print
"
Failed Command:
\n
$cmd
\n
Error string is:
"
.
$dbh
->
errstr
.
"
\n
"
&&
$error
++
);
}
exit
(
$error
);
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