resource: ipa_unit_id is expected to be a positive integer

Change-Id: I26d7a4351089b73716d193496d7161bf3d9988bb
This commit is contained in:
Pau Espin 2017-09-12 15:13:21 +02:00 committed by Neels Hofmeyr
parent cfac993bf2
commit fa9a6d39ab
2 changed files with 8 additions and 1 deletions

View File

@ -51,7 +51,7 @@ RESOURCES_SCHEMA = {
'ip_address[].addr': schema.IPV4,
'bts[].label': schema.STR,
'bts[].type': schema.STR,
'bts[].ipa_unit_id': schema.INT,
'bts[].ipa_unit_id': schema.UINT,
'bts[].addr': schema.IPV4,
'bts[].band': schema.BAND,
'bts[].trx_remote_ip': schema.IPV4,

View File

@ -66,8 +66,14 @@ def auth_algo(val):
return
raise ValueError('Unknown Authentication Algorithm: %r' % val)
def uint(val):
n = int(val)
if n < 0:
raise ValueError('Positive value expected instead of %d' % n)
INT = 'int'
STR = 'str'
UINT = 'uint'
BOOL_STR = 'bool_str'
BAND = 'band'
IPV4 = 'ipv4'
@ -79,6 +85,7 @@ AUTH_ALGO = 'auth_algo'
SCHEMA_TYPES = {
INT: int,
STR: str,
UINT: uint,
BOOL_STR: str2bool,
BAND: band,
IPV4: ipv4,