diff options
| author | Josh Durgin <josh.durgin@inktank.com> | 2013-05-24 17:31:17 -0700 |
|---|---|---|
| committer | Josh Durgin <josh.durgin@inktank.com> | 2013-05-28 13:35:02 -0700 |
| commit | 4d99a3486911badc39be4e089bd4106c03a8a671 (patch) | |
| tree | f0edbc240907b6989a260665d5fa0a180b8fb40f /nova/virt | |
| parent | 09526751a85535b3c4ebf7e062b0da10d1d1a99f (diff) | |
libvirt: improve the specification of network disks
Allow zero or more hosts, and make the name optional, since only a
host is needed to use nbd. This allows cinder to fully specify the
location of a sheepdog or rbd volume without depending on extra
configuration files, and lays the groundwork for supporting nbd.
Rename the internal attribute source_host to source_name to reflect
its usage in the libvirt xml, and add source_hosts and source_ports
attributes to store the new information.
Fixes: bug 1077817
blueprint better-libvirt-network-volume-support
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Change-Id: I8ac431751692e52ba0786768cea996388962922d
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/libvirt/config.py | 16 | ||||
| -rw-r--r-- | nova/virt/libvirt/volume.py | 8 |
2 files changed, 18 insertions, 6 deletions
diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py index 08a0566dd..e5319c514 100644 --- a/nova/virt/libvirt/config.py +++ b/nova/virt/libvirt/config.py @@ -460,7 +460,9 @@ class LibvirtConfigGuestDisk(LibvirtConfigGuestDevice): self.driver_cache = None self.source_path = None self.source_protocol = None - self.source_host = None + self.source_name = None + self.source_hosts = [] + self.source_ports = [] self.target_dev = None self.target_path = None self.target_bus = None @@ -499,8 +501,16 @@ class LibvirtConfigGuestDisk(LibvirtConfigGuestDevice): elif self.source_type == "mount": dev.append(etree.Element("source", dir=self.source_path)) elif self.source_type == "network": - dev.append(etree.Element("source", protocol=self.source_protocol, - name=self.source_host)) + source = etree.Element("source", protocol=self.source_protocol) + if self.source_name is not None: + source.set('name', self.source_name) + hosts_info = zip(self.source_hosts, self.source_ports) + for name, port in hosts_info: + host = etree.Element('host', name=name) + if port is not None: + host.set('port', port) + source.append(host) + dev.append(source) if self.auth_secret_type is not None: auth = etree.Element("auth") diff --git a/nova/virt/libvirt/volume.py b/nova/virt/libvirt/volume.py index 317d398d6..fa2f96743 100644 --- a/nova/virt/libvirt/volume.py +++ b/nova/virt/libvirt/volume.py @@ -131,7 +131,7 @@ class LibvirtFakeVolumeDriver(LibvirtBaseVolumeDriver): disk_info) conf.source_type = "network" conf.source_protocol = "fake" - conf.source_host = "fake" + conf.source_name = "fake" return conf @@ -145,10 +145,12 @@ class LibvirtNetVolumeDriver(LibvirtBaseVolumeDriver): conf = super(LibvirtNetVolumeDriver, self).connect_volume(connection_info, disk_info) + netdisk_properties = connection_info['data'] conf.source_type = "network" conf.source_protocol = connection_info['driver_volume_type'] - conf.source_host = connection_info['data']['name'] - netdisk_properties = connection_info['data'] + conf.source_name = netdisk_properties.get('name') + conf.source_hosts = netdisk_properties.get('hosts', []) + conf.source_ports = netdisk_properties.get('ports', []) auth_enabled = netdisk_properties.get('auth_enabled') if (conf.source_protocol == 'rbd' and CONF.rbd_secret_uuid): |
