opennebula-3.2.1-cmri.patch
opennebula-3.2.1-cmri/include/BackupDisk.h 2012-07-25 17:21:16.697333178 +0800 | ||
---|---|---|
1 |
/* -------------------------------------------------------------------------- */ |
|
2 |
/* Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) */ |
|
3 |
/* */ |
|
4 |
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ |
|
5 |
/* not use this file except in compliance with the License. You may obtain */ |
|
6 |
/* a copy of the License at */ |
|
7 |
/* */ |
|
8 |
/* http://www.apache.org/licenses/LICENSE-2.0 */ |
|
9 |
/* */ |
|
10 |
/* Unless required by applicable law or agreed to in writing, software */ |
|
11 |
/* distributed under the License is distributed on an "AS IS" BASIS, */ |
|
12 |
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ |
|
13 |
/* See the License for the specific language governing permissions and */ |
|
14 |
/* limitations under the License. */ |
|
15 |
/* -------------------------------------------------------------------------- */ |
|
16 | ||
17 |
#ifndef BACKUPDISK_H_ |
|
18 |
#define BACKUPDISK_H_ |
|
19 | ||
20 |
#include "ObjectSQL.h" |
|
21 | ||
22 |
using namespace std; |
|
23 | ||
24 |
/** |
|
25 |
* The BackupDisk class, it represents an execution record of a Virtual Machine. |
|
26 |
*/ |
|
27 | ||
28 |
class BackupDisk:public ObjectSQL |
|
29 |
{ |
|
30 |
public: |
|
31 |
enum DkState |
|
32 |
{ |
|
33 |
INIT = 0, |
|
34 |
START_BACKUPDISK = 1, |
|
35 |
BACKUPDISK_SUCESS = 2, |
|
36 |
BACKUPDISK_FAIL = 3 |
|
37 |
}; |
|
38 | ||
39 |
BackupDisk(int oid, int vid = -1); |
|
40 | ||
41 |
BackupDisk( |
|
42 |
int oid, |
|
43 |
int vid, |
|
44 |
string& dk_name, |
|
45 |
string& dk_dir); |
|
46 | ||
47 |
~BackupDisk(){}; |
|
48 | ||
49 |
/** |
|
50 |
* Function to write the Backup Record in an output stream |
|
51 |
*/ |
|
52 |
friend ostream& operator<<(ostream& os, const BackupDisk& backupdisk); |
|
53 | ||
54 |
/** |
|
55 |
* Function to print the Backup object into a string in |
|
56 |
* plain text |
|
57 |
* @param str the resulting string |
|
58 |
* @return a reference to the generated string |
|
59 |
*/ |
|
60 |
string& to_str(string& str) const; |
|
61 | ||
62 |
/** |
|
63 |
* Function to print the Backup object into a string in |
|
64 |
* XML format |
|
65 |
* @param xml the resulting XML string |
|
66 |
* @return a reference to the generated string |
|
67 |
*/ |
|
68 |
string& to_xml(string& xml) const; |
|
69 | ||
70 |
private: |
|
71 |
friend class VirtualMachine; |
|
72 |
friend class VirtualMachinePool; |
|
73 |
|
|
74 |
// ---------------------------------------- |
|
75 |
// DataBase implementation variables |
|
76 |
// ---------------------------------------- |
|
77 |
enum ColNames |
|
78 |
{ |
|
79 |
OID = 0, |
|
80 |
VID = 1, |
|
81 |
DK_NAME = 2, |
|
82 |
DK_DIR = 3, |
|
83 |
STATE = 4 |
|
84 |
}; |
|
85 | ||
86 |
static const char * table; |
|
87 | ||
88 |
static const char * db_names; |
|
89 | ||
90 |
static const char * extended_db_names; |
|
91 | ||
92 |
static const char * db_bootstrap; |
|
93 | ||
94 |
|
|
95 | ||
96 |
static string column_name(const ColNames column) |
|
97 |
{ |
|
98 |
switch (column) |
|
99 |
{ |
|
100 |
case VID: |
|
101 |
return "vid"; |
|
102 |
default: |
|
103 |
return ""; |
|
104 |
} |
|
105 |
} |
|
106 | ||
107 |
// ---------------------------------------- |
|
108 |
// BackupDisk fields |
|
109 |
// ---------------------------------------- |
|
110 |
int oid; |
|
111 |
int vid; |
|
112 | ||
113 |
|
|
114 |
string dk_dir; |
|
115 | ||
116 |
DkState state; |
|
117 | ||
118 |
|
|
119 |
string dk_name; |
|
120 | ||
121 | ||
122 | ||
123 |
|
|
124 |
|
|
125 |
/** |
|
126 |
* Writes the backup record in the DB |
|
127 |
* @param db pointer to the database. |
|
128 |
* @return 0 on success. |
|
129 |
*/ |
|
130 |
int insert(SqlDB * db, string& error_str); |
|
131 | ||
132 |
/** |
|
133 |
* Reads the backup record from the DB |
|
134 |
* @param db pointer to the database. |
|
135 |
* @return 0 on success. |
|
136 |
*/ |
|
137 |
int select(SqlDB * db); |
|
138 | ||
139 |
/** |
|
140 |
* Updates the backup record |
|
141 |
* @param db pointer to the database. |
|
142 |
* @return 0 on success. |
|
143 |
*/ |
|
144 |
int update(SqlDB * db); |
|
145 | ||
146 |
/** |
|
147 |
* Removes the all backup records from the DB |
|
148 |
* @param db pointer to the database. |
|
149 |
* @return 0 on success. |
|
150 |
*/ |
|
151 |
int drop(SqlDB * db); |
|
152 | ||
153 |
/** |
|
154 |
* Execute an INSERT or REPLACE Sql query. |
|
155 |
* @param db The SQL DB |
|
156 |
* @param replace Execute an INSERT or a REPLACE |
|
157 |
* @return 0 on success |
|
158 |
*/ |
|
159 |
int insert_replace(SqlDB *db, bool replace); |
|
160 | ||
161 |
/** |
|
162 |
* Callback function to unmarshall a history object (History::select) |
|
163 |
* @param num the number of columns read from the DB |
|
164 |
* @para names the column names |
|
165 |
* @para vaues the column values |
|
166 |
* @return 0 on success |
|
167 |
*/ |
|
168 |
int select_cb(void *nil, int num, char **values, char **names); |
|
169 | ||
170 |
/** |
|
171 |
* Function to unmarshall a backup object into an output stream with XML |
|
172 |
* format. |
|
173 |
* @param oss the output stream |
|
174 |
* @param num the number of columns read from the DB |
|
175 |
* @param names the column names |
|
176 |
* @param vaues the column values |
|
177 |
* @return 0 on success |
|
178 |
*/ |
|
179 |
static int dump(ostringstream& oss, int num, char **names, char **values); |
|
180 |
}; |
|
181 | ||
182 |
#endif /*BACKUPDISK_H_*/ |
|
183 |
opennebula-3.2.1-cmri/include/Backup.h 2012-07-25 17:21:16.698333180 +0800 | ||
---|---|---|
1 |
/* -------------------------------------------------------------------------- */ |
|
2 |
/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */ |
|
3 |
/* */ |
|
4 |
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ |
|
5 |
/* not use this file except in compliance with the License. You may obtain */ |
|
6 |
/* a copy of the License at */ |
|
7 |
/* */ |
|
8 |
/* http://www.apache.org/licenses/LICENSE-2.0 */ |
|
9 |
/* */ |
|
10 |
/* Unless required by applicable law or agreed to in writing, software */ |
|
11 |
/* distributed under the License is distributed on an "AS IS" BASIS, */ |
|
12 |
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ |
|
13 |
/* See the License for the specific language governing permissions and */ |
|
14 |
/* limitations under the License. */ |
|
15 |
/* -------------------------------------------------------------------------- */ |
|
16 | ||
17 |
#ifndef BACKUP_H_ |
|
18 |
#define BACKUP_H_ |
|
19 | ||
20 |
#include "ObjectSQL.h" |
|
21 | ||
22 |
using namespace std; |
|
23 | ||
24 |
/** |
|
25 |
* The Backup class, it represents an execution record of a Virtual Machine. |
|
26 |
*/ |
|
27 | ||
28 |
class Backup:public ObjectSQL |
|
29 |
{ |
|
30 |
public: |
|
31 |
enum BkState |
|
32 |
{ |
|
33 |
INIT = 0, |
|
34 |
START_BACKUP = 1, |
|
35 |
BACKUP_SUCESS = 2, |
|
36 |
START_RESUME = 3, |
|
37 |
RESUME_SUCESS = 4, |
|
38 |
BACKUP_FAIL = 100, |
|
39 |
RESUME_FAIL = 200, |
|
40 |
BACKUP_DELETE = 300 |
|
41 |
}; |
|
42 | ||
43 |
Backup(int oid, int vid = -1); |
|
44 | ||
45 |
Backup( |
|
46 |
int oid, |
|
47 |
int vid, |
|
48 |
string& bk_dir); |
|
49 | ||
50 |
~Backup(){}; |
|
51 | ||
52 |
/** |
|
53 |
* Function to write the Backup Record in an output stream |
|
54 |
*/ |
|
55 |
friend ostream& operator<<(ostream& os, const Backup& backup); |
|
56 | ||
57 |
/** |
|
58 |
* Function to print the Backup object into a string in |
|
59 |
* plain text |
|
60 |
* @param str the resulting string |
|
61 |
* @return a reference to the generated string |
|
62 |
*/ |
|
63 |
string& to_str(string& str) const; |
|
64 | ||
65 |
/** |
|
66 |
* Function to print the Backup object into a string in |
|
67 |
* XML format |
|
68 |
* @param xml the resulting XML string |
|
69 |
* @return a reference to the generated string |
|
70 |
*/ |
|
71 |
string& to_xml(string& xml) const; |
|
72 | ||
73 |
private: |
|
74 |
friend class VirtualMachine; |
|
75 |
friend class VirtualMachinePool; |
|
76 |
|
|
77 |
// ---------------------------------------- |
|
78 |
// DataBase implementation variables |
|
79 |
// ---------------------------------------- |
|
80 |
enum ColNames |
|
81 |
{ |
|
82 |
OID = 0, |
|
83 |
VID = 1, |
|
84 |
BK_DIR = 2, |
|
85 |
STATE = 3, |
|
86 |
STIME = 4, |
|
87 |
ETIME = 5 |
|
88 |
}; |
|
89 | ||
90 |
static const char * table; |
|
91 | ||
92 |
static const char * db_names; |
|
93 | ||
94 |
static const char * extended_db_names; |
|
95 | ||
96 |
static const char * db_bootstrap; |
|
97 | ||
98 |
|
|
99 | ||
100 |
static string column_name(const ColNames column) |
|
101 |
{ |
|
102 |
switch (column) |
|
103 |
{ |
|
104 |
case VID: |
|
105 |
return "vid"; |
|
106 |
case ETIME: |
|
107 |
return "etime"; |
|
108 |
case STIME: |
|
109 |
return "stime"; |
|
110 |
default: |
|
111 |
return ""; |
|
112 |
} |
|
113 |
} |
|
114 | ||
115 |
// ---------------------------------------- |
|
116 |
// Backup fields |
|
117 |
// ---------------------------------------- |
|
118 |
int oid; |
|
119 |
int vid; |
|
120 | ||
121 |
|
|
122 |
string bk_dir; |
|
123 | ||
124 |
BkState state; |
|
125 | ||
126 |
|
|
127 |
time_t stime; |
|
128 |
time_t etime; |
|
129 | ||
130 | ||
131 | ||
132 |
|
|
133 |
|
|
134 |
/** |
|
135 |
* Writes the backup record in the DB |
|
136 |
* @param db pointer to the database. |
|
137 |
* @return 0 on success. |
|
138 |
*/ |
|
139 |
int insert(SqlDB * db, string& error_str); |
|
140 | ||
141 |
/** |
|
142 |
* Reads the backup record from the DB |
|
143 |
* @param db pointer to the database. |
|
144 |
* @return 0 on success. |
|
145 |
*/ |
|
146 |
int select(SqlDB * db); |
|
147 | ||
148 |
/** |
|
149 |
* Updates the backup record |
|
150 |
* @param db pointer to the database. |
|
151 |
* @return 0 on success. |
|
152 |
*/ |
|
153 |
int update(SqlDB * db); |
|
154 | ||
155 |
/** |
|
156 |
* Removes the all backup records from the DB |
|
157 |
* @param db pointer to the database. |
|
158 |
* @return 0 on success. |
|
159 |
*/ |
|
160 |
int drop(SqlDB * db); |
|
161 | ||
162 |
/** |
|
163 |
* Execute an INSERT or REPLACE Sql query. |
|
164 |
* @param db The SQL DB |
|
165 |
* @param replace Execute an INSERT or a REPLACE |
|
166 |
* @return 0 on success |
|
167 |
*/ |
|
168 |
int insert_replace(SqlDB *db, bool replace); |
|
169 | ||
170 |
/** |
|
171 |
* Callback function to unmarshall a history object (History::select) |
|
172 |
* @param num the number of columns read from the DB |
|
173 |
* @para names the column names |
|
174 |
* @para vaues the column values |
|
175 |
* @return 0 on success |
|
176 |
*/ |
|
177 |
int select_cb(void *nil, int num, char **values, char **names); |
|
178 | ||
179 |
/** |
|
180 |
* Function to unmarshall a backup object into an output stream with XML |
|
181 |
* format. |
|
182 |
* @param oss the output stream |
|
183 |
* @param num the number of columns read from the DB |
|
184 |
* @param names the column names |
|
185 |
* @param vaues the column values |
|
186 |
* @return 0 on success |
|
187 |
*/ |
|
188 |
static int dump(ostringstream& oss, int num, char **names, char **values); |
|
189 |
}; |
|
190 | ||
191 |
#endif /*BACKUP_H_*/ |
|
192 |
opennebula-3.2.1-cmri/include/DispatchManager.h 2012-07-26 11:44:35.022337474 +0800 | ||
---|---|---|
117 | 117 |
* @param vm pointer to a VirtualMachine with its mutex locked. |
118 | 118 |
* @return 0 on success |
119 | 119 |
*/ |
120 |
|
|
121 |
/** |
|
122 |
* Backup a VM. The following actions must be performed before calling |
|
123 |
* this function: |
|
124 |
* - Lock the VM mutex. |
|
125 |
* - Add a new Backup record with the new host. |
|
126 |
* If the function fails the calling funtion is responsible for recovering |
|
127 |
* from the error. |
|
128 |
* @param vm pointer to a VirtualMachine with its mutex locked. |
|
129 |
* @return 0 on success |
|
130 |
*/ |
|
131 |
int backup( //added by CMRI&Neusoft author shenxy |
|
132 |
VirtualMachine * vm); |
|
133 | ||
134 |
/** |
|
135 |
* Recover a VM. The following actions must be performed before calling |
|
136 |
* this function: |
|
137 |
* - Lock the VM mutex. |
|
138 |
* - Add a new Recover record with the new host. |
|
139 |
* If the function fails the calling funtion is responsible for recovering |
|
140 |
* from the error. |
|
141 |
* @param vm pointer to a VirtualMachine with its mutex locked. |
|
142 |
* @return 0 on success |
|
143 |
*/ |
|
144 |
int recover( //added by CMRI&Neusoft author shenxy |
|
145 |
VirtualMachine * vm); |
|
146 | ||
147 |
/** |
|
148 |
* Backupdisk a VM. The following actions must be performed before calling |
|
149 |
* this function: |
|
150 |
* - Lock the VM mutex. |
|
151 |
* - Add a new Recover record with the new host. |
|
152 |
* If the function fails the calling funtion is responsible for recovering |
|
153 |
* from the error. |
|
154 |
* @param vm pointer to a VirtualMachine with its mutex locked. |
|
155 |
* @return 0 on success |
|
156 |
*/ |
|
157 |
int backupdisk( //added by CMRI&Neusoft author shenxy |
|
158 |
VirtualMachine * vm); |
|
159 | ||
160 |
|
|
120 | 161 |
int live_migrate( |
121 | 162 |
VirtualMachine * vm); |
122 | 163 | |
... | ... | |
165 | 206 |
int cancel( |
166 | 207 |
int vid); |
167 | 208 | |
209 |
//added by CMRI&Neusoft author shenxy 20120228 |
|
210 |
/** |
|
211 |
* Offs a VM. |
|
212 |
* @param vid VirtualMachine identification |
|
213 |
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is |
|
214 |
* in a wrong a state |
|
215 |
*/ |
|
216 |
int off( |
|
217 |
int vid); |
|
218 | ||
219 |
/** |
|
220 |
* Ons a VM. |
|
221 |
* @param vid VirtualMachine identification |
|
222 |
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is |
|
223 |
* in a wrong a state |
|
224 |
*/ |
|
225 |
int on( |
|
226 |
int vid); |
|
227 | ||
168 | 228 |
/** |
169 | 229 |
* Suspends a VM. |
170 | 230 |
* @param vid VirtualMachine identification |
opennebula-3.2.1-cmri/include/LifeCycleManager.h 2012-07-26 11:44:35.021335732 +0800 | ||
---|---|---|
51 | 51 |
SHUTDOWN_FAILURE, /**< Sent by the VMM when a shutdown action fails */ |
52 | 52 |
CANCEL_SUCCESS, /**< Sent by the VMM when a cancel action succeeds */ |
53 | 53 |
CANCEL_FAILURE, /**< Sent by the VMM when a cancel action fails */ |
54 |
OFF_SUCCESS, // ADDED BY CMRI&Neusoft author shenxy |
|
54 | 55 |
MONITOR_FAILURE, /**< Sent by the VMM when a VM has failed while active */ |
55 | 56 |
MONITOR_SUSPEND, /**< Sent by the VMM when a VM is paused while active */ |
56 | 57 |
MONITOR_DONE, /**< Sent by the VMM when a VM is not found */ |
... | ... | |
63 | 64 |
RESTORE, /**< Sent by the DM to restore a suspended VM */ |
64 | 65 |
STOP, /**< Sent by the DM to stop an running VM */ |
65 | 66 |
CANCEL, /**< Sent by the DM to cancel an running VM */ |
67 |
OFF, //ADDED BY CMRI&Neusoft author shenxy |
|
68 |
ON, |
|
69 |
XMLIST_SUCCESS, |
|
70 |
XMLIST_FAILURE, |
|
66 | 71 |
MIGRATE, /**< Sent by the DM to migrate a VM to other host */ |
72 |
BACKUP, //ADDED BY CMRI&Neusoft author shenxy |
|
73 |
RECOVER, |
|
74 |
BACKUPDISK, |
|
67 | 75 |
LIVE_MIGRATE, /**< Sent by the DM to live-migrate a VM */ |
68 | 76 |
SHUTDOWN, /**< Sent by the DM to shutdown a running VM */ |
69 | 77 |
RESTART, /**< Sent by the DM to restart a deployed VM */ |
70 | 78 |
REBOOT, /**< Sent by the DM to reboot a running VM */ |
71 | 79 |
DELETE, /**< Sent by the DM to delete a VM */ |
72 | 80 |
CLEAN, /**< Sent by the DM to cleanup a VM for resubmission*/ |
73 |
FINALIZE |
|
81 |
FINALIZE, |
|
82 |
PROLOG_RECOVER_DECOMPRESS //sent by the TM when prlog(recover) succeeds |
|
74 | 83 |
}; |
75 | 84 | |
76 | 85 |
/** |
... | ... | |
159 | 168 | |
160 | 169 |
void cancel_failure_action(int vid); |
161 | 170 | |
171 |
void off_success_action(int vid); //added by CMRI&Neusoft author shenxy |
|
172 | ||
173 |
void xmlist_success_action(int vid); //added by CMRI&Neusoft author shenxy |
|
174 | ||
175 |
void xmlist_failure_action(int vid); //added by CMRI&Neusoft author shenxy |
|
176 | ||
177 |
void prolog_recover_decompress_action(int vid); //added by CMRI&Neusoft author shenxy |
|
178 | ||
162 | 179 |
void monitor_failure_action(int vid); |
163 | 180 | |
164 | 181 |
void monitor_suspend_action(int vid); |
... | ... | |
183 | 200 | |
184 | 201 |
void cancel_action(int vid); |
185 | 202 | |
203 |
void off_action(int vid); //added by CMRI&Neusoft author shenxy |
|
204 | ||
205 |
void on_action(int vid); //added by CMRI&Neusoft author shenxy |
|
206 | ||
186 | 207 |
void checkpoint_action(int vid); |
187 | 208 | |
188 | 209 |
void migrate_action(int vid); |
189 | 210 | |
211 |
void backup_action(int vid); //added by CMRI&Neusoft author shenxy |
|
212 | ||
213 |
void recover_action(int vid); //added by CMRI&Neusoft author shenxy |
|
214 | ||
215 |
void backupdisk_action(int vid); //added by CMRI&Neusoft author shenxy |
|
216 | ||
190 | 217 |
void live_migrate_action(int vid); |
191 | 218 | |
192 | 219 |
void shutdown_action(int vid); |
opennebula-3.2.1-cmri/include/PoolObjectSQL.h 2012-07-26 11:44:35.025337235 +0800 | ||
---|---|---|
21 | 21 |
#include "ObjectXML.h" |
22 | 22 |
#include "Template.h" |
23 | 23 | |
24 |
#include "Attribute.h" |
|
25 | ||
24 | 26 |
#include <pthread.h> |
25 | 27 |
#include <string.h> |
26 | 28 | |
29 |
#include "NebulaLog.h" |
|
30 | ||
27 | 31 |
using namespace std; |
28 | 32 | |
29 | 33 |
class PoolObjectAuth; |
... | ... | |
329 | 333 |
return 0; |
330 | 334 |
} |
331 | 335 | |
336 |
/** |
|
337 |
* Adds a new attribute to the template (replacing it if |
|
338 |
* already defined), the object's mutex SHOULD be locked |
|
339 |
* @param name of the new attribute |
|
340 |
* @param value of the new attribute |
|
341 |
* @return 0 on success |
|
342 |
*/ |
|
343 |
int replace_template_xen_vcpu( //added by CMRI&Neusoft author shenxy 20120306 |
|
344 |
const string& value) |
|
345 |
{ |
|
346 |
vector<Attribute*> attrs; |
|
347 |
VectorAttribute * raw; |
|
348 |
string attribute_data; |
|
349 |
int position1,position2; |
|
350 |
|
|
351 |
obj_template->get("RAW",attrs); |
|
352 |
raw = dynamic_cast<VectorAttribute *>(attrs[0]); |
|
353 |
attribute_data = raw->vector_value("DATA"); |
|
354 | ||
355 |
//change attribute_data |
|
356 |
position1 =(int) attribute_data.find("vcpus"); |
|
357 |
position2 =(int) attribute_data.find("pae"); |
|
358 |
attribute_data.replace(position1+8, position2 - (position1+9) ,value); |
|
359 |
|
|
360 |
raw->replace("DATA",attribute_data); |
|
361 | ||
362 |
return 0; |
|
363 |
} |
|
364 | ||
365 |
int dymount_template_attribute( //added by CMRI&Neusoft author shenxy 20120413 |
|
366 |
const string& target, |
|
367 |
const string& source) |
|
368 |
{ |
|
369 |
if (source.empty()) //detach-disk |
|
370 |
{ |
|
371 |
vector<Attribute*> attrs; |
|
372 |
VectorAttribute * disk; |
|
373 |
string target_value; |
|
374 |
int i; |
|
375 | ||
376 |
int num = obj_template->remove("DISK",attrs); |
|
377 |
for ( i=0; i < num ;i++) //find the specified target |
|
378 |
{ |
|
379 |
disk = dynamic_cast<VectorAttribute *>(attrs[i]); |
|
380 | ||
381 |
target_value = disk->vector_value("TARGET"); |
|
382 |
NebulaLog::log("target_value is ", Log::INFO, target_value); |
|
383 |
if (target_value == target) |
|
384 |
{ |
|
385 |
NebulaLog::log("Test", Log::INFO, "have found target!!!"); |
|
386 |
|
|
387 |
attrs.erase(attrs.begin()+i); |
|
388 |
break; |
|
389 |
} |
|
390 |
} |
|
391 | ||
392 |
if( i == num ) |
|
393 |
{ |
|
394 |
NebulaLog::log("Test", Log::INFO, "no such target!!!"); |
|
395 |
} |
|
396 | ||
397 |
for(i=0; i<attrs.size();i++) |
|
398 |
{ |
|
399 |
disk = dynamic_cast<VectorAttribute *>(attrs[i]); |
|
400 |
obj_template->set(disk); |
|
401 |
} |
|
402 |
|
|
403 |
} |
|
404 |
else //attach-disk |
|
405 |
{ |
|
406 |
VectorAttribute * disk; |
|
407 | ||
408 |
disk = new VectorAttribute("DISK"); |
|
409 |
disk->replace("SOURCE_DM", source); |
|
410 |
disk->replace("TARGET", target); |
|
411 |
disk->replace("TYPE", "BLOCK"); |
|
412 | ||
413 |
obj_template->set(disk); |
|
414 |
} |
|
415 |
|
|
416 |
return 0; |
|
417 |
} |
|
418 | ||
332 | 419 |
/** |
333 | 420 |
* Generates a XML string for the template of the Object |
334 | 421 |
* @param xml the string to store the XML description. |
opennebula-3.2.1-cmri/include/PoolSQL.h 2012-07-26 11:44:35.028337720 +0800 | ||
---|---|---|
25 | 25 |
#include "PoolObjectSQL.h" |
26 | 26 |
#include "Log.h" |
27 | 27 |
#include "Hook.h" |
28 |
#include "Backup.h" |
|
29 |
#include "BackupDisk.h" |
|
30 | ||
28 | 31 | |
29 | 32 |
using namespace std; |
30 | 33 | |
... | ... | |
61 | 64 |
PoolObjectSQL *objsql, |
62 | 65 |
string& error_str); |
63 | 66 | |
67 |
//----------------------------------------------------added by CMRI&Neusoft author shenxy 20120227 |
|
68 |
/* Function to get VM backup recover info*/ |
|
69 |
virtual void bkstate(int oid); |
|
70 |
/* Function to init get VM backup recover info*/ |
|
71 |
int init_bkstate(void *nil, int num, char **values, char **names); |
|
72 | ||
73 | ||
74 |
//----------------------------------------------------added by CMRI&Neusoft author shenxy 20120228 |
|
75 |
/* Function to get VM backupdisk state info*/ |
|
76 |
virtual void dkstate(int oid); |
|
77 |
/* Function to init get VM backupdiskr info*/ |
|
78 |
int init_dkstate(void *nil, int num, char **values, char **names); |
|
79 |
|
|
80 | ||
81 |
//----------------------------------------------------added by CMRI&Neusoft author shenxy 20120229 |
|
82 |
/* Function to allocate a new VM backup object id,writting it in the pool database.*/ |
|
83 |
virtual int bkoid(); |
|
84 | ||
85 |
/* Callback to set the backup lastOID */ |
|
86 |
virtual void init_bkoid(); |
|
87 |
/* Callback to set the backup lastOID */ |
|
88 |
int init_bk(void *nil, int num, char **values, char **names); |
|
89 | ||
90 |
/* Function to update VM backup state*/ |
|
91 |
virtual void updatebkstate(int oid,Backup::BkState state); |
|
92 |
|
|
93 | ||
94 |
//-----------------------------------------------------added by CMRI&Neusoft author shenxy 20120301 |
|
95 |
/* Function to get VM backup id*/ |
|
96 |
virtual void getbid(int bid); |
|
97 |
/* Function to init get VM backup id*/ |
|
98 |
int init_getbid(void *nil, int num, char **values, char **names); |
|
99 | ||
100 |
/* Function to get VM backup url*/ |
|
101 |
virtual void bkdir(int oid); |
|
102 |
/* Function to init get VM backup url*/ |
|
103 |
int init_bkdir(void *nil, int num, char **values, char **names); |
|
104 |
|
|
105 | ||
106 |
//----------------------------------------------------added by CMRI&Neusoft author shenxy 20120302 |
|
107 |
/* Function to init get VM backupdisk id*/ |
|
108 |
virtual void init_dkoid(); |
|
109 |
/* Function to init get VM backupdisk id*/ |
|
110 |
int init_dk(void *nil, int num, char **values, char **names); |
|
111 | ||
112 |
/* Function to get VM backupdisk id*/ |
|
113 |
virtual int dkoid(); |
|
114 | ||
115 |
/* Function to update VM backupdisk state*/ |
|
116 |
virtual void updatedkstate(int oid,BackupDisk::DkState state); |
|
117 |
//------------------------------------------------------added by CMRI&Neusoft author shenxy |
|
118 | ||
119 |
|
|
120 | ||
64 | 121 |
/** |
65 | 122 |
* Gets an object from the pool (if needed the object is loaded from the |
66 | 123 |
* database). |
... | ... | |
210 | 267 |
update_lastOID(); |
211 | 268 |
}; |
212 | 269 | |
270 |
//added by CMRI&Neusoft author shenxy 20120227 |
|
271 |
/* Function to get VM backup recover info*/ |
|
272 |
int bkSTATE; |
|
273 | ||
274 |
/* Function to get VM backupdisk info*/ |
|
275 |
int dkSTATE; |
|
276 | ||
277 |
/* Function to check VM backup id*/ |
|
278 |
int checkgetbid; |
|
279 | ||
280 |
/* Function to VM backup url*/ |
|
281 |
string bkDIR; |
|
282 | ||
283 | ||
213 | 284 |
private: |
214 | 285 | |
215 | 286 |
pthread_mutex_t mutex; |
... | ... | |
226 | 297 |
* target pool. |
227 | 298 |
*/ |
228 | 299 |
int lastOID; |
300 |
|
|
301 |
/** |
|
302 |
* Last backup object ID |
|
303 |
*/ |
|
304 |
int bkOID; //added by CMRI&Neusoft author shenxy |
|
305 | ||
306 |
/** |
|
307 |
* Last backupdisk object ID |
|
308 |
*/ |
|
309 |
int dkOID; //added by CMRI&Neusoft author shenxy |
|
229 | 310 | |
230 | 311 |
/** |
231 | 312 |
* Tablename for this pool |
opennebula-3.2.1-cmri/include/Request.h 2012-07-26 11:44:35.026337649 +0800 | ||
---|---|---|
156 | 156 |
*/ |
157 | 157 |
void success_response(const string& val, RequestAttributes& att); |
158 | 158 | |
159 |
//added by CMRI&Neusoft author shenxy 20120227 |
|
160 |
/** |
|
161 |
* Builds an XML-RPC response updating retval. After calling this function |
|
162 |
* the xml-rpc excute method should return |
|
163 |
* @param val string to be returned to the client |
|
164 |
* @param oids stands for the number of VM on a specific status |
|
165 |
* @param att the specific request attributes |
|
166 |
*/ |
|
167 |
void success_response( |
|
168 |
const string& val, |
|
169 |
vector<int>& oids, |
|
170 |
RequestAttributes& att); |
|
171 | ||
159 | 172 |
/** |
160 | 173 |
* Builds an XML-RPC response updating retval. After calling this function |
161 | 174 |
* the xml-rpc excute method should return |
opennebula-3.2.1-cmri/include/RequestManagerPoolInfoFilter.h 2012-07-25 17:21:16.695333082 +0800 | ||
---|---|---|
62 | 62 |
int end_id, |
63 | 63 |
const string& and_clause, |
64 | 64 |
const string& or_clause); |
65 | ||
66 |
void get_statistic(RequestAttributes& att, |
|
67 |
int filter_flag, |
|
68 |
int start_id, |
|
69 |
int end_id, |
|
70 |
bool extended, |
|
71 |
int state, |
|
72 |
string lcm_state, |
|
73 |
bool returnxml, |
|
74 |
const string& and_clause, |
|
75 |
const string& or_clause); |
|
76 | ||
65 | 77 |
}; |
66 | 78 | |
67 | 79 |
/* ------------------------------------------------------------------------- */ |
... | ... | |
98 | 110 |
/* ------------------------------------------------------------------------- */ |
99 | 111 |
/* ------------------------------------------------------------------------- */ |
100 | 112 | |
113 |
class VirtualMachinePoolStatistic : public RequestManagerPoolInfoFilter |
|
114 |
{ |
|
115 |
public: |
|
116 |
/* -------------------------------------------------------------------- */ |
|
117 | ||
118 |
static const int ALL_VM; /**< VMs in any state (-2) */ |
|
119 |
static const int NOT_DONE; /**< VMs in any state expect DONE (-1)*/ |
|
120 | ||
121 |
/* -------------------------------------------------------------------- */ |
|
122 | ||
123 |
VirtualMachinePoolStatistic(): |
|
124 |
RequestManagerPoolInfoFilter("VirtualMachinePoolStatistic", |
|
125 |
"Returns the number of virtual machine on a specific status", |
|
126 |
"A:siiii") |
|
127 |
{ |
|
128 |
Nebula& nd = Nebula::instance(); |
|
129 |
pool = nd.get_vmpool(); |
|
130 |
auth_object = PoolObjectSQL::VM; |
|
131 |
}; |
|
132 | ||
133 |
~VirtualMachinePoolStatistic(){}; |
|
134 | ||
135 |
/* -------------------------------------------------------------------- */ |
|
136 | ||
137 |
void request_execute( |
|
138 |
xmlrpc_c::paramList const& paramList, RequestAttributes& att); |
|
139 |
}; |
|
140 | ||
141 |
/* ------------------------------------------------------------------------- */ |
|
142 |
/* ------------------------------------------------------------------------- */ |
|
143 | ||
101 | 144 |
class TemplatePoolInfo : public RequestManagerPoolInfoFilter |
102 | 145 |
{ |
103 | 146 |
public: |
opennebula-3.2.1-cmri/include/RequestManagerVirtualMachine.h 2012-07-26 11:44:35.032338124 +0800 | ||
---|---|---|
138 | 138 |
RequestAttributes& att); |
139 | 139 |
}; |
140 | 140 | |
141 |
//added by CMRI&Neusoft author shenxy 20120227 |
|
142 |
/* ------------------------------------------------------------------------- */ |
|
143 |
/* ------------------------------------------------------------------------- */ |
|
144 | ||
145 |
class VirtualMachineBackupInfo : public RequestManagerVirtualMachine |
|
146 |
{ |
|
147 |
public: |
|
148 |
VirtualMachineBackupInfo(): |
|
149 |
RequestManagerVirtualMachine("VirtualMachineAction", |
|
150 |
"Performs an action on a virtual machine", |
|
151 |
"A:ssi"){}; |
|
152 |
~VirtualMachineBackupInfo(){}; |
|
153 | ||
154 |
void request_execute(xmlrpc_c::paramList const& _paramList, |
|
155 |
RequestAttributes& att); |
|
156 |
}; |
|
157 | ||
158 |
/* ------------------------------------------------------------------------- */ |
|
159 |
/* ------------------------------------------------------------------------- */ |
|
160 | ||
161 |
class VirtualMachineBackupDelete : public RequestManagerVirtualMachine |
|
162 |
{ |
|
163 |
public: |
|
164 |
VirtualMachineBackupDelete(): |
|
165 |
RequestManagerVirtualMachine("VirtualMachineAction", |
|
166 |
"Performs an action on a virtual machine", |
|
167 |
"A:ssi"){}; |
|
168 |
~VirtualMachineBackupDelete(){}; |
|
169 | ||
170 |
void request_execute(xmlrpc_c::paramList const& _paramList, |
|
171 |
RequestAttributes& att); |
|
172 |
}; |
|
173 | ||
174 |
/* ------------------------------------------------------------------------- */ |
|
175 |
/* ------------------------------------------------------------------------- */ |
|
176 | ||
177 |
class VirtualMachineBackupDiskInfo : public RequestManagerVirtualMachine |
|
178 |
{ |
|
179 |
public: |
|
180 |
VirtualMachineBackupDiskInfo(): |
|
181 |
RequestManagerVirtualMachine("VirtualMachineAction", |
|
182 |
"Performs an action on a virtual machine", |
|
183 |
"A:ssi"){}; |
|
184 |
~VirtualMachineBackupDiskInfo(){}; |
|
185 | ||
186 |
void request_execute(xmlrpc_c::paramList const& _paramList, |
|
187 |
RequestAttributes& att); |
|
188 |
}; |
|
189 | ||
190 | ||
191 |
/* ------------------------------------------------------------------------- */ |
|
192 |
/* ------------------------------------------------------------------------- */ |
|
193 | ||
194 |
class VirtualMachineBackup: public RequestManagerVirtualMachine |
|
195 |
{ |
|
196 |
public: |
|
197 |
VirtualMachineBackup(): |
|
198 |
RequestManagerVirtualMachine("VirtualMachineDeploy", |
|
199 |
"Backup a virtual machine", |
|
200 |
"A:siib") |
|
201 |
{ |
|
202 |
auth_op = AuthRequest::ADMIN; |
|
203 |
}; |
|
204 | ||
205 |
~VirtualMachineBackup(){}; |
|
206 | ||
207 |
void request_execute(xmlrpc_c::paramList const& _paramList, |
|
208 |
RequestAttributes& att); |
|
209 |
}; |
|
210 | ||
211 |
/* ------------------------------------------------------------------------- */ |
|
212 |
/* ------------------------------------------------------------------------- */ |
|
213 | ||
214 |
class VirtualMachineRecover: public RequestManagerVirtualMachine |
|
215 |
{ |
|
216 |
public: |
|
217 |
VirtualMachineRecover(): |
|
218 |
RequestManagerVirtualMachine("VirtualMachineDeploy", |
|
219 |
"Recover a virtual machine", |
|
220 |
"A:siib") |
|
221 |
{ |
|
222 |
auth_op = AuthRequest::ADMIN; |
|
223 |
}; |
|
224 | ||
225 |
~VirtualMachineRecover(){}; |
|
226 | ||
227 |
void request_execute(xmlrpc_c::paramList const& _paramList, |
|
228 |
RequestAttributes& att); |
|
229 |
}; |
|
230 | ||
231 |
/* ------------------------------------------------------------------------- */ |
|
232 |
/* ------------------------------------------------------------------------- */ |
|
233 | ||
234 |
class VirtualMachineBackupDisk: public RequestManagerVirtualMachine |
|
235 |
{ |
|
236 |
public: |
|
237 |
VirtualMachineBackupDisk(): |
|
238 |
RequestManagerVirtualMachine("VirtualMachineDeploy", |
|
239 |
"BackupDisk a virtual machine", |
|
240 |
"A:siib") |
|
241 |
{ |
|
242 |
auth_op = AuthRequest::ADMIN; |
|
243 |
}; |
|
244 | ||
245 |
~VirtualMachineBackupDisk(){}; |
|
246 | ||
247 |
void request_execute(xmlrpc_c::paramList const& _paramList, |
|
248 |
RequestAttributes& att); |
|
249 |
}; |
|
250 | ||
251 |
/* ------------------------------------------------------------------------- */ |
|
252 |
/* ------------------------------------------------------------------------- */ |
|
253 | ||
254 |
class VirtualMachineChangeTemplate : public RequestManagerVirtualMachine |
|
255 |
{ |
|
256 |
public: |
|
257 |
VirtualMachineChangeTemplate(): |
|
258 |
RequestManagerVirtualMachine("VirtualMachineChangeTemplate", |
|
259 |
"change VM template", |
|
260 |
"A:sii") |
|
261 |
{ |
|
262 |
auth_op = AuthRequest::ADMIN; |
|
263 |
}; |
|
264 | ||
265 |
~VirtualMachineChangeTemplate(){}; |
|
266 | ||
267 |
void request_execute(xmlrpc_c::paramList const& _paramList, |
|
268 |
RequestAttributes& att); |
|
269 |
}; |
|
270 | ||
271 |
/* ------------------------------------------------------------------------- */ |
|
272 |
/* ------------------------------------------------------------------------- */ |
|
273 | ||
274 |
class VirtualMachineDynamicMount : public RequestManagerVirtualMachine |
|
275 |
{ |
|
276 |
public: |
|
277 |
VirtualMachineDynamicMount(): |
|
278 |
RequestManagerVirtualMachine("VirtualMachineDynamicMount", |
|
279 |
"dynamic mount a disc", |
|
280 |
"A:siib") |
|
281 |
{ |
|
282 |
auth_op = AuthRequest::ADMIN; |
|
283 |
}; |
|
284 | ||
285 |
~VirtualMachineDynamicMount(){}; |
|
286 | ||
287 |
void request_execute(xmlrpc_c::paramList const& _paramList, |
|
288 |
RequestAttributes& att); |
|
289 |
}; |
|
290 | ||
141 | 291 |
/* -------------------------------------------------------------------------- */ |
142 | 292 |
/* -------------------------------------------------------------------------- */ |
143 | 293 |
/* -------------------------------------------------------------------------- */ |
opennebula-3.2.1-cmri/include/TransferManager.h 2012-07-26 11:44:35.030337482 +0800 | ||
---|---|---|
49 | 49 |
PROLOG, |
50 | 50 |
PROLOG_MIGR, |
51 | 51 |
PROLOG_RESUME, |
52 |
PROLOG_BACKUP, //ADDED BY CMRI&Neusoft author shenxy |
|
53 |
PROLOG_RECOVER, //ADDED BY CMRI&Neusoft author shenxy |
|
54 |
PROLOG_BACKUPDISK, //ADDED BY CMRI&Neusoft author shenxy |
|
52 | 55 |
EPILOG, |
53 | 56 |
EPILOG_STOP, |
54 | 57 |
EPILOG_DELETE, |
55 | 58 |
EPILOG_DELETE_PREVIOUS, |
56 | 59 |
CHECKPOINT, |
57 | 60 |
DRIVER_CANCEL, |
58 |
FINALIZE |
|
61 |
DELETE_RECOVER_FAIL, |
|
62 |
DELETE_BACKUP_FAIL, |
|
63 |
DELETEBAK, |
|
64 |
FINALIZE, |
|
65 |
ON, //ADDED BY CMRI&Neusoft author shenxy |
|
66 |
DELETE_BACKUP_COMPRESS, //added by CMRI&Neusoft author shenxy 2012-04-23 |
|
67 |
PROLOG_RECOVER_DECOMPRESS, //added by CMRI&Neusoft author shenxy 2021-04-25 |
|
68 |
RECOVER_DECOMPRESS_FAIL |
|
59 | 69 |
}; |
60 | 70 | |
61 | 71 |
/** |
... | ... | |
94 | 104 |
return tm_thread; |
95 | 105 |
}; |
96 | 106 | |
107 |
//added by CMRI&Neusoft author shenxy 20120228 |
|
108 |
/** |
|
109 |
* This function used to delete the vm backup file |
|
110 |
*/ |
|
111 |
void delete_backup_action(string bkdir,int vid); |
|
112 | ||
113 | ||
97 | 114 |
private: |
98 | 115 |
/** |
99 | 116 |
* Thread id for the Transfer Manager |
... | ... | |
113 | 130 |
/** |
114 | 131 |
* Action engine for the Manager |
115 | 132 |
*/ |
116 |
ActionManager am;
|
|
133 |
ActionManager am;
|
|
117 | 134 | |
118 | 135 |
/** |
119 | 136 |
* Returns a pointer to a Transfer Manager driver. |
... | ... | |
165 | 182 |
*/ |
166 | 183 |
void prolog_action(int vid); |
167 | 184 | |
185 |
/** |
|
186 |
* This function starts the prolog xm list sequence |
|
187 |
*/ |
|
188 |
void prolog_on_action(int vid); //ADD BY CMRI&Neusoft author shenxy |
|
189 | ||
168 | 190 |
/** |
169 | 191 |
* This function starts the prolog migration sequence |
170 | 192 |
*/ |
... | ... | |
174 | 196 |
* This function starts the prolog resume sequence |
175 | 197 |
*/ |
176 | 198 |
void prolog_resume_action(int vid); |
177 |
|
|
199 | ||
200 |
/** |
|
201 |
* This function starts the prolog backup sequence |
|
202 |
*/ |
|
203 |
void prolog_backup_action(int vid); //added by CMRI&Neusoft author shenxy |
|
204 | ||
205 |
/** |
|
206 |
* This function starts the prolog recover sequence |
|
207 |
*/ |
|
208 |
void prolog_recover_action(int vid); //added by CMRI&Neusoft author shenxy |
|
209 | ||
210 |
/** |
|
211 |
* This function starts the prolog backupdisk sequence |
|
212 |
*/ |
|
213 |
void prolog_backupdisk_action(int vid); //added by CMRI&Neusoft author shenxy |
|
214 | ||
215 |
/** |
|
216 |
* This function delete the prolog recover fail backup |
|
217 |
*/ |
|
218 |
void delete_recover_fail_action(int vid); //added by CMRI&Neusoft author shenxy |
|
219 | ||
220 |
/** |
|
221 |
* This function delete the prolog recover fail backup |
|
222 |
*/ |
|
223 |
void recover_decompress_fail_action(int vid); //added by CMRI&Neusoft author shenxy |
|
224 | ||
225 |
/** |
|
226 |
* This function delete the prolog recover fail backup |
|
227 |
*/ |
|
228 |
void delete_backup_fail_action(int vid); //added by CMRI&Neusoft author shenxy |
|
229 | ||
230 |
/** |
|
231 |
* This function delete the prolog recover succeed backup |
|
232 |
*/ |
|
233 |
void epilog_deletebak_action(int vid); //added by CMRI&Neusoft author shenxy |
|
234 | ||
235 |
/** |
|
236 |
* This function starts the epilog_detelecps sequence |
|
237 |
*/ |
|
238 |
void epilog_deletecps_action(int vid); //added by CMRI&Neusoft author shenxy |
|
239 | ||
240 |
/** |
|
241 |
* This function starts the epilog_detelecps sequence |
|
242 |
*/ |
|
243 |
void epilog_decompress_action(int vid); //added by CMRI&Neusoft author shenxy |
|
244 | ||
178 | 245 |
/** |
179 | 246 |
* This function starts the epilog sequence |
180 | 247 |
*/ |
opennebula-3.2.1-cmri/include/VirtualMachine.h 2012-07-26 11:44:35.033337216 +0800 | ||
---|---|---|
20 | 20 |
#include "VirtualMachineTemplate.h" |
21 | 21 |
#include "PoolSQL.h" |
22 | 22 |
#include "History.h" |
23 |
#include "Backup.h" |
|
24 |
#include "BackupDisk.h" |
|
23 | 25 |
#include "Log.h" |
24 | 26 |
#include "NebulaLog.h" |
25 | 27 | |
... | ... | |
79 | 81 |
CANCEL = 13, |
80 | 82 |
FAILURE = 14, |
81 | 83 |
CLEANUP = 15, |
82 |
UNKNOWN = 16 |
|
84 |
UNKNOWN = 16, |
|
85 |
OFF = 17, |
|
86 |
OFF_BACKUP =18, |
|
87 |
PROLOG_BACKUP = 19, |
|
88 |
OFF_RECOVER = 20, //added by CMRI&Neusoft author shenxy |
|
89 |
PROLOG_RECOVER = 21, |
|
90 |
DELETEBAK = 22, |
|
91 |
DELETE_BACKUP_FAIL = 23, |
|
92 |
DELETE_RECOVER_FAIL = 24, |
|
93 |
OFF_BACKUPDISK =25, |
|
94 |
PROLOG_BACKUPDISK =26, |
|
95 |
ON = 28, |
|
96 |
DELETE_BACKUP_COMPRESS = 29, |
|
97 |
PROLOG_RECOVER_DECOMPRESS =30, |
|
98 |
RECOVER_DECOMPRESS_FAIL =31 |
|
83 | 99 |
}; |
84 | 100 | |
85 | 101 |
// ------------------------------------------------------------------------- |
... | ... | |
220 | 236 |
const string& vnm_mad, |
221 | 237 |
const string& tm_mad); |
222 | 238 | |
239 |
//-----------------------------------------------------added by CMRI&Neusoft author shenxy |
|
240 |
/** |
|
241 |
* Adds a new backup record an writes it in the database. |
|
242 |
*/ |
|
243 |
void add_backup( |
|
244 |
int oid, |
|
245 |
int vid, |
|
246 |
string& bk_dir, |
|
247 |
int * bid); |
|
248 | ||
249 |
/** |
|
250 |
* Sets the backup state that originated the VM backup state the previous host |
|
251 |
* @param _state backup state to leave this host |
|
252 |
*/ |
|
253 |
void set_bkstate(Backup::BkState _state) |
|
254 |
{ |
|
255 |
backup->state =_state; |
|
256 |
}; |
|
257 | ||
258 |
/** |
|
259 |
* Sets backup start time of a VM. |
|
260 |
* @param _stime time when the VM started |
|
261 |
*/ |
|
262 |
void set_bkstime(time_t _stime) |
|
263 |
{ |
|
264 |
backup->stime=_stime; |
|
265 |
}; |
|
266 | ||
267 |
/** |
|
268 |
* Sets backup end time of a VM. |
|
269 |
* @param _etime time when the VM finished |
|
270 |
*/ |
|
271 |
void set_bketime(time_t _etime) |
|
272 |
{ |
|
273 |
backup->etime=_etime; |
|
274 |
}; |
|
275 | ||
276 |
/** |
|
277 |
* Updates the VM backup record |
|
278 |
* @param db pointer to the db |
|
279 |
* @return 0 on success |
|
280 |
*/ |
|
281 |
int insert_backup(SqlDB * db) |
|
282 |
{ |
|
283 |
string error_str = "insert backup"; |
|
284 |
if ( backup != 0 ) |
|
285 |
{ |
|
286 |
return backup->insert(db,error_str); |
|
287 |
} |
|
288 |
else |
|
289 |
return -1; |
|
290 |
}; |
|
291 | ||
292 |
/** |
|
293 |
* Updates the VM backupdisk record |
|
294 |
* @param db pointer to the db |
|
295 |
* @return 0 on success |
|
296 |
*/ |
|
297 |
int insert_backupdisk(SqlDB * db) //added by CMRI&Neusoft author shenxy 20120302 |
|
298 |
{ |
|
299 |
string error_str = "insert backupdisk"; |
|
300 |
if ( backupdisk != 0 ) |
|
301 |
{ |
|
302 |
return backupdisk->insert(db,error_str); |
|
303 |
} |
|
304 |
else |
|
305 |
return -1; |
|
306 |
}; |
|
307 | ||
308 | ||
309 |
/** |
|
310 |
* Returns the VM backup url |
|
311 |
* function MUST be called before this one. |
|
312 |
* @return the VM backup url |
|
313 |
*/ |
|
314 |
const string & get_bk_dir() const |
|
315 |
{ |
|
316 |
return backup->bk_dir; |
|
317 |
}; |
|
318 | ||
319 |
/* Updates VM dynamic bakup information */ |
|
320 |
int update_backup(SqlDB * db) |
|
321 |
{ |
|
322 |
|
|
323 |
if ( backup != 0 ) |
|
324 |
{ |
|
325 |
return backup->update(db); |
|
326 |
} |
|
327 |
else |
|
328 |
return -1; |
|
329 |
}; |
|
330 | ||
331 | ||
332 |
//------------------------------------------------------------------- |
|
333 |
/** |
|
334 |
* Adds a new backupdisk record an writes it in the database. |
|
335 |
*/ |
|
336 |
void add_backupdisk( |
|
337 |
int oid, |
|
338 |
int vid, |
|
339 |
string& dk_name, |
|
340 |
string& dk_dir); |
|
341 | ||
342 |
/** |
|
343 |
* Sets the backupdisk state that originated the VM backup state the previous host |
|
344 |
* @param _state backupdisk state to leave this host |
|
345 |
*/ |
|
346 |
void set_dkstate(BackupDisk::DkState _state) |
|
347 |
{ |
|
348 |
backupdisk->state =_state; |
|
349 |
}; |
|
350 | ||
351 |
/* Updates VM dynamic bakupdisk information */ |
|
352 |
int update_backupdisk(SqlDB * db) |
|
353 |
{ |
|
354 |
if ( backupdisk != 0 ) |
|
355 |
{ |
|
356 |
return backupdisk->update(db); |
|
357 |
} |
|
358 |
else |
|
359 |
return -1; |
|
360 |
}; |
|
361 | ||
362 |
/** |
|
363 |
* Returns the VM backupdisk url |
|
364 |
* function MUST be called before this one. |
|
365 |
* @return the VM backupdisk url |
|
366 |
*/ |
|
367 |
const string & get_dk_dir() const |
|
368 |
{ |
|
369 |
return backupdisk->dk_dir; |
|
370 |
}; |
|
371 | ||
372 |
/** |
|
373 |
* Returns the VM backupdisk name |
|
374 |
* function MUST be called before this one. |
|
375 |
* @return the VM backupdisk name |
|
376 |
*/ |
|
377 |
const string & get_dk_name() const |
|
378 |
{ |
|
379 |
return backupdisk->dk_name; |
|
380 |
}; |
|
381 | ||
382 |
|
|
383 | ||
384 |
//-------------------------------------------------------------------- |
|
385 | ||
223 | 386 |
/** |
224 | 387 |
* Duplicates the last history record. Only the host related fields are |
225 | 388 |
* affected (i.e. no counter is copied nor initialized). |
... | ... | |
704 | 867 |
static void set_auth_request(int uid, |
705 | 868 |
AuthRequest& ar, |
706 | 869 |
VirtualMachineTemplate *tmpl); |
870 |
|
|
871 |
/** |
|
872 |
* Last VM backup id |
|
873 |
*/ |
|
874 |
int bakbid; //added by CMRI&Neusoft author shenxy |
|
875 | ||
876 |
/* VM recover url*/ |
|
877 |
string recover_dir; |
|
878 | ||
879 |
/* VM update backup state id*/ |
|
880 |
int updatebkstateoid; |
|
881 | ||
882 |
/* VM lcm state*/ |
|
883 |
LcmState lcmstate; |
|
884 | ||
885 |
/** |
|
886 |
* Last VM backupdisk id |
|
887 |
*/ |
|
888 |
int dkbid; //added by CMRI&Neusoft author shenxy |
|
889 | ||
890 | ||
707 | 891 |
private: |
708 | 892 | |
709 | 893 |
// ------------------------------------------------------------------------- |
... | ... | |
776 | 960 |
*/ |
777 | 961 |
History * history; |
778 | 962 | |
963 |
//added by CMRI&Neusoft author shenxy |
|
964 |
/** |
|
965 |
* Backup record, for the current host |
|
966 |
*/ |
|
967 |
Backup * backup; |
|
968 | ||
969 |
/** |
|
970 |
* Backupdisk record, for the current host |
|
971 |
*/ |
|
972 |
BackupDisk * backupdisk; |
|
973 | ||
779 | 974 |
/** |
780 | 975 |
* History record, for the previous host |
781 | 976 |
*/ |
... | ... | |
813 | 1008 | |
814 | 1009 |
ostringstream oss_vm(VirtualMachine::db_bootstrap); |
815 | 1010 |
ostringstream oss_hist(History::db_bootstrap); |
1011 |
//added by CMRI&Neusoft author shenxy |
|
1012 |
ostringstream oss_bist(Backup::db_bootstrap); |
|
1013 |
ostringstream oss_dist(BackupDisk::db_bootstrap); |
|
816 | 1014 | |
817 | 1015 |
rc = db->exec(oss_vm); |
818 | 1016 |
rc += db->exec(oss_hist); |
1017 |
//added by CMRI&Neusoft author shenxy |
|
1018 |
rc += db->exec(oss_bist); |
|
1019 |
rc += db->exec(oss_dist); |
|
819 | 1020 | |
820 | 1021 |
return rc; |
821 | 1022 |
}; |
opennebula-3.2.1-cmri/include/VirtualMachineManagerDriver.h 2012-07-25 17:21:16.694333194 +0800 | ||
---|---|---|
145 | 145 |
const int oid, |
146 | 146 |
const string& drv_msg) const; |
147 | 147 | |
148 |
/** |
|
149 |
* Sends a off request to the MAD: "OFF ID XML_DRV_MSG" |
|
150 |
* @param oid the virtual machine id. |
|
151 |
* @param drv_msg xml data for the mad operation |
|
152 |
*/ |
|
153 |
void off ( |
|
154 |
const int oid, |
|
155 |
const string& drv_msg) const; |
|
156 | ||
148 | 157 |
/** |
149 | 158 |
* Sends a checkpoint request to the MAD: "CHECKPOINT ID XML_DRV_MSG" |
150 | 159 |
* @param oid the virtual machine id. |
opennebula-3.2.1-cmri/include/VirtualMachineManager.h 2012-07-26 11:44:35.024337548 +0800 | ||
---|---|---|
48 | 48 |
SAVE, |
49 | 49 |
SHUTDOWN, |
50 | 50 |
CANCEL, |
51 |
OFF, //added by CMRI&Neusoft author shenxy |
|
51 | 52 |
CANCEL_PREVIOUS, |
52 | 53 |
MIGRATE, |
53 | 54 |
RESTORE, |
... | ... | |
55 | 56 |
POLL, |
56 | 57 |
TIMER, |
57 | 58 |
DRIVER_CANCEL, |
58 |
FINALIZE |
|
59 |
FINALIZE, |
|
60 |
ON, |
|
61 |
BACKUP, |
|
62 |
RECOVER, |
|
63 |
BACKUPDISK |
|
59 | 64 |
}; |
60 | 65 | |
61 | 66 |
/** |
... | ... | |
227 | 232 |
void save_action( |
228 | 233 |
int vid); |
229 | 234 | |
235 |
//-----------------------------------------added by CMRI&Neusoft author shenxy |
|
236 | ||
237 |
/** |
|
238 |
* Function to stop a running VM and generate a checkpoint file. This |
|
239 |
* function is executed when a BACKUP action is triggered. |
|
240 |
* @param vid the id of the VM. |
|
241 |
*/ |
|
242 |
void backup_action( |
|
243 |
int vid); |
|
244 | ||
245 |
/** |
|
246 |
* Function to recover backuped VM. This |
|
247 |
* function is executed when a RECOVER action is triggered. |
|
248 |
* @param vid the id of the VM. |
|
249 |
*/ |
|
250 |
void recover_action( |
|
251 |
int vid); |
|
252 | ||
253 |
/** |
|
254 |
* Function to backup VM's disk. This |
|
255 |
* function is executed when a RECOVER action is triggered. |
|
256 |
* @param vid the id of the VM. |
|
257 |
*/ |
|
258 |
void backupdisk_action( |
|
259 |
int vid); |
|
260 | ||
261 |
//--------------------------------------------------------- |
|
262 | ||
230 | 263 |
/** |
231 | 264 |
* Shutdowns a VM when a SHUTDOWN action is received. |
232 | 265 |
* @param vid the id of the VM. |
... | ... | |
242 | 275 |
int vid); |
243 | 276 | |
244 | 277 |
/** |
278 |
* Turn off a VM when a OFF action is received. |
|
279 |
* @param vid the id of the VM. |
|
280 |
*/ |
|
281 |
void off_action( |
|
282 |
int vid); |
|
283 | ||
284 |
/** |
|
285 |
* Ons a VM when a OFF action is received. |
|
286 |
* @param vid the id of the VM. |
|
287 |
*/ |
|
288 |
void on_action( |
|
289 |
int vid); |
|
290 | ||
291 |
/** |
|
245 | 292 |
* Cancels a VM (in the previous host) when a CANCEL action is received. |
246 | 293 |
* Note that the domain-id is the last one returned by a boot action |
247 | 294 |
* @param vid the id of the VM. |
opennebula-3.2.1-cmri/include/VirtualMachinePool.h 2012-07-26 11:44:35.029331625 +0800 | ||
---|---|---|
60 | 60 |
string& error_str, |
61 | 61 |
bool on_hold = false); |
62 | 62 | |
63 |
//added by CMRI&Neusoft author shenxy 20120227 |
|
64 |
/* Function to get backup recover info*/ |
|
65 |
void stateinfo(int oid ,int * state); |
|
66 | ||
67 |
//added by CMRI&Neusoft author shenxy 20120228 |
|
68 |
/* Function to get backupdisk info*/ |
|
69 |
void diskstateinfo(int oid,int* state); |
|
70 | ||
71 |
//-----------------------------------------added by CMRI&Neusoft author shenxy 20120229 |
|
72 |
/* Function to allocate a new VM backup object id*/ |
|
73 |
int bkoid(); |
|
74 | ||
75 |
/* Function to update VM backup state*/ |
|
76 |
void updatebkstate(int oid,Backup::BkState state); |
|
77 | ||
78 |
/* Function to update backup VM*/ |
|
79 |
int update_backup( |
|
80 |
VirtualMachine * vm) |
|
81 |
{ |
|
82 |
return vm->update_backup(db); |
|
83 |
} |
|
84 | ||
85 |
/* Function to check backup id*/ |
|
86 |
int checkbid(int bid); |
|
87 | ||
88 |
/* Function to get backup url*/ |
|
89 |
void bkdir(int oid,string* bkrecover); |
|
90 | ||
91 | ||
92 |
/* Function to update backupdisk VM*/ |
|
93 |
int update_backupdisk( |
|
94 |
VirtualMachine * vm) |
|
95 |
{ |
|
96 |
return vm->update_backupdisk(db); |