Modify the verification in RBDConnector

Two points:
1. IndexError will never meet, replace it with KeyError and ValueError.
2. cluster_name, hosts, ports are required parameters like auth_username.

Change-Id: Iff1f09544d593eb86cc2bfdaaa04630a7f1bdacb
This commit is contained in:
yenai 2018-08-17 15:59:06 +08:00
parent 92feff7367
commit 5fef8baf09
1 changed files with 5 additions and 5 deletions

View File

@ -103,12 +103,12 @@ class RBDConnector(base.BaseLinuxConnector):
try:
user = connection_properties['auth_username']
pool, volume = connection_properties['name'].split('/')
cluster_name = connection_properties.get('cluster_name')
monitor_ips = connection_properties.get('hosts')
monitor_ports = connection_properties.get('ports')
cluster_name = connection_properties['cluster_name']
monitor_ips = connection_properties['hosts']
monitor_ports = connection_properties['ports']
keyring = connection_properties.get('keyring')
except IndexError:
msg = _("Connect volume failed, malformed connection properties")
except (KeyError, ValueError):
msg = _("Connect volume failed, malformed connection properties.")
raise exception.BrickException(msg=msg)
conf = self._create_ceph_conf(monitor_ips, monitor_ports,