diff --git a/instances/views.py b/instances/views.py
index c16aa31..70fb9bf 100644
--- a/instances/views.py
+++ b/instances/views.py
@@ -389,6 +389,7 @@ def instance(request, compute_id, vname):
cache_modes = sorted(conn.get_cache_modes().items())
default_cache = settings.INSTANCE_VOLUME_DEFAULT_CACHE
default_format = settings.INSTANCE_VOLUME_DEFAULT_FORMAT
+ default_owner = settings.INSTANCE_VOLUME_DEFAULT_OWNER
formats = conn.get_image_formats()
busses = conn.get_busses()
@@ -546,14 +547,14 @@ def instance(request, compute_id, vname):
compute.type)
storage = request.POST.get('storage', '')
name = request.POST.get('name', '')
- format = request.POST.get('format', '')
+ format = request.POST.get('format', default_format)
size = request.POST.get('size', 0)
meta_prealloc = request.POST.get('meta_prealloc', False)
- bus = request.POST.get('bus', '')
- cache = request.POST.get('cache', '')
+ bus = request.POST.get('bus', default_bus)
+ cache = request.POST.get('cache', default_cache)
target = get_new_disk_dev(disks, bus)
- path = connCreate.create_volume(storage, name, size, format, meta_prealloc)
+ path = connCreate.create_volume(storage, name, size, format, meta_prealloc, default_owner)
conn.attach_disk(path, target, subdriver=format, cache=cache, targetbus=bus)
msg = _('Attach new disk')
addlogmsg(request.user.username, instance.name, msg)
diff --git a/vrtManager/instance.py b/vrtManager/instance.py
index 3cc99e4..d5bc1b9 100644
--- a/vrtManager/instance.py
+++ b/vrtManager/instance.py
@@ -713,13 +713,11 @@ class wvmInstance(wvmConnect):
source_file = elm.get('file')
if source_file:
clone_dev_path.append(source_file)
- clone_path = os.path.join(os.path.dirname(source_file),
- target_file)
+ clone_path = os.path.join(os.path.dirname(source_file), target_file)
elm.set('file', clone_path)
vol = self.get_volume_by_path(source_file)
- vol_format = util.get_xml_path(vol.XMLDesc(0),
- "/volume/target/format/@type")
+ vol_format = util.get_xml_path(vol.XMLDesc(0), "/volume/target/format/@type")
if vol_format == 'qcow2' and meta_prealloc:
meta_prealloc = True
@@ -742,8 +740,7 @@ class wvmInstance(wvmConnect):
elm.set('name', clone_name)
vol = self.get_volume_by_path(source_name)
- vol_format = util.get_xml_path(vol.XMLDesc(0),
- "/volume/target/format/@type")
+ vol_format = util.get_xml_path(vol.XMLDesc(0), "/volume/target/format/@type")
vol_clone_xml = """
diff --git a/vrtManager/storage.py b/vrtManager/storage.py
index 7dc7515..21a1a7a 100644
--- a/vrtManager/storage.py
+++ b/vrtManager/storage.py
@@ -1,5 +1,6 @@
from vrtManager import util
from vrtManager.connection import wvmConnect
+from webvirtcloud.settings import INSTANCE_VOLUME_DEFAULT_OWNER as owner
class wvmStorages(wvmConnect):
@@ -205,7 +206,7 @@ class wvmStorage(wvmConnect):
)
return vol_list
- def create_volume(self, name, size, vol_fmt='qcow2', metadata=False):
+ def create_volume(self, name, size, vol_fmt='qcow2', metadata=False, owner=owner):
size = int(size) * 1073741824
storage_type = self.get_type()
alloc = size
@@ -222,8 +223,8 @@ class wvmStorage(wvmConnect):
- 107
- 107
+ %s
+ %s
0644
@@ -232,10 +233,10 @@ class wvmStorage(wvmConnect):
- """ % (name, size, alloc, vol_fmt)
+ """ % (name, size, alloc, vol_fmt, owner, owner)
self._createXML(xml, metadata)
- def clone_volume(self, name, target_file, vol_fmt=None, metadata=False):
+ def clone_volume(self, name, target_file, vol_fmt=None, metadata=False, owner=owner):
storage_type = self.get_type()
if storage_type == 'dir':
target_file += '.img'
@@ -250,8 +251,8 @@ class wvmStorage(wvmConnect):
- 107
- 107
+ %s
+ %s
0644
@@ -260,5 +261,5 @@ class wvmStorage(wvmConnect):
- """ % (target_file, vol_fmt)
+ """ % (target_file, vol_fmt, owner,owner)
self._createXMLFrom(xml, vol, metadata)
diff --git a/webvirtcloud/settings.py.template b/webvirtcloud/settings.py.template
index 72c5460..8f20dd8 100644
--- a/webvirtcloud/settings.py.template
+++ b/webvirtcloud/settings.py.template
@@ -152,3 +152,5 @@ VIEW_INSTANCES_LIST_STYLE = 'grouped'
INSTANCE_VOLUME_DEFAULT_FORMAT = 'qcow2'
INSTANCE_VOLUME_DEFAULT_BUS = 'virtio'
INSTANCE_VOLUME_DEFAULT_CACHE = 'directsync'
+# up to os, 0=root, 107=qemu or libvirt-bin(for ubuntu)
+INSTANCE_VOLUME_DEFAULT_OWNER = 0
\ No newline at end of file