MCPcopy
hub / github.com/retspen/webvirtcloud / create_volume

Method create_volume

vrtManager/create.py:43–68  ·  view source on GitHub ↗
(self, storage, name, size, format='qcow2', metadata=False)

Source from the content-addressed store, hash-verified

41 return util.get_xml_path(self.get_cap_xml(), "/capabilities/host/cpu/arch")
42
43 def create_volume(self, storage, name, size, format='qcow2', metadata=False):
44 size = int(size) * 1073741824
45 stg = self.get_storage(storage)
46 storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
47 if storage_type == 'dir':
48 name += '.img'
49 alloc = 0
50 else:
51 alloc = size
52 metadata = False
53 xml = """
54 <volume>
55 <name>%s</name>
56 <capacity>%s</capacity>
57 <allocation>%s</allocation>
58 <target>
59 <format type='%s'/>
60 </target>
61 </volume>""" % (name, size, alloc, format)
62 stg.createXML(xml, metadata)
63 try:
64 stg.refresh(0)
65 except:
66 pass
67 vol = stg.storageVolLookupByName(name)
68 return vol.path()
69
70 def get_volume_type(self, path):
71 vol = self.get_volume_by_path(path)

Callers 2

storageFunction · 0.45
create_instanceFunction · 0.45

Calls 2

get_storageMethod · 0.80
refreshMethod · 0.80

Tested by

no test coverage detected