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

feautre #4217: API, OCA and command line tools for marketplace apps. Fix minor bugs

This commit is contained in:
Ruben S. Montero 2015-12-11 15:53:19 +01:00
parent 89599fda2e
commit a4cf0cc387
25 changed files with 421 additions and 69 deletions

View File

@ -69,6 +69,30 @@ public:
*/
int from_xml(const std::string &xml_str);
/**
* Returns the marketplace ID
*/
int get_market_id() const
{
return market_id;
};
/**
* Returns the marketplace name
*/
const std::string& get_market_name() const
{
return market_name;
};
/**
* Updates the marketplace name
*/
void set_market_name(const std::string& name)
{
market_name = name;
};
private:
friend class MarketPlaceAppPool;
@ -77,9 +101,9 @@ private:
// MarketPlaceApp Attributes
// *************************************************************************
/**
* Size of this app
* Publishing date
*/
std::string date;
time_t date;
/**
* Source URL for the marketplace app
@ -119,12 +143,12 @@ private:
/**
* Marketplace ID that holds this app
*/
int mp_id;
int market_id;
/**
* Marketplace name
*/
std::string mp_name;
std::string market_name;
/**
* Marketplace App state
@ -204,6 +228,14 @@ private:
* @return 0 on success
*/
int post_update_template(std::string& error);
/**
* Factory method for marketplace app templates
*/
Template * get_new_template() const
{
return new MarketPlaceAppTemplate;
}
};
#endif /*MARKETPLACEAPP_H*/

View File

@ -42,8 +42,6 @@ public:
* @param apptemplate MarketPlaceApp definition template
* @param mp_id of the MarketPlace to store de App
* @param mp_name of the MarketPlace
* @param origin an opaque string with the origin of the App. Used by
* the MARKET_MAD.
* @param oid the id assigned to the MarketPlace
* @param error_str Returns the error reason, if any
*
@ -58,7 +56,6 @@ public:
MarketPlaceAppTemplate * apptemplate,
int mp_id,
const std::string& mp_name,
const std::string& origin,
int * oid,
std::string& error_str);

View File

@ -95,8 +95,8 @@ public:
return name;
};
/** Update a particular MarketPlaceApp
* @param zone pointer to Zone
/** Update a particular MarketPlace
* @param objsql points to the market
* @return 0 on success
*/
int update(PoolObjectSQL * objsql);

View File

