1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 15:15:22 +00:00

db migrations and storage list allocation info changes

This commit is contained in:
catborise 2018-07-25 09:37:38 +03:00
parent 4126ad2591
commit 171f98b232
2 changed files with 40 additions and 3 deletions

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-07-24 11:36
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('instances', '0003_instance_created'),
]
operations = [
migrations.AlterField(
model_name='instance',
name='name',
field=models.CharField(max_length=120),
),
]

View file

@ -169,6 +169,10 @@ class wvmStorage(wvmConnect):
vol = self.get_volume(name)
return vol.info()[1]
def get_volume_allocation(self, name):
vol = self.get_volume(name)
return vol.info()[2]
def _vol_XMLDesc(self, name):
vol = self.get_volume(name)
return vol.XMLDesc(0)
@ -196,6 +200,7 @@ class wvmStorage(wvmConnect):
vol_list.append(
{'name': volname,
'size': self.get_volume_size(volname),
'allocation': self.get_volume_allocation(volname),
'type': self.get_volume_type(volname)}
)
return vol_list
@ -216,14 +221,20 @@ class wvmStorage(wvmConnect):
<allocation>%s</allocation>
<target>
<format type='%s'/>
<permissions>
<owner>107</owner>
<group>107</group>
<mode>0644</mode>
<label>virt_image_t</label>
</permissions>
</target>
</volume>""" % (name, size, alloc, vol_fmt)
self._createXML(xml, metadata)
def clone_volume(self, name, clone, vol_fmt=None, metadata=False):
def clone_volume(self, name, target_file, vol_fmt=None, metadata=False):
storage_type = self.get_type()
if storage_type == 'dir':
clone += '.img'
target_file += '.img'
vol = self.get_volume(name)
if not vol_fmt:
vol_fmt = self.get_volume_type(name)
@ -234,6 +245,12 @@ class wvmStorage(wvmConnect):
<allocation>0</allocation>
<target>
<format type='%s'/>
<permissions>
<owner>107</owner>
<group>107</group>
<mode>0644</mode>
<label>virt_image_t</label>
</permissions>
</target>
</volume>""" % (clone, vol_fmt)
</volume>""" % (target_file, vol_fmt)
self._createXMLFrom(xml, vol, metadata)