Add new type for swiftdevices
Swift devices consist of a zone, region, host, port and device, if they are passed into swift hosts via heat metadata we can now verify them as native types. Closes-Bug: #1252165 Change-Id: I8681e36a0b02f62e4856e42ef1900ce4888cb305
This commit is contained in:
parent
5ac22fc53b
commit
7b6d63ad6f
|
@ -193,7 +193,7 @@ 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|raw>')
|
||||
' <int|default|netaddress|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'
|
||||
|
|
|
@ -99,3 +99,29 @@ class ValueTypeTestCase(testtools.TestCase):
|
|||
value_types.ensure_type,
|
||||
"mysql://user:pass@host/db?charset=utf8;DROP TABLE "
|
||||
"foo", 'dsn')
|
||||
|
||||
def test_swiftdevices_single(self):
|
||||
test_swiftdevices = 'r1z1-127.0.0.1:%PORT%/d1'
|
||||
self.assertEqual(test_swiftdevices, value_types.ensure_type(
|
||||
test_swiftdevices,
|
||||
'swiftdevices'))
|
||||
|
||||
def test_swiftdevices_multi(self):
|
||||
test_swiftdevices = 'r1z1-127.0.0.1:%PORT%/d1,r1z1-127.0.0.1:%PORT%/d2'
|
||||
self.assertEqual(test_swiftdevices, value_types.ensure_type(
|
||||
test_swiftdevices,
|
||||
'swiftdevices'))
|
||||
|
||||
def test_swiftdevices_blank(self):
|
||||
test_swiftdevices = ''
|
||||
self.assertRaises(config_exception.ConfigException,
|
||||
value_types.ensure_type,
|
||||
test_swiftdevices,
|
||||
'swiftdevices')
|
||||
|
||||
def test_swiftdevices_bad(self):
|
||||
test_swiftdevices = 'rz1-127.0.0.1:%PORT%/d1'
|
||||
self.assertRaises(config_exception.ConfigException,
|
||||
value_types.ensure_type,
|
||||
test_swiftdevices,
|
||||
'swiftdevices')
|
||||
|
|
|
@ -26,6 +26,7 @@ TYPES = {
|
|||
"(?#@host or file)(@?[a-zA-Z0-9/_.-]+)?"
|
||||
"(?#/dbname)(/[a-zA-Z0-9_-]+)?"
|
||||
"(?#?variable=value)(\?[a-zA-Z0-9=_-]+)?$",
|
||||
"swiftdevices": "^(r\d+z\d+-[A-Za-z0-9.-_]+:%PORT%/[^,]+,?)+$",
|
||||
"raw": ""
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue