Revision ade6513a src/market/MarketPlaceManagerActions.cc
src/market/MarketPlaceManagerActions.cc | ||
---|---|---|
19 | 19 |
#include "MarketPlaceAppPool.h" |
20 | 20 |
#include "MarketPlaceManagerDriver.h" |
21 | 21 |
|
22 |
#include "Image.h" |
|
23 |
#include "Datastore.h" |
|
24 |
#include "ImageManager.h" |
|
25 |
|
|
22 | 26 |
#include "NebulaLog.h" |
23 | 27 |
#include "Nebula.h" |
24 | 28 |
|
... | ... | |
31 | 35 |
const std::string& market_data, |
32 | 36 |
std::string& err) |
33 | 37 |
{ |
34 |
std::string app_data; |
|
38 |
std::string app_data, image_data, ds_data; |
|
39 |
std::string * msg; |
|
40 |
|
|
41 |
Image * image; |
|
42 |
Datastore * ds; |
|
43 |
|
|
44 |
int ds_id; |
|
45 |
|
|
46 |
const MarketPlaceManagerDriver* mpmd = get(); |
|
47 |
|
|
48 |
if ( mpmd == 0 ) |
|
49 |
{ |
|
50 |
err = "Error getting MarketPlaceManagerDriver"; |
|
51 |
return -1; |
|
52 |
} |
|
53 |
|
|
35 | 54 |
MarketPlaceApp * app = apppool->get(appid, true); |
36 | 55 |
|
37 | 56 |
if ( app == 0 ) |
... | ... | |
42 | 61 |
|
43 | 62 |
app->to_xml(app_data); |
44 | 63 |
|
45 |
app->unlock();
|
|
64 |
MarketPlaceApp::MarketPlaceAppType type = app->get_type();
|
|
46 | 65 |
|
47 |
std::string * msg = format_message(app_data, market_data, ""); |
|
66 |
int app_id = app->get_oid(); |
|
67 |
int origin_id = app->get_origin_id(); |
|
48 | 68 |
|
49 |
const MarketPlaceManagerDriver* mpmd = get();
|
|
69 |
app->unlock();
|
|
50 | 70 |
|
51 |
if ( mpmd == 0 )
|
|
71 |
switch (type)
|
|
52 | 72 |
{ |
53 |
err = "Error getting MarketPlaceManagerDriver"; |
|
54 |
return -1; |
|
73 |
case MarketPlaceApp::IMAGE: |
|
74 |
image = ipool->get(origin_id, true); |
|
75 |
|
|
76 |
if ( image == 0 ) |
|
77 |
{ |
|
78 |
err = "Image does not exist."; |
|
79 |
return -1; |
|
80 |
} |
|
81 |
|
|
82 |
image->to_xml(image_data); |
|
83 |
|
|
84 |
ds_id = image->get_ds_id(); |
|
85 |
|
|
86 |
image->unlock(); |
|
87 |
|
|
88 |
ds = dspool->get(ds_id, true); |
|
89 |
|
|
90 |
if ( ds == 0 ) |
|
91 |
{ |
|
92 |
err = "Image datastore no longer exists."; |
|
93 |
return -1; |
|
94 |
} |
|
95 |
|
|
96 |
ds->to_xml(ds_data); |
|
97 |
|
|
98 |
ds->unlock(); |
|
99 |
|
|
100 |
if (imagem->set_clone_state(-app_id, origin_id, err) != 0) |
|
101 |
{ |
|
102 |
return -1; |
|
103 |
} |
|
104 |
break; |
|
105 |
|
|
106 |
case MarketPlaceApp::VMTEMPLATE: |
|
107 |
case MarketPlaceApp::FLOW: |
|
108 |
case MarketPlaceApp::UNKNOWN: |
|
109 |
err = "Marketplace app type not supported."; |
|
110 |
return -1; |
|
55 | 111 |
} |
56 | 112 |
|
113 |
msg = format_message(app_data, market_data, image_data + ds_data); |
|
114 |
|
|
57 | 115 |
mpmd->importapp(appid, *msg); |
58 | 116 |
|
59 | 117 |
delete msg; |
Also available in: Unified diff