mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
volume owner/group converted to choosable from settings.py, cloning and creating volume owner parameter added.
This commit is contained in:
parent
b916c9dcf9
commit
e44e01cad4
4 changed files with 19 additions and 18 deletions
|
|
@ -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 = """
|
||||
<volume type='network'>
|
||||
|
|
|
|||
|
|
@ -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):
|
|||
<target>
|
||||
<format type='%s'/>
|
||||
<permissions>
|
||||
<owner>107</owner>
|
||||
<group>107</group>
|
||||
<owner>%s</owner>
|
||||
<group>%s</group>
|
||||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
|
|
@ -232,10 +233,10 @@ class wvmStorage(wvmConnect):
|
|||
<lazy_refcounts/>
|
||||
</features>
|
||||
</target>
|
||||
</volume>""" % (name, size, alloc, vol_fmt)
|
||||
</volume>""" % (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):
|
|||
<target>
|
||||
<format type='%s'/>
|
||||
<permissions>
|
||||
<owner>107</owner>
|
||||
<group>107</group>
|
||||
<owner>%s</owner>
|
||||
<group>%s</group>
|
||||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
|
|
@ -260,5 +261,5 @@ class wvmStorage(wvmConnect):
|
|||
<lazy_refcounts/>
|
||||
</features>
|
||||
</target>
|
||||
</volume>""" % (target_file, vol_fmt)
|
||||
</volume>""" % (target_file, vol_fmt, owner,owner)
|
||||
self._createXMLFrom(xml, vol, metadata)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue