42
43
def connect_volume(self, connection_info, mount_device):
43
44
"""Connect the volume. Returns xml for libvirt."""
44
driver = self._pick_volume_driver()
45
device_path = connection_info['data']['device_path']
46
xml = """<disk type='block'>
47
<driver name='%s' type='raw' cache='none'/>
49
<target dev='%s' bus='virtio'/>
50
</disk>""" % (driver, device_path, mount_device)
45
conf = config.LibvirtConfigGuestDisk()
46
conf.source_type = "block"
47
conf.driver_name = self._pick_volume_driver()
48
conf.driver_format = "raw"
49
conf.driver_cache = "none"
50
conf.source_path = connection_info['data']['device_path']
51
conf.target_dev = mount_device
52
conf.target_bus = "virtio"
53
55
def disconnect_volume(self, connection_info, mount_device):
54
56
"""Disconnect the volume"""
59
61
"""Driver to attach Network volumes to libvirt."""
61
63
def connect_volume(self, connection_info, mount_device):
64
xml = """<disk type='network'>
65
<driver name='qemu' type='raw' cache='none'/>
66
<source protocol='%s' name='%s'/>
67
<target dev='%s' bus='virtio'/>
68
</disk>""" % (protocol, name, mount_device)
64
conf = config.LibvirtConfigGuestDisk()
65
conf.source_type = "network"
66
conf.driver_name = "qemu"
67
conf.driver_format = "raw"
68
conf.driver_cache = "none"
69
conf.source_protocol = "fake"
70
conf.source_host = "fake"
71
conf.target_dev = mount_device
72
conf.target_bus = "virtio"
72
76
class LibvirtNetVolumeDriver(LibvirtVolumeDriver):
73
77
"""Driver to attach Network volumes to libvirt."""
75
79
def connect_volume(self, connection_info, mount_device):
76
driver = self._pick_volume_driver()
77
protocol = connection_info['driver_volume_type']
78
name = connection_info['data']['name']
79
if connection_info['data'].get('auth_enabled'):
80
username = connection_info['data']['auth_username']
81
secret_type = connection_info['data']['secret_type']
82
secret_uuid = connection_info['data']['secret_uuid']
83
xml = """<disk type='network'>
84
<driver name='%s' type='raw' cache='none'/>
85
<source protocol='%s' name='%s'/>
87
<secret type='%s' uuid='%s'/>
89
<target dev='%s' bus='virtio'/>
90
</disk>""" % (driver, protocol, name, username,
91
secret_type, secret_uuid, mount_device)
93
xml = """<disk type='network'>
94
<driver name='%s' type='raw' cache='none'/>
95
<source protocol='%s' name='%s'/>
96
<target dev='%s' bus='virtio'/>
97
</disk>""" % (driver, protocol, name, mount_device)
80
conf = config.LibvirtConfigGuestDisk()
81
conf.source_type = "network"
82
conf.driver_name = self._pick_volume_driver()
83
conf.driver_format = "raw"
84
conf.driver_cache = "none"
85
conf.source_protocol = connection_info['driver_volume_type']
86
conf.source_host = connection_info['data']['name']
87
conf.target_dev = mount_device
88
conf.target_bus = "virtio"
89
netdisk_properties = connection_info['data']
90
if netdisk_properties.get('auth_enabled'):
91
conf.auth_username = netdisk_properties['auth_username']
92
conf.auth_secret_type = netdisk_properties['secret_type']
93
conf.auth_secret_uuid = netdisk_properties['secret_uuid']
101
97
class LibvirtISCSIVolumeDriver(LibvirtVolumeDriver):