Skip to content
GitLab
Menu
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
0182a592
Commit
0182a592
authored
Aug 28, 2017
by
Leigh B Stoller
Browse files
Move update script to a pre-install, and change library loads to run
from the build tree.
parent
1efef41b
Changes
2
Hide whitespace changes
Inline
Side-by-side
db/updatewires.in
View file @
0182a592
...
...
@@ -38,8 +38,29 @@ my $impotent = 0;
# Configure variables
my
$TB
=
"
@prefix
@
";
#
# We want to force this to run from the build tree to avoid any
# problems with the install tree not being in a consistent state.
#
BEGIN
{
if
(
-
e
"
../Makeconf
")
{
my
$srcdir
=
"
@top_srcdir
@
";
my
$objdir
=
`
/bin/pwd
`;
chomp
(
$objdir
);
# Prior to first install or running from object dir.
unshift
(
@INC
,
"
$objdir
/../db
");
if
(
$srcdir
=~
/^\//
)
{
unshift
(
@INC
,
"
$srcdir
/install
");
unshift
(
@INC
,
"
$srcdir
/tbsetup
");
}
else
{
unshift
(
@INC
,
"
$objdir
/
$srcdir
/install
");
unshift
(
@INC
,
"
$objdir
/
$srcdir
/tbsetup
");
}
unshift
(
@INC
,
"
$objdir
/../tbsetup
");
}
}
# Load the Testbed support stuff.
use
lib
"
@prefix
@/lib
";
use
emdb
;
use
Interface
;
use
Node
;
...
...
@@ -91,9 +112,9 @@ while (my ($node_id1,$card1,$port1) = $query_result->fetchrow_array()) {
}
$query_result
=
DBQueryFatal
("
select node_id,card,port from interfaces
");
while
(
my
(
$node_id
,
$card
,
$port
)
=
$query_result
->
fetchrow_array
())
{
my
$interface
=
Interface
->
Lookup
(
$node_id
,
$
card
,
$port
);
DBQueryFatal
("
select node_id,
iface,
card,port from interfaces
");
while
(
my
(
$node_id
,
$
iface
,
$
card
,
$port
)
=
$query_result
->
fetchrow_array
())
{
my
$interface
=
Interface
->
Lookup
ByIface
(
$node_id
,
$
iface
);
if
(
!
defined
(
$interface
))
{
print
STDERR
"
No interface object for
$node_id
:
$card
:
$port
\n
";
next
;
...
...
@@ -101,8 +122,22 @@ while (my ($node_id,$card,$port) = $query_result->fetchrow_array()) {
$ifaces
{"
$node_id
:
$card
:
$port
"}
=
$interface
;
my
$node
=
Node
->
Lookup
(
$node_id
);
if
(
!
exists
(
$wires
{"
$node_id
:
$card
:
$port
"})
&&
if
(
$impotent
&&
!
exists
(
$wires
{"
$node_id
:
$card
:
$port
"})
&&
$node
->
role
()
eq
"
testnode
")
{
#
# See if its the other side of existing wire.
#
my
$tmp
=
Interface::
Wire
->
LookupAnyByIface
(
$node_id
,
$iface
);
if
(
defined
(
$tmp
))
{
my
$n
=
$tmp
->
node_id1
();
my
$c
=
$tmp
->
card1
();
my
$p
=
$tmp
->
port1
();
if
(
exists
(
$wires
{"
$n
:
$c
:
$p
"}))
{
next
;
}
}
print
STDERR
"
No wires row for
$interface
\n
";
}
}
...
...
@@ -115,8 +150,8 @@ my %ifacenames = ();
foreach
my
$interface
(
values
(
%ifaces
))
{
my
$node_id
=
$interface
->
node_id
();
my
$card
=
$interface
->
card
();
my
$port
=
$interface
->
port
();
my
$card
=
$interface
->
card
_saved
();
my
$port
=
$interface
->
port
_saved
();
my
$iface
=
$interface
->
iface
();
if
(
!
defined
(
$interface
->
iface
())
||
$interface
->
iface
()
eq
"")
{
...
...
@@ -174,13 +209,13 @@ foreach my $interface (values(%ifaces)) {
#
if
(
$impotent
)
{
print
STDERR
"
Would create missing interface_state for
"
.
"
$nodeid
:
$iface
\n
";
"
$node
_
id
:
$iface
\n
";
}
else
{
print
STDERR
"
Creating missing interface_state for
"
.
"
$nodeid
:
$iface
\n
";
"
$node
_
id
:
$iface
\n
";
DBQueryFatal
("
insert into interface_state set
"
.
"
node_id='
$nodeid
',card='
$card
',
"
.
"
node_id='
$node
_
id
',card='
$card
',
"
.
"
port='
$port
',iface='
$iface
'
");
}
}
...
...
install/updates/5/49
View file @
0182a592
#
# Change to wires table; add iface1 and iface2. We now require both sides
# of wires to have associated interfaces. Run updatewires script to get
# everything set up.
# everything set up. This runs as a pre install, and from the object tree,
# so that the subsequent sql updates in script 51 can safely rename the
# columns that the updatewires script uses.
#
use strict;
use libinstall;
...
...
@@ -15,15 +17,15 @@ sub InstallUpdate($$)
# If something should run in the pre-install phase.
#
if ($phase eq "pre") {
Phase "updatewires", "Updating wires and interfaces", sub {
ExecQuietFatal("cd $TOP_OBJDIR/db; perl updatewires");
};
}
#
# If something should run in the post-install phase.
#
if ($phase eq "post") {
Phase "updatewires", "Updating wires and interfaces", sub {
ExecQuietFatal("$TBROOT/sbin/updatewires");
};
}
return 0;
}
...
...
Write
Preview
Supports
Markdown
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