@ -36,6 +36,7 @@
#include "VdcPool.h"
#include "VirtualRouterPool.h"
#include "MarketPlacePool.h"
#include "MarketPlaceAppPool.h"
#include "VirtualMachineManager.h"
#include "LifeCycleManager.h"
@ -143,10 +144,16 @@ public:
return vrouterpool;
};
MarketPlacePool * get_mppool()
MarketPlacePool * get_marketpool()
{
return mppool;
return marketpool;
};
MarketPlaceAppPool * get_apppool()
{
return apppool;
};
// --------------------------------------------------------------
// Manager Accessors
// --------------------------------------------------------------
@ -669,7 +676,7 @@ private:
system_db(0), db(0),
vmpool(0), hpool(0), vnpool(0), upool(0), ipool(0), gpool(0), tpool(0),
dspool(0), clpool(0), docpool(0), zonepool(0),
secgrouppool(0), vdcpool(0), vrouterpool(0), mppool(0),
secgrouppool(0), vdcpool(0), vrouterpool(0), marketpool(0), apppool(0),
lcm(0), vmm(0), im(0), tm(0), dm(0), rm(0), hm(0), authm(0),
aclm(0), imagem(0)
{
@ -720,7 +727,8 @@ private:
delete secgrouppool;
delete vdcpool;
delete vrouterpool;
delete mppool;
delete marketpool;
delete apppool;
delete vmm;
delete lcm;
delete im;
@ -801,7 +809,8 @@ private:
SecurityGroupPool * secgrouppool;
VdcPool * vdcpool;
VirtualRouterPool * vrouterpool;
MarketPlacePool * mppool;
MarketPlacePool * marketpool;
MarketPlaceAppPool * apppool;
// ---------------------------------------------------------------
// Nebula Managers

View File

@ -631,7 +631,7 @@ public:
true)
{
Nebula& nd = Nebula::instance();
pool = nd.get_mppool();
pool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACE;
};
@ -651,6 +651,42 @@ public:
RequestAttributes& att);
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppAllocate : public RequestManagerAllocate
{
public:
MarketPlaceAppAllocate():
RequestManagerAllocate("MarketPlaceAppAllocate",
"Allocates a new marketplace app",
"A:ssi",
true)
{
Nebula& nd = Nebula::instance();
pool = nd.get_apppool();
mppool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACEAPP;
};
~MarketPlaceAppAllocate(){};
/* --------------------------------------------------------------------- */
Template * get_object_template()
{
return new MarketPlaceAppTemplate;
};
int pool_allocate(xmlrpc_c::paramList const& _paramList,
Template * tmpl,
int& id,
string& error_str,
RequestAttributes& att);
private:
MarketPlacePool * mppool;
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -200,7 +200,7 @@ public:
"Changes permission bits of a marketplace")
{
Nebula& nd = Nebula::instance();
pool = nd.get_mppool();
pool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACE;
};
@ -208,6 +208,25 @@ public:
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppChmod: public RequestManagerChmod
{
public:
MarketPlaceAppChmod():
RequestManagerChmod("MarketPlaceAppChmod",
"Changes permission bits of a marketplace app")
{
Nebula& nd = Nebula::instance();
pool = nd.get_apppool();
auth_object = PoolObjectSQL::MARKETPLACEAPP;
};
~MarketPlaceAppChmod(){};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -303,7 +303,7 @@ public:
"Changes ownership of a marketplace")
{
Nebula& nd = Nebula::instance();
pool = nd.get_mppool();
pool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACE;
};
@ -315,6 +315,29 @@ public:
};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppChown: public RequestManagerChown
{
public:
MarketPlaceAppChown():
RequestManagerChown("MarketPlaceAppChown",
"Changes ownership of a marketplace app")
{
Nebula& nd = Nebula::instance();
pool = nd.get_apppool();
auth_object = PoolObjectSQL::MARKETPLACEAPP;
};
~MarketPlaceAppChown(){};
PoolObjectSQL * get(const string& name, int uid, bool lock)
{
return static_cast<MarketPlaceAppPool *>(pool)->get(name, uid, lock);
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -383,13 +383,30 @@ public:
"Deletes a marketplace")
{
Nebula& nd = Nebula::instance();
pool = nd.get_mppool();
pool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACE;
};
~MarketPlaceDelete(){};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppDelete : public RequestManagerDelete
{
public:
MarketPlaceAppDelete():
RequestManagerDelete("MarketPlaceAppDelete",
"Deletes a marketplace app")
{
Nebula& nd = Nebula::instance();
pool = nd.get_apppool();
auth_object = PoolObjectSQL::MARKETPLACEAPP;
};
~MarketPlaceAppDelete(){};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -344,16 +344,33 @@ class MarketPlaceInfo : public RequestManagerInfo
public:
MarketPlaceInfo():
RequestManagerInfo("MarketPlaceInfo",
"Returns MarketPlace information")
"Returns marketplace information")
{
Nebula& nd = Nebula::instance();
pool = nd.get_mppool();
pool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACE;
};
~MarketPlaceInfo(){};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppInfo : public RequestManagerInfo
{
public:
MarketPlaceAppInfo():
RequestManagerInfo("MarketPlaceAppInfo",
"Returns marketplace app information")
{
Nebula& nd = Nebula::instance();
pool = nd.get_apppool();
auth_object = PoolObjectSQL::MARKETPLACEAPP;
};
~MarketPlaceAppInfo(){};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -518,11 +518,11 @@ class MarketPlacePoolInfo : public RequestManagerPoolInfoFilter
public:
MarketPlacePoolInfo():
RequestManagerPoolInfoFilter("MarketPlacePoolInfo",
"Returns the market place pool",
"Returns the marketplace pool",
"A:s")
{
Nebula& nd = Nebula::instance();
pool = nd.get_mppool();
pool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACE;
};
@ -531,4 +531,23 @@ public:
void request_execute(xmlrpc_c::paramList const& pl, RequestAttributes& att);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class MarketPlaceAppPoolInfo : public RequestManagerPoolInfoFilter
{
public:
MarketPlaceAppPoolInfo():
RequestManagerPoolInfoFilter("MarketPlacePoolInfo",
"Returns the market place pool",
"A:siii")
{
Nebula& nd = Nebula::instance();
pool = nd.get_apppool();
auth_object = PoolObjectSQL::MARKETPLACEAPP;
};
~MarketPlaceAppPoolInfo(){};
};
#endif

View File

@ -366,7 +366,7 @@ public:
RequestManagerRename("MarketPlaceRename", "Renames a marketplace")
{
Nebula& nd = Nebula::instance();
pool = nd.get_mppool();
pool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACE;
};
@ -377,9 +377,31 @@ public:
return static_cast<MarketPlacePool*>(pool)->get(name, lock);
};
//TODO implement batch rename for MarketPlaceApps
//void batch_rename(int oid);
void batch_rename(int oid);
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppRename: public RequestManagerRename
{
public:
MarketPlaceAppRename():
RequestManagerRename("MarketPlaceRename", "Renames a marketplace app")
{
Nebula& nd = Nebula::instance();
pool = nd.get_apppool();
auth_object = PoolObjectSQL::MARKETPLACEAPP;
};
~MarketPlaceAppRename(){};
PoolObjectSQL * get(const string& name, int uid, bool lock)
{
return static_cast<MarketPlaceAppPool*>(pool)->get(name, uid, lock);
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -312,15 +312,34 @@ class MarketPlaceUpdateTemplate : public RequestManagerUpdateTemplate
public:
MarketPlaceUpdateTemplate():
RequestManagerUpdateTemplate("MarketPlaceUpdateTemplate",
"Updates a virtual router template")
"Updates a marketplace template")
{
Nebula& nd = Nebula::instance();
pool = nd.get_mppool();
pool = nd.get_marketpool();
auth_object = PoolObjectSQL::MARKETPLACE;
};
~MarketPlaceUpdateTemplate(){};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class MarketPlaceAppUpdateTemplate : public RequestManagerUpdateTemplate
{
public:
MarketPlaceAppUpdateTemplate():
RequestManagerUpdateTemplate("MarketPlaceUpdateTemplate",
"Updates a marketplace app template")
{
Nebula& nd = Nebula::instance();
pool = nd.get_apppool();
auth_object = PoolObjectSQL::MARKETPLACEAPP;
};
~MarketPlaceAppUpdateTemplate(){};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -586,6 +586,7 @@ BIN_FILES="src/nebula/oned \
src/cli/onevdc \
src/cli/onevrouter \
src/cli/onemarket \
src/cli/onemarketapp \
src/cli/onevcenter \
src/onedb/onedb \
src/mad/utils/tty_expect \
@ -1382,7 +1383,9 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/opennebula/acl_pool.rb \
src/oca/ruby/opennebula/virtual_router_pool.rb \
src/oca/ruby/opennebula/virtual_router.rb \
src/oca/ruby/opennebula/marketplace_pool.rb \
src/oca/ruby/opennebula/marketplace.rb"
src/oca/ruby/opennebula/marketplace.rb \
src/oca/ruby/opennebula/marketplaceapp_pool.rb \
src/oca/ruby/opennebula/marketplaceapp.rb"
#-------------------------------------------------------------------------------
# Common Cloud Files
@ -1534,6 +1537,7 @@ ONE_CLI_LIB_FILES="src/cli/one_helper/onegroup_helper.rb \
src/cli/one_helper/oneacct_helper.rb \
src/cli/one_helper/onesecgroup_helper.rb \
src/cli/one_helper/onevrouter_helper.rb \
src/cli/one_helper/onemarketapp_helper.rb \
src/cli/one_helper/onemarket_helper.rb"
CLI_BIN_FILES="src/cli/onevm \
@ -1554,6 +1558,7 @@ CLI_BIN_FILES="src/cli/onevm \
src/cli/oneshowback \
src/cli/onevdc \
src/cli/onevrouter \
src/cli/onemarketapp \
src/cli/onemarket"
CLI_CONF_FILES="src/cli/etc/onegroup.yaml \
@ -1572,6 +1577,7 @@ CLI_CONF_FILES="src/cli/etc/onegroup.yaml \
src/cli/etc/oneshowback.yaml \
src/cli/etc/onevdc.yaml \
src/cli/etc/onevrouter.yaml \
src/cli/etc/onemarketapp.yaml \
src/cli/etc/onemarket.yaml"
#-----------------------------------------------------------------------------
@ -1846,6 +1852,7 @@ MAN_FILES="share/man/oneacct.1.gz \
share/man/onevdc.1.gz \
share/man/onevrouter.1.gz \
share/man/onemarket.1.gz \
share/man/onemarketapp.1.gz \
share/man/econe-allocate-address.1.gz \
share/man/econe-associate-address.1.gz \
share/man/econe-attach-volume.1.gz \

View File

@ -17,7 +17,7 @@
:size: 5
:left: true
:MARKETAPPS:
:APPS:
:desc: Number of Marketplace Apps
:size: 6
@ -36,6 +36,6 @@
- :NAME
- :SIZE
- :AVAIL
- :MARKETAPPS
- :APPS
- :TYPE
- :MAD

View File

@ -17,7 +17,7 @@
require 'one_helper'
class OneMarketPlaceHelper < OpenNebulaHelper::OneHelper
DATASTORE = {
MARKETPLACE = {
:name => "marketplace",
:short => "-m id|name",
:large => "--marketplace id|name" ,
@ -60,7 +60,7 @@ class OneMarketPlaceHelper < OpenNebulaHelper::OneHelper
end
end
column :MARKETAPPS, "Number of marketplace apps", :size=>6 do |d|
column :APPS, "Number of marketplace apps", :size=>6 do |d|
if d["MARKETPLACEAPPS"]["ID"].nil?
"0"
else
@ -77,7 +77,7 @@ class OneMarketPlaceHelper < OpenNebulaHelper::OneHelper
d["MARKET_MAD"]
end
default :ID, :NAME, :SIZE, :AVAIL, :MARKETAPPS, :TYPE, :MAD
default :ID, :NAME, :SIZE, :AVAIL, :APPS, :TYPE, :MAD
end
table

View File

@ -52,8 +52,8 @@ MarketPlaceApp::MarketPlaceApp(
publisher(""),
version(""),
apptemplate64(""),
mp_id(-1),
mp_name(""),
market_id(-1),
market_name(""),
state(INIT)
{
if (app_template != 0)
@ -81,11 +81,6 @@ int MarketPlaceApp::insert(SqlDB *db, string& error_str)
{
std::ostringstream oss;
std::string attr;
char str[26];
time_t the_time = time(NULL);
// -------------------------------------------------------------------------
// Check default marketplace app attributes
// -------------------------------------------------------------------------
@ -94,36 +89,41 @@ int MarketPlaceApp::insert(SqlDB *db, string& error_str)
erase_template_attribute("NAME", name);
//Atrributes updated after export
remove_template_attribute("ORIGIN");
remove_template_attribute("SOURCE");
remove_template_attribute("SIZE");
remove_template_attribute("CHECKSUM");
ctime_r(&(the_time), str);
date = str;
date = time(NULL);
//Known attributes
//ORIGIN
//DESCRIPTION
//APPTEMPLATE64
//PUBLISHER
//VERSION
erase_template_attribute("ORIGIN", origin);
if (origin.empty())
{
goto error_origin;
}
get_template_attribute("DESCRIPTION", description);
get_template_attribute("APPTEMPLATE64", apptemplate64);
get_template_attribute("PUBLISHER", attr);
get_template_attribute("PUBLISHER", publisher);
if (attr.empty())
if (publisher.empty())
{
publisher = uname;
}
get_template_attribute("VERSION", attr);
get_template_attribute("VERSION", version);
if (!attr.empty())
if (version.empty())
{
version = attr;
version = "0.0";
}
state = LOCKED;
@ -131,6 +131,11 @@ int MarketPlaceApp::insert(SqlDB *db, string& error_str)
//--------------------------------------------------------------------------
return insert_replace(db, false, error_str);
error_origin:
error_str = "Missing ORIGIN for the MARKETPLACEAPP";
NebulaLog::log("MRK", Log::ERROR, error_str);
return -1;
}
/* --------------------------------------------------------------------------- */
@ -241,8 +246,8 @@ std::string& MarketPlaceApp::to_xml(std::string& xml) const
"<PUBLISHER>" << publisher << "</PUBLISHER>" <<
"<VERSION>" << version << "</VERSION>" <<
"<APPTEMPLATE64>" << apptemplate64 << "</APPTEMPLATE64>" <<
"<MARKETPLACE_ID>" << mp_id << "</MARKETPLACE_ID>" <<
"<MARKETPLACE>" << mp_name << "</MARKETPLACE>" <<
"<MARKETPLACE_ID>" << market_id << "</MARKETPLACE_ID>" <<
"<MARKETPLACE>" << market_name << "</MARKETPLACE>" <<
"<STATE>" << state << "</STATE>" <<
perms_to_xml(perm_str) <<
obj_template->to_xml(template_xml) <<
@ -272,7 +277,7 @@ int MarketPlaceApp::from_xml(const std::string &xml_str)
rc += xpath(uname, "/MARKETPLACEAPP/UNAME", "not_found");
rc += xpath(gname, "/MARKETPLACEAPP/GNAME", "not_found");
rc += xpath(name, "/MARKETPLACEAPP/NAME", "not_found");
rc += xpath(date, "/MARKETPLACEAPP/DATE", "not_found");
rc += xpath(date, "/MARKETPLACEAPP/DATE", -1);
rc += xpath(source, "/MARKETPLACEAPP/SOURCE","not_found");
rc += xpath(origin, "/MARKETPLACEAPP/ORIGIN","not_found");
rc += xpath(istate, "/MARKETPLACEAPP/STATE", -1);
@ -282,8 +287,8 @@ int MarketPlaceApp::from_xml(const std::string &xml_str)
rc += xpath(checksum, "/MARKETPLACEAPP/CHECKSUM", "not_found");
rc += xpath(publisher, "/MARKETPLACEAPP/PUBLISHER", "not_found");
rc += xpath(apptemplate64,"/MARKETPLACEAPP/APPTEMPLATE64", "not_found");
rc += xpath(mp_name, "/MARKETPLACEAPP/MARKETPLACE", "not_found");
rc += xpath(mp_id, "/MARKETPLACEAPP/MARKETPLACE_ID", -1);
rc += xpath(market_name, "/MARKETPLACEAPP/MARKETPLACE", "not_found");
rc += xpath(market_id, "/MARKETPLACEAPP/MARKETPLACE_ID", -1);
state = static_cast<MarketPlaceAppState>(istate);

View File

@ -29,7 +29,6 @@ int MarketPlaceAppPool:: allocate(
MarketPlaceAppTemplate * apptemplate,
int mp_id,
const std::string& mp_name,
const std::string& origin,
int * oid,
std::string& error_str)
{
@ -42,10 +41,10 @@ int MarketPlaceAppPool:: allocate(
mp = new MarketPlaceApp(uid, gid, uname, gname, umask, apptemplate);
mp->mp_id = mp_id;
mp->mp_name = mp_name;
mp->state = MarketPlaceApp::INIT;
mp->origin = origin;
mp->market_id = mp_id;
mp->market_name = mp_name;
mp->state = MarketPlaceApp::INIT;
// -------------------------------------------------------------------------
// Check name & duplicates

View File

@ -348,6 +348,7 @@ void Nebula::start(bool bootstrap_only)
rc += SecurityGroupPool::bootstrap(db);
rc += VirtualRouterPool::bootstrap(db);
rc += MarketPlacePool::bootstrap(db);
rc += MarketPlaceAppPool::bootstrap(db);
// Create the system tables only if bootstrap went well
if (rc == 0)
@ -493,8 +494,10 @@ void Nebula::start(bool bootstrap_only)
docpool = new DocumentPool(db);
zonepool= new ZonePool(db, is_federation_slave());
vdcpool = new VdcPool(db, is_federation_slave());
vrouterpool = new VirtualRouterPool(db);
mppool = new MarketPlacePool(db);
marketpool = new MarketPlacePool(db);
apppool = new MarketPlaceAppPool(db);
nebula_configuration->get("VM_HOOK", vm_hooks);
nebula_configuration->get("HOST_HOOK", host_hooks);

View File

@ -60,6 +60,8 @@ require 'opennebula/virtual_router'
require 'opennebula/virtual_router_pool'
require 'opennebula/marketplace'
require 'opennebula/marketplace_pool'
require 'opennebula/marketplaceapp'
require 'opennebula/marketplaceapp_pool'
module OpenNebula

View File

@ -23,7 +23,6 @@ module OpenNebula
# Constants and Class attribute accessors
#######################################################################
IMAGE_POOL_METHODS = {
:info => "imagepool.info"
}

View File

@ -67,16 +67,16 @@ module OpenNebula
# XML-RPC Methods for the MarketPlace Object
#######################################################################
# Retrieves the information of the given MarketPlace.
# Retrieves the information of the given marketplace.
def info()
super(MARKETPLACE_METHODS[:info], 'MARKETPLACE')
end
alias_method :info!, :info
# Allocates a new MarketPlace in OpenNebula
# Allocates a new marketplace in OpenNebula
#
# @param description [String] The template of the MarketPlace.
# @param description [String] The template of the marketplace.
#
# @return [Integer, OpenNebula::Error] the new ID in case of
# success, error otherwise
@ -84,7 +84,7 @@ module OpenNebula
super(MARKETPLACE_METHODS[:allocate], description)
end
# Deletes the MarketPlace
# Deletes the marketplace
def delete()
super(MARKETPLACE_METHODS[:delete])
end
@ -161,11 +161,6 @@ module OpenNebula
SHORT_MARKETPLACE_TYPES[type_str]
end
# Returns the state of the marketplace (numeric value)
def state
self['STATE'].to_i
end
# Returns whether or not the marketplace app with id 'id' is part of
# this marketplace
def contains(id)

View File

@ -629,6 +629,8 @@ string Request::object_name(PoolObjectSQL::ObjectType ob)
case PoolObjectSQL::MARKETPLACEAPP:
return "marketplaceapp";
}
return "unknown";
};
/* -------------------------------------------------------------------------- */

View File

@ -949,6 +949,52 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.marketpool.info", marketpool_info);
/* MarketPlaceApp related methods */
xmlrpc_c::method * marketapp_allocate_pt;
xmlrpc_c::method * marketapp_update_pt;
xmlrpc_c::method * marketapp_delete_pt;
xmlrpc_c::method * marketapp_chmod_pt;
xmlrpc_c::method * marketapp_chown_pt;
if (nebula.is_federation_slave())
{
marketapp_allocate_pt = new RequestManagerProxy("one.marketapp.allocate");
marketapp_update_pt = new RequestManagerProxy("one.marketapp.update");
marketapp_delete_pt = new RequestManagerProxy("one.marketapp.delete");
marketapp_chmod_pt = new RequestManagerProxy("one.marketapp.chmod");
marketapp_chown_pt = new RequestManagerProxy("one.marketapp.chown");
}
else
{
marketapp_allocate_pt = new MarketPlaceAppAllocate();
marketapp_update_pt = new MarketPlaceAppUpdateTemplate();
marketapp_delete_pt = new MarketPlaceAppDelete();
marketapp_chmod_pt = new MarketPlaceAppChmod();
marketapp_chown_pt = new MarketPlaceAppChown();
}
xmlrpc_c::methodPtr marketapp_allocate(marketapp_allocate_pt);
xmlrpc_c::methodPtr marketapp_update(marketapp_update_pt);
xmlrpc_c::methodPtr marketapp_delete(marketapp_delete_pt);
xmlrpc_c::methodPtr marketapp_chmod(marketapp_chmod_pt);
xmlrpc_c::methodPtr marketapp_chown(marketapp_chown_pt);
xmlrpc_c::methodPtr marketapp_info(new MarketPlaceAppInfo());
xmlrpc_c::methodPtr marketapp_rename(new MarketPlaceAppRename());
xmlrpc_c::methodPtr marketapppool_info(new MarketPlaceAppPoolInfo());
RequestManagerRegistry.addMethod("one.marketapp.allocate", marketapp_allocate);
RequestManagerRegistry.addMethod("one.marketapp.update", marketapp_update);
RequestManagerRegistry.addMethod("one.marketapp.delete", marketapp_delete);
RequestManagerRegistry.addMethod("one.marketapp.chmod", marketapp_chmod);
RequestManagerRegistry.addMethod("one.marketapp.chown", marketapp_chown);
RequestManagerRegistry.addMethod("one.marketapp.info", marketapp_info);
RequestManagerRegistry.addMethod("one.marketapp.rename", marketapp_rename);
RequestManagerRegistry.addMethod("one.marketapppool.info", marketapppool_info);
/* System related methods */
RequestManagerRegistry.addMethod("one.system.version", system_version);
RequestManagerRegistry.addMethod("one.system.config", system_config);

View File

@ -810,3 +810,49 @@ int MarketPlaceAllocate::pool_allocate(
ttmpl, &id, error_str);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int MarketPlaceAppAllocate::pool_allocate(
xmlrpc_c::paramList const& paramList,
Template * tmpl,
int& id,
string& error_str,
RequestAttributes& att)
{
MarketPlaceAppPool * appool = static_cast<MarketPlaceAppPool *>(pool);
MarketPlaceAppTemplate * ttmpl = static_cast<MarketPlaceAppTemplate *>(tmpl);
int mp_id = xmlrpc_c::value_int(paramList.getInt(2));
MarketPlace * mp = mppool->get(mp_id, true);
if ( mp == 0 )
{
error_str = "Cannot find associated MARKETPLACE";
return -1;
}
std::string mp_name = mp->get_name();
mp->unlock();
int rc = appool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask,
ttmpl, mp_id, mp_name, &id, error_str);
if (rc < 0)
{
return rc;
}
mp = mppool->get(mp_id, true);
if ( mp != 0 ) // TODO: error otherwise or leave app in ERROR?
{
mp->add_marketapp(id);
mppool->update(mp);
mp->unlock();
}
}

View File

@ -302,3 +302,41 @@ void HostRename::batch_rename(int oid)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void MarketPlaceRename::batch_rename(int oid)
{
MarketPlace * market = static_cast<MarketPlacePool*>(pool)->get(oid, true);
if (market == 0)
{
return;
}
const std::set<int> & apps = market->get_marketapp_ids();
std::set<int>::iterator it;
std::string market_name = market->get_name();
market->unlock();
MarketPlaceApp * app;
MarketPlaceAppPool * apppool = Nebula::instance().get_apppool();
for (it = apps.begin(); it != apps.end(); it++)
{
app = apppool->get(*it, true);
if (app != 0)
{
if (app->get_market_id() == oid)
{
app->set_market_name(market_name);
apppool->update(app);
}
app->unlock();
}
}
}