~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/virt/xenapi/volume_utils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import re
23
23
import string
24
24
 
25
 
from nova import flags
 
25
from nova.openstack.common import cfg
26
26
from nova.openstack.common import log as logging
27
27
 
28
28
 
29
 
FLAGS = flags.FLAGS
 
29
CONF = cfg.CONF
30
30
LOG = logging.getLogger(__name__)
31
31
 
32
32
 
275
275
    forget_sr(session, sr_rec['uuid'])
276
276
 
277
277
 
278
 
def parse_volume_info(connection_info, mountpoint):
 
278
def get_device_number(mountpoint):
 
279
    device_number = mountpoint_to_number(mountpoint)
 
280
    if device_number < 0:
 
281
        raise StorageError(_('Unable to obtain target information'
 
282
                ' %(mountpoint)s') % locals())
 
283
    return device_number
 
284
 
 
285
 
 
286
def parse_volume_info(connection_data):
279
287
    """
280
288
    Parse device_path and mountpoint as they can be used by XenAPI.
281
289
    In particular, the mountpoint (e.g. /dev/sdc) must be translated
288
296
    db in the iscsi_target table with the necessary info and modify
289
297
    the iscsi driver to set them.
290
298
    """
291
 
    device_number = mountpoint_to_number(mountpoint)
292
 
    data = connection_info['data']
293
 
    volume_id = data['volume_id']
294
 
    target_portal = data['target_portal']
 
299
    volume_id = connection_data['volume_id']
 
300
    target_portal = connection_data['target_portal']
295
301
    target_host = _get_target_host(target_portal)
296
302
    target_port = _get_target_port(target_portal)
297
 
    target_iqn = data['target_iqn']
 
303
    target_iqn = connection_data['target_iqn']
298
304
    LOG.debug('(vol_id,number,host,port,iqn): (%s,%s,%s,%s)',
299
305
              volume_id, target_host, target_port, target_iqn)
300
 
    if (device_number < 0 or
301
 
        volume_id is None or
 
306
    if (volume_id is None or
302
307
        target_host is None or
303
308
        target_iqn is None):
304
309
        raise StorageError(_('Unable to obtain target information'
305
 
                ' %(data)s, %(mountpoint)s') % locals())
 
310
                ' %(connection_data)s') % locals())
306
311
    volume_info = {}
307
312
    volume_info['id'] = volume_id
308
313
    volume_info['target'] = target_host
309
314
    volume_info['port'] = target_port
310
315
    volume_info['targetIQN'] = target_iqn
311
 
    if ('auth_method' in connection_info and
312
 
        connection_info['auth_method'] == 'CHAP'):
313
 
        volume_info['chapuser'] = connection_info['auth_username']
314
 
        volume_info['chappassword'] = connection_info['auth_password']
 
316
    if ('auth_method' in connection_data and
 
317
        connection_data['auth_method'] == 'CHAP'):
 
318
        volume_info['chapuser'] = connection_data['auth_username']
 
319
        volume_info['chappassword'] = connection_data['auth_password']
315
320
 
316
321
    return volume_info
317
322
 
354
359
    """Retrieve target host"""
355
360
    if iscsi_string:
356
361
        return iscsi_string[0:iscsi_string.find(':')]
357
 
    elif iscsi_string is None or FLAGS.target_host:
358
 
        return FLAGS.target_host
 
362
    elif iscsi_string is None or CONF.target_host:
 
363
        return CONF.target_host
359
364
 
360
365
 
361
366
def _get_target_port(iscsi_string):
362
367
    """Retrieve target port"""
363
368
    if iscsi_string:
364
369
        return iscsi_string[iscsi_string.find(':') + 1:]
365
 
    elif iscsi_string is None or FLAGS.target_port:
366
 
        return FLAGS.target_port
 
370
    elif iscsi_string is None or CONF.target_port:
 
371
        return CONF.target_port
367
372
 
368
373
 
369
374
def _get_iqn(iscsi_string, id):
370
375
    """Retrieve target IQN"""
371
376
    if iscsi_string:
372
377
        return iscsi_string
373
 
    elif iscsi_string is None or FLAGS.iqn_prefix:
 
378
    elif iscsi_string is None or CONF.iqn_prefix:
374
379
        volume_id = _get_volume_id(id)
375
 
        return '%s:%s' % (FLAGS.iqn_prefix, volume_id)
 
380
        return '%s:%s' % (CONF.iqn_prefix, volume_id)