Replace VDI.location with a more generic VDI.other_config map. Remove

VDI.sector_size.

Xend work by Tom Wilkie <tom.wilkie@gmail.com>.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
Ewan Mellor committed 2007-03-17 23:55:03 +00:00
1 parent 716d0617c9
commit 98321440ec
12 files changed
+272 -107

No files matched your search

+1 -2
View File
@@ -39,14 +39,13 @@ vm_cfg = {
local_vdi_cfg = {
'name_label': 'gentoo.hvm',
'name_description': '',
'location': 'file:/root/gentoo.amd64.hvm.img',
'virtual_size': 0,
'sector_size': 0,
'type': 'system',
'parent': '',
'SR_name': 'Local',
'sharable': False,
'read_only': False,
'other_config': {'location': 'file:/root/gentoo.amd64.hvm.img'},
}
local_vbd_cfg = {
+2 -4
View File
@@ -39,8 +39,7 @@ vm_cfg = {
vdi_cfg = {
'name_label': 'API_VDI',
'name_description': '',
'virtual_size': 100 * 1024 * 1024,
'sector_size': 1024,
'virtual_size': 100 * 1024 * 1024 * 1024,
'type': 'system',
'parent': '',
'SR_name': 'QCoW',
@@ -60,14 +59,13 @@ vbd_cfg = {
local_vdi_cfg = {
'name_label': 'gentoo.amd64.img',
'name_description': '',
'location': 'file:/root/gentoo.amd64.img',
'virtual_size': 0,
'sector_size': 0,
'type': 'system',
'parent': '',
'SR_name': 'Local',
'sharable': False,
'read_only': False,
'other_config': {'location': 'file:/root/gentoo.amd64.img'},
}
local_vbd_cfg = {
+3 -8
View File
@@ -40,8 +40,7 @@ VM_LIST_FORMAT = '%(name_label)-18s %(memory_actual)-5s %(VCPUs_number)-5s'\
' %(power_state)-10s %(uuid)-36s'
SR_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(physical_size)-10s' \
'%(type)-10s'
VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s '\
'%(sector_size)-8s'
VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s'
VBD_LIST_FORMAT = '%(device)-6s %(uuid)-36s %(VDI)-8s'
TASK_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(status)-8s %(progress)-4s'
VIF_LIST_FORMAT = '%(name)-8s %(device)-7s %(uuid)-36s %(MAC)-10s'
@@ -96,12 +95,9 @@ OPTIONS = {
'vdi-create': [(('--name-label',), {'help': 'Name for VDI'}),
(('--name-description',), {'help': 'Description for VDI'}),
(('--sector-size',), {'type': 'int',
'help': 'Sector size',
'default': 0}),
(('--virtual-size',), {'type': 'int',
'default': 0,
'help': 'Size of VDI in sectors'}),
'help': 'Size of VDI in bytes'}),
(('--type',), {'choices': ['system', 'user', 'ephemeral'],
'default': 'system',
'help': 'VDI type'}),
@@ -569,8 +565,7 @@ def xapi_vdi_list(args, async = False):
if not is_long:
print VDI_LIST_FORMAT % {'name_label': 'VDI Label',
'uuid' : 'UUID',
'virtual_size': 'Bytes',
'sector_size': 'Sector Size'}
'virtual_size': 'Bytes'}
for vdi in vdis:
vdi_struct = execute(server, 'VDI.get_record', (session, vdi))
+1 -2
View File
@@ -1,7 +1,6 @@
name_label = 'VDI 1'
name_description = ''
virtual_size = 10 * 1024 * 1024
sector_size = 1024
virtual_size = 10 * 1024 * 1024 * 1024
type = 'system'
sharable = False
read_only = False
+12 -7
View File
@@ -1811,13 +1811,13 @@ class XendAPI(object):
VDI_attr_ro = ['SR',
'VBDs',
'physical_utilisation',
'sector_size',
'type']
VDI_attr_rw = ['name_label',
'name_description',
'virtual_size',
'sharable',
'read_only']
'read_only',
'other_config']
VDI_attr_inst = VDI_attr_ro + VDI_attr_rw
VDI_methods = [('snapshot', 'VDI')]
@@ -1832,10 +1832,7 @@ class XendAPI(object):
def VDI_get_physical_utilisation(self, session, vdi_ref):
return xen_api_success(self._get_VDI(vdi_ref).
get_physical_utilisation())
def VDI_get_sector_size(self, session, vdi_ref):
return xen_api_success(self._get_VDI(vdi_ref).sector_size)
get_physical_utilisation())
def VDI_get_type(self, session, vdi_ref):
return xen_api_success(self._get_VDI(vdi_ref).type)
@@ -1877,6 +1874,14 @@ class XendAPI(object):
self._get_VDI(vdi_ref).read_only = bool(value)
return xen_api_success_void()
def VDI_get_other_config(self, session, vdi_ref):
return xen_api_success(
self._get_VDI(vdi_ref).other_config)
def VDI_set_other_config(self, session, vdi_ref, other_config):
self._get_VDI(vdi_ref).other_config = other_config
return xen_api_success_void()
# Object Methods
def VDI_snapshot(self, session, vdi_ref):
return xen_api_todo()
@@ -1896,10 +1901,10 @@ class XendAPI(object):
'VBDs': [], # TODO
'virtual_size': image.virtual_size,
'physical_utilisation': image.physical_utilisation,
'sector_size': image.sector_size,
'type': image.type,
'sharable': image.sharable,
'read_only': image.read_only,
'other_config': image.other_config
})
# Class Functions
+6 -11
View File
@@ -54,7 +54,6 @@ class XendVDI(AutoSaveObject):
SAVED_CFG = ['name_label',
'name_description',
'sector_size',
'virtual_size',
'physical_utilisation',
'sharable',
@@ -67,13 +66,12 @@ class XendVDI(AutoSaveObject):
self.sr_uuid = sr_uuid
self.name_label = ""
self.name_description = ""
self.sector_size = 1024
self.virtual_size = 0
self.physical_utilisation = 0
self.sharable = False
self.read_only = False
self.type = "system"
self.location = ''
self.other_config = {}
def load_config_dict(self, cfg):
"""Loads configuration into the object from a dict.
@@ -144,11 +142,10 @@ class XendVDI(AutoSaveObject):
'name_description': self.name_description,
'virtual_size': self.virtual_size,
'physical_utilisation': self.physical_utilisation,
'sector_size': self.sector_size,
'sharable': False,
'readonly': False,
'SR': self.sr_uuid,
'location': self.get_location(),
'other_config': self.other_config,
'VBDs': []}
def get_location(self):
@@ -163,12 +160,11 @@ class XendQCoWVDI(XendVDI):
self.cfg_path = cfg_path
self.physical_utilisation = psize
self.virtual_size = vsize
self.sector_size = 512
self.auto_save = True
self.location = 'tap:qcow:%s' % self.qcow_path
self.other_config['location'] = 'tap:qcow:%s' % self.qcow_path
def get_location(self):
return self.location
return self.other_config['location']
class XendLocalVDI(XendVDI):
def __init__(self, vdi_struct):
@@ -182,11 +178,10 @@ class XendLocalVDI(XendVDI):
self.name_description = vdi_struct.get('name_description', '')
self.physical_utilisation = 0
self.virtual_size = 0
self.sector_size = 0
self.type = vdi_struct.get('type', '')
self.sharable = vdi_struct.get('sharable', False)
self.read_only = vdi_struct.get('read_only', False)
self.location = vdi_struct.get('location', 'file:/dev/null')
self.other_config = vdi_struct.get('other_config', {})
def get_location(self):
return self.location
return self.other_config['location']
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.