1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-08-24 17:49:28 +03:00

feature #523: Interation of the Image Manager with RM for allocate. Multiple bug fixes and integration issues

This commit is contained in:
Ruben S. Montero
2011-03-24 19:52:59 +01:00
parent 8d3a1e3557
commit 0d0a569741
7 changed files with 35 additions and 7 deletions

View File

@ -116,7 +116,7 @@ public:
*
*
*/
int register_image(Image *img);
int register_image(int iid);
private:
/**

View File

@ -194,6 +194,7 @@ LIB_DIRS="$LIB_LOCATION/ruby \
$LIB_LOCATION/remotes/im/ganglia.d \
$LIB_LOCATION/remotes/vmm/xen \
$LIB_LOCATION/remotes/vmm/kvm \
$LIB_LOCATION/remotes/image \
$LIB_LOCATION/remotes/image/fs"
VAR_DIRS="$VAR_LOCATION/remotes \
@ -202,7 +203,9 @@ VAR_DIRS="$VAR_LOCATION/remotes \
$VAR_LOCATION/remotes/im/xen.d \
$VAR_LOCATION/remotes/im/ganglia.d \
$VAR_LOCATION/remotes/vmm/xen \
$VAR_LOCATION/remotes/vmm/kvm"
$VAR_LOCATION/remotes/vmm/kvm \
$VAR_LOCATION/remotes/image \
$VAR_LOCATION/remotes/image/fs"
SUNSTONE_DIRS="$SUNSTONE_LOCATION/models \
$SUNSTONE_LOCATION/models/OpenNebulaJSON \
@ -279,6 +282,7 @@ INSTALL_FILES=(
DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy
LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm
IMAGE_DRIVER_FS_SCRIPTS:$LIB_LOCATION/remotes/image/fs
IMAGE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/image/fs
EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples
TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm
HOOK_SHARE_FILES:$SHARE_LOCATION/hooks

View File

@ -266,11 +266,13 @@ int ImageManager::enable_image(Image *img, bool to_enable)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int ImageManager::register_image(Image *img)
int ImageManager::register_image(int iid)
{
const ImageManagerDriver* imd = get();
ostringstream oss;
string path;
Image* img;
if ( imd == 0 )
{
@ -279,6 +281,13 @@ int ImageManager::register_image(Image *img)
return -1;
}
img = ipool->get(iid,true);
if (img == 0)
{
return -1;
}
img->get_template_attribute("PATH",path);
switch (img->get_type())
@ -316,5 +325,7 @@ int ImageManager::register_image(Image *img)
NebulaLog::log("ImM",Log::INFO,oss);
img->unlock();
return 0;
}

View File

@ -208,6 +208,7 @@ void ImageManagerDriver::protocol(
NebulaLog::log("ImM", Log::INFO, info.c_str());
}
return;
error_cp:
os.str("");

View File

@ -74,7 +74,7 @@ class ImageDriver < OpenNebulaDriver
if command_exe.code == 0
result = :success
info = command_exe.stdout
info = "-"
else
result = :failure
info = command_exe.stderr
@ -86,7 +86,7 @@ class ImageDriver < OpenNebulaDriver
end
# -------------------------------------------------------------------------
# Virtual Machine Manager Protocol Actions (generic implementation
# Image Manager Protocol Actions (generic implementation
# -------------------------------------------------------------------------
def mv(id, src, dst)
local_action("#{@actions_path}/mv #{src} #{dst}",id,:mv)
@ -101,7 +101,7 @@ class ImageDriver < OpenNebulaDriver
end
def mkfs(id, dst, fs, size)
local_action("#{@actions_path}/mkfs #{src} #{fs} #{size}",id,:mkfs)
local_action("#{@actions_path}/mkfs #{dst} #{fs} #{size}",id,:mkfs)
end
end

View File

@ -38,5 +38,5 @@ FSTYPE=$2
SIZE=$3
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M"
exec_and_log "$MKFS -t $FSTYPE -F $DST_PATH"
exec_and_log "$MKFS -t $FSTYPE -F $DST"
exec_and_log "chmod 0660 $DST"

View File

@ -48,6 +48,9 @@ void RequestManager::ImageAllocate::execute(
vector<xmlrpc_c::value> arrayData;
xmlrpc_c::value_array * arrayresult;
Nebula& nd = Nebula::instance();
ImageManager * imagem = nd.get_imagem();
NebulaLog::log("ReM",Log::DEBUG,"ImageAllocate invoked");
session = xmlrpc_c::value_string(paramList.getString(0));
@ -124,7 +127,11 @@ void RequestManager::ImageAllocate::execute(
if ( rc < 0 )
{
goto error_allocate;
}
if ( imagem->register_image(rc) == -1 )
{
goto error_register;
}
arrayData.push_back(xmlrpc_c::value_boolean(true));
@ -169,6 +176,11 @@ error_allocate:
oss << " " << error_str;
goto error_common;
error_register:
oss << action_error(method_name, "CREATE", "IMAGE", -2, 0);
oss << " Failed to copy image to repository. Image left in ERROR state.";
goto error_common;
error_common:
arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE
arrayData.push_back(xmlrpc_c::value_string(oss.str()));