Ejemplo n.º 1
0
def create(caller_id, name, address, directory, capacity):
    """
    Registers new Storage.

    @cmview_admin_cm
    @param_post{name,string} libvirt's pool name
    @param_post{address,string} storage ip address or hostname
    @param_post{directory,string} directory on storage
    @param_post{capacity,int} maximum storage capacity [MB]

    @raises{storage_already_exist,CMException}
    @raises{storage_create,CMException}
    """

    #error if already exists a storage with the same name
    if Storage.objects.filter(name__exact=name).exists():
        raise CMException('storage_already_exist')

    try:
        st = Storage()
        st.name = name
        st.address = address
        st.dir = directory
        st.capacity = capacity
        st.state = storage_states['ok']

    except Exception, e:
        log.debug(caller_id,
                  'Cannot register storage - missing element: %s' % str(e))
        raise CMException('storage_create')
Ejemplo n.º 2
0
def create(caller_id, name, address, directory, capacity):
    """
    Registers new Storage.

    @cmview_admin_cm
    @param_post{name,string} libvirt's pool name
    @param_post{address,string} storage ip address or hostname
    @param_post{directory,string} directory on storage
    @param_post{capacity,int} maximum storage capacity [MB]

    @raises{storage_already_exist,CMException}
    @raises{storage_create,CMException}
    """

    #error if already exists a storage with the same name
    if Storage.objects.filter(name__exact=name).exists():
        raise CMException('storage_already_exist')

    try:
        st = Storage()
        st.name = name
        st.address = address
        st.dir = directory
        st.capacity = capacity
        st.state = storage_states['ok']

    except Exception, e:
        log.debug(caller_id, 'Cannot register storage - missing element: %s' % str(e))
        raise CMException('storage_create')
Ejemplo n.º 3
0
 def create(cls, name, description, user, disk_dev, disk_controller, size=0, progress=100):
     image = cls()
     image.name = name
     image.description = description
     image.state = image_states['adding']
     image.user = user
     image.size = size
     image.progress = progress
     image.disk_dev = disk_dev
     image.storage = Storage.get()
     image.disk_controller = disk_controller
     image.access = image_access['private']
     return image
Ejemplo n.º 4
0
 def create(cls,
            name,
            description,
            user,
            disk_dev,
            disk_controller,
            size=0,
            progress=100):
     image = cls()
     image.name = name
     image.description = description
     image.state = image_states['adding']
     image.user = user
     image.size = size
     image.progress = progress
     image.disk_dev = disk_dev
     image.storage = Storage.get()
     image.disk_controller = disk_controller
     image.access = image_access['private']
     return image