1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

feature #523: Fix wrong handling of PATH/SOURCE attributes in image templates

This commit is contained in:
Ruben S. Montero 2011-04-04 00:01:50 +02:00
parent 20d29f14ac
commit e31bf066f5
2 changed files with 26 additions and 28 deletions

View File

@ -400,7 +400,6 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \
src/oca/ruby/OpenNebula/VirtualNetworkPool.rb \
src/oca/ruby/OpenNebula/Image.rb \
src/oca/ruby/OpenNebula/ImagePool.rb \
src/oca/ruby/OpenNebula/ImageRepository.rb \
src/oca/ruby/OpenNebula/Cluster.rb \
src/oca/ruby/OpenNebula/ClusterPool.rb \
src/oca/ruby/OpenNebula/XMLUtils.rb"

View File

@ -354,37 +354,36 @@ int ImageManager::register_image(int iid)
img->get_template_attribute("PATH",path);
switch (img->get_type())
if ( path.empty() == true ) //NO PATH -> USE SOURCE OR MKFS FOR DATABLOCK
{
case Image::DATABLOCK:
if (path.empty() == true)
{
string fs;
string size;
string fs;
string size;
img->get_template_attribute("SIZE", size);
img->get_template_attribute("FSTYPE", fs);
img->get_template_attribute("SIZE", size);
img->get_template_attribute("FSTYPE", fs);
imd->mkfs(img->get_oid(), img->get_source(), fs, size);
oss << "Creating disk at " << img->get_source()
<< " of " << size << "Mb with format " << fs;
}
else
{
imd->cp(img->get_oid(),path, img->get_source());
if ( img->get_type() == Image::DATABLOCK &&
!size.empty() && !fs.empty() )
{
imd->mkfs(img->get_oid(), img->get_source(), fs, size);
oss << "Creating disk at " << img->get_source() << " of "
<< size << "Mb with format " << fs;
}
else
{
img->set_state(Image::READY);
ipool->update(img);
oss << "Copying file " << path << " to " << img->get_source();
}
break;
case Image::CDROM:
case Image::OS:
imd->cp(img->get_oid(),path, img->get_source());
oss << "Copying file " << path << " to " << img->get_source();
break;
default:
break;
oss << "Using source " << img->get_source()
<< " from template for image " << img->get_name();
}
}
else //PATH -> COPY TO REPOSITORY AS SOURCE
{
imd->cp(img->get_oid(), path, img->get_source());
oss << "Copying image " << path
<< " to repository as " << img->get_source();
}
NebulaLog::log("ImM",Log::INFO,oss);