Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-stable
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
emulab
emulab-stable
Commits
3f7b2fd6
Commit
3f7b2fd6
authored
Sep 04, 2012
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few more changes to allow cloning a VM container.
Add global flag.
parent
340dd57d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
utils/clone_image.in
utils/clone_image.in
+24
-7
No files found.
utils/clone_image.in
View file @
3f7b2fd6
...
@@ -31,16 +31,18 @@ sub usage()
...
@@ -31,16 +31,18 @@ sub usage()
"
Options:
\n
"
.
"
Options:
\n
"
.
"
-d Turn on debug mode
\n
"
.
"
-d Turn on debug mode
\n
"
.
"
-e Create a whole disk image
\n
"
.
"
-e Create a whole disk image
\n
"
.
"
-g 0,1 Override base image global setting
\n
"
.
"
-s Create descriptor but do not snapshot
\n
"
.
"
-s Create descriptor but do not snapshot
\n
"
.
"
-n Impotent mode
\n
");
"
-n Impotent mode
\n
");
exit
(
-
1
);
exit
(
-
1
);
}
}
my
$optlist
=
"
dens
";
my
$optlist
=
"
dens
g:
";
my
$debug
=
0
;
my
$debug
=
0
;
my
$wholedisk
=
0
;
my
$wholedisk
=
0
;
my
$impotent
=
0
;
my
$impotent
=
0
;
my
$nosnapshot
=
0
;
my
$nosnapshot
=
0
;
my
$isvirtnode
=
0
;
my
$isvirtnode
=
0
;
my
$global
;
#
#
# Configure variables
# Configure variables
...
@@ -96,6 +98,9 @@ if (defined($options{"n"})) {
...
@@ -96,6 +98,9 @@ if (defined($options{"n"})) {
if
(
defined
(
$options
{"
s
"}))
{
if
(
defined
(
$options
{"
s
"}))
{
$nosnapshot
=
1
;
$nosnapshot
=
1
;
}
}
if
(
defined
(
$options
{"
g
"}))
{
$global
=
$options
{"
g
"};
}
usage
()
usage
()
if
(
@ARGV
!=
2
);
if
(
@ARGV
!=
2
);
...
@@ -209,12 +214,16 @@ my %xmlfields =
...
@@ -209,12 +214,16 @@ my %xmlfields =
"
path
"
=>
"
$PROJROOT
/
$pid
/images/
${imagename}
.ndz
",
"
path
"
=>
"
$PROJROOT
/
$pid
/images/
${imagename}
.ndz
",
"
osfeatures
",
=>
$base_osinfo
->
osfeatures
(),
"
osfeatures
",
=>
$base_osinfo
->
osfeatures
(),
"
op_mode
",
=>
$base_osinfo
->
op_mode
(),
"
op_mode
",
=>
$base_osinfo
->
op_mode
(),
"
wholedisk
",
=>
$wholedisk
,
"
global
"
=>
(
defined
(
$global
)
?
(
$global
?
1
:
0
)
:
$base_osinfo
->
shared
()),
"
wholedisk
",
=>
(
$isvirtnode
?
1
:
$wholedisk
),
"
reboot_waittime
"
=>
$base_osinfo
->
reboot_waittime
(),
);
);
if
(
defined
(
$base_image
))
{
if
(
defined
(
$base_image
))
{
$xmlfields
{"
mbr_version
"}
=
$base_image
->
mbr_version
();
$xmlfields
{"
mbr_version
"}
=
$base_image
->
mbr_version
();
$xmlfields
{"
reboot_waittime
"}
=
$base_image
->
reboot_waittime
();
$xmlfields
{"
loadpart
"}
=
(
$isvirtnode
?
1
:
$base_image
->
loadpart
());
$xmlfields
{"
loadpart
"}
=
$base_image
->
loadpart
();
$xmlfields
{"
global
"}
=
(
defined
(
$global
)
?
(
$global
?
1
:
0
)
:
$base_image
->
global
());
}
}
elsif
(
$isvirtnode
)
{
elsif
(
$isvirtnode
)
{
$xmlfields
{"
reboot_waittime
"}
=
240
;
$xmlfields
{"
reboot_waittime
"}
=
240
;
...
@@ -227,8 +236,12 @@ else {
...
@@ -227,8 +236,12 @@ else {
}
}
# This needs more thought.
# This needs more thought.
if
(
$isvirtnode
)
{
if
(
$isvirtnode
)
{
my
$parentosinfo
=
OSinfo
->
Lookup
(
$base_osinfo
->
def_parentosid
());
if
(
!
defined
(
$parentosinfo
))
{
fatal
("
Could not lookup object for parent osid of
$base_osinfo
");
}
$xmlfields
{"
def_parentosid
"}
=
$xmlfields
{"
def_parentosid
"}
=
$
base_osinfo
->
pid
()
.
"
,
"
.
$base_
osinfo
->
osname
();
$
parentosinfo
->
pid
()
.
"
,
"
.
$parent
osinfo
->
osname
();
}
}
#
#
...
@@ -264,7 +277,11 @@ foreach my $key (keys(%xmlfields)) {
...
@@ -264,7 +277,11 @@ foreach my $key (keys(%xmlfields)) {
print
$fh
"
</image>
\n
";
print
$fh
"
</image>
\n
";
close
(
$fh
);
close
(
$fh
);
my
$output
=
emutil::
ExecQuiet
("
$NEWIMAGEEZ
-v
$filename
");
if
(
$debug
)
{
system
("
/bin/cat
$filename
");
}
my
$output
=
emutil::
ExecQuiet
("
$NEWIMAGEEZ
-s -v
$filename
");
if
(
$?
)
{
if
(
$?
)
{
print
STDERR
$output
;
print
STDERR
$output
;
fatal
("
Failed to verify image descriptor from
$filename
");
fatal
("
Failed to verify image descriptor from
$filename
");
...
@@ -274,7 +291,7 @@ if ($impotent) {
...
@@ -274,7 +291,7 @@ if ($impotent) {
system
("
cat
$filename
");
system
("
cat
$filename
");
exit
(
0
);
exit
(
0
);
}
}
$output
=
emutil::
ExecQuiet
("
$NEWIMAGEEZ
$filename
");
$output
=
emutil::
ExecQuiet
("
$NEWIMAGEEZ
-s
$filename
");
if
(
$?
)
{
if
(
$?
)
{
print
STDERR
$output
;
print
STDERR
$output
;
my
$foo
=
`
cat
$filename
`;
my
$foo
=
`
cat
$filename
`;
...
...
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