From dc0f299337cf8cdd4f5ddcfbb4b99feebc12986e Mon Sep 17 00:00:00 2001 From: Dave Lapsley Date: Fri, 20 Jan 2012 17:44:08 -0500 Subject: bug 917397 Add configuration sanity to QuantumManager. Logs error message if a parameter not used by QuantumManager's create_networks() method is passed into it. Change-Id: I1d6daa7f77590a61b542122ada33ed1c188df19f --- Authors | 1 + nova/network/quantum/manager.py | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/Authors b/Authors index 159296731..43360384a 100644 --- a/Authors +++ b/Authors @@ -35,6 +35,7 @@ Cory Wright Dan Prince Dan Wendlandt Daniel P. Berrange +Dave Lapsley Dave Walker David Pravec David Subiros diff --git a/nova/network/quantum/manager.py b/nova/network/quantum/manager.py index 4e3459011..8a1dfa488 100644 --- a/nova/network/quantum/manager.py +++ b/nova/network/quantum/manager.py @@ -132,9 +132,55 @@ class QuantumManager(manager.FlatManager): In both cases, we initialize a subnet using the IPAM lib. """ + # Enforce Configuration sanity. + # + # These flags are passed in from bin/nova-manage. The script + # collects the arguments and then passes them in through this + # function call. Note that in some cases, the script pre-processes + # the arguments, and sets them to a default value if a parameter's + # value was not specified on the command line. For pre-processed + # parameters, the most effective check to see if the user passed it + # in is to see if is different from the default value. (This + # does miss the use case where the user passes in the default value + # on the command line -- but it is unavoidable.) + if multi_host != FLAGS.multi_host: + # User specified it on the command line. + raise Exception(_("QuantumManager does not use 'multi_host'" + " parameter.")) + if num_networks != 1: raise Exception(_("QuantumManager requires that only one" " network is created per call")) + + if network_size != int(FLAGS.network_size): + # User specified it on the command line. + LOG.warning("Ignoring unnecessary parameter 'network_size'") + + if kwargs.get('vlan_start', None): + if kwargs['vlan_start'] != int(FLAGS.vlan_start): + # User specified it on the command line. + LOG.warning(_("QuantumManager does not use 'vlan_start'" + " parameter.")) + + if kwargs.get('vpn_start', None): + if kwargs['vpn_start'] != int(FLAGS.vpn_start): + # User specified it on the command line. + LOG.warning(_("QuantumManager does not use 'vpn_start'" + " parameter.")) + + if bridge is not None and len(bridge) > 0: + LOG.warning(_("QuantumManager does not use 'bridge'" + " parameter.")) + + if bridge_interface is not None and len(bridge_interface) > 0: + LOG.warning(_("QuantumManager does not use 'bridge_interface'" + " parameter.")) + + if gateway is not None and len(gateway) > 0: + if gateway.split('.')[3] != '1': + raise Exception(_("QuantumManager requires a valid (.1)" + " gateway address.")) + q_tenant_id = kwargs["project_id"] or FLAGS.quantum_default_tenant_id quantum_net_id = uuid # If a uuid was specified with the network it should have already been -- cgit