mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-22 17:57:46 +03:00
F #4393: New VirtualMachineDisk interface to abstract all disk
management logic. Adapted classes to new interface and re-allocated some functions. Work on disk resize operations.
This commit is contained in:
parent
bc45654203
commit
9297321d91
@ -23,6 +23,8 @@
|
||||
#include "Clusterable.h"
|
||||
#include "Image.h"
|
||||
|
||||
class VirtualMachineDisk;
|
||||
|
||||
/**
|
||||
* The Datastore class.
|
||||
*/
|
||||
@ -191,7 +193,7 @@ public:
|
||||
* into the disk
|
||||
*/
|
||||
void disk_attribute(
|
||||
VectorAttribute * disk,
|
||||
VirtualMachineDisk * disk,
|
||||
const vector<string>& inherit_attrs);
|
||||
|
||||
/**
|
||||
|
@ -185,7 +185,7 @@ public:
|
||||
*
|
||||
* @return -1 if the DS does not exists
|
||||
*/
|
||||
int disk_attribute(int ds_id, VectorAttribute * disk);
|
||||
int disk_attribute(int ds_id, VirtualMachineDisk * disk);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -65,7 +65,8 @@ public:
|
||||
DISK_SNAPSHOT_CREATE_ACTION = 25,
|
||||
DISK_SNAPSHOT_DELETE_ACTION = 26,
|
||||
TERMINATE_ACTION = 27,
|
||||
TERMINATE_HARD_ACTION = 28
|
||||
TERMINATE_HARD_ACTION = 28,
|
||||
DISK_RESIZE_ACTION = 29
|
||||
};
|
||||
|
||||
static string action_to_str(VMAction action)
|
||||
@ -149,6 +150,9 @@ public:
|
||||
case DISK_SNAPSHOT_DELETE_ACTION:
|
||||
st = "snap-delete";
|
||||
break;
|
||||
case DISK_RESIZE_ACTION:
|
||||
st = "disk-resize";
|
||||
break;
|
||||
case NONE_ACTION:
|
||||
st = "none";
|
||||
break;
|
||||
@ -259,6 +263,10 @@ public:
|
||||
{
|
||||
action = DISK_SNAPSHOT_DELETE_ACTION;
|
||||
}
|
||||
else if (st == "disk-resize")
|
||||
{
|
||||
action = DISK_RESIZE_ACTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
action = NONE_ACTION;
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
class VirtualMachineDisk;
|
||||
|
||||
/**
|
||||
* The Image class.
|
||||
*/
|
||||
@ -454,11 +456,10 @@ public:
|
||||
* into the disk
|
||||
*
|
||||
*/
|
||||
void disk_attribute(VectorAttribute * disk,
|
||||
ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
const vector<string>& inherit_attrs);
|
||||
|
||||
void disk_attribute(VirtualMachineDisk * disk,
|
||||
ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
const vector<string>& inherit_attrs);
|
||||
/**
|
||||
* Factory method for image templates
|
||||
*/
|
||||
|
@ -158,16 +158,15 @@ public:
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int acquire_disk( int vm_id,
|
||||
VectorAttribute * disk,
|
||||
int disk_id,
|
||||
Image::ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
int uid,
|
||||
int& image_id,
|
||||
Snapshots ** snaps,
|
||||
string& error_str);
|
||||
|
||||
int acquire_disk(int vm_id,
|
||||
VirtualMachineDisk * disk,
|
||||
int disk_id,
|
||||
Image::ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
int uid,
|
||||
int& image_id,
|
||||
Snapshots ** snaps,
|
||||
string& error_str);
|
||||
/**
|
||||
* Generates a DISK attribute for VM templates using the Image metadata
|
||||
*
|
||||
@ -176,17 +175,16 @@ public:
|
||||
* @param uid of VM owner (to look for the image id within its images)
|
||||
*
|
||||
*/
|
||||
void disk_attribute(VectorAttribute * disk,
|
||||
void disk_attribute(VirtualMachineDisk* disk,
|
||||
int disk_id,
|
||||
int uid);
|
||||
|
||||
/**
|
||||
* Generates an Authorization token for the DISK attribute
|
||||
* @param disk the disk to be authorized
|
||||
* @param uid of owner (to look for the image id within her images)
|
||||
* @param ar the AuthRequest
|
||||
*/
|
||||
void authorize_disk(VectorAttribute * disk, int uid, AuthRequest * ar);
|
||||
void authorize_disk(VirtualMachineDisk * disk, int uid, AuthRequest * ar);
|
||||
|
||||
static const string& default_type()
|
||||
{
|
||||
@ -203,31 +201,6 @@ public:
|
||||
return _default_cdrom_dev_prefix;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the effective uid to get an image. Used in VM parsers
|
||||
* @param disk a vector attribute with the image data
|
||||
* @param uid default uid
|
||||
* @return the uid to get the image;
|
||||
*/
|
||||
static int get_disk_uid(VectorAttribute * disk, int _uid);
|
||||
|
||||
/**
|
||||
* Gets the IDs of the images associated to a set of disks
|
||||
* @param dsk a vector with the DISK attributes
|
||||
* @param ids set of image ids
|
||||
* @param uid effective user id making the call
|
||||
*/
|
||||
void get_image_ids(vector<VectorAttribute *>& dsk, set<int>& ids, int uid);
|
||||
|
||||
/**
|
||||
* Gets the IDs of the images associated to a set of disks
|
||||
* @param disk DISK attribute
|
||||
* @param ids the image id, if found
|
||||
* @param uid effective user id making the call
|
||||
* @return 0 if the disk uses an image, -1 otherwise
|
||||
*/
|
||||
int get_image_id(VectorAttribute * disk, int &id, int uid);
|
||||
|
||||
private:
|
||||
//--------------------------------------------------------------------------
|
||||
// Configuration Attributes for Images
|
||||
|
@ -104,10 +104,13 @@ public:
|
||||
RESTART, /**< Sent by the DM to restart a deployed VM */
|
||||
DELETE, /**< Sent by the DM to delete a VM */
|
||||
DELETE_RECREATE, /**< Sent by the DM to cleanup a VM for resubmission*/
|
||||
FINALIZE,
|
||||
UPDATESG, /**< Sent by RM/VMM to trigger the secgroup update */
|
||||
DISK_LOCK_SUCCESS,/**< Sent by IM, image moves from locked to ready */
|
||||
DISK_LOCK_FAILURE,/**< Sent by IM, image moves from locked to error */
|
||||
UPDATESG, /**< Sent by RM/VMM to trigger the secgroup update*/
|
||||
DISK_LOCK_SUCCESS, /**< Sent by IM, image moves from locked to ready */
|
||||
DISK_LOCK_FAILURE, /**< Sent by IM, image moves from locked to error */
|
||||
DISK_RESIZE_SUCCESS,/**< Sent by TM/VMM when a disk resize succeeds */
|
||||
DISK_RESIZE_FAILURE,/**< Sent by TM/VMM when a disk resize fails */
|
||||
DISK_RESIZE, /**< Sent by DM to resize a disk */
|
||||
FINALIZE
|
||||
};
|
||||
|
||||
/**
|
||||
@ -309,6 +312,10 @@ private:
|
||||
|
||||
void disk_lock_failure(int vid);
|
||||
|
||||
void disk_resize_success(int vid);
|
||||
|
||||
void disk_resize_failure(int vid);
|
||||
|
||||
void deploy_action(int vid);
|
||||
|
||||
void suspend_action(int vid);
|
||||
|
@ -27,6 +27,8 @@ using namespace std;
|
||||
|
||||
extern "C" void * tm_action_loop(void *arg);
|
||||
|
||||
class VirtualMachineDisk;
|
||||
|
||||
class TransferManager : public MadManager, public ActionListener
|
||||
{
|
||||
public:
|
||||
@ -64,6 +66,7 @@ public:
|
||||
SNAPSHOT_CREATE,
|
||||
SNAPSHOT_REVERT,
|
||||
SNAPSHOT_DELETE,
|
||||
RESIZE,
|
||||
FINALIZE
|
||||
};
|
||||
|
||||
@ -118,7 +121,7 @@ public:
|
||||
*/
|
||||
int prolog_transfer_command(
|
||||
VirtualMachine * vm,
|
||||
const VectorAttribute * disk,
|
||||
const VirtualMachineDisk* disk,
|
||||
string& system_tm_mad,
|
||||
string& opennebula_hostname,
|
||||
ostream& xfr,
|
||||
@ -154,7 +157,7 @@ public:
|
||||
void epilog_transfer_command(
|
||||
VirtualMachine * vm,
|
||||
const string& host,
|
||||
const VectorAttribute * disk,
|
||||
const VirtualMachineDisk * disk,
|
||||
ostream& xfr);
|
||||
/**
|
||||
* Inserts a transfer command in the xfs stream, for live migration
|
||||
@ -191,6 +194,17 @@ public:
|
||||
int snapshot_transfer_command(VirtualMachine * vm,
|
||||
const char * snap_action,
|
||||
ostream& xfr);
|
||||
|
||||
/**
|
||||
* Inserts a resize command in the xfr stream
|
||||
* @param vm
|
||||
* @param disk to resize
|
||||
* @param xfr stream to include the command.
|
||||
*/
|
||||
void resize_command(
|
||||
VirtualMachine * vm,
|
||||
const VirtualMachineDisk * disk,
|
||||
ostream& xfr);
|
||||
private:
|
||||
/**
|
||||
* Thread id for the Transfer Manager
|
||||
@ -380,6 +394,11 @@ private:
|
||||
* This function deletes an snapshot of a disk
|
||||
*/
|
||||
void snapshot_delete_action(int vid);
|
||||
|
||||
/**
|
||||
* This function resizes a VM disk
|
||||
*/
|
||||
void resize_action(int vid);
|
||||
};
|
||||
|
||||
#endif /*TRANSFER_MANAGER_H*/
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define VIRTUAL_MACHINE_H_
|
||||
|
||||
#include "VirtualMachineTemplate.h"
|
||||
#include "VirtualMachineDisk.h"
|
||||
#include "VirtualMachineMonitorInfo.h"
|
||||
#include "PoolSQL.h"
|
||||
#include "History.h"
|
||||
@ -174,7 +175,9 @@ public:
|
||||
//DISK_SNAPSHOT_REVERT = 58,
|
||||
DISK_SNAPSHOT_DELETE = 59,
|
||||
PROLOG_MIGRATE_UNKNOWN = 60,
|
||||
PROLOG_MIGRATE_UNKNOWN_FAILURE = 61
|
||||
PROLOG_MIGRATE_UNKNOWN_FAILURE = 61,
|
||||
DISK_RESIZE = 62,
|
||||
DISK_RESIZE_POWEROFF = 63
|
||||
};
|
||||
|
||||
static int lcm_state_from_str(string& st, LcmState& state)
|
||||
@ -240,6 +243,8 @@ public:
|
||||
else if ( st == "DISK_SNAPSHOT_DELETE") { state = DISK_SNAPSHOT_DELETE; }
|
||||
else if ( st == "PROLOG_MIGRATE_UNKNOWN") { state = PROLOG_MIGRATE_UNKNOWN; }
|
||||
else if ( st == "PROLOG_MIGRATE_UNKNOWN_FAILURE") { state = PROLOG_MIGRATE_UNKNOWN_FAILURE; }
|
||||
else if ( st == "DISK_RESIZE") { state = DISK_RESIZE; }
|
||||
else if ( st == "DISK_RESIZE_POWEROFF") { state = DISK_RESIZE_POWEROFF; }
|
||||
else {return -1;}
|
||||
|
||||
return 0;
|
||||
@ -308,6 +313,8 @@ public:
|
||||
case DISK_SNAPSHOT_DELETE: st = "DISK_SNAPSHOT_DELETE"; break;
|
||||
case PROLOG_MIGRATE_UNKNOWN: st = "PROLOG_MIGRATE_UNKNOWN"; break;
|
||||
case PROLOG_MIGRATE_UNKNOWN_FAILURE: st = "PROLOG_MIGRATE_UNKNOWN_FAILURE"; break;
|
||||
case DISK_RESIZE: st = "DISK_RESIZE"; break;
|
||||
case DISK_RESIZE_POWEROFF: st = "DISK_RESIZE_POWEROFF"; break;
|
||||
}
|
||||
|
||||
return st;
|
||||
@ -1238,6 +1245,37 @@ public:
|
||||
*/
|
||||
int resize (float cpu, int memory, int vcpu, string& error_str);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Virtual Machine Disks
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* Get all disk images for this Virtual Machine
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 if success
|
||||
*/
|
||||
int get_disk_images(string &error_str);
|
||||
|
||||
/**
|
||||
* Releases all disk images taken by this Virtual Machine
|
||||
*/
|
||||
void release_disk_images();
|
||||
|
||||
/**
|
||||
* @return reference to the VirtualMachine disks
|
||||
*/
|
||||
VirtualMachineDisks& get_disks()
|
||||
{
|
||||
return disks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a pointer to the given disk
|
||||
*/
|
||||
VirtualMachineDisk * get_disk(int disk_id) const
|
||||
{
|
||||
return disks.get_disk(disk_id);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Network Leases & Disk Images
|
||||
// ------------------------------------------------------------------------
|
||||
@ -1274,21 +1312,6 @@ public:
|
||||
*/
|
||||
void remove_security_group(int sgid);
|
||||
|
||||
/**
|
||||
* Releases all disk images taken by this Virtual Machine
|
||||
*/
|
||||
void release_disk_images();
|
||||
|
||||
/**
|
||||
* Check if the given disk is volatile
|
||||
*/
|
||||
static bool is_volatile(const VectorAttribute * disk);
|
||||
|
||||
/**
|
||||
* Check if the disk is persistent
|
||||
*/
|
||||
static bool is_persistent(const VectorAttribute * disk);
|
||||
|
||||
/**
|
||||
* Check if the VM is imported
|
||||
*/
|
||||
@ -1306,31 +1329,11 @@ public:
|
||||
*/
|
||||
bool is_imported_action_supported(History::VMAction action) const;
|
||||
|
||||
/**
|
||||
* Return the total disk SIZE that the VM instance needs in the system DS
|
||||
*/
|
||||
static long long get_system_disk_size(Template * tmpl);
|
||||
|
||||
/**
|
||||
* Returns the disk CLONE_TARGET or LN_TARGET
|
||||
* @param disk
|
||||
* @return NONE, SYSTEM, SELF. Empty string if it could not be determined
|
||||
*/
|
||||
static string disk_tm_target(const VectorAttribute * disk);
|
||||
|
||||
/**
|
||||
* Returns the DISK attribute for a disk
|
||||
* @param disk_id of the DISK
|
||||
* @return pointer to the attribute ir null if not found
|
||||
*/
|
||||
const VectorAttribute* get_disk(int disk_id) const;
|
||||
|
||||
const VectorAttribute* get_nic(int nic_id) const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Virtual Router related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the Virtual Router ID if this VM is a VR, or -1
|
||||
* @return VR ID or -1
|
||||
@ -1343,7 +1346,6 @@ public:
|
||||
*/
|
||||
bool is_vrouter();
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Context related functions
|
||||
// ------------------------------------------------------------------------
|
||||
@ -1432,18 +1434,9 @@ public:
|
||||
AuthRequest& ar,
|
||||
VirtualMachineTemplate *tmpl);
|
||||
|
||||
/**
|
||||
* Adds extra info to the given template:
|
||||
* DISK/IMAGE_ID and SIZE
|
||||
* @param uid for template owner
|
||||
* @param tmpl the virtual machine template
|
||||
*/
|
||||
static void disk_extended_info(int uid,
|
||||
VirtualMachineTemplate *tmpl);
|
||||
// -------------------------------------------------------------------------
|
||||
// Hotplug related functions
|
||||
// Attach Disk Interface
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generate and attach a new DISK attribute to the VM. This method check
|
||||
* that the DISK is compatible with the VM cluster allocation and disk target
|
||||
@ -1460,31 +1453,70 @@ public:
|
||||
*
|
||||
* @return the disk waiting for an attachment action, or 0
|
||||
*/
|
||||
VectorAttribute* get_attach_disk();
|
||||
VirtualMachineDisk * get_attach_disk()
|
||||
{
|
||||
return disks.get_attach();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the ATTACH = YES attribute from the disks
|
||||
*/
|
||||
void clear_attach_disk();
|
||||
void clear_attach_disk()
|
||||
{
|
||||
disks.clear_attach();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the DISK that was in the process of being attached
|
||||
*
|
||||
* @return the DISK or 0 if no disk was deleted
|
||||
*/
|
||||
VectorAttribute * delete_attach_disk(Snapshots **snap);
|
||||
VirtualMachineDisk * delete_attach_disk()
|
||||
{
|
||||
return disks.delete_attach();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attach attribute to the given disk
|
||||
* @param disk_id of the DISK
|
||||
* @return 0 if the disk_id was found -1 otherwise
|
||||
*/
|
||||
int set_attach_disk(int disk_id);
|
||||
int set_attach_disk(int disk_id)
|
||||
{
|
||||
return disks.set_attach(disk_id);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Resize Disk Interface
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns the disk that is going to be resized
|
||||
*
|
||||
* @return the disk or 0 if not found
|
||||
*/
|
||||
VirtualMachineDisk * get_resize_disk()
|
||||
{
|
||||
return disks.get_resize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the RESIZE = YES attribute from the disks
|
||||
*/
|
||||
void clear_resize_disk(bool restore)
|
||||
{
|
||||
disks.clear_resize(restore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resize attribute to the given disk
|
||||
* @param disk_id of the DISK
|
||||
* @return 0 if the disk_id was found -1 otherwise
|
||||
*/
|
||||
int set_resize_disk(int disk_id);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// NIC Hotplug related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Generate and attach a new NIC attribute to the VM. This method check
|
||||
* that the NIC is compatible with the VM cluster allocation and fills SG
|
||||
@ -1529,16 +1561,18 @@ public:
|
||||
void detach_nic_failure();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Snapshot related functions
|
||||
// Disk Snapshot related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the snapshot list for the disk
|
||||
* @param disk_id of the disk
|
||||
* @param error if any
|
||||
* @return pointer to Snapshots or 0 if not found
|
||||
*/
|
||||
const Snapshots * get_disk_snapshots(int did, string& err) const;
|
||||
const Snapshots * get_disk_snapshots(int did, string& err) const
|
||||
{
|
||||
return disks.get_snapshots(did, err);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new snapshot of the given disk
|
||||
@ -1547,7 +1581,10 @@ public:
|
||||
* @param error if any
|
||||
* @return the id of the new snapshot or -1 if error
|
||||
*/
|
||||
int new_disk_snapshot(int disk_id, const string& name, string& error);
|
||||
int new_disk_snapshot(int disk_id, const string& name, string& error)
|
||||
{
|
||||
return disks.create_snapshot(disk_id, name, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the snap_id as active, the VM will boot from it next time
|
||||
@ -1556,7 +1593,10 @@ public:
|
||||
* @param error if any
|
||||
* @return -1 if error
|
||||
*/
|
||||
int revert_disk_snapshot(int disk_id, int snap_id);
|
||||
int revert_disk_snapshot(int disk_id, int snap_id)
|
||||
{
|
||||
return disks.revert_snapshot(disk_id, snap_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the snap_id from the list
|
||||
@ -1566,7 +1606,10 @@ public:
|
||||
* @param vm_quotas template with snapshot usage for the VM quotas
|
||||
*/
|
||||
void delete_disk_snapshot(int disk_id, int snap_id, Template **ds_quotas,
|
||||
Template **vm_quotas);
|
||||
Template **vm_quotas)
|
||||
{
|
||||
disks.delete_snapshot(disk_id, snap_id, ds_quotas, vm_quotas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all the disk snapshots for non-persistent disks and for persistent
|
||||
@ -1575,7 +1618,10 @@ public:
|
||||
* @param ds_quotas The DS SIZE freed from image datastores.
|
||||
*/
|
||||
void delete_non_persistent_disk_snapshots(Template **vm_quotas,
|
||||
map<int, Template *>& ds_quotas);
|
||||
map<int, Template *>& ds_quotas)
|
||||
{
|
||||
disks.delete_non_persistent_snapshots(vm_quotas, ds_quotas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about the disk to take the snapshot from
|
||||
@ -1585,23 +1631,32 @@ public:
|
||||
* @param snap_id of the snapshot
|
||||
*/
|
||||
int get_snapshot_disk(int& ds_id, string& tm_mad, int& disk_id,
|
||||
int& snap_id);
|
||||
int& snap_id)
|
||||
{
|
||||
return disks.get_active_snapshot(ds_id, tm_mad, disk_id, snap_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the current disk being snapshotted (reverted...)
|
||||
*/
|
||||
void clear_snapshot_disk();
|
||||
void clear_snapshot_disk()
|
||||
{
|
||||
disks.clear_active_snapshot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the disk as being snapshotted (reverted...)
|
||||
* @param disk_id of the disk
|
||||
* @param snap_id of the target snap_id
|
||||
*/
|
||||
int set_snapshot_disk(int disk_id, int snap_id);
|
||||
int set_snapshot_disk(int disk_id, int snap_id)
|
||||
{
|
||||
return disks.set_active_snapshot(disk_id, snap_id);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Snapshot related functions
|
||||
// System Snapshot related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a new Snapshot attribute, and sets it to ACTIVE=YES
|
||||
*
|
||||
@ -1648,23 +1703,31 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
// Cloning state related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if any of the disks is waiting for an image in LOCKED state
|
||||
* @return true if cloning
|
||||
*/
|
||||
bool has_cloning_disks();
|
||||
bool has_cloning_disks()
|
||||
{
|
||||
return disks.has_cloning();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image IDs for the disks waiting for the LOCKED state to finish
|
||||
* @param ids image ID set
|
||||
*/
|
||||
void get_cloning_image_ids(set<int>& ids);
|
||||
void get_cloning_image_ids(set<int>& ids)
|
||||
{
|
||||
disks.get_cloning_image_ids(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the flag for the disks waiting for the given image
|
||||
*/
|
||||
void clear_cloning_image_id(int image_id, const string& source);
|
||||
void clear_cloning_image_id(int image_id, const string& source)
|
||||
{
|
||||
disks.clear_cloning_image_id(image_id, source);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -1774,9 +1837,9 @@ private:
|
||||
vector<History *> history_records;
|
||||
|
||||
/**
|
||||
* Snapshots for each disk
|
||||
* VirtualMachine disks
|
||||
*/
|
||||
map<int, Snapshots *> snapshots;
|
||||
VirtualMachineDisks disks;
|
||||
|
||||
/**
|
||||
* User template to store custom metadata. This template can be updated
|
||||
@ -2085,24 +2148,6 @@ private:
|
||||
one_util::split_unique(nic->vector_value("SECURITY_GROUPS"), ',', sgs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all disk images for this Virtual Machine
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 if success
|
||||
*/
|
||||
int get_disk_images(string &error_str);
|
||||
|
||||
/**
|
||||
* Return the VectorAttribute representation of a disk
|
||||
* @param disk_id of the disk
|
||||
* @return pointer to the VectorAttribute
|
||||
*/
|
||||
VectorAttribute* get_disk(int disk_id)
|
||||
{
|
||||
return const_cast<VectorAttribute *>(
|
||||
static_cast<const VirtualMachine&>(*this).get_disk(disk_id));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the NIC that is waiting for an attachment action
|
||||
*
|
||||
@ -2113,7 +2158,6 @@ private:
|
||||
// ------------------------------------------------------------------------
|
||||
// Public cloud templates related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets the list of public clouds defined in this VM.
|
||||
* @param clouds list to store the cloud hypervisors in the template
|
||||
|
312
include/VirtualMachineAttribute.h
Normal file
312
include/VirtualMachineAttribute.h
Normal file
@ -0,0 +1,312 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef VIRTUAL_MACHINE_ATTRIBUTE_H_
|
||||
#define VIRTUAL_MACHINE_ATTRIBUTE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "Attribute.h"
|
||||
#include "Template.h"
|
||||
|
||||
/**
|
||||
* This class represents a generic VirtualMachine attribute, it exposes the
|
||||
* basic VectorAttribute interface and can be decorated with functionality
|
||||
* for an specific class, (e.g. disks or nics).
|
||||
*
|
||||
* The attribute operates directly on the VirtualMachineTemplate attribute. IT
|
||||
* IS NOT CLONED OR COPIED
|
||||
*/
|
||||
class VirtualMachineAttribute: public Attribute
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Return the associated VectorAttribute to interface with vector attribute
|
||||
* functions
|
||||
*/
|
||||
VectorAttribute * vector_attribute()
|
||||
{
|
||||
return va;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* VectorAttribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
template<typename T>
|
||||
int vector_value(const std::string& name, T& value) const
|
||||
{
|
||||
return va->vector_value(name, value);
|
||||
}
|
||||
|
||||
string vector_value(const std::string& name) const
|
||||
{
|
||||
return va->vector_value(name);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void replace(const std::string& name, T value)
|
||||
{
|
||||
va->replace(name, value);
|
||||
}
|
||||
|
||||
void remove(const std::string& name)
|
||||
{
|
||||
va->remove(name);
|
||||
}
|
||||
protected:
|
||||
/**
|
||||
* Creates the attribute with a reference to a VectorAttribute. The object
|
||||
* is shared and WILL BE modified through this interface.
|
||||
* @param va pointer to the VectorAttribute.
|
||||
*/
|
||||
VirtualMachineAttribute(VectorAttribute *_va):
|
||||
Attribute(_va->name()) ,va(_va), id(-1) {};
|
||||
|
||||
VirtualMachineAttribute(VectorAttribute *_va, int _id):
|
||||
Attribute(_va->name()) ,va(_va), id(_id) {};
|
||||
|
||||
virtual ~VirtualMachineAttribute(){};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Attribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
string * marshall(const char * _sep = 0) const
|
||||
{
|
||||
return va->marshall(_sep);
|
||||
};
|
||||
|
||||
string * to_xml() const
|
||||
{
|
||||
return va->to_xml();
|
||||
};
|
||||
|
||||
void unmarshall(const std::string& sattr, const char * _sep = 0)
|
||||
{
|
||||
va->unmarshall(sattr, _sep);
|
||||
}
|
||||
|
||||
AttributeType type()
|
||||
{
|
||||
return va->type();
|
||||
};
|
||||
|
||||
Attribute* clone() const
|
||||
{
|
||||
return va->clone();
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* VirtualMachineAttribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Sets the flag in the attribute in the form (FLAG="YES")
|
||||
*/
|
||||
void set_flag(const string& flag)
|
||||
{
|
||||
replace(flag, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears a previously set flag
|
||||
*/
|
||||
void clear_flag(const string& flag)
|
||||
{
|
||||
remove(flag);
|
||||
};
|
||||
|
||||
bool is_flag(const string& flag) const
|
||||
{
|
||||
bool value;
|
||||
|
||||
va->vector_value(flag, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int get_id() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
friend class VirtualMachineAttributeSet;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* The associated VectorAttribute
|
||||
*/
|
||||
VectorAttribute * va;
|
||||
|
||||
/**
|
||||
* Set if the attribute can be addressed by an identifier, -1 otherwise
|
||||
*/
|
||||
int id;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents a set of VirtualMachineAttributes it provides fast
|
||||
* access to individual elements (by ID) and implement collective operations
|
||||
*/
|
||||
class VirtualMachineAttributeSet
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* Creates the VirtualMachineAttribute set from the Template or vector with
|
||||
* all the attributes.
|
||||
* @param a_name the attribute name (e.g. "DISK")
|
||||
* @param id_name to search for attributes (e.g. "DISK_ID")
|
||||
*/
|
||||
VirtualMachineAttributeSet(const std::string a_name,
|
||||
const std::string& id_name, Template * tmpl);
|
||||
|
||||
VirtualMachineAttributeSet(const std::string& id_name,
|
||||
std::vector<VectorAttribute *>& vas, bool dispose);
|
||||
|
||||
VirtualMachineAttributeSet(bool _dispose):dispose(_dispose){};
|
||||
|
||||
virtual ~VirtualMachineAttributeSet();
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Methods to access attributes */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* @return attribute by id or 0 if not found
|
||||
*/
|
||||
VirtualMachineAttribute * get_attribute(int id) const;
|
||||
|
||||
/**
|
||||
* @return attribute with the given flag set or 0 if not found
|
||||
*/
|
||||
VirtualMachineAttribute * get_attribute(const string& flag) const;
|
||||
|
||||
/**
|
||||
* Deletes the attribute with the given flag set.
|
||||
* @return Pointer to the attribute or 0 if not found
|
||||
*/
|
||||
VirtualMachineAttribute * remove_attribute(const string& flag);
|
||||
|
||||
/**
|
||||
* Sets flag in a VirtualMachineAttribute
|
||||
* @param a_id of the attribute
|
||||
* @param flag_name
|
||||
* @return 0 on success
|
||||
*/
|
||||
int set_flag(int a_id, const string& flag_name);
|
||||
|
||||
/**
|
||||
* Clears the flag from the VirtualMachineAttributes in the set.
|
||||
* @return the attribute for which the flag was cleared, 0 if none
|
||||
*/
|
||||
VirtualMachineAttribute * clear_flag(const string& flag_name);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Iterators */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Generic iterator for the set. Wraps the STL iterator for map, can be
|
||||
* used to iterate over the attributes
|
||||
*/
|
||||
class AttributeIterator
|
||||
{
|
||||
public:
|
||||
AttributeIterator& operator=(const AttributeIterator& rhs)
|
||||
{
|
||||
map_it = rhs.map_it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AttributeIterator& operator++()
|
||||
{
|
||||
++map_it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator!=(const AttributeIterator& rhs)
|
||||
{
|
||||
return map_it != rhs.map_it;
|
||||
}
|
||||
|
||||
AttributeIterator(){};
|
||||
AttributeIterator(const AttributeIterator& ait):map_it(ait.map_it){};
|
||||
AttributeIterator(const std::map<int,
|
||||
VirtualMachineAttribute *>::iterator& _map_it):map_it(_map_it){};
|
||||
|
||||
virtual ~AttributeIterator(){};
|
||||
|
||||
protected:
|
||||
std::map<int, VirtualMachineAttribute *>::iterator map_it;
|
||||
};
|
||||
|
||||
AttributeIterator begin()
|
||||
{
|
||||
AttributeIterator it(a_set.begin());
|
||||
return it;
|
||||
}
|
||||
|
||||
AttributeIterator end()
|
||||
{
|
||||
AttributeIterator it(a_set.end());
|
||||
return it;
|
||||
}
|
||||
|
||||
typedef class AttributeIterator attribute_iterator;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Attribute map interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Adds a new VirtualMachine attribute to the set
|
||||
*/
|
||||
void add_attribute(VirtualMachineAttribute * a, int id)
|
||||
{
|
||||
a_set.insert(make_pair(id, a));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the attribute set from a vector
|
||||
* @param id_name with the ID of the attribute
|
||||
* @param auto_ids automatically generate ids for the attributes
|
||||
* @param vas vector of attribute to use
|
||||
*/
|
||||
void init_attribute_map(const std::string& id_name,
|
||||
std::vector<VectorAttribute *>& vas);
|
||||
/**
|
||||
* Abstract method to create the VirtualMachineAttributes for this set
|
||||
*/
|
||||
virtual VirtualMachineAttribute * attribute_factory(VectorAttribute * va,
|
||||
int id) const = 0;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Map with the disk attributes
|
||||
*/
|
||||
std::map<int, VirtualMachineAttribute *> a_set;
|
||||
|
||||
/**
|
||||
* Frees the VectorAttribute associated with each VirtualMachineAttribute
|
||||
* upon object destruction
|
||||
*/
|
||||
bool dispose;
|
||||
};
|
||||
|
||||
#endif /*VIRTUAL_MACHINE_ATTRIBUTE_H_*/
|
570
include/VirtualMachineDisk.h
Normal file
570
include/VirtualMachineDisk.h
Normal file
@ -0,0 +1,570 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef VIRTUAL_MACHINE_DISK_H_
|
||||
#define VIRTUAL_MACHINE_DISK_H_
|
||||
|
||||
#include <queue>
|
||||
#include <set>
|
||||
|
||||
#include "VirtualMachineAttribute.h"
|
||||
#include "Snapshots.h"
|
||||
|
||||
/**
|
||||
* The VirtualMachine DISK attribute
|
||||
*/
|
||||
class VirtualMachineDisk : public VirtualMachineAttribute
|
||||
{
|
||||
public:
|
||||
VirtualMachineDisk(VectorAttribute *va, int id):
|
||||
VirtualMachineAttribute(va, id), snapshots(0){};
|
||||
|
||||
virtual ~VirtualMachineDisk()
|
||||
{
|
||||
delete snapshots;
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* DISK get/set functions for boolean disk flags */
|
||||
/* ATTACH */
|
||||
/* RESIZE */
|
||||
/* CLONING */
|
||||
/* PERSISTENT */
|
||||
/* DISK_SNAPSHOT_ACTIVE */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
bool is_persistent() const
|
||||
{
|
||||
return is_flag("PERSISTENT");
|
||||
}
|
||||
|
||||
void set_attach()
|
||||
{
|
||||
set_flag("ATTACH");
|
||||
};
|
||||
|
||||
void set_resize()
|
||||
{
|
||||
set_flag("RESIZE");
|
||||
};
|
||||
|
||||
void clear_resize()
|
||||
{
|
||||
clear_flag("RESIZE");
|
||||
};
|
||||
|
||||
void clear_cloning()
|
||||
{
|
||||
clear_flag("CLONING");
|
||||
};
|
||||
|
||||
bool is_cloning() const
|
||||
{
|
||||
return is_flag("CLONING");
|
||||
}
|
||||
|
||||
void set_active_snapshot()
|
||||
{
|
||||
set_flag("DISK_SNAPSHOT_ACTIVE");
|
||||
};
|
||||
|
||||
void clear_active_snapshot()
|
||||
{
|
||||
set_flag("DISK_SNAPSHOT_ACTIVE");
|
||||
};
|
||||
|
||||
bool is_active_snapshot()
|
||||
{
|
||||
return is_flag("DISK_SNAPSHOT_ACTIVE");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Disk attributes, not accesible through vector_value */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Return the disk id ("DISK_ID")
|
||||
*/
|
||||
int get_disk_id() const
|
||||
{
|
||||
return get_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the "effective" target (LN_TARGET/CLONE_TARGET)
|
||||
*/
|
||||
string get_tm_target() const;
|
||||
|
||||
/**
|
||||
* Check if the given disk is volatile
|
||||
*/
|
||||
bool is_volatile() const;
|
||||
|
||||
/**
|
||||
* Get the effective uid to get an image. Used in VM parsers
|
||||
*/
|
||||
int get_uid(int _uid);
|
||||
|
||||
/**
|
||||
* Gets the ID of the image associated to the disks
|
||||
* @param id the image id, if found
|
||||
* @param uid effective user id making the call
|
||||
* @return 0 if the disk uses an image, -1 otherwise
|
||||
*/
|
||||
int get_image_id(int &id, int uid);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Image Manager Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Fills the disk extended information attributes
|
||||
*/
|
||||
void extended_info(int uid);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Snapshots Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Set the snapshots for this disks
|
||||
*/
|
||||
void set_snapshots(Snapshots * _snapshots)
|
||||
{
|
||||
snapshots = _snapshots;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the snapshots of this disk
|
||||
*/
|
||||
const Snapshots * get_snapshots() const
|
||||
{
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear snapshots from the disk and free resources
|
||||
*/
|
||||
void clear_snapshots()
|
||||
{
|
||||
snapshots->clear();
|
||||
|
||||
delete snapshots;
|
||||
|
||||
snapshots = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return total snapshot size (virtual) in mb
|
||||
*/
|
||||
long long get_total_snapshot_size() const
|
||||
{
|
||||
return snapshots->get_total_size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size (virtual) in mb of the given snapshot
|
||||
* @param id of the snapshot
|
||||
* @return size or 0 if not found
|
||||
*/
|
||||
long long get_snapshot_size(int snap_id) const
|
||||
{
|
||||
return snapshots->get_snapshot_size(snap_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the disk has snapshots
|
||||
*/
|
||||
bool has_snapshots()
|
||||
{
|
||||
return (snapshots != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new snapshot of the disk
|
||||
* @param name a description for this snapshot
|
||||
* @param error if any
|
||||
* @return the id of the new snapshot or -1 if error
|
||||
*/
|
||||
int create_snapshot(const string& name, string& error);
|
||||
|
||||
/**
|
||||
* Sets the snap_id as active, the VM will boot from it next time
|
||||
* @param snap_id of the snapshot
|
||||
* @return -1 if error
|
||||
*/
|
||||
int revert_snapshot(int snap_id);
|
||||
|
||||
/**
|
||||
* Deletes the snap_id from the list
|
||||
* @param snap_id of the snapshot
|
||||
* @param ds_quotas template with snapshot usage for the DS quotas
|
||||
* @param vm_quotas template with snapshot usage for the VM quotas
|
||||
*/
|
||||
void delete_snapshot(int snap_id, Template **ds_quota, Template **vm_quota);
|
||||
|
||||
private:
|
||||
|
||||
Snapshots * snapshots;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set of VirtualMachine DIKS
|
||||
*/
|
||||
class VirtualMachineDisks : public VirtualMachineAttributeSet
|
||||
{
|
||||
public:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Constructor and Initialization functions */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Creates the VirtualMachineDisk set from a Template with DISK=[...]
|
||||
* attributes, in this case the id's of each disk is auto assigned
|
||||
* @param tmpl template with DISK
|
||||
*/
|
||||
VirtualMachineDisks(Template * tmpl, bool has_id):
|
||||
VirtualMachineAttributeSet(DISK_NAME, id_name(has_id), tmpl){};
|
||||
|
||||
/**
|
||||
* Creates the VirtualMachineDisk set from a vector of DISK VectorAttribute
|
||||
* The DIKS need to have a DISK_ID assgined to create the disk set.
|
||||
* @param va vector of DISK Vector Attributes
|
||||
*/
|
||||
VirtualMachineDisks(vector<VectorAttribute *>& va, bool has_id, bool dispose):
|
||||
VirtualMachineAttributeSet(id_name(has_id), va, dispose){};
|
||||
|
||||
/**
|
||||
* Creates an empty disk set
|
||||
*/
|
||||
VirtualMachineDisks(bool dispose):
|
||||
VirtualMachineAttributeSet(dispose){};
|
||||
|
||||
virtual ~VirtualMachineDisks(){};
|
||||
|
||||
/**
|
||||
* Function used to initialize the attribute map based on a vector of DISK
|
||||
*/
|
||||
void init(std::vector<VectorAttribute *>& vas, bool has_id)
|
||||
{
|
||||
if ( has_id )
|
||||
{
|
||||
init_attribute_map(DISK_ID_NAME, vas);
|
||||
}
|
||||
else
|
||||
{
|
||||
init_attribute_map("", vas);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Iterators */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Generic iterator for the disk set.
|
||||
*/
|
||||
class DiskIterator : public AttributeIterator
|
||||
{
|
||||
public:
|
||||
DiskIterator():AttributeIterator(){};
|
||||
DiskIterator(const AttributeIterator& dit):AttributeIterator(dit){};
|
||||
virtual ~DiskIterator(){};
|
||||
|
||||
VirtualMachineDisk * operator*() const
|
||||
{
|
||||
return static_cast<VirtualMachineDisk *>(map_it->second);
|
||||
}
|
||||
};
|
||||
|
||||
DiskIterator begin()
|
||||
{
|
||||
DiskIterator it(VirtualMachineAttributeSet::begin());
|
||||
return it;
|
||||
}
|
||||
|
||||
DiskIterator end()
|
||||
{
|
||||
DiskIterator it(VirtualMachineAttributeSet::end());
|
||||
return it;
|
||||
}
|
||||
|
||||
typedef class DiskIterator disk_iterator;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* DISK interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Returns the DISK attribute for a disk
|
||||
* @param disk_id of the DISK
|
||||
* @return pointer to the attribute ir null if not found
|
||||
*/
|
||||
VirtualMachineDisk * get_disk(int disk_id) const
|
||||
{
|
||||
return static_cast<VirtualMachineDisk*>(get_attribute(disk_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the storage needed in the system datastore. The static version
|
||||
* uses the disk definitions in the template (first argument)
|
||||
* @return the total disk SIZE that the VM instance needs in the system DS
|
||||
*/
|
||||
long long system_ds_size();
|
||||
|
||||
static long long system_ds_size(Template * ds_tmpl);
|
||||
|
||||
/**
|
||||
* Completes the information of the disks (IMAGE_ID, SIZE...)
|
||||
*/
|
||||
void extended_info(int uid);
|
||||
|
||||
static void extended_info(int uid, Template * tmpl);
|
||||
|
||||
/**
|
||||
* Sets Datastore information on volatile disks
|
||||
*/
|
||||
bool volatile_info(int ds_id);
|
||||
|
||||
/**
|
||||
* @return the total disk SIZE that the VM instance needs in the system DS
|
||||
*/
|
||||
void image_ds_size(std::map<int, long long>& ds_size) const;
|
||||
|
||||
/**
|
||||
* Gets the IDs of the images associated to the disk set
|
||||
* @param ids set of image ids
|
||||
* @param uid effective user id making the call
|
||||
*/
|
||||
void get_image_ids(set<int>& ids, int uid);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Image Manager Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Get all disk images for this Virtual Machine
|
||||
* @param vm_id of the VirtualMachine
|
||||
* @param uid of owner
|
||||
* @param disks list of DISK Attribute in VirtualMachine Template
|
||||
* @param context attribute, 0 if none
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 if success
|
||||
*/
|
||||
int get_images(int vm_id, int uid, vector<Attribute *> disks,
|
||||
VectorAttribute * context, std::string& error_str);
|
||||
|
||||
/**
|
||||
* Release the images in the disk set
|
||||
* @param vmid id of VM
|
||||
* @param image_error true if the image has to be set in error state
|
||||
*/
|
||||
void release_images(int vmid, bool image_error);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* DISK cloning functions */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Returns true if any of the disks is waiting for an image in LOCKED state
|
||||
* to become READY
|
||||
* @return true if cloning
|
||||
*/
|
||||
bool has_cloning();
|
||||
|
||||
/**
|
||||
* Returns the image IDs for the disks waiting for the LOCKED state be READY
|
||||
* @param ids image ID set
|
||||
*/
|
||||
void get_cloning_image_ids(std::set<int>& ids);
|
||||
|
||||
/**
|
||||
* Clears the flag for the disks waiting for the given image
|
||||
*/
|
||||
void clear_cloning_image_id(int image_id, const string& source);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Attach disk Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Sets the attach attribute to the given disk
|
||||
* @param disk_id of the DISK
|
||||
* @return 0 if the disk_id was found -1 otherwise
|
||||
*/
|
||||
int set_attach(int disk_id);
|
||||
|
||||
/**
|
||||
* Cleans the attach attribute from the disk
|
||||
*/
|
||||
void clear_attach()
|
||||
{
|
||||
clear_flag("ATTACH");
|
||||
}
|
||||
|
||||
VirtualMachineDisk * delete_attach()
|
||||
{
|
||||
return static_cast<VirtualMachineDisk *>(remove_attribute("ATTACH"));
|
||||
}
|
||||
|
||||
VirtualMachineDisk * get_attach()
|
||||
{
|
||||
return static_cast<VirtualMachineDisk *>(get_attribute("ATTACH"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a disk to be attached to the virtual machine and adds it to the
|
||||
* disk set. It checks target assigment and cluster compatibility.
|
||||
* @param vmid id of virtual machine
|
||||
* @param uid of VM owner
|
||||
* @param cluster_id where the VM is running
|
||||
* @param vdisk VectorAttribute for the new disk
|
||||
* @param vcontext VectorAttribute for the CONTEXT disk, 0 if none
|
||||
* @param error
|
||||
*
|
||||
* @return Pointer to the new disk or 0 in case of error
|
||||
*/
|
||||
VirtualMachineDisk * set_up_attach(int vmid, int uid, int cluster_id,
|
||||
VectorAttribute * vdisk, VectorAttribute * vcontext, string& error);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Resize disk Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Sets the resize attribute to the given disk
|
||||
* @param disk_id of the DISK
|
||||
* @return 0 if the disk_id was found -1 otherwise
|
||||
*/
|
||||
int set_resize(int disk_id);
|
||||
|
||||
/**
|
||||
* Cleans the resize attribute from the disk
|
||||
* @param restore the previous size
|
||||
*/
|
||||
void clear_resize(bool restore);
|
||||
|
||||
VirtualMachineDisk * delete_resize()
|
||||
{
|
||||
return static_cast<VirtualMachineDisk *>(remove_attribute("RESIZE"));
|
||||
}
|
||||
|
||||
VirtualMachineDisk * get_resize()
|
||||
{
|
||||
return static_cast<VirtualMachineDisk *>(get_attribute("RESIZE"));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* SNAPSHOT interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Set the snapshots for a disk
|
||||
* @param id of disk
|
||||
* @param snapshots of disk;
|
||||
*/
|
||||
void set_snapshots(int id, Snapshots * snapshots);
|
||||
|
||||
/**
|
||||
* Return the snapshots for the disk
|
||||
*/
|
||||
const Snapshots * get_snapshots(int id, string& error) const;
|
||||
|
||||
/**
|
||||
* Set the disk as being snapshotted (reverted...)
|
||||
* @param disk_id of the disk
|
||||
* @param snap_id of the target snap_id
|
||||
*/
|
||||
int set_active_snapshot(int id, int snap_id);
|
||||
|
||||
/**
|
||||
* Unset the current disk being snapshotted (reverted...)
|
||||
*/
|
||||
void clear_active_snapshot();
|
||||
|
||||
/**
|
||||
* Get information about the disk to take the snapshot from
|
||||
* @param ds_id id of the datastore
|
||||
* @param tm_mad used by the datastore
|
||||
* @param disk_id of the disk
|
||||
* @param snap_id of the snapshot
|
||||
*/
|
||||
int get_active_snapshot(int& ds_id, string& tm_mad, int& disk_id,
|
||||
int& snap_id);
|
||||
/**
|
||||
* Creates a new snapshot of the given disk
|
||||
* @param disk_id of the disk
|
||||
* @param name a description for this snapshot
|
||||
* @param error if any
|
||||
* @return the id of the new snapshot or -1 if error
|
||||
*/
|
||||
int create_snapshot(int disk_id, const string& name, string& error);
|
||||
|
||||
/**
|
||||
* Sets the snap_id as active, the VM will boot from it next time
|
||||
* @param disk_id of the disk
|
||||
* @param snap_id of the snapshot
|
||||
* @return -1 if error
|
||||
*/
|
||||
int revert_snapshot(int disk_id, int snap_id);
|
||||
|
||||
/**
|
||||
* Deletes the snap_id from the list
|
||||
* @param disk_id of the disk
|
||||
* @param snap_id of the snapshot
|
||||
* @param ds_quotas template with snapshot usage for the DS quotas
|
||||
* @param vm_quotas template with snapshot usage for the VM quotas
|
||||
*/
|
||||
void delete_snapshot(int disk_id, int snap_id, Template **ds_quota,
|
||||
Template **vm_quota);
|
||||
|
||||
/**
|
||||
* Deletes all the disk snapshots for non-persistent disks and for persistent
|
||||
* disks in no shared system ds.
|
||||
* @param vm_quotas The SYSTEM_DISK_SIZE freed by the deleted snapshots
|
||||
* @param ds_quotas The DS SIZE freed from image datastores.
|
||||
*/
|
||||
void delete_non_persistent_snapshots(Template **vm_quotas,
|
||||
map<int, Template *>& ds_quotas);
|
||||
|
||||
protected:
|
||||
|
||||
VirtualMachineAttribute * attribute_factory(VectorAttribute * va,
|
||||
int id) const
|
||||
{
|
||||
return new VirtualMachineDisk(va, id);
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
static const char * DISK_NAME; //"DISK"
|
||||
|
||||
static const char * DISK_ID_NAME; //"DISK_ID"
|
||||
|
||||
/**
|
||||
* Finds the first free target to assign to a disk
|
||||
* @param dqueue queue of disks to assign target, each disk is associated
|
||||
* with its bus (DEV_PREFIX)
|
||||
* @param used_targets that cannot be used
|
||||
*/
|
||||
void assign_disk_targets(
|
||||
std::queue<pair <std::string, VirtualMachineDisk *> >& dqueue,
|
||||
std::set<std::string>& used_targets);
|
||||
|
||||
static const char * id_name(bool has_id)
|
||||
{
|
||||
if (has_id)
|
||||
{
|
||||
return DISK_ID_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*VIRTUAL_MACHINE_DISK_H_*/
|
||||
|
@ -101,20 +101,17 @@ int Datastore::enable(bool enable, string& error_str)
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void Datastore::disk_attribute(
|
||||
VectorAttribute * disk,
|
||||
VirtualMachineDisk * disk,
|
||||
const vector<string>& inherit_attrs)
|
||||
{
|
||||
ostringstream oss;
|
||||
string st;
|
||||
string inherit_val;
|
||||
string current_val;
|
||||
|
||||
vector<string>::const_iterator it;
|
||||
|
||||
oss << oid;
|
||||
|
||||
disk->replace("DATASTORE", get_name());
|
||||
disk->replace("DATASTORE_ID", oss.str());
|
||||
disk->replace("DATASTORE_ID", oid);
|
||||
disk->replace("TM_MAD", get_tm_mad());
|
||||
|
||||
set<int> cluster_ids = get_cluster_ids();
|
||||
@ -146,7 +143,7 @@ void Datastore::disk_attribute(
|
||||
}
|
||||
}
|
||||
|
||||
if (VirtualMachine::is_volatile(disk))
|
||||
if (disk->is_volatile())
|
||||
{
|
||||
disk->replace("DISK_TYPE", Image::disk_type_to_str(get_disk_type()));
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ int DatastorePool::drop(PoolObjectSQL * objsql, string& error_msg)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DatastorePool::disk_attribute(int ds_id, VectorAttribute * disk)
|
||||
int DatastorePool::disk_attribute(int ds_id, VirtualMachineDisk * disk)
|
||||
{
|
||||
Datastore * ds = get(ds_id, true);
|
||||
|
||||
|
@ -462,10 +462,10 @@ int Image::from_xml(const string& xml)
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void Image::disk_attribute( VectorAttribute * disk,
|
||||
ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
const vector<string>& inherit_attrs)
|
||||
void Image::disk_attribute(VirtualMachineDisk * disk,
|
||||
ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
const vector<string>& inherit_attrs)
|
||||
{
|
||||
string target;
|
||||
string driver;
|
||||
@ -520,15 +520,12 @@ void Image::disk_attribute( VectorAttribute * disk,
|
||||
//--------------------------------------------------------------------------
|
||||
// BASE DISK ATTRIBUTES
|
||||
//--------------------------------------------------------------------------
|
||||
disk->replace("IMAGE", name);
|
||||
disk->replace("IMAGE", name);
|
||||
disk->replace("IMAGE_ID", oid);
|
||||
disk->replace("SOURCE", source);
|
||||
disk->replace("SOURCE", source);
|
||||
disk->replace("ORIGINAL_SIZE", size_mb);
|
||||
|
||||
if ( disk->vector_value("SIZE", size) == 0 && size != size_mb)
|
||||
{
|
||||
disk->replace("ORIGINAL_SIZE", size_mb);
|
||||
}
|
||||
else
|
||||
if ( disk->vector_value("SIZE").empty() )
|
||||
{
|
||||
disk->replace("SIZE", size_mb);
|
||||
}
|
||||
|
@ -289,53 +289,8 @@ error_common:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int ImagePool::get_disk_uid(VectorAttribute * disk, int _uid)
|
||||
{
|
||||
istringstream is;
|
||||
|
||||
string uid_s ;
|
||||
string uname;
|
||||
int uid;
|
||||
|
||||
if (!(uid_s = disk->vector_value("IMAGE_UID")).empty())
|
||||
{
|
||||
is.str(uid_s);
|
||||
is >> uid;
|
||||
|
||||
if( is.fail() )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (!(uname = disk->vector_value("IMAGE_UNAME")).empty())
|
||||
{
|
||||
User * user;
|
||||
Nebula& nd = Nebula::instance();
|
||||
UserPool * upool = nd.get_upool();
|
||||
|
||||
user = upool->get(uname,true);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
uid = user->get_oid();
|
||||
|
||||
user->unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
uid = _uid;
|
||||
}
|
||||
|
||||
return uid;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int ImagePool::acquire_disk(int vm_id,
|
||||
VectorAttribute * disk,
|
||||
VirtualMachineDisk * disk,
|
||||
int disk_id,
|
||||
Image::ImageType& img_type,
|
||||
string& dev_prefix,
|
||||
@ -368,7 +323,7 @@ int ImagePool::acquire_disk(int vm_id,
|
||||
}
|
||||
else if ( disk->vector_value("IMAGE", source) == 0 )
|
||||
{
|
||||
int uiid = get_disk_uid(disk,uid);
|
||||
int uiid = disk->get_uid(uid);
|
||||
|
||||
if ( uiid == -1)
|
||||
{
|
||||
@ -510,7 +465,7 @@ int ImagePool::acquire_disk(int vm_id,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void ImagePool::disk_attribute(
|
||||
VectorAttribute * disk,
|
||||
VirtualMachineDisk* disk,
|
||||
int disk_id,
|
||||
int uid)
|
||||
{
|
||||
@ -533,7 +488,7 @@ void ImagePool::disk_attribute(
|
||||
}
|
||||
else if ( disk->vector_value("IMAGE", source) == 0 )
|
||||
{
|
||||
int uiid = get_disk_uid(disk, uid);
|
||||
int uiid = disk->get_uid(uid);
|
||||
|
||||
if ( uiid != -1)
|
||||
{
|
||||
@ -558,7 +513,7 @@ void ImagePool::disk_attribute(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void ImagePool::authorize_disk(VectorAttribute * disk,int uid, AuthRequest * ar)
|
||||
void ImagePool::authorize_disk(VirtualMachineDisk* disk,int uid,AuthRequest* ar)
|
||||
{
|
||||
string source;
|
||||
Image * img = 0;
|
||||
@ -569,7 +524,7 @@ void ImagePool::authorize_disk(VectorAttribute * disk,int uid, AuthRequest * ar)
|
||||
|
||||
if ( disk->vector_value("IMAGE", source) == 0 )
|
||||
{
|
||||
int uiid = get_disk_uid(disk,uid);
|
||||
int uiid = disk->get_uid(uid);
|
||||
|
||||
if ( uiid == -1)
|
||||
{
|
||||
@ -600,60 +555,3 @@ void ImagePool::authorize_disk(VectorAttribute * disk,int uid, AuthRequest * ar)
|
||||
ar->add_auth(AuthRequest::USE, perm);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void ImagePool::get_image_ids(vector<VectorAttribute *>& disks, set<int>& ids,
|
||||
int uid)
|
||||
{
|
||||
vector<VectorAttribute *>::iterator i;
|
||||
|
||||
int id;
|
||||
|
||||
for ( i = disks.begin() ; i != disks.end(); ++i )
|
||||
{
|
||||
if ( get_image_id(*i, id, uid) == 0 )
|
||||
{
|
||||
ids.insert(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int ImagePool::get_image_id(VectorAttribute * disk, int &id, int uid)
|
||||
{
|
||||
int iid;
|
||||
string iname;
|
||||
|
||||
Image * img = 0;
|
||||
|
||||
if ( disk->vector_value("IMAGE_ID", iid) == 0 )
|
||||
{
|
||||
id = iid;
|
||||
return 0;
|
||||
}
|
||||
else if ( disk->vector_value("IMAGE", iname) == 0 )
|
||||
{
|
||||
int uiid = get_disk_uid(disk, uid);
|
||||
|
||||
if ( uiid == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
img = get(iname, uiid, true);
|
||||
|
||||
if ( img != 0 )
|
||||
{
|
||||
id = img->get_oid();
|
||||
|
||||
img->unlock();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -1029,6 +1029,25 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
|
||||
vmm->trigger(VirtualMachineManager::CLEANUP,vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::DISK_RESIZE:
|
||||
vm->clear_resize_disk(true);
|
||||
vmpool->update(vm);
|
||||
|
||||
vm->set_running_etime(the_time);
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid);
|
||||
vmm->trigger(VirtualMachineManager::CLEANUP,vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::DISK_RESIZE_POWEROFF:
|
||||
vm->clear_resize_disk(true);
|
||||
vmpool->update(vm);
|
||||
|
||||
tm->trigger(TransferManager::DRIVER_CANCEL, vid);
|
||||
tm->trigger(TransferManager::EPILOG_DELETE,vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::MIGRATE:
|
||||
vm->set_running_etime(the_time);
|
||||
vmpool->update_history(vm);
|
||||
@ -1316,6 +1335,18 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success)
|
||||
lcm_action = LifeCycleManager::DISK_SNAPSHOT_FAILURE;
|
||||
}
|
||||
break;
|
||||
|
||||
case VirtualMachine::DISK_RESIZE_POWEROFF:
|
||||
case VirtualMachine::DISK_RESIZE:
|
||||
if (success)
|
||||
{
|
||||
lcm_action = LifeCycleManager::DISK_RESIZE_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
lcm_action = LifeCycleManager::DISK_RESIZE_FAILURE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (lcm_action != LifeCycleManager::FINALIZE)
|
||||
@ -1533,6 +1564,8 @@ void LifeCycleManager::retry(VirtualMachine * vm)
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED:
|
||||
case VirtualMachine::DISK_SNAPSHOT:
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE:
|
||||
case VirtualMachine::DISK_RESIZE:
|
||||
case VirtualMachine::DISK_RESIZE_POWEROFF:
|
||||
case VirtualMachine::RUNNING:
|
||||
case VirtualMachine::UNKNOWN:
|
||||
break;
|
||||
@ -1642,6 +1675,7 @@ void LifeCycleManager::updatesg_action(int sgid)
|
||||
case VirtualMachine::SAVE_MIGRATE:
|
||||
case VirtualMachine::CLEANUP_RESUBMIT:
|
||||
case VirtualMachine::CLEANUP_DELETE:
|
||||
case VirtualMachine::DISK_RESIZE_POWEROFF:
|
||||
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
|
||||
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
|
||||
@ -1662,6 +1696,7 @@ void LifeCycleManager::updatesg_action(int sgid)
|
||||
case VirtualMachine::HOTPLUG_SAVEAS:
|
||||
case VirtualMachine::DISK_SNAPSHOT:
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE:
|
||||
case VirtualMachine::DISK_RESIZE:
|
||||
is_update = true;
|
||||
break;
|
||||
}
|
||||
|
@ -233,6 +233,22 @@ void LifeCycleManager::trigger(Actions action, int _vid)
|
||||
aname = "DISK_SNAPSHOT_FAILURE";
|
||||
break;
|
||||
|
||||
case DISK_LOCK_SUCCESS:
|
||||
aname = "DISK_LOCK_SUCCESS";
|
||||
break;
|
||||
|
||||
case DISK_LOCK_FAILURE:
|
||||
aname = "DISK_LOCK_FAILURE";
|
||||
break;
|
||||
|
||||
case DISK_RESIZE_SUCCESS:
|
||||
aname = "DISK_RESIZE_SUCCESS";
|
||||
break;
|
||||
|
||||
case DISK_RESIZE_FAILURE:
|
||||
aname = "DISK_RESIZE_FAILURE";
|
||||
break;
|
||||
|
||||
case DEPLOY:
|
||||
aname = "DEPLOY";
|
||||
break;
|
||||
@ -301,14 +317,6 @@ void LifeCycleManager::trigger(Actions action, int _vid)
|
||||
aname = "UPDATESG";
|
||||
break;
|
||||
|
||||
case DISK_LOCK_SUCCESS:
|
||||
aname = "DISK_LOCK_SUCCESS";
|
||||
break;
|
||||
|
||||
case DISK_LOCK_FAILURE:
|
||||
aname = "DISK_LOCK_FAILURE";
|
||||
break;
|
||||
|
||||
default:
|
||||
delete vid;
|
||||
return;
|
||||
@ -478,6 +486,22 @@ void LifeCycleManager::do_action(const string &action, void * arg)
|
||||
{
|
||||
disk_snapshot_failure(vid);
|
||||
}
|
||||
else if (action == "DISK_LOCK_SUCCESS")
|
||||
{
|
||||
disk_lock_success(vid);
|
||||
}
|
||||
else if (action == "DISK_LOCK_FAILURE")
|
||||
{
|
||||
disk_lock_failure(vid);
|
||||
}
|
||||
else if (action == "DISK_RESIZE_SUCCESS")
|
||||
{
|
||||
disk_resize_success(vid);
|
||||
}
|
||||
else if (action == "DISK_RESIZE_FAILURE")
|
||||
{
|
||||
disk_resize_failure(vid);
|
||||
}
|
||||
else if (action == "DEPLOY")
|
||||
{
|
||||
deploy_action(vid);
|
||||
@ -542,14 +566,6 @@ void LifeCycleManager::do_action(const string &action, void * arg)
|
||||
{
|
||||
updatesg_action(vid);
|
||||
}
|
||||
else if (action == "DISK_LOCK_SUCCESS")
|
||||
{
|
||||
disk_lock_success(vid);
|
||||
}
|
||||
else if (action == "DISK_LOCK_FAILURE")
|
||||
{
|
||||
disk_lock_failure(vid);
|
||||
}
|
||||
else if (action == ACTION_FINALIZE)
|
||||
{
|
||||
NebulaLog::log("LCM",Log::INFO,"Stopping Life-cycle Manager...");
|
||||
|
@ -1895,7 +1895,7 @@ void LifeCycleManager::disk_snapshot_success(int vid)
|
||||
Template *ds_quotas = 0;
|
||||
Template *vm_quotas = 0;
|
||||
|
||||
const VectorAttribute* disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
Snapshots snaps(-1);
|
||||
const Snapshots* tmp_snaps;
|
||||
bool has_snaps = false;
|
||||
@ -1940,7 +1940,6 @@ void LifeCycleManager::disk_snapshot_success(int vid)
|
||||
case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED:
|
||||
vm->log("LCM", Log::INFO, "VM disk snapshot deleted.");
|
||||
vm->delete_disk_snapshot(disk_id, snap_id, &ds_quotas, &vm_quotas);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1963,8 +1962,8 @@ void LifeCycleManager::disk_snapshot_success(int vid)
|
||||
|
||||
disk->vector_value("IMAGE_ID", img_id);
|
||||
|
||||
bool is_persistent = VirtualMachine::is_persistent(disk);
|
||||
string target = VirtualMachine::disk_tm_target(disk);
|
||||
bool is_persistent = disk->is_persistent();
|
||||
string target = disk->get_tm_target();
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
@ -2033,7 +2032,7 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
|
||||
Template *ds_quotas = 0;
|
||||
Template *vm_quotas = 0;
|
||||
|
||||
const VectorAttribute* disk;
|
||||
const VirtualMachineDisk* disk;
|
||||
Snapshots snaps(-1);
|
||||
const Snapshots* tmp_snaps;
|
||||
bool has_snaps = false;
|
||||
@ -2099,8 +2098,8 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
|
||||
|
||||
disk->vector_value("IMAGE_ID", img_id);
|
||||
|
||||
bool is_persistent = VirtualMachine::is_persistent(disk);
|
||||
string target = VirtualMachine::disk_tm_target(disk);
|
||||
bool is_persistent = disk->is_persistent();
|
||||
string target = disk->get_tm_target();
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
@ -2268,3 +2267,23 @@ void LifeCycleManager::disk_lock_failure(int vid)
|
||||
{
|
||||
disk_lock_success(vid);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::disk_resize_success(int vid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::disk_resize_failure(int vid)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "MarketPlacePool.h"
|
||||
#include "MarketPlaceAppPool.h"
|
||||
#include "VirtualMachineDisk.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -113,7 +114,7 @@ bool VirtualMachineAllocate::allocate_authorization(
|
||||
|
||||
VirtualMachineTemplate aux_tmpl(*ttmpl);
|
||||
|
||||
VirtualMachine::disk_extended_info(att.uid, &aux_tmpl);
|
||||
VirtualMachineDisks::extended_info(att.uid, &aux_tmpl);
|
||||
|
||||
if ( quota_authorization(&aux_tmpl, Quotas::VIRTUALMACHINE, att) == false )
|
||||
{
|
||||
|
@ -215,9 +215,11 @@ Request::ErrorCode TemplateChmod::chmod(
|
||||
|
||||
VMTemplate* tmpl = static_cast<VMTemplatePool*>(pool)->get(oid, true);
|
||||
|
||||
vector<VectorAttribute *> disks;
|
||||
vector<VectorAttribute *> vdisks;
|
||||
vector<VectorAttribute *>::iterator i;
|
||||
|
||||
VirtualMachineDisks disks(true);
|
||||
|
||||
set<int> error_ids;
|
||||
set<int> img_ids;
|
||||
|
||||
@ -232,11 +234,13 @@ Request::ErrorCode TemplateChmod::chmod(
|
||||
return NO_EXISTS;
|
||||
}
|
||||
|
||||
tmpl->clone_disks(disks);
|
||||
tmpl->clone_disks(vdisks);
|
||||
|
||||
tmpl->unlock();
|
||||
|
||||
ipool->get_image_ids(disks, img_ids, att.uid);
|
||||
disks.init(vdisks, false);
|
||||
|
||||
disks.get_image_ids(img_ids, att.uid);
|
||||
|
||||
for (set<int>::iterator it = img_ids.begin(); it != img_ids.end(); it++)
|
||||
{
|
||||
@ -251,11 +255,6 @@ Request::ErrorCode TemplateChmod::chmod(
|
||||
}
|
||||
}
|
||||
|
||||
for (i = disks.begin(); i != disks.end() ; i++)
|
||||
{
|
||||
delete *i;
|
||||
}
|
||||
|
||||
if ( !error_ids.empty() )
|
||||
{
|
||||
att.resp_msg = "Cannot chmod " + object_name(PoolObjectSQL::IMAGE) +
|
||||
|
@ -147,15 +147,15 @@ Request::ErrorCode VMTemplateClone::clone(int source_id, const string &name,
|
||||
|
||||
TemplateDelete tmpl_delete;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
ImagePool* ipool = nd.get_ipool();
|
||||
VMTemplatePool* tpool = static_cast<VMTemplatePool*>(pool);
|
||||
|
||||
vector<int> new_ids;
|
||||
|
||||
int ndisk = 0;
|
||||
vector<VectorAttribute *> disks;
|
||||
vector<VectorAttribute *>::iterator it;
|
||||
vector<VectorAttribute *> vdisks;
|
||||
|
||||
VirtualMachineDisks disks(false);
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
|
||||
RequestAttributes del_att(att);
|
||||
RequestAttributes img_att(att);
|
||||
@ -170,16 +170,18 @@ Request::ErrorCode VMTemplateClone::clone(int source_id, const string &name,
|
||||
return ACTION;
|
||||
}
|
||||
|
||||
vmtmpl->clone_disks(disks);
|
||||
vmtmpl->clone_disks(vdisks);
|
||||
|
||||
vmtmpl->unlock();
|
||||
|
||||
for (it = disks.begin(); it != disks.end(); it++)
|
||||
disks.init(vdisks, false);
|
||||
|
||||
for ( disk = disks.begin(); disk != disks.end() ; ++disk )
|
||||
{
|
||||
int img_id;
|
||||
int new_img_id;
|
||||
|
||||
if (ipool->get_image_id(*it, img_id, att.uid) == 0)
|
||||
if ( (*disk)->get_image_id(img_id, att.uid) == 0)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -209,11 +211,11 @@ Request::ErrorCode VMTemplateClone::clone(int source_id, const string &name,
|
||||
goto error_images;
|
||||
}
|
||||
|
||||
(*it)->remove("IMAGE");
|
||||
(*it)->remove("IMAGE_UNAME");
|
||||
(*it)->remove("IMAGE_UID");
|
||||
(*disk)->remove("IMAGE");
|
||||
(*disk)->remove("IMAGE_UNAME");
|
||||
(*disk)->remove("IMAGE_UID");
|
||||
|
||||
(*it)->replace("IMAGE_ID", new_img_id);
|
||||
(*disk)->replace("IMAGE_ID", new_img_id);
|
||||
|
||||
new_ids.push_back(new_img_id);
|
||||
}
|
||||
@ -230,7 +232,7 @@ Request::ErrorCode VMTemplateClone::clone(int source_id, const string &name,
|
||||
goto error_template;
|
||||
}
|
||||
|
||||
vmtmpl->replace_disks(disks);
|
||||
vmtmpl->replace_disks(vdisks);
|
||||
|
||||
tpool->update(vmtmpl);
|
||||
|
||||
@ -255,7 +257,8 @@ error_template:
|
||||
}
|
||||
}
|
||||
|
||||
for (it = disks.begin(); it != disks.end() ; it++)
|
||||
for (vector<VectorAttribute *>::iterator it = vdisks.begin();
|
||||
it != vdisks.end() ; it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
|
@ -171,12 +171,16 @@ int RequestManagerDelete::drop(PoolObjectSQL * object, bool recursive,
|
||||
int TemplateDelete::drop(PoolObjectSQL * object, bool recursive,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
vector<VectorAttribute *> disks;
|
||||
vector<VectorAttribute *> vdisks;
|
||||
vector<VectorAttribute *>::iterator i;
|
||||
|
||||
VirtualMachineDisks disks(true);
|
||||
|
||||
if (recursive)
|
||||
{
|
||||
static_cast<VMTemplate *>(object)->clone_disks(disks);
|
||||
static_cast<VMTemplate *>(object)->clone_disks(vdisks);
|
||||
|
||||
disks.init(vdisks, false);
|
||||
}
|
||||
|
||||
int rc = RequestManagerDelete::drop(object, false, att);
|
||||
@ -193,11 +197,9 @@ int TemplateDelete::drop(PoolObjectSQL * object, bool recursive,
|
||||
set<int> error_ids;
|
||||
set<int> img_ids;
|
||||
|
||||
ImagePool* ipool = Nebula::instance().get_ipool();
|
||||
|
||||
ImageDelete img_delete;
|
||||
|
||||
ipool->get_image_ids(disks, img_ids, att.uid);
|
||||
disks.get_image_ids(img_ids, att.uid);
|
||||
|
||||
for (set<int>::iterator it = img_ids.begin(); it != img_ids.end(); it++)
|
||||
{
|
||||
@ -210,11 +212,6 @@ int TemplateDelete::drop(PoolObjectSQL * object, bool recursive,
|
||||
}
|
||||
}
|
||||
|
||||
for (i = disks.begin(); i != disks.end() ; i++)
|
||||
{
|
||||
delete *i;
|
||||
}
|
||||
|
||||
if ( !error_ids.empty() )
|
||||
{
|
||||
att.resp_msg = "Cannot delete " + object_name(PoolObjectSQL::IMAGE) +
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "RequestManagerInfo.h"
|
||||
#include "RequestManagerPoolInfoFilter.h"
|
||||
#include "VirtualMachineDisk.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -111,7 +112,7 @@ void TemplateInfo::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
{
|
||||
VirtualMachine::set_auth_request(att.uid, ar, extended_tmpl);
|
||||
|
||||
VirtualMachine::disk_extended_info(att.uid, extended_tmpl);
|
||||
VirtualMachineDisks::extended_info(att.uid, extended_tmpl);
|
||||
}
|
||||
|
||||
if ( att.uid != UserPool::ONEADMIN_ID && att.gid != GroupPool::ONEADMIN_ID )
|
||||
|
@ -15,6 +15,7 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "RequestManagerVMTemplate.h"
|
||||
#include "VirtualMachineDisk.h"
|
||||
#include "PoolObjectAuth.h"
|
||||
#include "Nebula.h"
|
||||
#include "RequestManagerClone.h"
|
||||
@ -215,7 +216,7 @@ Request::ErrorCode VMTemplateInstantiate::request_execute(int id, string name,
|
||||
|
||||
extended_tmpl = new VirtualMachineTemplate(*tmpl);
|
||||
|
||||
VirtualMachine::disk_extended_info(att.uid, extended_tmpl);
|
||||
VirtualMachineDisks::extended_info(att.uid, extended_tmpl);
|
||||
|
||||
if (quota_authorization(extended_tmpl, Quotas::VIRTUALMACHINE, att,
|
||||
att.resp_msg) == false)
|
||||
|
@ -15,6 +15,7 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "RequestManagerVirtualMachine.h"
|
||||
#include "VirtualMachineDisk.h"
|
||||
#include "PoolObjectAuth.h"
|
||||
#include "Nebula.h"
|
||||
#include "Quotas.h"
|
||||
@ -639,34 +640,11 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
* @param vd vector of DISKS
|
||||
* @return true if there at least one volatile disk was found
|
||||
*/
|
||||
static bool set_volatile_disk_info(int ds_id, vector<VectorAttribute *>& vd)
|
||||
{
|
||||
DatastorePool * ds_pool = Nebula::instance().get_dspool();
|
||||
|
||||
bool found = false;
|
||||
|
||||
for(vector<VectorAttribute *>::iterator it = vd.begin(); it!=vd.end(); ++it)
|
||||
{
|
||||
if ( !VirtualMachine::is_volatile(*it) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ds_pool->disk_attribute(ds_id, *it);
|
||||
|
||||
found = true;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static bool set_volatile_disk_info(VirtualMachine *vm, int ds_id)
|
||||
{
|
||||
vector<VectorAttribute *> disks;
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
vm->get_template_attribute("DISK", disks);
|
||||
|
||||
bool found = set_volatile_disk_info(ds_id, disks);
|
||||
bool found = disks.volatile_info(ds_id);
|
||||
|
||||
if ( found )
|
||||
{
|
||||
@ -679,11 +657,9 @@ static bool set_volatile_disk_info(VirtualMachine *vm, int ds_id)
|
||||
|
||||
static bool set_volatile_disk_info(VirtualMachine *vm, int ds_id, Template& tmpl)
|
||||
{
|
||||
vector<VectorAttribute *> disks;
|
||||
VirtualMachineDisks disks(&tmpl, false);
|
||||
|
||||
tmpl.get("DISK", disks);
|
||||
|
||||
bool found = set_volatile_disk_info(ds_id, disks);
|
||||
bool found = disks.volatile_info(ds_id);
|
||||
|
||||
if ( found )
|
||||
{
|
||||
@ -1707,7 +1683,7 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes att_quota(vm_perms.uid, vm_perms.gid, att);
|
||||
|
||||
VirtualMachineTemplate deltas(tmpl);
|
||||
VirtualMachine::disk_extended_info(att.uid, &deltas);
|
||||
VirtualMachineDisks::extended_info(att.uid, &deltas);
|
||||
|
||||
deltas.add("VMS", 0);
|
||||
|
||||
@ -2572,7 +2548,7 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
|
||||
PoolObjectAuth vm_perms;
|
||||
|
||||
const VectorAttribute * disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
VectorAttribute * delta_disk = 0;
|
||||
|
||||
Template ds_deltas;
|
||||
@ -2607,9 +2583,9 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
|
||||
string disk_size = disk->vector_value("SIZE");
|
||||
string ds_id = disk->vector_value("DATASTORE_ID");
|
||||
bool is_volatile = VirtualMachine::is_volatile(disk);
|
||||
bool is_system = VirtualMachine::disk_tm_target(disk) == "SYSTEM";
|
||||
bool do_ds_quota = VirtualMachine::is_persistent(disk) || !is_system;
|
||||
bool is_volatile = disk->is_volatile();
|
||||
bool is_system = disk->get_tm_target() == "SYSTEM";
|
||||
bool do_ds_quota = disk->is_persistent() || !is_system;
|
||||
|
||||
int img_id = -1;
|
||||
disk->vector_value("IMAGE_ID", img_id);
|
||||
@ -2766,7 +2742,7 @@ void VirtualMachineDiskSnapshotDelete::request_execute(
|
||||
DispatchManager * dm = nd.get_dm();
|
||||
VirtualMachine * vm;
|
||||
|
||||
const VectorAttribute * disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
|
||||
int rc;
|
||||
|
||||
@ -2791,7 +2767,7 @@ void VirtualMachineDiskSnapshotDelete::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
bool persistent = VirtualMachine::is_persistent(disk);
|
||||
bool persistent = disk->is_persistent();
|
||||
|
||||
int img_id = -1;
|
||||
disk->vector_value("IMAGE_ID", img_id);
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define FLEX_SCANNER
|
||||
#define YY_FLEX_MAJOR_VERSION 2
|
||||
#define YY_FLEX_MINOR_VERSION 6
|
||||
#define YY_FLEX_SUBMINOR_VERSION 0
|
||||
#define YY_FLEX_SUBMINOR_VERSION 1
|
||||
#if YY_FLEX_SUBMINOR_VERSION > 0
|
||||
#define FLEX_BETA
|
||||
#endif
|
||||
@ -107,25 +107,13 @@ typedef unsigned int flex_uint32_t;
|
||||
|
||||
#endif /* ! FLEXINT_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/* The "const" storage-class-modifier is valid. */
|
||||
#define YY_USE_CONST
|
||||
|
||||
#else /* ! __cplusplus */
|
||||
|
||||
/* C99 requires __STDC__ to be defined as 1. */
|
||||
#if defined (__STDC__)
|
||||
|
||||
#define YY_USE_CONST
|
||||
|
||||
#endif /* defined (__STDC__) */
|
||||
#endif /* ! __cplusplus */
|
||||
|
||||
#ifdef YY_USE_CONST
|
||||
/* TODO: this is always defined, so inline it */
|
||||
#define yyconst const
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
#define yynoreturn __attribute__((__noreturn__))
|
||||
#else
|
||||
#define yyconst
|
||||
#define yynoreturn
|
||||
#endif
|
||||
|
||||
/* Returned upon end-of-file. */
|
||||
@ -186,7 +174,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
|
||||
typedef size_t yy_size_t;
|
||||
#endif
|
||||
|
||||
extern yy_size_t template_leng;
|
||||
extern int template_leng;
|
||||
|
||||
extern FILE *template_in, *template_out;
|
||||
|
||||
@ -244,12 +232,12 @@ struct yy_buffer_state
|
||||
/* Size of input buffer in bytes, not including room for EOB
|
||||
* characters.
|
||||
*/
|
||||
yy_size_t yy_buf_size;
|
||||
int yy_buf_size;
|
||||
|
||||
/* Number of characters read into yy_ch_buf, not including EOB
|
||||
* characters.
|
||||
*/
|
||||
yy_size_t yy_n_chars;
|
||||
int yy_n_chars;
|
||||
|
||||
/* Whether we "own" the buffer - i.e., we know we created it,
|
||||
* and can realloc() it to grow it, and should free() it to
|
||||
@ -300,7 +288,7 @@ struct yy_buffer_state
|
||||
/* Stack of input buffers. */
|
||||
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
|
||||
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
|
||||
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
|
||||
static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
|
||||
|
||||
/* We provide macros for accessing buffer states in case in the
|
||||
* future we want to put the buffer states in a more general
|
||||
@ -319,11 +307,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
|
||||
|
||||
/* yy_hold_char holds the character lost when template_text is formed. */
|
||||
static char yy_hold_char;
|
||||
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
|
||||
yy_size_t template_leng;
|
||||
static int yy_n_chars; /* number of characters read into yy_ch_buf */
|
||||
int template_leng;
|
||||
|
||||
/* Points to current character in buffer. */
|
||||
static char *yy_c_buf_p = (char *) 0;
|
||||
static char *yy_c_buf_p = NULL;
|
||||
static int yy_init = 0; /* whether we need to initialize */
|
||||
static int yy_start = 0; /* start state number */
|
||||
|
||||
@ -348,7 +336,7 @@ static void template__init_buffer (YY_BUFFER_STATE b,FILE *file );
|
||||
|
||||
YY_BUFFER_STATE template__scan_buffer (char *base,yy_size_t size );
|
||||
YY_BUFFER_STATE template__scan_string (yyconst char *yy_str );
|
||||
YY_BUFFER_STATE template__scan_bytes (yyconst char *bytes,yy_size_t len );
|
||||
YY_BUFFER_STATE template__scan_bytes (yyconst char *bytes,int len );
|
||||
|
||||
void *template_alloc (yy_size_t );
|
||||
void *template_realloc (void *,yy_size_t );
|
||||
@ -382,7 +370,7 @@ void template_free (void * );
|
||||
|
||||
typedef unsigned char YY_CHAR;
|
||||
|
||||
FILE *template_in = (FILE *) 0, *template_out = (FILE *) 0;
|
||||
FILE *template_in = NULL, *template_out = NULL;
|
||||
|
||||
typedef int yy_state_type;
|
||||
|
||||
@ -399,17 +387,14 @@ extern char *template_text;
|
||||
static yy_state_type yy_get_previous_state (void );
|
||||
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
|
||||
static int yy_get_next_buffer (void );
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
__attribute__((__noreturn__))
|
||||
#endif
|
||||
static void yy_fatal_error (yyconst char msg[] );
|
||||
static void yynoreturn yy_fatal_error (yyconst char* msg );
|
||||
|
||||
/* Done after the current pattern has been matched and before the
|
||||
* corresponding action - sets up template_text.
|
||||
*/
|
||||
#define YY_DO_BEFORE_ACTION \
|
||||
(yytext_ptr) = yy_bp; \
|
||||
template_leng = (size_t) (yy_cp - yy_bp); \
|
||||
template_leng = (int) (yy_cp - yy_bp); \
|
||||
(yy_hold_char) = *yy_cp; \
|
||||
*yy_cp = '\0'; \
|
||||
(yy_c_buf_p) = yy_cp;
|
||||
@ -603,7 +588,7 @@ char *template_text;
|
||||
llocp->first_column = llocp->last_column; \
|
||||
llocp->last_column += template_leng;
|
||||
|
||||
#line 607 "template_parser.c"
|
||||
#line 592 "template_parser.c"
|
||||
|
||||
#define INITIAL 0
|
||||
#define VALUE 1
|
||||
@ -643,7 +628,7 @@ FILE *template_get_out (void );
|
||||
|
||||
void template_set_out (FILE * _out_str );
|
||||
|
||||
yy_size_t template_get_leng (void );
|
||||
int template_get_leng (void );
|
||||
|
||||
char *template_get_text (void );
|
||||
|
||||
@ -700,7 +685,7 @@ static int input (void );
|
||||
/* This used to be an fputs(), but since the string might contain NUL's,
|
||||
* we now use fwrite().
|
||||
*/
|
||||
#define ECHO do { if (fwrite( template_text, template_leng, 1, template_out )) {} } while (0)
|
||||
#define ECHO do { if (fwrite( template_text, (size_t) template_leng, 1, template_out )) {} } while (0)
|
||||
#endif
|
||||
|
||||
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
||||
@ -724,7 +709,7 @@ static int input (void );
|
||||
else \
|
||||
{ \
|
||||
errno=0; \
|
||||
while ( (result = fread(buf, 1, max_size, template_in))==0 && ferror(template_in)) \
|
||||
while ( (result = (int) fread(buf, 1, max_size, template_in))==0 && ferror(template_in)) \
|
||||
{ \
|
||||
if( errno != EINTR) \
|
||||
{ \
|
||||
@ -826,7 +811,7 @@ YY_DECL
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Comments (lines with an starting #), and empty lines */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#line 830 "template_parser.c"
|
||||
#line 815 "template_parser.c"
|
||||
|
||||
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
|
||||
{
|
||||
@ -856,7 +841,7 @@ yy_match:
|
||||
if ( yy_current_state >= 69 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_base[yy_current_state] != 196 );
|
||||
@ -977,7 +962,7 @@ YY_RULE_SETUP
|
||||
#line 89 "template_parser.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 981 "template_parser.c"
|
||||
#line 966 "template_parser.c"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
case YY_STATE_EOF(VALUE):
|
||||
yyterminate();
|
||||
@ -1165,7 +1150,7 @@ static int yy_get_next_buffer (void)
|
||||
|
||||
else
|
||||
{
|
||||
yy_size_t num_to_read =
|
||||
int num_to_read =
|
||||
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
||||
|
||||
while ( num_to_read <= 0 )
|
||||
@ -1179,7 +1164,7 @@ static int yy_get_next_buffer (void)
|
||||
|
||||
if ( b->yy_is_our_buffer )
|
||||
{
|
||||
yy_size_t new_size = b->yy_buf_size * 2;
|
||||
int new_size = b->yy_buf_size * 2;
|
||||
|
||||
if ( new_size <= 0 )
|
||||
b->yy_buf_size += b->yy_buf_size / 8;
|
||||
@ -1192,7 +1177,7 @@ static int yy_get_next_buffer (void)
|
||||
}
|
||||
else
|
||||
/* Can't grow it, we don't own it. */
|
||||
b->yy_ch_buf = 0;
|
||||
b->yy_ch_buf = NULL;
|
||||
|
||||
if ( ! b->yy_ch_buf )
|
||||
YY_FATAL_ERROR(
|
||||
@ -1234,9 +1219,9 @@ static int yy_get_next_buffer (void)
|
||||
else
|
||||
ret_val = EOB_ACT_CONTINUE_SCAN;
|
||||
|
||||
if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
|
||||
if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
|
||||
/* Extend the array by 50%, plus the number we really need. */
|
||||
yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
|
||||
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
|
||||
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) template_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
|
||||
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
|
||||
@ -1274,7 +1259,7 @@ static int yy_get_next_buffer (void)
|
||||
if ( yy_current_state >= 69 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
|
||||
}
|
||||
|
||||
return yy_current_state;
|
||||
@ -1302,7 +1287,7 @@ static int yy_get_next_buffer (void)
|
||||
if ( yy_current_state >= 69 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
|
||||
yy_is_jam = (yy_current_state == 68);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
@ -1336,7 +1321,7 @@ static int yy_get_next_buffer (void)
|
||||
|
||||
else
|
||||
{ /* need more input */
|
||||
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
|
||||
int offset = (yy_c_buf_p) - (yytext_ptr);
|
||||
++(yy_c_buf_p);
|
||||
|
||||
switch ( yy_get_next_buffer( ) )
|
||||
@ -1360,7 +1345,7 @@ static int yy_get_next_buffer (void)
|
||||
case EOB_ACT_END_OF_FILE:
|
||||
{
|
||||
if ( template_wrap( ) )
|
||||
return EOF;
|
||||
return 0;
|
||||
|
||||
if ( ! (yy_did_buffer_switch_on_eof) )
|
||||
YY_NEW_FILE;
|
||||
@ -1613,7 +1598,7 @@ void template_pop_buffer_state (void)
|
||||
*/
|
||||
static void template_ensure_buffer_stack (void)
|
||||
{
|
||||
yy_size_t num_to_alloc;
|
||||
int num_to_alloc;
|
||||
|
||||
if (!(yy_buffer_stack)) {
|
||||
|
||||
@ -1668,7 +1653,7 @@ YY_BUFFER_STATE template__scan_buffer (char * base, yy_size_t size )
|
||||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
|
||||
base[size-1] != YY_END_OF_BUFFER_CHAR )
|
||||
/* They forgot to leave room for the EOB's. */
|
||||
return 0;
|
||||
return NULL;
|
||||
|
||||
b = (YY_BUFFER_STATE) template_alloc(sizeof( struct yy_buffer_state ) );
|
||||
if ( ! b )
|
||||
@ -1677,7 +1662,7 @@ YY_BUFFER_STATE template__scan_buffer (char * base, yy_size_t size )
|
||||
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
|
||||
b->yy_buf_pos = b->yy_ch_buf = base;
|
||||
b->yy_is_our_buffer = 0;
|
||||
b->yy_input_file = 0;
|
||||
b->yy_input_file = NULL;
|
||||
b->yy_n_chars = b->yy_buf_size;
|
||||
b->yy_is_interactive = 0;
|
||||
b->yy_at_bol = 1;
|
||||
@ -1700,7 +1685,7 @@ YY_BUFFER_STATE template__scan_buffer (char * base, yy_size_t size )
|
||||
YY_BUFFER_STATE template__scan_string (yyconst char * yystr )
|
||||
{
|
||||
|
||||
return template__scan_bytes(yystr,strlen(yystr) );
|
||||
return template__scan_bytes(yystr,(int) strlen(yystr) );
|
||||
}
|
||||
|
||||
/** Setup the input buffer state to scan the given bytes. The next call to template_lex() will
|
||||
@ -1710,7 +1695,7 @@ YY_BUFFER_STATE template__scan_string (yyconst char * yystr )
|
||||
*
|
||||
* @return the newly allocated buffer state object.
|
||||
*/
|
||||
YY_BUFFER_STATE template__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
|
||||
YY_BUFFER_STATE template__scan_bytes (yyconst char * yybytes, int _yybytes_len )
|
||||
{
|
||||
YY_BUFFER_STATE b;
|
||||
char *buf;
|
||||
@ -1718,7 +1703,7 @@ YY_BUFFER_STATE template__scan_bytes (yyconst char * yybytes, yy_size_t _yybyt
|
||||
yy_size_t i;
|
||||
|
||||
/* Get memory for full buffer, including space for trailing EOB's. */
|
||||
n = _yybytes_len + 2;
|
||||
n = (yy_size_t) _yybytes_len + 2;
|
||||
buf = (char *) template_alloc(n );
|
||||
if ( ! buf )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in template__scan_bytes()" );
|
||||
@ -1744,7 +1729,7 @@ YY_BUFFER_STATE template__scan_bytes (yyconst char * yybytes, yy_size_t _yybyt
|
||||
#define YY_EXIT_FAILURE 2
|
||||
#endif
|
||||
|
||||
static void yy_fatal_error (yyconst char* msg )
|
||||
static void yynoreturn yy_fatal_error (yyconst char* msg )
|
||||
{
|
||||
(void) fprintf( stderr, "%s\n", msg );
|
||||
exit( YY_EXIT_FAILURE );
|
||||
@ -1797,7 +1782,7 @@ FILE *template_get_out (void)
|
||||
/** Get the length of the current token.
|
||||
*
|
||||
*/
|
||||
yy_size_t template_get_leng (void)
|
||||
int template_get_leng (void)
|
||||
{
|
||||
return template_leng;
|
||||
}
|
||||
@ -1856,10 +1841,10 @@ static int yy_init_globals (void)
|
||||
/* We do not touch template_lineno unless the option is enabled. */
|
||||
template_lineno = 1;
|
||||
|
||||
(yy_buffer_stack) = 0;
|
||||
(yy_buffer_stack) = NULL;
|
||||
(yy_buffer_stack_top) = 0;
|
||||
(yy_buffer_stack_max) = 0;
|
||||
(yy_c_buf_p) = (char *) 0;
|
||||
(yy_c_buf_p) = NULL;
|
||||
(yy_init) = 0;
|
||||
(yy_start) = 0;
|
||||
|
||||
@ -1868,8 +1853,8 @@ static int yy_init_globals (void)
|
||||
template_in = stdin;
|
||||
template_out = stdout;
|
||||
#else
|
||||
template_in = (FILE *) 0;
|
||||
template_out = (FILE *) 0;
|
||||
template_in = NULL;
|
||||
template_out = NULL;
|
||||
#endif
|
||||
|
||||
/* For future reference: Set errno on error, since we are called by
|
||||
@ -1927,7 +1912,7 @@ static int yy_flex_strlen (yyconst char * s )
|
||||
|
||||
void *template_alloc (yy_size_t size )
|
||||
{
|
||||
return (void *) malloc( size );
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *template_realloc (void * ptr, yy_size_t size )
|
||||
@ -1940,7 +1925,7 @@ void *template_realloc (void * ptr, yy_size_t size )
|
||||
* any pointer type to void*, and deal with argument conversions
|
||||
* as though doing an assignment.
|
||||
*/
|
||||
return (void *) realloc( (char *) ptr, size );
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
void template_free (void * ptr )
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "NebulaLog.h"
|
||||
|
||||
#include "Nebula.h"
|
||||
#include "NebulaUtil.h"
|
||||
#include "VirtualMachineDisk.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -155,6 +157,10 @@ void TransferManager::trigger(Actions action, int _vid)
|
||||
aname = "SNAPSHOT_DELETE";
|
||||
break;
|
||||
|
||||
case RESIZE:
|
||||
aname = "RESIZE";
|
||||
break;
|
||||
|
||||
case FINALIZE:
|
||||
aname = ACTION_FINALIZE;
|
||||
break;
|
||||
@ -421,6 +427,10 @@ void TransferManager::do_action(const string &action, void * arg)
|
||||
{
|
||||
snapshot_delete_action(vid);
|
||||
}
|
||||
else if (action == "RESIZE")
|
||||
{
|
||||
resize_action(vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
ostringstream oss;
|
||||
@ -435,7 +445,7 @@ void TransferManager::do_action(const string &action, void * arg)
|
||||
|
||||
int TransferManager::prolog_transfer_command(
|
||||
VirtualMachine * vm,
|
||||
const VectorAttribute * disk,
|
||||
const VirtualMachineDisk* disk,
|
||||
string& vm_tm_mad,
|
||||
string& opennebula_hostname,
|
||||
ostream& xfr,
|
||||
@ -449,13 +459,11 @@ int TransferManager::prolog_transfer_command(
|
||||
string tm_mad;
|
||||
string ds_id;
|
||||
|
||||
int disk_id;
|
||||
|
||||
disk->vector_value("DISK_ID", disk_id);
|
||||
int disk_id = disk->get_disk_id();
|
||||
|
||||
type = disk->vector_value("TYPE");
|
||||
|
||||
transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper);
|
||||
one_util::toupper(type);
|
||||
|
||||
if ( type == "SWAP" )
|
||||
{
|
||||
@ -530,7 +538,7 @@ int TransferManager::prolog_transfer_command(
|
||||
goto error_attributes;
|
||||
}
|
||||
|
||||
transform(clon.begin(),clon.end(),clon.begin(),(int(*)(int))toupper);
|
||||
one_util::toupper(clon);
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// CLONE or LINK disk images
|
||||
@ -569,7 +577,7 @@ int TransferManager::prolog_transfer_command(
|
||||
error_attributes:
|
||||
os << "missing DISK mandatory attributes "
|
||||
<< "(SOURCE, TM_MAD, CLONE, DATASTORE_ID) for VM " << vm->get_oid()
|
||||
<< ", DISK " << disk->vector_value("DISK_ID");
|
||||
<< ", DISK " << disk_id;
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -681,16 +689,15 @@ void TransferManager::prolog_action(int vid)
|
||||
|
||||
const TransferManagerDriver * tm_md;
|
||||
|
||||
vector<const VectorAttribute *> disk;
|
||||
const VectorAttribute * os_attr;
|
||||
int num;
|
||||
|
||||
string token_password;
|
||||
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
|
||||
if (vm == 0)
|
||||
@ -716,6 +723,8 @@ void TransferManager::prolog_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
if (!vm->hasHistory())
|
||||
{
|
||||
goto error_history;
|
||||
@ -742,16 +751,12 @@ void TransferManager::prolog_action(int vid)
|
||||
// -------------------------------------------------------------------------
|
||||
// Image Transfer Commands
|
||||
// -------------------------------------------------------------------------
|
||||
num = vm->get_template_attribute("DISK", disk);
|
||||
|
||||
for (int i=0; i < num; i++)
|
||||
for ( disk = disks.begin() ; disk != disks.end() ; ++disk )
|
||||
{
|
||||
rc = prolog_transfer_command(vm,
|
||||
disk[i],
|
||||
vm_tm_mad,
|
||||
opennebula_hostname,
|
||||
xfr,
|
||||
os);
|
||||
rc = prolog_transfer_command(vm, *disk, vm_tm_mad, opennebula_hostname,
|
||||
xfr, os);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
goto error_attributes;
|
||||
@ -851,8 +856,7 @@ void TransferManager::prolog_migr_action(int vid)
|
||||
int ds_id;
|
||||
int disk_id;
|
||||
|
||||
vector<const VectorAttribute *> disk;
|
||||
int num;
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
|
||||
VirtualMachine * vm;
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -869,6 +873,8 @@ void TransferManager::prolog_migr_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
if (!vm->hasHistory() || !vm->hasPreviousHistory())
|
||||
{
|
||||
goto error_history;
|
||||
@ -894,21 +900,19 @@ void TransferManager::prolog_migr_action(int vid)
|
||||
// Move system directory and disks
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
num = vm->get_template_attribute("DISK", disk);
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
for ( disk = disks.begin() ; disk != disks.end() ; ++disk )
|
||||
{
|
||||
disk[i]->vector_value_str("DISK_ID", disk_id);
|
||||
disk_id = (*disk)->get_disk_id();
|
||||
|
||||
if ( VirtualMachine::is_volatile(disk[i]) == true )
|
||||
if ( (*disk)->is_volatile() == true )
|
||||
{
|
||||
tm_mad = vm_tm_mad;
|
||||
ds_id = vm->get_ds_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
tm_mad = disk[i]->vector_value("TM_MAD");
|
||||
int vv_rc = disk[i]->vector_value("DATASTORE_ID", ds_id);
|
||||
tm_mad = (*disk)->vector_value("TM_MAD");
|
||||
int vv_rc = (*disk)->vector_value("DATASTORE_ID", ds_id);
|
||||
|
||||
if (tm_mad.empty() || vv_rc == -1)
|
||||
{
|
||||
@ -983,11 +987,10 @@ void TransferManager::prolog_resume_action(int vid)
|
||||
int ds_id;
|
||||
int disk_id;
|
||||
|
||||
vector<const VectorAttribute *> disk;
|
||||
int num;
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
|
||||
VirtualMachine * vm;
|
||||
Nebula& nd = Nebula::instance();
|
||||
VirtualMachine * vm;
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
const TransferManagerDriver * tm_md;
|
||||
|
||||
@ -1002,6 +1005,7 @@ void TransferManager::prolog_resume_action(int vid)
|
||||
}
|
||||
|
||||
int uid = vm->get_created_by_uid();
|
||||
|
||||
vm->unlock();
|
||||
|
||||
User * user = Nebula::instance().get_upool()->get(uid, true);
|
||||
@ -1019,6 +1023,8 @@ void TransferManager::prolog_resume_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
if (!vm->hasHistory())
|
||||
{
|
||||
goto error_history;
|
||||
@ -1043,21 +1049,19 @@ void TransferManager::prolog_resume_action(int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Move system directory and disks
|
||||
// ------------------------------------------------------------------------
|
||||
num = vm->get_template_attribute("DISK", disk);
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
for (disk = disks.begin(); disk != disks.end(); ++disk)
|
||||
{
|
||||
disk[i]->vector_value_str("DISK_ID", disk_id);
|
||||
disk_id = (*disk)->get_disk_id();
|
||||
|
||||
if ( VirtualMachine::is_volatile(disk[i]) == true )
|
||||
if ( (*disk)->is_volatile() == true )
|
||||
{
|
||||
tm_mad = vm_tm_mad;
|
||||
ds_id = vm->get_ds_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
tm_mad = disk[i]->vector_value("TM_MAD");
|
||||
int vv_rc = disk[i]->vector_value("DATASTORE_ID", ds_id);
|
||||
tm_mad = (*disk)->vector_value("TM_MAD");
|
||||
int vv_rc = (*disk)->vector_value("DATASTORE_ID", ds_id);
|
||||
|
||||
if ( tm_mad.empty() || vv_rc == -1)
|
||||
{
|
||||
@ -1124,7 +1128,7 @@ void TransferManager::prolog_attach_action(int vid)
|
||||
ostringstream os("prolog, ");
|
||||
string xfr_name;
|
||||
|
||||
const VectorAttribute * disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
|
||||
string files;
|
||||
string vm_tm_mad;
|
||||
@ -1236,13 +1240,11 @@ error_common:
|
||||
void TransferManager::epilog_transfer_command(
|
||||
VirtualMachine * vm,
|
||||
const string& host,
|
||||
const VectorAttribute * disk,
|
||||
const VirtualMachineDisk * disk,
|
||||
ostream& xfr)
|
||||
{
|
||||
int disk_id;
|
||||
string save = disk->vector_value("SAVE");
|
||||
|
||||
disk->vector_value("DISK_ID", disk_id);
|
||||
int disk_id = disk->get_disk_id();
|
||||
|
||||
if ( one_util::toupper(save) == "YES" )
|
||||
{
|
||||
@ -1278,7 +1280,7 @@ void TransferManager::epilog_transfer_command(
|
||||
int ds_id_i;
|
||||
int vv_rc = 0;
|
||||
|
||||
if ( VirtualMachine::is_volatile(disk) == true )
|
||||
if ( disk->is_volatile() == true )
|
||||
{
|
||||
tm_mad = vm->get_tm_mad();
|
||||
ds_id_i= vm->get_ds_id();
|
||||
@ -1320,8 +1322,7 @@ void TransferManager::epilog_action(bool local, int vid)
|
||||
|
||||
const TransferManagerDriver * tm_md;
|
||||
|
||||
vector<const VectorAttribute *> disk;
|
||||
int num;
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
@ -1333,6 +1334,8 @@ void TransferManager::epilog_action(bool local, int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
if (!vm->hasHistory())
|
||||
{
|
||||
goto error_history;
|
||||
@ -1366,11 +1369,9 @@ void TransferManager::epilog_action(bool local, int vid)
|
||||
// -------------------------------------------------------------------------
|
||||
// copy back VM image (DISK with SAVE="yes")
|
||||
// -------------------------------------------------------------------------
|
||||
num = vm->get_template_attribute("DISK", disk);
|
||||
|
||||
for (int i=0; i < num; i++)
|
||||
for ( disk = disks.begin() ; disk != disks.end() ; ++disk )
|
||||
{
|
||||
epilog_transfer_command(vm, host, disk[i], xfr);
|
||||
epilog_transfer_command(vm, host, *disk, xfr);
|
||||
}
|
||||
|
||||
//DELETE vm_tm_mad hostname:remote_system_dir vmid ds_id
|
||||
@ -1430,8 +1431,7 @@ void TransferManager::epilog_stop_action(int vid)
|
||||
|
||||
const TransferManagerDriver * tm_md;
|
||||
|
||||
vector<const VectorAttribute *> disk;
|
||||
int num;
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
@ -1443,6 +1443,8 @@ void TransferManager::epilog_stop_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
if (!vm->hasHistory())
|
||||
{
|
||||
goto error_history;
|
||||
@ -1467,21 +1469,19 @@ void TransferManager::epilog_stop_action(int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Move system directory and disks
|
||||
// ------------------------------------------------------------------------
|
||||
num = vm->get_template_attribute("DISK", disk);
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
for (disk = disks.begin(); disk != disks.end(); ++disk)
|
||||
{
|
||||
disk[i]->vector_value_str("DISK_ID", disk_id);
|
||||
disk_id = (*disk)->get_disk_id();
|
||||
|
||||
if ( VirtualMachine::is_volatile(disk[i]) == true )
|
||||
if ( (*disk)->is_volatile() == true )
|
||||
{
|
||||
tm_mad = vm_tm_mad;
|
||||
ds_id = vm->get_ds_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
tm_mad = disk[i]->vector_value("TM_MAD");
|
||||
int vv_rc = disk[i]->vector_value("DATASTORE_ID", ds_id);
|
||||
tm_mad = (*disk)->vector_value("TM_MAD");
|
||||
int vv_rc = (*disk)->vector_value("DATASTORE_ID", ds_id);
|
||||
|
||||
if (tm_mad.empty() || vv_rc == -1)
|
||||
{
|
||||
@ -1561,8 +1561,8 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
vector<const VectorAttribute *> disk;
|
||||
int num;
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup transfer
|
||||
@ -1610,21 +1610,19 @@ int TransferManager::epilog_delete_commands(VirtualMachine *vm,
|
||||
// -------------------------------------------------------------------------
|
||||
// Delete disk images and the remote system Directory
|
||||
// -------------------------------------------------------------------------
|
||||
num = vm->get_template_attribute("DISK", disk);
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
for ( disk = disks.begin() ; disk != disks.end() ; ++disk )
|
||||
{
|
||||
disk[i]->vector_value_str("DISK_ID", disk_id);
|
||||
disk_id = (*disk)->get_disk_id();
|
||||
|
||||
if ( VirtualMachine::is_volatile(disk[i]) == true )
|
||||
if ( (*disk)->is_volatile() == true )
|
||||
{
|
||||
tm_mad = vm_tm_mad;
|
||||
ds_id = vm_ds_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
tm_mad = disk[i]->vector_value("TM_MAD");
|
||||
int vv_rc = disk[i]->vector_value("DATASTORE_ID", ds_id);
|
||||
tm_mad = (*disk)->vector_value("TM_MAD");
|
||||
int vv_rc = (*disk)->vector_value("DATASTORE_ID", ds_id);
|
||||
|
||||
if (tm_mad.empty() || vv_rc == -1)
|
||||
{
|
||||
@ -1898,7 +1896,7 @@ void TransferManager::epilog_detach_action(int vid)
|
||||
string vm_tm_mad;
|
||||
string error_str;
|
||||
|
||||
const VectorAttribute * disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
|
||||
VirtualMachine * vm;
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -2279,6 +2277,121 @@ void TransferManager::snapshot_delete_action(int vid)
|
||||
return do_snapshot_action(vid, "SNAP_DELETE");
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void TransferManager::resize_command(VirtualMachine * vm,
|
||||
const VirtualMachineDisk * disk, ostream& xfr)
|
||||
{
|
||||
string tm_mad;
|
||||
string ds_id;
|
||||
|
||||
if ( disk->is_volatile() )
|
||||
{
|
||||
tm_mad = vm->get_tm_mad();
|
||||
ds_id = vm->get_ds_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
tm_mad = disk->vector_value("TM_MAD");
|
||||
ds_id = disk->vector_value("DATASTORE_ID");
|
||||
}
|
||||
|
||||
//RESIZE tm_mad host:remote_system_dir/disk.i size vmid dsid
|
||||
xfr << "RESIZE "
|
||||
<< tm_mad << " "
|
||||
<< vm->get_hostname() << ":"
|
||||
<< vm->get_system_dir()<< "/disk."<< disk->vector_value("DISK_ID")<< " "
|
||||
<< disk->vector_value("SIZE") << " "
|
||||
<< vm->get_oid() << " "
|
||||
<< ds_id
|
||||
<< endl;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void TransferManager::resize_action(int vid)
|
||||
{
|
||||
ostringstream os;
|
||||
|
||||
ofstream xfr;
|
||||
string xfr_name;
|
||||
|
||||
VirtualMachine * vm;
|
||||
VirtualMachineDisk * disk;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
const TransferManagerDriver * tm_md = get();
|
||||
|
||||
if (tm_md == 0)
|
||||
{
|
||||
goto error_driver;
|
||||
}
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!vm->hasHistory())
|
||||
{
|
||||
goto error_history;
|
||||
}
|
||||
|
||||
xfr_name = vm->get_transfer_file() + ".disk_resize";
|
||||
xfr.open(xfr_name.c_str(), ios::out | ios::trunc);
|
||||
|
||||
if (xfr.fail() == true)
|
||||
{
|
||||
goto error_file;
|
||||
}
|
||||
|
||||
disk = vm->get_resize_disk();
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
goto error_disk;
|
||||
}
|
||||
|
||||
resize_command(vm, disk, xfr);
|
||||
|
||||
xfr.close();
|
||||
|
||||
tm_md->transfer(vid, xfr_name);
|
||||
|
||||
vm->unlock();
|
||||
|
||||
return;
|
||||
|
||||
error_driver:
|
||||
os << "disk_resize, error getting TM driver.";
|
||||
goto error_common;
|
||||
|
||||
error_history:
|
||||
os << "disk_resize, the VM has no history";
|
||||
goto error_common;
|
||||
|
||||
error_file:
|
||||
os << "disk_resize, could not open file: " << xfr_name;
|
||||
goto error_common;
|
||||
|
||||
error_disk:
|
||||
os << "disk_resize, could not find resize disk";
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
vm->log("TM", Log::ERROR, os);
|
||||
|
||||
(nd.get_lcm())->trigger(LifeCycleManager::DISK_RESIZE_FAILURE, vid);
|
||||
|
||||
vm->unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* MAD Loading */
|
||||
/* ************************************************************************** */
|
||||
|
@ -158,6 +158,10 @@ void TransferManagerDriver::protocol(const string& message) const
|
||||
lcm_action = LifeCycleManager::DISK_SNAPSHOT_SUCCESS;
|
||||
break;
|
||||
|
||||
case VirtualMachine::DISK_RESIZE_POWEROFF:
|
||||
lcm_action = LifeCycleManager::DISK_RESIZE_SUCCESS;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto error_state;
|
||||
}
|
||||
@ -224,6 +228,10 @@ void TransferManagerDriver::protocol(const string& message) const
|
||||
lcm_action = LifeCycleManager::DISK_SNAPSHOT_FAILURE;
|
||||
break;
|
||||
|
||||
case VirtualMachine::DISK_RESIZE_POWEROFF:
|
||||
lcm_action = LifeCycleManager::DISK_RESIZE_FAILURE;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto error_state;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ bool QuotaDatastore::check(Template * tmpl, Quotas& default_quotas, string& erro
|
||||
map<string, float> ds_request;
|
||||
|
||||
string ds_id;
|
||||
int size;
|
||||
float size;
|
||||
int images, images_req = 1;
|
||||
|
||||
tmpl->get("DATASTORE", ds_id);
|
||||
@ -68,7 +68,7 @@ void QuotaDatastore::del(Template * tmpl)
|
||||
map<string, float> ds_request;
|
||||
|
||||
string ds_id;
|
||||
int size;
|
||||
float size;
|
||||
int images, images_req = 1;
|
||||
|
||||
tmpl->get("DATASTORE", ds_id);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "QuotaVirtualMachine.h"
|
||||
#include "Quotas.h"
|
||||
#include "VirtualMachine.h"
|
||||
#include "VirtualMachineDisk.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -61,7 +62,7 @@ bool QuotaVirtualMachine::check(Template * tmpl,
|
||||
return false;
|
||||
}
|
||||
|
||||
size = VirtualMachine::get_system_disk_size(tmpl);
|
||||
size = VirtualMachineDisks::system_ds_size(tmpl);
|
||||
|
||||
vm_request.insert(make_pair("VMS",1));
|
||||
vm_request.insert(make_pair("MEMORY", memory));
|
||||
@ -97,7 +98,7 @@ void QuotaVirtualMachine::del(Template * tmpl)
|
||||
vms = 1;
|
||||
}
|
||||
|
||||
size = VirtualMachine::get_system_disk_size(tmpl);
|
||||
size = VirtualMachineDisks::system_ds_size(tmpl);
|
||||
|
||||
vm_request.insert(make_pair("VMS", vms));
|
||||
vm_request.insert(make_pair("MEMORY", memory));
|
||||
@ -141,7 +142,7 @@ bool QuotaVirtualMachine::update(Template * tmpl,
|
||||
vm_request.insert(make_pair("CPU", delta_cpu));
|
||||
}
|
||||
|
||||
delta_size = VirtualMachine::get_system_disk_size(tmpl);
|
||||
delta_size = VirtualMachineDisks::system_ds_size(tmpl);
|
||||
|
||||
if ( delta_size != 0 )
|
||||
{
|
||||
|
@ -48,6 +48,9 @@ source_files=[
|
||||
'VirtualMachinePool.cc',
|
||||
'VirtualMachineHook.cc',
|
||||
'VirtualMachineTemplate.cc',
|
||||
'VirtualMachineAttribute.cc',
|
||||
'VirtualMachineDisk.cc',
|
||||
'VirtualMachineSystemSnapshot.cc',
|
||||
'Snapshots.cc'
|
||||
]
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
175
src/vm/VirtualMachineAttribute.cc
Normal file
175
src/vm/VirtualMachineAttribute.cc
Normal file
@ -0,0 +1,175 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "VirtualMachineAttribute.h"
|
||||
|
||||
|
||||
VirtualMachineAttributeSet::VirtualMachineAttributeSet(const std::string anam,
|
||||
const std::string& idnam, Template * tmpl):dispose(false)
|
||||
{
|
||||
std::vector<VectorAttribute *> vas;
|
||||
|
||||
tmpl->get(anam, vas);
|
||||
|
||||
init_attribute_map(idnam, vas);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualMachineAttributeSet::VirtualMachineAttributeSet(const std::string& idnam,
|
||||
std::vector<VectorAttribute *>& vas, bool _dispose):dispose(_dispose)
|
||||
{
|
||||
init_attribute_map(idnam, vas);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualMachineAttributeSet::~VirtualMachineAttributeSet()
|
||||
{
|
||||
std::map<int, VirtualMachineAttribute *>::iterator it;
|
||||
|
||||
for (it = a_set.begin(); it != a_set.end(); ++it)
|
||||
{
|
||||
if ( dispose )
|
||||
{
|
||||
delete it->second->va;
|
||||
}
|
||||
|
||||
delete it->second;
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualMachineAttribute * VirtualMachineAttributeSet::get_attribute(int id) const
|
||||
{
|
||||
std::map<int, VirtualMachineAttribute*>::const_iterator it = a_set.find(id);
|
||||
|
||||
if ( it == a_set.end() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualMachineAttribute * VirtualMachineAttributeSet::get_attribute(
|
||||
const string& flag) const
|
||||
{
|
||||
std::map<int, VirtualMachineAttribute*>::const_iterator it;
|
||||
|
||||
for( it = a_set.begin(); it != a_set.end(); ++it)
|
||||
{
|
||||
if ( it->second->is_flag(flag) == true )
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualMachineAttribute * VirtualMachineAttributeSet::remove_attribute(
|
||||
const string& flag)
|
||||
{
|
||||
std::map<int, VirtualMachineAttribute*>::const_iterator it;
|
||||
VirtualMachineAttribute * tmp = 0;
|
||||
|
||||
for( it = a_set.begin(); it != a_set.end(); ++it)
|
||||
{
|
||||
if ( it->second->is_flag(flag) == true )
|
||||
{
|
||||
tmp = it->second;
|
||||
a_set.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachineAttributeSet::init_attribute_map(const std::string& id_name,
|
||||
std::vector<VectorAttribute *>& vas)
|
||||
{
|
||||
std::vector<VectorAttribute *>::iterator it;
|
||||
int id, auto_id;
|
||||
|
||||
for (it = vas.begin(), auto_id = 0; it != vas.end(); ++it, ++auto_id)
|
||||
{
|
||||
if (id_name.empty())
|
||||
{
|
||||
id = auto_id;
|
||||
}
|
||||
else if ( (*it)->vector_value(id_name, id) != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
VirtualMachineAttribute * a = attribute_factory(*it, id);
|
||||
|
||||
a_set.insert(make_pair(id, a));
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachineAttributeSet::set_flag(int a_id, const string& flag_name)
|
||||
{
|
||||
VirtualMachineAttribute * va = get_attribute(a_id);
|
||||
|
||||
if ( va == 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
va->set_flag(flag_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualMachineAttribute * VirtualMachineAttributeSet::clear_flag(
|
||||
const string& flag)
|
||||
{
|
||||
std::map<int, VirtualMachineAttribute*>::iterator it;
|
||||
|
||||
for( it = a_set.begin(); it != a_set.end(); ++it)
|
||||
{
|
||||
if ( it->second->is_flag(flag) == true )
|
||||
{
|
||||
it->second->clear_flag(flag);
|
||||
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
1075
src/vm/VirtualMachineDisk.cc
Normal file
1075
src/vm/VirtualMachineDisk.cc
Normal file
File diff suppressed because it is too large
Load Diff
@ -1038,8 +1038,6 @@ int VirtualMachinePool::calculate_showback(
|
||||
void VirtualMachinePool::delete_attach_disk(int vid)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
VectorAttribute * disk;
|
||||
Snapshots * snap;
|
||||
|
||||
int uid;
|
||||
int gid;
|
||||
@ -1052,7 +1050,7 @@ void VirtualMachinePool::delete_attach_disk(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
disk = vm->delete_attach_disk(&snap);
|
||||
VirtualMachineDisk * disk = vm->delete_attach_disk();
|
||||
uid = vm->get_uid();
|
||||
gid = vm->get_gid();
|
||||
oid = vm->get_oid();
|
||||
@ -1069,10 +1067,10 @@ void VirtualMachinePool::delete_attach_disk(int vid)
|
||||
Template tmpl;
|
||||
int image_id;
|
||||
|
||||
tmpl.set(disk);
|
||||
tmpl.set(disk->vector_attribute());
|
||||
tmpl.add("VMS", 0);
|
||||
|
||||
if (VirtualMachine::is_volatile(disk))
|
||||
if (disk->is_volatile())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, &tmpl);
|
||||
}
|
||||
@ -1082,20 +1080,21 @@ void VirtualMachinePool::delete_attach_disk(int vid)
|
||||
|
||||
Quotas::quota_del(Quotas::IMAGE, uid, gid, &tmpl);
|
||||
|
||||
if (!VirtualMachine::is_persistent(disk))
|
||||
if (!disk->is_persistent())
|
||||
{
|
||||
Quotas::quota_del(Quotas::VM, uid, gid, &tmpl);
|
||||
}
|
||||
|
||||
if (snap != 0)
|
||||
if ( disk->has_snapshots() )
|
||||
{
|
||||
imagem->set_image_snapshots(image_id, *snap);
|
||||
delete snap;
|
||||
imagem->set_image_snapshots(image_id, *disk->get_snapshots());
|
||||
}
|
||||
|
||||
imagem->release_image(oid, image_id, false);
|
||||
}
|
||||
}
|
||||
|
||||
delete disk;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
161
src/vm/VirtualMachineSystemSnapshot.cc
Normal file
161
src/vm/VirtualMachineSystemSnapshot.cc
Normal file
@ -0,0 +1,161 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "VirtualMachine.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// System Snapshot Interface
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
int VirtualMachine::new_snapshot(string& name, int& snap_id)
|
||||
{
|
||||
int num_snaps;
|
||||
int id;
|
||||
int max_id = -1;
|
||||
|
||||
vector<VectorAttribute *> snaps;
|
||||
|
||||
num_snaps = obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for(int i=0; i<num_snaps; i++)
|
||||
{
|
||||
snaps[i]->vector_value("SNAPSHOT_ID", id);
|
||||
|
||||
if (id > max_id)
|
||||
{
|
||||
max_id = id;
|
||||
}
|
||||
}
|
||||
|
||||
snap_id = max_id + 1;
|
||||
|
||||
if (name.empty())
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "snapshot-" << snap_id;
|
||||
|
||||
name = oss.str();
|
||||
}
|
||||
|
||||
VectorAttribute * snap = new VectorAttribute("SNAPSHOT");
|
||||
snap->replace("SNAPSHOT_ID", snap_id);
|
||||
snap->replace("NAME", name);
|
||||
snap->replace("TIME", (int)time(0));
|
||||
snap->replace("HYPERVISOR_ID", "");
|
||||
|
||||
snap->replace("ACTIVE", "YES");
|
||||
|
||||
obj_template->set(snap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::set_active_snapshot(int snap_id)
|
||||
{
|
||||
int s_id;
|
||||
|
||||
vector<VectorAttribute *> snaps;
|
||||
int num_snaps = obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for(int i=0; i<num_snaps; i++)
|
||||
{
|
||||
snaps[i]->vector_value("SNAPSHOT_ID", s_id);
|
||||
|
||||
if ( s_id == snap_id )
|
||||
{
|
||||
snaps[i]->replace("ACTIVE", "YES");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::update_snapshot_id(string& hypervisor_id)
|
||||
{
|
||||
vector<VectorAttribute *> snaps;
|
||||
int num_snaps = obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for(int i=0; i<num_snaps; i++)
|
||||
{
|
||||
if ( snaps[i]->vector_value("ACTIVE") == "YES" )
|
||||
{
|
||||
snaps[i]->replace("HYPERVISOR_ID", hypervisor_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::clear_active_snapshot()
|
||||
{
|
||||
vector<VectorAttribute *> snaps;
|
||||
|
||||
int num_snaps = obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for(int i=0; i<num_snaps; i++)
|
||||
{
|
||||
if ( snaps[i]->vector_value("ACTIVE") == "YES" )
|
||||
{
|
||||
snaps[i]->remove("ACTIVE");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::delete_active_snapshot()
|
||||
{
|
||||
vector<VectorAttribute *> snaps;
|
||||
int num_snaps = obj_template->get("SNAPSHOT", snaps);
|
||||
|
||||
for(int i=0; i<num_snaps; i++)
|
||||
{
|
||||
if ( snaps[i]->vector_value("ACTIVE") == "YES" )
|
||||
{
|
||||
delete obj_template->remove(snaps[i]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::delete_snapshots()
|
||||
{
|
||||
obj_template->erase("SNAPSHOT");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -168,7 +168,9 @@ int get_image_path(VirtualMachine * vm,
|
||||
file_values.insert(make_pair(var2, val2));
|
||||
|
||||
vfile = new VectorAttribute("FILE", file_values);
|
||||
uid = ImagePool::get_disk_uid(vfile, uid);
|
||||
|
||||
VirtualMachineDisk file_disk(vfile, 0);
|
||||
uid = file_disk.get_uid(uid);
|
||||
|
||||
delete vfile;
|
||||
}
|
||||
@ -252,7 +254,7 @@ int get_image_path(VirtualMachine * vm,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#line 256 "vm_file_var_syntax.cc" /* yacc.c:339 */
|
||||
#line 258 "vm_file_var_syntax.cc" /* yacc.c:339 */
|
||||
|
||||
# ifndef YY_NULLPTR
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
@ -304,13 +306,13 @@ extern int vm_file_var__debug;
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 208 "vm_file_var_syntax.y" /* yacc.c:355 */
|
||||
#line 210 "vm_file_var_syntax.y" /* yacc.c:355 */
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
char val_char;
|
||||
|
||||
#line 314 "vm_file_var_syntax.cc" /* yacc.c:355 */
|
||||
#line 316 "vm_file_var_syntax.cc" /* yacc.c:355 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
@ -340,7 +342,7 @@ int vm_file_var__parse (mem_collector * mc, VirtualMachine * vm, vector<int> *
|
||||
|
||||
/* Copy the second part of user declarations. */
|
||||
|
||||
#line 344 "vm_file_var_syntax.cc" /* yacc.c:358 */
|
||||
#line 346 "vm_file_var_syntax.cc" /* yacc.c:358 */
|
||||
|
||||
#ifdef short
|
||||
# undef short
|
||||
@ -638,9 +640,9 @@ static const yytype_uint8 yytranslate[] =
|
||||
|
||||
#if YYDEBUG
|
||||
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
||||
static const yytype_uint8 yyrline[] =
|
||||
static const yytype_uint16 yyrline[] =
|
||||
{
|
||||
0, 232, 232, 233, 237, 255
|
||||
0, 234, 234, 235, 239, 257
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1520,7 +1522,7 @@ yyreduce:
|
||||
switch (yyn)
|
||||
{
|
||||
case 4:
|
||||
#line 238 "vm_file_var_syntax.y" /* yacc.c:1646 */
|
||||
#line 240 "vm_file_var_syntax.y" /* yacc.c:1646 */
|
||||
{
|
||||
string file((yyvsp[-6].val_str));
|
||||
string var1((yyvsp[-4].val_str));
|
||||
@ -1538,11 +1540,11 @@ yyreduce:
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
#line 1542 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1544 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
break;
|
||||
|
||||
case 5:
|
||||
#line 256 "vm_file_var_syntax.y" /* yacc.c:1646 */
|
||||
#line 258 "vm_file_var_syntax.y" /* yacc.c:1646 */
|
||||
{
|
||||
string file((yyvsp[-10].val_str));
|
||||
string var1((yyvsp[-8].val_str));
|
||||
@ -1563,11 +1565,11 @@ yyreduce:
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
#line 1567 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1569 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
break;
|
||||
|
||||
|
||||
#line 1571 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1573 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
default: break;
|
||||
}
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
@ -1802,7 +1804,7 @@ yyreturn:
|
||||
#endif
|
||||
return yyresult;
|
||||
}
|
||||
#line 277 "vm_file_var_syntax.y" /* yacc.c:1906 */
|
||||
#line 279 "vm_file_var_syntax.y" /* yacc.c:1906 */
|
||||
|
||||
|
||||
extern "C" void vm_file_var__error(
|
||||
|
@ -62,7 +62,7 @@ extern int vm_file_var__debug;
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 208 "vm_file_var_syntax.y" /* yacc.c:1909 */
|
||||
#line 210 "vm_file_var_syntax.y" /* yacc.c:1909 */
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
|
@ -113,7 +113,9 @@ int get_image_path(VirtualMachine * vm,
|
||||
file_values.insert(make_pair(var2, val2));
|
||||
|
||||
vfile = new VectorAttribute("FILE", file_values);
|
||||
uid = ImagePool::get_disk_uid(vfile, uid);
|
||||
|
||||
VirtualMachineDisk file_disk(vfile, 0);
|
||||
uid = file_disk.get_uid(uid);
|
||||
|
||||
delete vfile;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define FLEX_SCANNER
|
||||
#define YY_FLEX_MAJOR_VERSION 2
|
||||
#define YY_FLEX_MINOR_VERSION 6
|
||||
#define YY_FLEX_SUBMINOR_VERSION 0
|
||||
#define YY_FLEX_SUBMINOR_VERSION 1
|
||||
#if YY_FLEX_SUBMINOR_VERSION > 0
|
||||
#define FLEX_BETA
|
||||
#endif
|
||||
@ -107,25 +107,13 @@ typedef unsigned int flex_uint32_t;
|
||||
|
||||
#endif /* ! FLEXINT_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/* The "const" storage-class-modifier is valid. */
|
||||
#define YY_USE_CONST
|
||||
|
||||
#else /* ! __cplusplus */
|
||||
|
||||
/* C99 requires __STDC__ to be defined as 1. */
|
||||
#if defined (__STDC__)
|
||||
|
||||
#define YY_USE_CONST
|
||||
|
||||
#endif /* defined (__STDC__) */
|
||||
#endif /* ! __cplusplus */
|
||||
|
||||
#ifdef YY_USE_CONST
|
||||
/* TODO: this is always defined, so inline it */
|
||||
#define yyconst const
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
#define yynoreturn __attribute__((__noreturn__))
|
||||
#else
|
||||
#define yyconst
|
||||
#define yynoreturn
|
||||
#endif
|
||||
|
||||
/* Returned upon end-of-file. */
|
||||
@ -186,7 +174,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
|
||||
typedef size_t yy_size_t;
|
||||
#endif
|
||||
|
||||
extern yy_size_t vm_var_leng;
|
||||
extern int vm_var_leng;
|
||||
|
||||
extern FILE *vm_var_in, *vm_var_out;
|
||||
|
||||
@ -244,12 +232,12 @@ struct yy_buffer_state
|
||||
/* Size of input buffer in bytes, not including room for EOB
|
||||
* characters.
|
||||
*/
|
||||
yy_size_t yy_buf_size;
|
||||
int yy_buf_size;
|
||||
|
||||
/* Number of characters read into yy_ch_buf, not including EOB
|
||||
* characters.
|
||||
*/
|
||||
yy_size_t yy_n_chars;
|
||||
int yy_n_chars;
|
||||
|
||||
/* Whether we "own" the buffer - i.e., we know we created it,
|
||||
* and can realloc() it to grow it, and should free() it to
|
||||
@ -300,7 +288,7 @@ struct yy_buffer_state
|
||||
/* Stack of input buffers. */
|
||||
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
|
||||
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
|
||||
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
|
||||
static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
|
||||
|
||||
/* We provide macros for accessing buffer states in case in the
|
||||
* future we want to put the buffer states in a more general
|
||||
@ -319,11 +307,11 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
|
||||
|
||||
/* yy_hold_char holds the character lost when vm_var_text is formed. */
|
||||
static char yy_hold_char;
|
||||
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
|
||||
yy_size_t vm_var_leng;
|
||||
static int yy_n_chars; /* number of characters read into yy_ch_buf */
|
||||
int vm_var_leng;
|
||||
|
||||
/* Points to current character in buffer. */
|
||||
static char *yy_c_buf_p = (char *) 0;
|
||||
static char *yy_c_buf_p = NULL;
|
||||
static int yy_init = 0; /* whether we need to initialize */
|
||||
static int yy_start = 0; /* start state number */
|
||||
|
||||
@ -348,7 +336,7 @@ static void vm_var__init_buffer (YY_BUFFER_STATE b,FILE *file );
|
||||
|
||||
YY_BUFFER_STATE vm_var__scan_buffer (char *base,yy_size_t size );
|
||||
YY_BUFFER_STATE vm_var__scan_string (yyconst char *yy_str );
|
||||
YY_BUFFER_STATE vm_var__scan_bytes (yyconst char *bytes,yy_size_t len );
|
||||
YY_BUFFER_STATE vm_var__scan_bytes (yyconst char *bytes,int len );
|
||||
|
||||
void *vm_var_alloc (yy_size_t );
|
||||
void *vm_var_realloc (void *,yy_size_t );
|
||||
@ -382,7 +370,7 @@ void vm_var_free (void * );
|
||||
|
||||
typedef unsigned char YY_CHAR;
|
||||
|
||||
FILE *vm_var_in = (FILE *) 0, *vm_var_out = (FILE *) 0;
|
||||
FILE *vm_var_in = NULL, *vm_var_out = NULL;
|
||||
|
||||
typedef int yy_state_type;
|
||||
|
||||
@ -399,17 +387,14 @@ extern char *vm_var_text;
|
||||
static yy_state_type yy_get_previous_state (void );
|
||||
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
|
||||
static int yy_get_next_buffer (void );
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
__attribute__((__noreturn__))
|
||||
#endif
|
||||
static void yy_fatal_error (yyconst char msg[] );
|
||||
static void yynoreturn yy_fatal_error (yyconst char* msg );
|
||||
|
||||
/* Done after the current pattern has been matched and before the
|
||||
* corresponding action - sets up vm_var_text.
|
||||
*/
|
||||
#define YY_DO_BEFORE_ACTION \
|
||||
(yytext_ptr) = yy_bp; \
|
||||
vm_var_leng = (size_t) (yy_cp - yy_bp); \
|
||||
vm_var_leng = (int) (yy_cp - yy_bp); \
|
||||
(yy_hold_char) = *yy_cp; \
|
||||
*yy_cp = '\0'; \
|
||||
(yy_c_buf_p) = yy_cp;
|
||||
@ -559,7 +544,7 @@ char *vm_var_text;
|
||||
llocp->last_column += vm_var_leng;
|
||||
|
||||
|
||||
#line 563 "vm_var_parser.c"
|
||||
#line 548 "vm_var_parser.c"
|
||||
|
||||
#define INITIAL 0
|
||||
#define VAR 1
|
||||
@ -600,7 +585,7 @@ FILE *vm_var_get_out (void );
|
||||
|
||||
void vm_var_set_out (FILE * _out_str );
|
||||
|
||||
yy_size_t vm_var_get_leng (void );
|
||||
int vm_var_get_leng (void );
|
||||
|
||||
char *vm_var_get_text (void );
|
||||
|
||||
@ -657,7 +642,7 @@ static int input (void );
|
||||
/* This used to be an fputs(), but since the string might contain NUL's,
|
||||
* we now use fwrite().
|
||||
*/
|
||||
#define ECHO do { if (fwrite( vm_var_text, vm_var_leng, 1, vm_var_out )) {} } while (0)
|
||||
#define ECHO do { if (fwrite( vm_var_text, (size_t) vm_var_leng, 1, vm_var_out )) {} } while (0)
|
||||
#endif
|
||||
|
||||
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
||||
@ -681,7 +666,7 @@ static int input (void );
|
||||
else \
|
||||
{ \
|
||||
errno=0; \
|
||||
while ( (result = fread(buf, 1, max_size, vm_var_in))==0 && ferror(vm_var_in)) \
|
||||
while ( (result = (int) fread(buf, 1, max_size, vm_var_in))==0 && ferror(vm_var_in)) \
|
||||
{ \
|
||||
if( errno != EINTR) \
|
||||
{ \
|
||||
@ -788,7 +773,7 @@ YY_DECL
|
||||
/* $NUM.CONTEXT_VARIABLE */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#line 792 "vm_var_parser.c"
|
||||
#line 777 "vm_var_parser.c"
|
||||
|
||||
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
|
||||
{
|
||||
@ -818,7 +803,7 @@ yy_match:
|
||||
if ( yy_current_state >= 34 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_base[yy_current_state] != 47 );
|
||||
@ -938,7 +923,7 @@ YY_RULE_SETUP
|
||||
#line 92 "vm_var_parser.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 942 "vm_var_parser.c"
|
||||
#line 927 "vm_var_parser.c"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
case YY_STATE_EOF(VALUE):
|
||||
yyterminate();
|
||||
@ -1126,7 +1111,7 @@ static int yy_get_next_buffer (void)
|
||||
|
||||
else
|
||||
{
|
||||
yy_size_t num_to_read =
|
||||
int num_to_read =
|
||||
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
||||
|
||||
while ( num_to_read <= 0 )
|
||||
@ -1140,7 +1125,7 @@ static int yy_get_next_buffer (void)
|
||||
|
||||
if ( b->yy_is_our_buffer )
|
||||
{
|
||||
yy_size_t new_size = b->yy_buf_size * 2;
|
||||
int new_size = b->yy_buf_size * 2;
|
||||
|
||||
if ( new_size <= 0 )
|
||||
b->yy_buf_size += b->yy_buf_size / 8;
|
||||
@ -1153,7 +1138,7 @@ static int yy_get_next_buffer (void)
|
||||
}
|
||||
else
|
||||
/* Can't grow it, we don't own it. */
|
||||
b->yy_ch_buf = 0;
|
||||
b->yy_ch_buf = NULL;
|
||||
|
||||
if ( ! b->yy_ch_buf )
|
||||
YY_FATAL_ERROR(
|
||||
@ -1195,9 +1180,9 @@ static int yy_get_next_buffer (void)
|
||||
else
|
||||
ret_val = EOB_ACT_CONTINUE_SCAN;
|
||||
|
||||
if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
|
||||
if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
|
||||
/* Extend the array by 50%, plus the number we really need. */
|
||||
yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
|
||||
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
|
||||
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) vm_var_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
|
||||
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
|
||||
@ -1235,7 +1220,7 @@ static int yy_get_next_buffer (void)
|
||||
if ( yy_current_state >= 34 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
|
||||
}
|
||||
|
||||
return yy_current_state;
|
||||
@ -1263,7 +1248,7 @@ static int yy_get_next_buffer (void)
|
||||
if ( yy_current_state >= 34 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
|
||||
yy_is_jam = (yy_current_state == 33);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
@ -1297,7 +1282,7 @@ static int yy_get_next_buffer (void)
|
||||
|
||||
else
|
||||
{ /* need more input */
|
||||
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
|
||||
int offset = (yy_c_buf_p) - (yytext_ptr);
|
||||
++(yy_c_buf_p);
|
||||
|
||||
switch ( yy_get_next_buffer( ) )
|
||||
@ -1321,7 +1306,7 @@ static int yy_get_next_buffer (void)
|
||||
case EOB_ACT_END_OF_FILE:
|
||||
{
|
||||
if ( vm_var_wrap( ) )
|
||||
return EOF;
|
||||
return 0;
|
||||
|
||||
if ( ! (yy_did_buffer_switch_on_eof) )
|
||||
YY_NEW_FILE;
|
||||
@ -1574,7 +1559,7 @@ void vm_var_pop_buffer_state (void)
|
||||
*/
|
||||
static void vm_var_ensure_buffer_stack (void)
|
||||
{
|
||||
yy_size_t num_to_alloc;
|
||||
int num_to_alloc;
|
||||
|
||||
if (!(yy_buffer_stack)) {
|
||||
|
||||
@ -1629,7 +1614,7 @@ YY_BUFFER_STATE vm_var__scan_buffer (char * base, yy_size_t size )
|
||||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
|
||||
base[size-1] != YY_END_OF_BUFFER_CHAR )
|
||||
/* They forgot to leave room for the EOB's. */
|
||||
return 0;
|
||||
return NULL;
|
||||
|
||||
b = (YY_BUFFER_STATE) vm_var_alloc(sizeof( struct yy_buffer_state ) );
|
||||
if ( ! b )
|
||||
@ -1638,7 +1623,7 @@ YY_BUFFER_STATE vm_var__scan_buffer (char * base, yy_size_t size )
|
||||
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
|
||||
b->yy_buf_pos = b->yy_ch_buf = base;
|
||||
b->yy_is_our_buffer = 0;
|
||||
b->yy_input_file = 0;
|
||||
b->yy_input_file = NULL;
|
||||
b->yy_n_chars = b->yy_buf_size;
|
||||
b->yy_is_interactive = 0;
|
||||
b->yy_at_bol = 1;
|
||||
@ -1661,7 +1646,7 @@ YY_BUFFER_STATE vm_var__scan_buffer (char * base, yy_size_t size )
|
||||
YY_BUFFER_STATE vm_var__scan_string (yyconst char * yystr )
|
||||
{
|
||||
|
||||
return vm_var__scan_bytes(yystr,strlen(yystr) );
|
||||
return vm_var__scan_bytes(yystr,(int) strlen(yystr) );
|
||||
}
|
||||
|
||||
/** Setup the input buffer state to scan the given bytes. The next call to vm_var_lex() will
|
||||
@ -1671,7 +1656,7 @@ YY_BUFFER_STATE vm_var__scan_string (yyconst char * yystr )
|
||||
*
|
||||
* @return the newly allocated buffer state object.
|
||||
*/
|
||||
YY_BUFFER_STATE vm_var__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
|
||||
YY_BUFFER_STATE vm_var__scan_bytes (yyconst char * yybytes, int _yybytes_len )
|
||||
{
|
||||
YY_BUFFER_STATE b;
|
||||
char *buf;
|
||||
@ -1679,7 +1664,7 @@ YY_BUFFER_STATE vm_var__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes
|
||||
yy_size_t i;
|
||||
|
||||
/* Get memory for full buffer, including space for trailing EOB's. */
|
||||
n = _yybytes_len + 2;
|
||||
n = (yy_size_t) _yybytes_len + 2;
|
||||
buf = (char *) vm_var_alloc(n );
|
||||
if ( ! buf )
|
||||
YY_FATAL_ERROR( "out of dynamic memory in vm_var__scan_bytes()" );
|
||||
@ -1705,7 +1690,7 @@ YY_BUFFER_STATE vm_var__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes
|
||||
#define YY_EXIT_FAILURE 2
|
||||
#endif
|
||||
|
||||
static void yy_fatal_error (yyconst char* msg )
|
||||
static void yynoreturn yy_fatal_error (yyconst char* msg )
|
||||
{
|
||||
(void) fprintf( stderr, "%s\n", msg );
|
||||
exit( YY_EXIT_FAILURE );
|
||||
@ -1758,7 +1743,7 @@ FILE *vm_var_get_out (void)
|
||||
/** Get the length of the current token.
|
||||
*
|
||||
*/
|
||||
yy_size_t vm_var_get_leng (void)
|
||||
int vm_var_get_leng (void)
|
||||
{
|
||||
return vm_var_leng;
|
||||
}
|
||||
@ -1817,10 +1802,10 @@ static int yy_init_globals (void)
|
||||
/* We do not touch vm_var_lineno unless the option is enabled. */
|
||||
vm_var_lineno = 1;
|
||||
|
||||
(yy_buffer_stack) = 0;
|
||||
(yy_buffer_stack) = NULL;
|
||||
(yy_buffer_stack_top) = 0;
|
||||
(yy_buffer_stack_max) = 0;
|
||||
(yy_c_buf_p) = (char *) 0;
|
||||
(yy_c_buf_p) = NULL;
|
||||
(yy_init) = 0;
|
||||
(yy_start) = 0;
|
||||
|
||||
@ -1829,8 +1814,8 @@ static int yy_init_globals (void)
|
||||
vm_var_in = stdin;
|
||||
vm_var_out = stdout;
|
||||
#else
|
||||
vm_var_in = (FILE *) 0;
|
||||
vm_var_out = (FILE *) 0;
|
||||
vm_var_in = NULL;
|
||||
vm_var_out = NULL;
|
||||
#endif
|
||||
|
||||
/* For future reference: Set errno on error, since we are called by
|
||||
@ -1888,7 +1873,7 @@ static int yy_flex_strlen (yyconst char * s )
|
||||
|
||||
void *vm_var_alloc (yy_size_t size )
|
||||
{
|
||||
return (void *) malloc( size );
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *vm_var_realloc (void * ptr, yy_size_t size )
|
||||
@ -1901,7 +1886,7 @@ void *vm_var_realloc (void * ptr, yy_size_t size )
|
||||
* any pointer type to void*, and deal with argument conversions
|
||||
* as though doing an assignment.
|
||||
*/
|
||||
return (void *) realloc( (char *) ptr, size );
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
void vm_var_free (void * ptr )
|
||||
|
@ -1708,7 +1708,7 @@ void VirtualMachineManager::attach_action(
|
||||
string epilog_cmd;
|
||||
string disk_path;
|
||||
|
||||
const VectorAttribute * disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
int disk_id;
|
||||
int rc;
|
||||
|
||||
@ -1771,7 +1771,7 @@ void VirtualMachineManager::attach_action(
|
||||
|
||||
os.str("");
|
||||
|
||||
disk->vector_value("DISK_ID", disk_id);
|
||||
disk_id = disk->get_disk_id();
|
||||
|
||||
os << vm->get_system_dir() << "/disk." << disk_id;
|
||||
|
||||
@ -1850,7 +1850,7 @@ void VirtualMachineManager::detach_action(
|
||||
string disk_path;
|
||||
string error_str;
|
||||
|
||||
const VectorAttribute * disk;
|
||||
const VirtualMachineDisk * disk;
|
||||
int disk_id;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -1887,7 +1887,7 @@ void VirtualMachineManager::detach_action(
|
||||
vm_tm_mad = vm->get_tm_mad();
|
||||
opennebula_hostname = nd.get_nebula_hostname();
|
||||
|
||||
disk->vector_value("DISK_ID", disk_id);
|
||||
disk_id = disk->get_disk_id();
|
||||
|
||||
tm->epilog_transfer_command(vm, vm->get_hostname(), disk, os);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user