-Implement detach in clonevm -b for kvm
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7322 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
149e7eeae6
commit
80bcccc1eb
@ -1603,13 +1603,14 @@ sub clonevm {
|
||||
if ($target) { #we need to take a single vm and create a master out of it
|
||||
return promote_vm_to_master(target=>$target,force=>$force,detach=>$detach);
|
||||
} elsif ($base) {
|
||||
return clone_vm_from_master(base=>$base);
|
||||
return clone_vm_from_master(base=>$base,detach=>$detach);
|
||||
}
|
||||
}
|
||||
|
||||
sub clone_vm_from_master {
|
||||
my %args = @_;
|
||||
my $base=$args{base};
|
||||
my $detach=$args{detach};
|
||||
my $vmmastertab=xCAT::Table->new('vmmaster',-create=>0);
|
||||
my $kvmmastertab = xCAT::Table->new('kvm_masterdata',-create=>0);
|
||||
unless ($vmmastertab and $kvmmastertab) {
|
||||
@ -1653,8 +1654,19 @@ sub clone_vm_from_master {
|
||||
$filename =~ s/^.*$mastername/$node/;
|
||||
$filename =~ m!\.([^\.]*)\z!;
|
||||
my $format=$1;
|
||||
my $newbasexml="<volume><name>$filename</name><target><format type='$format'/></target><capacity>0</capacity><backingStore><path>$srcfilename</path><format type='$format'/></backingStore></volume>";
|
||||
my $newvol = $destinationpool->create_volume($newbasexml);
|
||||
my $newvol;
|
||||
if ($detach) {
|
||||
my $sourcevol = $hypconn->get_volume_by_path($srcfilename);
|
||||
my %sourceinfo = %{$sourcevol->get_info()};
|
||||
my $targxml = "<volume><name>$filename</name><target><format type='$format'/></target><capacity>".$sourceinfo{capacity}."</capacity></volume>";
|
||||
xCAT::SvrUtils::sendmsg("Cloning ".$sourcevol->get_name()." (currently is ".($sourceinfo{allocation}/1048576)." MB and has a capacity of ".($sourceinfo{capacity}/1048576)."MB)",$callback,$node);
|
||||
eval {
|
||||
$newvol =$destinationpool->clone_volume($targxml,$sourcevol);
|
||||
};
|
||||
} else {
|
||||
my $newbasexml="<volume><name>$filename</name><target><format type='$format'/></target><capacity>0</capacity><backingStore><path>$srcfilename</path><format type='$format'/></backingStore></volume>";
|
||||
$newvol = $destinationpool->create_volume($newbasexml);
|
||||
}
|
||||
my $newfilename=$newvol->get_path();
|
||||
$disk->findnodes("./source")->[0]->setAttribute("file"=>$newfilename);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user