From: Walter A. Boring IV Date: Mon, 30 Mar 2015 17:10:45 +0000 (-0700) Subject: Fix potential access to missing key X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=65e1b1d28286018b4df9fcfd732ec1ebb4d2a60c;p=openstack-build%2Fcinder-build.git Fix potential access to missing key 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 --- diff --git a/cinder/scheduler/filter_scheduler.py b/cinder/scheduler/filter_scheduler.py index d84ad48b3..1e30dbe1c 100644 --- a/cinder/scheduler/filter_scheduler.py +++ b/cinder/scheduler/filter_scheduler.py @@ -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=' True')