Use function is_valid_mac from oslo.utils

Oslo.utils 3.17 provides same function, just use it.

Change-Id: I16e3775a239b017c3431c425d86085380e28da4c
This commit is contained in:
Luong Anh Tuan 2016-11-22 10:38:00 +07:00 committed by Tuan Luong-Anh
parent 25c5a774e3
commit 185effbb18
2 changed files with 2 additions and 10 deletions

View File

@ -17,6 +17,7 @@ import sys
import netaddr
from oslo_config import cfg
from oslo_utils import netutils
from oslo_utils import units
import six
@ -177,7 +178,7 @@ class ValidateInterfacesHook(base.ProcessingHook):
name, data=data)
continue
if not utils.is_valid_mac(mac):
if not netutils.is_valid_mac(mac):
LOG.warning(_LW('MAC %(mac)s for interface %(name)s is '
'not valid, skipping'),
{'mac': mac, 'name': name},

View File

@ -13,7 +13,6 @@
import datetime
import logging as pylog
import re
import futurist
from keystonemiddleware import auth_token
@ -21,7 +20,6 @@ from oslo_config import cfg
from oslo_log import log
from oslo_middleware import cors as cors_middleware
import pytz
import six
from ironic_inspector.common.i18n import _, _LE
from ironic_inspector import conf # noqa
@ -189,13 +187,6 @@ def check_auth(request):
raise Error(_('Access denied'), code=403)
def is_valid_mac(address):
"""Return whether given value is a valid MAC."""
m = "[0-9a-f]{2}(:[0-9a-f]{2}){5}$"
return (isinstance(address, six.string_types)
and re.match(m, address.lower()))
def get_auth_strategy():
if CONF.authenticate is not None:
return 'keystone' if CONF.authenticate else 'noauth'