Avoid KeyError when accessing "dns_name" as it may not exist

Neutron LBaaS does not pass a full copy of the request_data
into this function, and causes the port create to fail
with a KeyError

Change-Id: Ib81cbbaf24a4ffaa983e1b05146aea0dc74e29bb
Fixes-Bug: #1605336
This commit is contained in:
Graham Hayes
2016-07-22 20:55:44 +01:00
parent ab1b3f9bed
commit 625fdb423e
2 changed files with 19 additions and 1 deletions

View File

@@ -76,7 +76,7 @@ class DNSExtensionDriver(api.ExtensionDriver):
db_data[dns.DNSDOMAIN] = new_value
def process_create_port(self, plugin_context, request_data, db_data):
if not request_data[dns.DNSNAME]:
if not request_data.get(dns.DNSNAME):
return
dns_name, is_dns_domain_default = self._get_request_dns_name(
request_data)