diff options
author | Andrea Rosa <andrea.rosa@hp.com> | 2016-01-07 16:20:50 +0000 |
---|---|---|
committer | Andrea Rosa <andrea.rosa@hp.com> | 2016-01-28 09:32:13 +0000 |
commit | 3f9802127181ef35903deafdf00ec60f05ad3004 (patch) | |
tree | 5bc3acd74a640a8d6622768fd53841d60e06ef7f /nova/block_device.py | |
parent | 42e4126f0545ff9dbd27871964bb010f083515a4 (diff) | |
download | nova-3f9802127181ef35903deafdf00ec60f05ad3004.tar.gz |
Adding guard on None value for some helpers method
We use some helper methods to strip and extrapolate details from the
device name string, some of these methods are missing the check on None
values, if a None is passed the code raise a TypeError exception. This
change adds a check for managing None values correctly.
Change-Id: Iebfaa09e494dac085b78dbaffa867f8047c2106b
Diffstat (limited to 'nova/block_device.py')
-rw-r--r-- | nova/block_device.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/nova/block_device.py b/nova/block_device.py index cf670a6486..38e1c62f80 100644 --- a/nova/block_device.py +++ b/nova/block_device.py @@ -494,7 +494,7 @@ _pref = re.compile('^((x?v|s|h)d)') def strip_prefix(device_name): """remove both leading /dev/ and xvd or sd or vd or hd.""" device_name = strip_dev(device_name) - return _pref.sub('', device_name) + return _pref.sub('', device_name) if device_name else device_name _nums = re.compile('\d+') @@ -504,7 +504,7 @@ def get_device_letter(device_name): letter = strip_prefix(device_name) # NOTE(vish): delete numbers in case we have something like # /dev/sda1 - return _nums.sub('', letter) + return _nums.sub('', letter) if device_name else device_name def instance_block_mapping(instance, bdms): |