Skip to content

Commit

Permalink
Merge "Subnet uuid passed in network-ipam-refs by WebUI/any vnc api C…
Browse files Browse the repository at this point in the history
…lient can be invalid." into R2.22-dev
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Sep 16, 2015
2 parents 8805dde + ab47969 commit 5f6f2fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/config/api-server/vnc_addr_mgmt.py
Expand Up @@ -3,6 +3,7 @@
#

import copy
import uuid
from netaddr import *
from vnc_quota import *
from pprint import pformat
Expand Down Expand Up @@ -661,7 +662,7 @@ def net_check_subnet_overlap(self, db_vn_dict, req_vn_dict):
return True, ""
# end net_check_subnet_overlap

def net_check_subnet(self, db_vn_dict, req_vn_dict):
def net_check_subnet(self, req_vn_dict):
ipam_refs = req_vn_dict.get('network_ipam_refs', [])
for ipam_ref in ipam_refs:
vnsn_data = ipam_ref['attr']
Expand All @@ -674,6 +675,16 @@ def net_check_subnet(self, db_vn_dict, req_vn_dict):
subnet_name = subnet_dict['ip_prefix'] + '/' + str(
subnet_dict['ip_prefix_len'])

# check subnet-uuid
ipam_cfg_subnet_uuid = ipam_subnet.get('subnet_uuid', None)
try:
if ipam_cfg_subnet_uuid:
subnet_uuid = uuid.UUID(ipam_cfg_subnet_uuid)
except ValueError:
err_msg = "Invalid subnet-uuid %s in subnet:%s" \
%(ipam_cfg_subnet_uuid, subnet_name)
return False, err_msg

# check allocation-pool
alloc_pools = ipam_subnet.get('allocation_pools', None)
for pool in alloc_pools or []:
Expand Down
6 changes: 5 additions & 1 deletion src/config/api-server/vnc_cfg_types.py
Expand Up @@ -492,6 +492,10 @@ def http_post_collection(cls, tenant_name, obj_dict, db_conn):

db_conn.update_subnet_uuid(obj_dict)

(ok, result) = cls.addr_mgmt.net_check_subnet(obj_dict)
if not ok:
return (ok, (409, result))

(ok, error) = cls._check_route_targets(obj_dict, db_conn)
if not ok:
return (False, (400, error))
Expand Down Expand Up @@ -529,7 +533,7 @@ def http_put(cls, id, fq_name, obj_dict, db_conn):
if not read_ok:
return (False, (500, read_result))

(ok, result) = cls.addr_mgmt.net_check_subnet(read_result, obj_dict)
(ok, result) = cls.addr_mgmt.net_check_subnet(obj_dict)
if not ok:
return (ok, (409, result))

Expand Down

0 comments on commit 5f6f2fc

Please sign in to comment.