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
a3dd5200
Commit
a3dd5200
authored
Sep 10, 2008
by
Leigh B. Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checkpoint
parent
b7da57f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
19 deletions
+53
-19
protogeni/lib/addnode.pl.in
protogeni/lib/addnode.pl.in
+53
-19
No files found.
protogeni/lib/addnode.pl.in
View file @
a3dd5200
...
...
@@ -13,11 +13,19 @@ use GeniUser;
use
GeniCredential
;
use
GeniComponent
;
use
English
;
# Hate to import all this crap; need a utility library.
use
libdb
qw(TBGetUniqueIndex)
;
use
Node
;
use
Interface
;
use
Experiment
;
use
Data::
Dumper
;
if
(
@ARGV
!=
2
)
{
die
("
Bad arguments
\n
");
}
my
$remote_node_id
=
$ARGV
[
0
];
my
$local_node_id
=
$ARGV
[
1
];
my
$this_user
=
User
->
LookupByUnixId
(
$UID
);
if
(
!
defined
(
$this_user
))
{
print
STDERR
"
You (
$UID
) do not exist!
\n
";
...
...
@@ -75,37 +83,63 @@ my $response =
$context
,
"
Resolve
",
{
"
credential
"
=>
$credential
->
asString
(),
"
hrn
"
=>
"
pc167
"
,
"
hrn
"
=>
$remote_node_id
,
"
type
"
=>
"
Node
",
});
if
(
!
defined
(
$response
)
||
$response
->
code
()
!=
GENIRESPONSE_SUCCESS
)
{
die
("
Could not look up resource
\n
");
}
my
$value
=
$response
->
value
();
#print Dumper($response->value());
print
Dumper
(
$response
->
value
());
my
$node
;
if
(
$value
->
{'
role
'}
eq
"
testnode
")
{
my
$nodeargs
=
{
"
uuid
"
=>
$value
->
{'
uuid
'},
"
type
"
=>
"
pcfedphys
",
"
role
"
=>
"
testnode
",
"
vtype
"
=>
"
pcfed
"
};
$node
=
Node
->
Create
(
$local_node_id
,
$experiment
,
$nodeargs
);
if
(
!
defined
(
$node
))
{
die
("
Could not create new node.
\n
");
}
$node
->
SetStatus
('
up
');
$component
->
NewResource
(
$node
->
uuid
());
}
elsif
(
$value
->
{'
role
'}
eq
"
testswitch
")
{
my
$nodeargs
=
{
"
uuid
"
=>
$value
->
{'
uuid
'},
"
type
"
=>
"
cisco6509
",
"
role
"
=>
"
testswitch
"
};
my
$nodeargs
=
{
"
uuid
"
=>
$value
->
{'
uuid
'},
"
type
"
=>
"
pcfedphys
",
"
role
"
=>
"
testnode
",
"
vtype
"
=>
"
pcfed
"
};
my
$switch_id
=
Interface
->
LookUpWideAreaSwitch
(
$value
->
{'
hrn
'});
my
$node
=
Node
->
Create
("
pcfedphys2
",
$experiment
,
$nodeargs
);
if
(
!
defined
(
$node
))
{
die
("
Could not create new node.
\n
");
$node
=
Node
->
Create
(
$switch_id
,
undef
,
$nodeargs
);
if
(
!
defined
(
$node
))
{
die
("
Could not create new node.
\n
");
}
}
else
{
die
("
unknown node role
\n
");
}
$node
->
SetStatus
('
up
');
foreach
my
$ref
(
@
{
$value
->
{'
interfaces
'}
})
{
my
$ifaceargs
=
{
"
uuid
"
=>
$ref
->
{'
uuid
'},
"
type
"
=>
$ref
->
{'
type
'},
"
role
"
=>
$ref
->
{'
role
'},
"
card
"
=>
$ref
->
{'
card
'},
"
port
"
=>
$ref
->
{'
port
'},
"
MAC
"
=>
$ref
->
{'
MAC
'},
"
IP
"
=>
$ref
->
{'
IP
'},
"
mask
"
=>
$ref
->
{'
mask
'},
my
$ifaceargs
=
{
"
uuid
"
=>
$ref
->
{'
uuid
'},
"
type
"
=>
$ref
->
{'
type
'},
"
role
"
=>
$ref
->
{'
role
'},
"
card
"
=>
$ref
->
{'
card
'},
"
port
"
=>
$ref
->
{'
port
'},
"
MAC
"
=>
$ref
->
{'
MAC
'},
"
IP
"
=>
$ref
->
{'
IP
'},
"
mask
"
=>
$ref
->
{'
mask
'},
};
if
(
exists
(
$ref
->
{'
switch_id
'}))
{
my
$switch_id
=
Interface
->
LookUpWideAreaSwitch
(
$ref
->
{'
switch_id
'});
$ifaceargs
->
{"
wire_type
"}
=
$ref
->
{'
wire_type
'};
$ifaceargs
->
{"
switch_id
"}
=
$switch_id
;
$ifaceargs
->
{"
switch_card
"}
=
$ref
->
{'
switch_card
'};
$ifaceargs
->
{"
switch_port
"}
=
$ref
->
{'
switch_port
'};
}
print
Dumper
(
$ifaceargs
);
Interface
->
Create
(
$node
,
$ifaceargs
);
}
$component
->
NewResource
(
$node
->
uuid
());
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