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

Feature #4217: Send the market data to the driver

This commit is contained in:
Jaime Melis
2016-01-26 20:24:33 +01:00
parent 0477eb2ad6
commit 15e54f59ea
7 changed files with 66 additions and 20 deletions

View File

@ -65,6 +65,7 @@ public:
* @param ds_type disk type for the image
* @param ds_data the datastore data
* @param ds_type the datastore type
* @param extra_data extra data that will be sent to the driver
* @param source_img_id If the new Image is a clone, this must be the
* source Image ID. Otherwise, it must be set to -1
* @param oid the id assigned to the Image
@ -85,6 +86,7 @@ public:
Image::DiskType disk_type,
const string& ds_data,
Datastore::DatastoreType ds_type,
const string& extra_data,
int source_img_id,
int * oid,
string& error_str);

View File

@ -117,6 +117,15 @@ public:
*/
int from_template64(const std::string &xml_str, std::string& error_str);
/**
* Copies the special attributes of the App to the template
* @param tmp The template object
* @param error_str Returns the error reason, if any
*
* @return 0 on success, -1 otherwise
*/
int to_template(Template * tmpl, std::string& error_str);
/**
* Enable or disable the app. A disabled app cannot be exported
* @param enable true to enable

View File

@ -89,6 +89,7 @@ int ImagePool::allocate (
Image::DiskType disk_type,
const string& ds_data,
Datastore::DatastoreType ds_type,
const string& extra_data,
int cloning_id,
int * oid,
string& error_str)

View File

@ -411,6 +411,39 @@ int MarketPlaceApp::enable(bool enable, string& error_str)
/* --------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------- */
int MarketPlaceApp::to_template(Template * tmpl, std::string& error_str)
{
bool rc;
string app_path;
string app_format;
string app_md5;
string app_name;
int market_id;
get_template_attribute("SOURCE", app_path);
get_template_attribute("FORMAT", app_format);
get_template_attribute("MD5", app_md5);
get_template_attribute("NAME", app_name);
if ( app_path.empty() )
{
error_str = "The appliance has no SOURCE";
return -1;
}
tmpl->replace("PATH", app_path);
tmpl->replace("FORMAT", app_format);
tmpl->replace("MD5", app_format);
tmpl->replace("FROM_APP_NAME", app_name);
return 0;
}
/* --------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------- */
int MarketPlaceApp::from_template64(const std::string &info64, std::string& err)
{
std::string * info = one_util::base64_decode(info64);

View File

@ -398,12 +398,6 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
{
// This image comes from a MarketPlaceApp. Get the Market info and
// the size.
string app_path;
string app_format;
string app_md5;
string app_name;
bool market_check;
app = apppool->get(app_id, true);
@ -417,39 +411,43 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
return;
}
app->get_template_attribute("SOURCE", app_path);
app->get_template_attribute("FORMAT", app_format);
app->get_template_attribute("MD5", app_md5);
app->get_template_attribute("NAME", app_name);
app->get_template_attribute("SIZE", size_str);
rc = app->to_template(tmpl, error_str);
app->get_template_attribute("SIZE", size_str);
market_check = app->get_template_attribute("MARKETPLACE_ID", market_id);
app->unlock();
if ( app_path.empty() )
if ( rc == -1 )
{
failure_response(INTERNAL, "The appliance has no SOURCE", att);
failure_response(INTERNAL, allocate_error(error_str), att);
delete tmpl;
return;
}
if ( !market_check )
{
failure_response(INTERNAL, "The appliance has no MARKETPLACE_ID",
att);
error_str = "The appliance has no MARKETPLACE_ID";
failure_response(INTERNAL, allocate_error(error_str), att);
delete tmpl;
return;
}
tmpl->replace("PATH", app_path);
tmpl->replace("FORMAT", app_format);
tmpl->replace("MD5", app_format);
tmpl->replace("FROM_APP_NAME", app_name);
if ( size_str.empty() )
{
error_str = "The appliance has no SIZE";
failure_response(INTERNAL, allocate_error(error_str), att);
delete tmpl;
return;
}
market = marketpool->get(market_id, true);
if (market == 0)
if ( market == 0 )
{
failure_response(INTERNAL, "Could not get the appliance's market.",
att);
@ -565,6 +563,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
ds_disk_type,
ds_data,
ds_type,
extra_data,
-1,
&id,
error_str);

View File

@ -444,6 +444,7 @@ void ImageClone::request_execute(
disk_type,
ds_data,
Datastore::IMAGE_DS,
"",
clone_id,
&new_id,
error_str);

View File

@ -1403,6 +1403,7 @@ void VirtualMachineDiskSaveas::request_execute(
ds_disk_type,
ds_data,
Datastore::IMAGE_DS,
"",
-1,
&iid,
error);