From 6f1ff7a92498c26f16b1b73cfc0cfe02ff88cd39 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 31 Oct 2013 01:42:57 -0700 Subject: [PATCH] fix defect #3813 imgexport 2.7 will not imgimport 2.8 --- xCAT-server/lib/xcat/plugins/imgport.pm | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/imgport.pm b/xCAT-server/lib/xcat/plugins/imgport.pm index e09706659..d9af3c7c9 100644 --- a/xCAT-server/lib/xcat/plugins/imgport.pm +++ b/xCAT-server/lib/xcat/plugins/imgport.pm @@ -1061,6 +1061,9 @@ sub extract_bundle { } #print Dumper($data); #push @{$datas}, $data; + + #support imgimport osimage exported by xCAT 2.7 + manifest_adapter($data); # now we need to import the files... unless(verify_manifest($data, $callback)){ @@ -1362,6 +1365,36 @@ sub set_config { return 1; } +#an adapter to convert the manifest structure from 2.7 to 2.8 +sub manifest_adapter { + my $data = shift; + + if(exists($data->{osimage}) or exists($data->{linuximage})){ + return 0; + } + + my %colstodel; + foreach my $col (@{$xCAT::Schema::tabspec{osimage}->{cols}}){ + if(defined($data->{$col})){ + $colstodel{$col}=1; + $data->{osimage}->{$col}=$data->{$col}; + } + } + + foreach my $col (@{$xCAT::Schema::tabspec{linuximage}->{cols}}){ + if(defined($data->{$col})){ + $colstodel{$col}=1; + $data->{linuximage}->{$col}=$data->{$col}; + } + } + + foreach my $col(keys %colstodel){ + delete($data->{$col}); + } + + return 1; +} + sub verify_manifest { my $data = shift;