:param request: :return:
(request, compute_id, pool)
| 69 | |
| 70 | |
| 71 | def storage(request, compute_id, pool): |
| 72 | """ |
| 73 | :param request: |
| 74 | :return: |
| 75 | """ |
| 76 | |
| 77 | if not request.user.is_authenticated(): |
| 78 | return HttpResponseRedirect(reverse('index')) |
| 79 | |
| 80 | if not request.user.is_superuser: |
| 81 | return HttpResponseRedirect(reverse('index')) |
| 82 | |
| 83 | def handle_uploaded_file(path, f_name): |
| 84 | target = path + '/' + str(f_name) |
| 85 | destination = open(target, 'wb+') |
| 86 | for chunk in f_name.chunks(): |
| 87 | destination.write(chunk) |
| 88 | destination.close() |
| 89 | |
| 90 | error_messages = [] |
| 91 | compute = get_object_or_404(Compute, pk=compute_id) |
| 92 | meta_prealloc = False |
| 93 | |
| 94 | try: |
| 95 | conn = wvmStorage(compute.hostname, |
| 96 | compute.login, |
| 97 | compute.password, |
| 98 | compute.type, |
| 99 | pool) |
| 100 | |
| 101 | storages = conn.get_storages() |
| 102 | state = conn.is_active() |
| 103 | size, free = conn.get_size() |
| 104 | used = (size - free) |
| 105 | if state: |
| 106 | percent = (used * 100) / size |
| 107 | else: |
| 108 | percent = 0 |
| 109 | status = conn.get_status() |
| 110 | path = conn.get_target_path() |
| 111 | type = conn.get_type() |
| 112 | autostart = conn.get_autostart() |
| 113 | |
| 114 | if state: |
| 115 | conn.refresh() |
| 116 | volumes = conn.update_volumes() |
| 117 | else: |
| 118 | volumes = None |
| 119 | except libvirtError as lib_err: |
| 120 | error_messages.append(lib_err) |
| 121 | |
| 122 | if request.method == 'POST': |
| 123 | if 'start' in request.POST: |
| 124 | try: |
| 125 | conn.start() |
| 126 | return HttpResponseRedirect(request.get_full_path()) |
| 127 | except libvirtError as lib_err: |
| 128 | error_messages.append(lib_err.message) |
nothing calls this directly
no test coverage detected