~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/virt/libvirt/volume.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from nova import flags
25
25
from nova import log as logging
26
26
from nova import utils
 
27
from nova.virt.libvirt import config
27
28
 
28
29
LOG = logging.getLogger(__name__)
29
30
FLAGS = flags.FLAGS
41
42
 
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'/>
48
 
                     <source dev='%s'/>
49
 
                     <target dev='%s' bus='virtio'/>
50
 
                 </disk>""" % (driver, device_path, mount_device)
51
 
        return xml
 
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
        return conf
52
54
 
53
55
    def disconnect_volume(self, connection_info, mount_device):
54
56
        """Disconnect the volume"""
59
61
    """Driver to attach Network volumes to libvirt."""
60
62
 
61
63
    def connect_volume(self, connection_info, mount_device):
62
 
        protocol = 'fake'
63
 
        name = 'fake'
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)
69
 
        return xml
 
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"
 
73
        return conf
70
74
 
71
75
 
72
76
class LibvirtNetVolumeDriver(LibvirtVolumeDriver):
73
77
    """Driver to attach Network volumes to libvirt."""
74
78
 
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'/>
86
 
                         <auth username='%s'>
87
 
                             <secret type='%s' uuid='%s'/>
88
 
                         </auth>
89
 
                         <target dev='%s' bus='virtio'/>
90
 
                     </disk>""" % (driver, protocol, name, username,
91
 
                                   secret_type, secret_uuid, mount_device)
92
 
        else:
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)
98
 
        return xml
 
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']
 
94
        return conf
99
95
 
100
96
 
101
97
class LibvirtISCSIVolumeDriver(LibvirtVolumeDriver):
164
160
        tries = 0
165
161
        while not os.path.exists(host_device):
166
162
            if tries >= FLAGS.num_iscsi_scan_tries:
167
 
                raise exception.Error(_("iSCSI device not found at %s") %
168
 
                                      (host_device))
 
163
                raise exception.NovaException(_("iSCSI device not found at %s")
 
164
                                              % (host_device))
169
165
 
170
166
            LOG.warn(_("ISCSI volume not yet found at: %(mount_device)s. "
171
167
                       "Will rescan & retry.  Try number: %(tries)s") %