def backups(request, hostname): """ List of server backups stored on this node. """ context = collect_view_data(request, 'node_list') context['node'] = node = get_node(request, hostname) context['nodes'] = (node, ) context['node_online'] = node.is_online() context['submenu_auto'] = '' context['lastbkp'] = [] context['can_edit'] = True context['bkp_node'] = True context['last_bkpid'] = request.GET.get('last_bkpid', None) # This could change the current DC _backup_list_context(request, node, context) context['bkpform_update'] = UpdateBackupForm(None, prefix='snap_update') context['bkpform_restore'] = RestoreBackupForm( get_vms(request, sr=(), prefetch_tags=False)) context['update_mod_source'] = reverse('node_backup_form', node.hostname, query_string=context['qs']) return render(request, 'gui/node/backups.html', context)
def backup(request, hostname): """ Backup list and backup definitions. """ dc_settings = request.dc.settings context = collect_view_data(request, 'vm_list') context['vm'] = vm = get_vm(request, hostname, sr=('dc', 'owner', 'template', 'slavevm')) context['vms'] = vms = get_vms(request) context['vms_tags'] = get_vms_tags(vms) context['can_edit'] = request.user.is_admin(request) context['bkpdefs'] = bkpdefs = get_vm_bkpdefs(vm) context['lastbkp'] = [] context.update(get_vm_backups(request, vm)) # Add paginator if context['can_edit']: context['bkpform_create'] = CreateBackupForm(vm, bkpdefs, prefix='snap_create') context['bkpform_restore'] = RestoreBackupForm(vms) context['bkpform_update'] = UpdateBackupForm(vm, prefix='snap_update') context['bkpdeform_update'] = UpdateBackupDefineForm(request, vm) bkpdef_initial = { 'zpool': dc_settings.VMS_STORAGE_DEFAULT, 'type': BackupDefine.DATASET, 'disk_id': 1, 'active': True, 'compression': dc_settings.VMS_VM_BACKUP_COMPRESSION_DEFAULT } context['bkpdeform_create'] = CreateBackupDefineForm(request, vm, prefix='bkpdef_create', initial=bkpdef_initial) view_vm_backup.send(sender='gui.vm.views.backup', request=request, context=context) return render(request, 'gui/vm/backup.html', context)
def snapshot(request, hostname): """ Snapshot list and snapshot definitions. """ context = collect_view_data(request, 'vm_list') context['vm'] = vm = get_vm(request, hostname, sr=('dc', 'owner', 'template', 'slavevm')) context['vms'] = vms = get_vms(request) context['vms_tags'] = get_vms_tags(vms) context['can_edit'] = request.user.is_admin(request) context[ 'can_image'] = request.user.is_staff or request.user.has_permission( request, ImageAdminPermission.name) context['cannot_snapshot'] = not (request.user.is_admin(request) or vm.is_installed()) context['snapform_create'] = CreateSnapshotForm(vm, prefix='snap_create', initial={'disk_id': 1}) context['snapform_update'] = UpdateSnapshotForm(vm, prefix='snap_update') context['lastsnap'] = [] context['snapdefs'] = get_vm_snapdefs(vm) context.update(get_vm_snapshots( request, vm)) # Add snapshots and count attributes + paginator if context['can_edit']: context['snapdeform_update'] = UpdateSnapshotDefineForm(request, vm) context['snapdeform_create'] = CreateSnapshotDefineForm( request, vm, prefix='snapdef_create', initial={ 'disk_id': 1, 'active': True }) context['bkpform_restore'] = RestoreBackupForm(vms) if context['can_image']: context['imgform'] = SnapshotImageForm(vm, request, None, prefix='img', initial={ 'owner': request.user.username, 'access': Image.PRIVATE, 'version': '1.0' }) view_vm_snapshot.send(sender='gui.vm.views.snapshot', request=request, context=context) return render(request, 'gui/vm/snapshot.html', context)