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
536252ee
Commit
536252ee
authored
Apr 12, 2012
by
Jonathon Duerig
Committed by
Jonathon Duerig
Apr 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checkpoint: Various bug fixes. Added a better way to assign IP addresses.
parent
49ff182d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
8 deletions
+50
-8
backend/add_rack_nodes.in
backend/add_rack_nodes.in
+44
-2
backend/newnode_research.in
backend/newnode_research.in
+6
-6
No files found.
backend/add_rack_nodes.in
View file @
536252ee
...
...
@@ -8,7 +8,10 @@ if (scalar(@ARGV) != 1) {
my
$type
=
$ARGV
[
0
];
our
$TB
=
"
/usr/testbed
";
our
$IP_START
=
"
155.98.34.11
";
use
lib
"
/usr/testbed/lib
";
use
libdb
;
use
IPC::
Open2
;
sub
sequentialSystem
($$)
...
...
@@ -55,12 +58,51 @@ foreach my $node (@nodeListText) {
}
}
my
@octets
=
split
(
/\./
,
$IP_START
);
if
(
scalar
(
@octets
)
!=
4
)
{
print
STDERR
"
Start IP Address is not a well-formed IPv4 address.
\n
";
print
STDERR
join
("
--
",
@octets
)
.
"
\n
";
exit
(
1
);
}
my
%used_ips
=
();
my
$dbresult
=
DBQueryFatal
("
select IP from interfaces where role='ctrl'
");
while
(
my
(
$ip
)
=
$dbresult
->
fetchrow_array
)
{
$used_ips
{
$ip
}
=
1
;
}
my
%node2ip
=
();
foreach
my
$node
(
@nodeList
)
{
my
$done
=
0
;
while
(
!
$done
)
{
my
$current
=
join
("
.
",
@octets
);
if
(
!
exists
(
$used_ips
{
$current
}))
{
$node2ip
{
$node
}
=
$current
;
$done
=
1
;
}
$octets
[
3
]
+=
1
;
if
(
$octets
[
3
]
>
254
)
{
$octets
[
3
]
=
1
;
$octets
[
2
]
+=
1
;
}
if
(
$octets
[
2
]
>
254
)
{
$octets
[
2
]
=
1
;
$octets
[
1
]
+=
1
;
}
if
(
$octets
[
1
]
>
254
)
{
$octets
[
1
]
=
1
;
$octets
[
0
]
+=
1
;
}
}
}
# Set Node Types
foreach
my
$node
(
@nodeList
)
{
newAction
("
table
"
=>
"
node
",
"
id
"
=>
$node
,
"
command
"
=>
"
update
",
"
type
"
=>
$type
);
"
type
"
=>
$type
,
"
IP
"
=>
$node2ip
{
$node
});
}
# Associate Interfaces with Switch Ports
...
...
@@ -68,5 +110,5 @@ system("perl newnode_research.in");
# Commit Changes
foreach
my
$node
(
@nodeList
)
{
newAction
("
table
"
=>
"
node
",
"
id
"
=>
$node
,
"
command
"
=>
"
commit
");
#
newAction("table" => "node", "id" => $node, "command" => "commit");
}
backend/newnode_research.in
View file @
536252ee
...
...
@@ -194,17 +194,17 @@ foreach my $key (keys(%mac_list)) {
my
$current_card
=
0
;
foreach
my
$iface_key
(
sort
(
keys
(
%iface_sort
)))
{
$mac_list
{
$iface_sort
{
$iface_key
}}
->
{'
card
'}
=
$current_card
;
#
my $id = $mac_list{$iface_sort{$iface_key}}->{'id'};
#
my $card = $mac_list{$iface_sort{$iface_key}}->{'iface'};
#
print STDERR "iface $id:$card\n";
my
$id
=
$mac_list
{
$iface_sort
{
$iface_key
}}
->
{'
id
'};
my
$card
=
$mac_list
{
$iface_sort
{
$iface_key
}}
->
{'
iface
'};
print
STDERR
"
iface
$id
:
$card
\n
";
++
$current_card
;
}
foreach
my
$card_key
(
sort
(
keys
(
%card_sort
)))
{
$mac_list
{
$card_sort
{
$card_key
}}
->
{'
card
'}
=
$current_card
;
#
my $id = $mac_list{$card_sort{$card_key}}->{'id'};
#
my $card = $mac_list{$card_sort{$card_key}}->{'card'};
#
print STDERR "card $id:$card\n";
my
$id
=
$mac_list
{
$card_sort
{
$card_key
}}
->
{'
id
'};
my
$card
=
$mac_list
{
$card_sort
{
$card_key
}}
->
{'
card
'};
print
STDERR
"
card
$id
:
$card
\n
";
++
$current_card
;
}
...
...
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