mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-25 15:45:23 +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 vrtManager.connection import wvmConnect
|
||||||
from webvirtcloud.settings import QEMU_CONSOLE_DEFAULT_TYPE
|
from webvirtcloud.settings import QEMU_CONSOLE_DEFAULT_TYPE
|
||||||
from webvirtcloud.settings import QEMU_CONSOLE_LISTEN_ADDRESSES
|
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
|
from webvirtcloud.settings import INSTANCE_VOLUME_DEFAULT_FORMAT
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ class wvmCreate(wvmConnect):
|
||||||
"""Get guest capabilities"""
|
"""Get guest capabilities"""
|
||||||
return util.get_xml_path(self.get_cap_xml(), "/capabilities/host/cpu/arch")
|
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
|
size = int(size) * 1073741824
|
||||||
stg = self.get_storage(storage)
|
stg = self.get_storage(storage)
|
||||||
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
||||||
|
@ -70,13 +71,13 @@ class wvmCreate(wvmConnect):
|
||||||
<target>
|
<target>
|
||||||
<format type='%s'/>
|
<format type='%s'/>
|
||||||
<permissions>
|
<permissions>
|
||||||
<owner>107</owner>
|
<owner>%s</owner>
|
||||||
<group>107</group>
|
<group>%s</group>
|
||||||
<mode>0644</mode>
|
<mode>0644</mode>
|
||||||
<label>virt_image_t</label>
|
<label>virt_image_t</label>
|
||||||
</permissions>
|
</permissions>
|
||||||
</target>
|
</target>
|
||||||
</volume>""" % (name, size, alloc, image_format)
|
</volume>""" % (name, size, alloc, image_format, owner['uid'], owner['guid'])
|
||||||
stg.createXML(xml, metadata)
|
stg.createXML(xml, metadata)
|
||||||
try:
|
try:
|
||||||
stg.refresh(0)
|
stg.refresh(0)
|
||||||
|
@ -110,7 +111,7 @@ class wvmCreate(wvmConnect):
|
||||||
vol = self.get_volume_by_path(vol_path)
|
vol = self.get_volume_by_path(vol_path)
|
||||||
return vol.storagePoolLookupByVolume()
|
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)
|
vol = self.get_volume_by_path(template)
|
||||||
stg = vol.storagePoolLookupByVolume()
|
stg = vol.storagePoolLookupByVolume()
|
||||||
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
||||||
|
@ -127,8 +128,8 @@ class wvmCreate(wvmConnect):
|
||||||
<target>
|
<target>
|
||||||
<format type='%s'/>
|
<format type='%s'/>
|
||||||
<permissions>
|
<permissions>
|
||||||
<owner>107</owner>
|
<owner>%s</owner>
|
||||||
<group>107</group>
|
<group>%s</group>
|
||||||
<mode>0644</mode>
|
<mode>0644</mode>
|
||||||
<label>virt_image_t</label>
|
<label>virt_image_t</label>
|
||||||
</permissions>
|
</permissions>
|
||||||
|
@ -137,7 +138,7 @@ class wvmCreate(wvmConnect):
|
||||||
<lazy_refcounts/>
|
<lazy_refcounts/>
|
||||||
</features>
|
</features>
|
||||||
</target>
|
</target>
|
||||||
</volume>""" % (clone, format)
|
</volume>""" % (clone, format, owner['uid'], owner['guid'])
|
||||||
stg.createXMLFrom(xml, vol, metadata)
|
stg.createXMLFrom(xml, vol, metadata)
|
||||||
clone_vol = stg.storageVolLookupByName(clone)
|
clone_vol = stg.storageVolLookupByName(clone)
|
||||||
return clone_vol.path()
|
return clone_vol.path()
|
||||||
|
|
Loading…
Reference in a new issue