MCPcopy
hub / github.com/retspen/webvirtcloud / storage

Function storage

storages/views.py:71–208  ·  view source on GitHub ↗

:param request: :return:

(request, compute_id, pool)

Source from the content-addressed store, hash-verified

69
70
71def 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)

Callers

nothing calls this directly

Calls 15

wvmStorageClass · 0.90
AddImageClass · 0.90
CloneImageClass · 0.90
handle_uploaded_fileFunction · 0.85
get_storagesMethod · 0.80
get_sizeMethod · 0.80
get_target_pathMethod · 0.80
refreshMethod · 0.80
update_volumesMethod · 0.80
get_volumeMethod · 0.80
clone_volumeMethod · 0.80
is_activeMethod · 0.45

Tested by

no test coverage detected