Add netdevice value type
While it is just a copy of the netaddress regexp, they may diverge later and users should be able to continue using the appropriate one. Change-Id: Ib6d96113f16fc5f4dc4b8918d2409d08e317a47d Closes-Bug: #1262786
This commit is contained in:
parent
c9c176dbe6
commit
3e9c796f52
|
@ -200,7 +200,8 @@ def parse_opts(argv):
|
|||
parser.add_argument('--type', default='default',
|
||||
help='exit with error if the specified --key does not'
|
||||
' match type. Valid types are'
|
||||
' <int|default|netaddress|dsn|swiftdevices|raw>')
|
||||
' <int|default|netaddress|netdevice|dsn|'
|
||||
'swiftdevices|raw>')
|
||||
parser.add_argument('--key-default',
|
||||
help='This option only affects running with --key.'
|
||||
' Print this if key is not found. This value is'
|
||||
|
|
|
@ -71,6 +71,23 @@ class ValueTypeTestCase(testtools.TestCase):
|
|||
self.assertRaises(config_exception.ConfigException,
|
||||
value_types.ensure_type, "192.0.2.1;DROP TABLE foo")
|
||||
|
||||
def test_netdevice(self):
|
||||
self.assertEqual('eth0',
|
||||
value_types.ensure_type('eth0', 'netdevice'))
|
||||
|
||||
def test_netdevice_dash(self):
|
||||
self.assertEqual('br-ctlplane',
|
||||
value_types.ensure_type('br-ctlplane', 'netdevice'))
|
||||
|
||||
def test_netdevice_alias(self):
|
||||
self.assertEqual('eth0:1',
|
||||
value_types.ensure_type('eth0:1', 'netdevice'))
|
||||
|
||||
def test_netdevice_bad(self):
|
||||
self.assertRaises(config_exception.ConfigException,
|
||||
value_types.ensure_type, "br-tun; DROP TABLE bar",
|
||||
'netdevice')
|
||||
|
||||
def test_dsn_nopass(self):
|
||||
test_dsn = 'mysql://user@host/db'
|
||||
self.assertEqual(test_dsn, value_types.ensure_type(test_dsn, 'dsn'))
|
||||
|
|
|
@ -21,6 +21,7 @@ TYPES = {
|
|||
"int": "^[0-9]+$",
|
||||
"default": "^[A-Za-z0-9_]*$",
|
||||
"netaddress": "^[A-Za-z0-9/.:-]*$",
|
||||
"netdevice": "^[A-Za-z0-9/.:-]*$",
|
||||
"dsn": "(?#driver)^[a-zA-Z0-9]+://"
|
||||
"(?#username[:password])([a-zA-Z0-9+_-]+(:[^@]+)?)?"
|
||||
"(?#@host or file)(@?[a-zA-Z0-9/_.-]+)?"
|
||||
|
|
Loading…
Reference in New Issue