]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix potential access to missing key
authorWalter A. Boring IV <walter.boring@hp.com>
Mon, 30 Mar 2015 17:10:45 +0000 (10:10 -0700)
committerWalter A. Boring IV <walter.boring@hp.com>
Mon, 30 Mar 2015 17:10:45 +0000 (10:10 -0700)
This patch puts a simple check around the 'extra_specs'
key, and makes sure it's there, while trying to inject
the multiattach capabilities filtering.

If we want to change the approach, we can do so in early
Liberty, when we enable multiattach for drivers.   At this
stage of the release, lets just do the simple and safe thing.

Change-Id: I45496e4325122ba20e79351f85945ca9804eaa61
Closes-Bug: 1438141

cinder/scheduler/filter_scheduler.py

index d84ad48b3e352ec373e470f9535e7931e0a84c90..1e30dbe1ce2714b0e838110669cdbbef723d24a3 100644 (file)
@@ -289,6 +289,9 @@ class FilterScheduler(driver.Scheduler):
         multiattach = volume_properties.get('multiattach', False)
         if multiattach and 'multiattach' not in resource_type.get(
                 'extra_specs', {}):
+            if 'extra_specs' not in resource_type:
+                resource_type['extra_specs'] = {}
+
             resource_type['extra_specs'].update(
                 multiattach='<is> True')