Beispiel #1
0
    def save_and_shutdown(farm, name, description):
        """
        """
        from cm.models.vm import VM

        if farm.state == farm_states['failed']:
            raise CMException('farm_wrong_state')

        head_vm = farm.head
        try:
            VM.save_and_shutdown(head_vm.user_id, head_vm, name, description)
        except Exception:
            CMException('farm_save')

        node_vms = []
        if farm.state == farm_states['init_head']:
            for vm in farm.vms.all():
                if vm.is_head():
                    continue
                vm.release_resources()
                vm.state = vm_states['closed']
        else:
            for vm in farm.vms.all():
                if not vm.is_head():
                    node_vms.append(vm)
            VM.destroy(node_vms)

        try:
            farm.state = farm_states['closed']
            farm.save()
        except:
            CMException('farm_save')
Beispiel #2
0
    def save_and_shutdown(farm, name, description):
        """
        """
        from cm.models.vm import VM

        if farm.state == farm_states["failed"]:
            raise CMException("farm_wrong_state")

        head_vm = farm.head
        try:
            VM.save_and_shutdown(head_vm.user_id, head_vm, name, description)
        except Exception:
            CMException("farm_save")

        node_vms = []
        if farm.state == farm_states["init_head"]:
            for vm in farm.vms.all():
                if vm.is_head():
                    continue
                vm.release_resources()
                vm.state = vm_states["closed"]
        else:
            for vm in farm.vms.all():
                if not vm.is_head():
                    node_vms.append(vm)
            VM.destroy(node_vms)

        try:
            farm.state = farm_states["closed"]
            farm.save()
        except:
            CMException("farm_save")
Beispiel #3
0
def save_and_shutdown(caller_id, vm_id, name, description):
    """
    Calls VM.save_and_shutdown() on specified VM

    @cmview_user
    @param_post{vm_id,int} id of the VM to save and shutdown.
    @param_post{name,string} name of the new SystemImage VM should be saved to
    @param_post{description,string} description of the new SystemImage VM
    should be saved to
    """
    user = User.get(caller_id)
    vm = VM.get(caller_id, vm_id)

    if user.used_storage + vm.system_image.size > user.storage:
        raise CMException('user_storage_limit')

    VM.save_and_shutdown(caller_id, vm, name, description)
Beispiel #4
0
def save_and_shutdown(caller_id, vm_id, name, description):
    """
    Calls VM.save_and_shutdown() on specified VM

    @cmview_user
    @param_post{vm_id,int} id of the VM to save and shutdown.
    @param_post{name,string} name of the new SystemImage VM should be saved to
    @param_post{description,string} description of the new SystemImage VM
    should be saved to
    """
    user = User.get(caller_id)
    vm = VM.get(caller_id, vm_id)

    if user.used_storage + vm.system_image.size > user.storage:
        raise CMException('user_storage_limit')

    VM.save_and_shutdown(caller_id, vm, name, description)
Beispiel #5
0
def save_and_shutdown(caller_id, vm_id, name, description):
    """
    Calls src.cm.views.utils.image.save_and_shutdown() for the VM selected.

    @cmview_user

    @parameter{vm_id,int} id of the VM to save and shutdown.
    @parameter{name,string}
    @parameter{description,string}
    """
    user = User.get(caller_id)
    vm = VM.get(caller_id, vm_id)

    if user.used_storage + vm.system_image.size > user.storage:
        raise CMException('user_storage_limit')

    VM.save_and_shutdown(caller_id, vm, name, description)
Beispiel #6
0
def save_and_shutdown(caller_id, vm_id, name, description):
    """
    Saves and shutdowns specified VM, without checking User quota.

    @cmview_admin_cm
    @param_post{vm_id,string} id of the VM to save
    @param_post{name,string}
    @param_post{description,string}
    """

    vm = VM.admin_get(vm_id)
    user = User.get(vm.user.id)

    if user.used_storage + vm.system_image.size > user.storage:
        raise CMException('user_storage_limit')

    VM.save_and_shutdown(user.id, vm, name, description)
Beispiel #7
0
def save_and_shutdown(caller_id, vm_id, name, description):
    """
    Saves and shutdowns specified VM, without checking User quota.

    @cmview_admin_cm
    @param_post{vm_id,string} id of the VM to save
    @param_post{name,string}
    @param_post{description,string}
    """

    vm = VM.admin_get(vm_id)
    user = User.get(vm.user.id)

    if user.used_storage + vm.system_image.size > user.storage:
        raise CMException('user_storage_limit')

    VM.save_and_shutdown(user.id, vm, name, description)
Beispiel #8
0
def save_and_shutdown(caller_id, vm_id, name, description):
    """
    Method calls save_and_shutdown for each VM with id is in @prm{vm_id} (for
    administrator only).
    @cmview_admin_cm

    @parameter{vm_id,string}
    @parameter{name,string}
    @parameter{description,string}
    """

    vm = VM.admin_get(vm_id)
    user = User.get(vm.user.id)

    if user.used_storage + vm.system_image.size > user.storage:
        raise CMException('user_storage_limit')

    VM.save_and_shutdown(user.id, vm, name, description)