mirror of
https://github.com/retspen/webvirtcloud
synced 2024-10-31 19:44:16 +00:00
add image owner option to clone_volume, create_volume functions
This commit is contained in:
parent
e1910c75ff
commit
df4cf01f05
1 changed files with 9 additions and 8 deletions
|
@ -3,6 +3,7 @@ from vrtManager import util
|
|||
from vrtManager.connection import wvmConnect
|
||||
from webvirtcloud.settings import QEMU_CONSOLE_DEFAULT_TYPE
|
||||
from webvirtcloud.settings import QEMU_CONSOLE_LISTEN_ADDRESSES
|
||||
from webvirtcloud.settings import INSTANCE_VOLUME_DEFAULT_OWNER as default_owner
|
||||
from webvirtcloud.settings import INSTANCE_VOLUME_DEFAULT_FORMAT
|
||||
|
||||
|
||||
|
@ -52,7 +53,7 @@ class wvmCreate(wvmConnect):
|
|||
"""Get guest capabilities"""
|
||||
return util.get_xml_path(self.get_cap_xml(), "/capabilities/host/cpu/arch")
|
||||
|
||||
def create_volume(self, storage, name, size, image_format=image_format, metadata=False):
|
||||
def create_volume(self, storage, name, size, image_format=image_format, metadata=False, owner=default_owner):
|
||||
size = int(size) * 1073741824
|
||||
stg = self.get_storage(storage)
|
||||
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
||||
|
@ -70,13 +71,13 @@ class wvmCreate(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>
|
||||
</target>
|
||||
</volume>""" % (name, size, alloc, image_format)
|
||||
</volume>""" % (name, size, alloc, image_format, owner['uid'], owner['guid'])
|
||||
stg.createXML(xml, metadata)
|
||||
try:
|
||||
stg.refresh(0)
|
||||
|
@ -110,7 +111,7 @@ class wvmCreate(wvmConnect):
|
|||
vol = self.get_volume_by_path(vol_path)
|
||||
return vol.storagePoolLookupByVolume()
|
||||
|
||||
def clone_from_template(self, clone, template, metadata=False):
|
||||
def clone_from_template(self, clone, template, metadata=False, owner=default_owner):
|
||||
vol = self.get_volume_by_path(template)
|
||||
stg = vol.storagePoolLookupByVolume()
|
||||
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
||||
|
@ -127,8 +128,8 @@ class wvmCreate(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>
|
||||
|
@ -137,7 +138,7 @@ class wvmCreate(wvmConnect):
|
|||
<lazy_refcounts/>
|
||||
</features>
|
||||
</target>
|
||||
</volume>""" % (clone, format)
|
||||
</volume>""" % (clone, format, owner['uid'], owner['guid'])
|
||||
stg.createXMLFrom(xml, vol, metadata)
|
||||
clone_vol = stg.storageVolLookupByName(clone)
|
||||
return clone_vol.path()
|
||||
|
|
Loading…
Reference in a new issue