cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
src.cm.models.storage_image.StorageImage Class Reference

DISK_VOLUME Model. More...

Inherits Image.

Public Member Functions

def attach
 Attaches this StorageImage to specified VM.
def check_attached
def create
def detach
 Requests Libvirt to detach from given VM this StorageImage.
def dict
def has_access
def revoke

Static Public Member Functions

def admin_get
 Getter, which should be called by admin.
def get

Public Attributes

 disk_dev
 vm

Static Public Attributes

tuple vm = models.ForeignKey(VM, null=True, blank=True)

Detailed Description

DISK_VOLUME Model.

Storage type image's class.

Disk Volume is one of the Images type. StorageImage class extends src.cm.models.image.Image class.

Storage images are meant to collect data produced by VM it's attached to. It should be considered as storage disk. Data may be saved on it.

There are several disk controllers to choose from. Only storage image with USB disk controller may be plugged to and unplugged from running VM on the fly. Other ones ought to be plugged while starting VM and are automatically unplugged when VM is closed or destroyed.

Definition at line 48 of file storage_image.py.

Member Function Documentation

def src.cm.models.storage_image.StorageImage.admin_get (   disk_image_id)
static

Getter, which should be called by admin.

It doesn't check Image's ownership.

    @param img_id <i>(\c int)</i> id of the requested Image

    @returns <i>(\c Image)</i> instance of the requested Image
    @exception CMException('image_get') requested Image doesn't exist

Definition at line 137 of file storage_image.py.

def src.cm.models.storage_image.StorageImage.attach (   self,
  vm 
)

Attaches this StorageImage to specified VM.

It searches for first free device and if there's any, tries to attach this to it via Libvirt. Further it updates DB information.

Parameters
vm(VM) instance of the existing VM
Exceptions
CMException('storage_image_attach')no free device found or cannot attach StorageImage

Definition at line 158 of file storage_image.py.

def src.cm.models.storage_image.StorageImage.check_attached (   self)

Definition at line 232 of file storage_image.py.

def src.cm.models.storage_image.StorageImage.create (   cls,
  name,
  description,
  user,
  disk_controller,
  size = 0 
)

Definition at line 52 of file storage_image.py.

def src.cm.models.storage_image.StorageImage.detach (   self,
  vm 
)

Requests Libvirt to detach from given VM this StorageImage.

Parameters
vm(VM) VM from which StorageImage should be detached.
Exceptions
CMException('storage_image_detach')cannot detach StorageImage

Definition at line 209 of file storage_image.py.

def src.cm.models.storage_image.StorageImage.dict (   self)
Returns
(dict) image's data
fields:
  • id
  • user_id (int)
  • name
  • platform
  • description
  • creation_date

Definition at line 69 of file storage_image.py.

def src.cm.models.storage_image.StorageImage.get (   user_id,
  disk_image_id 
)
static
Parameters
user_id(int) declared owner of the requested StorageImage
disk_image_id(int) id of the requested StorageImage
Returns
(StorageImage) requested StorageImage instance, provided it actually belongs to user_id.
Exceptions
CMException('image_get')no such Image

Definition at line 94 of file storage_image.py.

def src.cm.models.storage_image.StorageImage.has_access (   self,
  user_id 
)
Parameters
user_id(int)
Returns
(bool) True, if user user_id is the owner of the image. Otherwise exception is thrown.
Exceptions
CMException('storage_image_permission')

Definition at line 121 of file storage_image.py.

def src.cm.models.storage_image.StorageImage.revoke (   self)

Definition at line 236 of file storage_image.py.

Member Data Documentation

src.cm.models.storage_image.StorageImage.disk_dev

Definition at line 195 of file storage_image.py.

tuple src.cm.models.storage_image.StorageImage.vm = models.ForeignKey(VM, null=True, blank=True)
static

Definition at line 49 of file storage_image.py.

src.cm.models.storage_image.StorageImage.vm

Definition at line 196 of file storage_image.py.


The documentation for this class was generated from the following file: