opennebula-update-hook.patch
include/Hook.h | ||
---|---|---|
164 | 164 |
|
165 | 165 |
/** |
166 | 166 |
* This class is general ObjectSQL Remove Hook that executes a command |
167 |
* when the ObjectSQL is inserted in the database.
|
|
167 |
* when the ObjectSQL is deleted from the database.
|
|
168 | 168 |
*/ |
169 | 169 |
class RemoveHook : public AllocateRemoveHook |
170 | 170 |
{ |
171 | 171 |
public: |
172 | 172 |
// ------------------------------------------------------------------------- |
173 |
// Init a hook of ALLOCATE type
|
|
173 |
// Init a hook of REMOVE type
|
|
174 | 174 |
// ------------------------------------------------------------------------- |
175 | 175 |
RemoveHook(const string& name, |
176 | 176 |
const string& cmd, |
... | ... | |
182 | 182 |
}; |
183 | 183 |
|
184 | 184 |
/** |
185 |
* This class is general ObjectSQL Update Hook that executes a command |
|
186 |
* when the ObjectSQL is updated from the database. |
|
187 |
*/ |
|
188 |
class UpdateHook : public AllocateRemoveHook |
|
189 |
{ |
|
190 |
public: |
|
191 |
// ------------------------------------------------------------------------- |
|
192 |
// Init a hook of UPDATE type |
|
193 |
// ------------------------------------------------------------------------- |
|
194 |
UpdateHook(const string& name, |
|
195 |
const string& cmd, |
|
196 |
const string& args, |
|
197 |
bool remote): |
|
198 |
AllocateRemoveHook(name, cmd, args, Hook::UPDATE, remote){}; |
|
199 |
|
|
200 |
virtual ~UpdateHook(){}; |
|
201 |
}; |
|
202 |
|
|
203 |
/** |
|
185 | 204 |
* Objects that inherits from hookable will allow others to hook into it. The |
186 | 205 |
* Hookable interface handles the list of hooks and provide a method to invoke |
187 | 206 |
* the hooks. |
src/pool/PoolSQL.cc | ||
---|---|---|
754 | 754 |
|
755 | 755 |
add_hook(hook); |
756 | 756 |
} |
757 |
else if ( on == "UPDATE" ) |
|
758 |
{ |
|
759 |
UpdateHook * hook; |
|
760 |
|
|
761 |
hook = new UpdateHook(name, cmd, arg, false); |
|
762 |
|
|
763 |
add_hook(hook); |
|
764 |
} |
|
757 | 765 |
} |
758 | 766 |
} |
759 |
- |