Clean up ML2 Manager
Some things need cleanup in the ML2Manager. 1) Replace sys.exit(1) with raise SystemExit(1) 2) Replace reserved keyword type with network_type Change-Id: I921bfaec7d3e31503942b3ca4a1b2218c44b14ac Closes-Bug: #1259646
This commit is contained in:
parent
ee7ddbe812
commit
ca668a0b9e
@ -13,8 +13,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import stevedore
|
import stevedore
|
||||||
|
|
||||||
@ -46,16 +44,16 @@ class TypeManager(stevedore.named.NamedExtensionManager):
|
|||||||
|
|
||||||
def _register_types(self):
|
def _register_types(self):
|
||||||
for ext in self:
|
for ext in self:
|
||||||
type = ext.obj.get_type()
|
network_type = ext.obj.get_type()
|
||||||
if type in self.drivers:
|
if network_type in self.drivers:
|
||||||
LOG.error(_("Type driver '%(new_driver)s' ignored because type"
|
LOG.error(_("Type driver '%(new_driver)s' ignored because type"
|
||||||
" driver '%(old_driver)s' is already registered"
|
" driver '%(old_driver)s' is already registered"
|
||||||
" for type '%(type)s'"),
|
" for type '%(type)s'"),
|
||||||
{'new_driver': ext.name,
|
{'new_driver': ext.name,
|
||||||
'old_driver': self.drivers[type].name,
|
'old_driver': self.drivers[network_type].name,
|
||||||
'type': type})
|
'type': network_type})
|
||||||
else:
|
else:
|
||||||
self.drivers[type] = ext
|
self.drivers[network_type] = ext
|
||||||
LOG.info(_("Registered types: %s"), self.drivers.keys())
|
LOG.info(_("Registered types: %s"), self.drivers.keys())
|
||||||
|
|
||||||
def _check_tenant_network_types(self, types):
|
def _check_tenant_network_types(self, types):
|
||||||
@ -64,15 +62,15 @@ class TypeManager(stevedore.named.NamedExtensionManager):
|
|||||||
if network_type in self.drivers:
|
if network_type in self.drivers:
|
||||||
self.tenant_network_types.append(network_type)
|
self.tenant_network_types.append(network_type)
|
||||||
else:
|
else:
|
||||||
LOG.error(_("No type driver for tenant network_type: %s. "
|
msg = _("No type driver for tenant network_type: %s. "
|
||||||
"Service terminated!"),
|
"Service terminated!") % network_type
|
||||||
network_type)
|
LOG.error(msg)
|
||||||
sys.exit(1)
|
raise SystemExit(msg)
|
||||||
LOG.info(_("Tenant network_types: %s"), self.tenant_network_types)
|
LOG.info(_("Tenant network_types: %s"), self.tenant_network_types)
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
for type, driver in self.drivers.iteritems():
|
for network_type, driver in self.drivers.iteritems():
|
||||||
LOG.info(_("Initializing driver for type '%s'"), type)
|
LOG.info(_("Initializing driver for type '%s'"), network_type)
|
||||||
driver.obj.initialize()
|
driver.obj.initialize()
|
||||||
|
|
||||||
def validate_provider_segment(self, segment):
|
def validate_provider_segment(self, segment):
|
||||||
|
Loading…
Reference in New Issue
Block a user