-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvdi.py
34 lines (30 loc) · 936 Bytes
/
vdi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
"""
SECTOR_SIZE = 512
MBR_SIZE_SECTORS = 63
MBR_SIZE_BYTES = MBR_SIZE_SECTORS * SECTOR_SIZE
class VDI:
def __init__(self, session):
self._session = session
sr = self._session.xenapi.SR.get_by_name_label('Local storage')
if sr:
self._sr_ref = sr[0]
else:
raise ValueError('Cannot determine local storage')
def create(self, name_label, virtual_size):
virtual_size *= (1024 * 1024)
rec = {
'name_label': name_label,
'name_description': '',
'SR': self._sr_ref,
'virtual_size': '10737418240',
'type': 'User',
'sharable': False,
'read_only': False,
'xenstore_data': {},
'other_config': {},
'sm_config': {},
'tags': []
}
self._vdi_ref = self._session.xenapi.VDI.create(rec)
return self._vdi_ref