summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-17 03:28:27 +0000
committerGerrit Code Review <review@openstack.org>2017-06-17 03:28:27 +0000
commite38e86f0f0787393eb77ed6e4f4e615cd37317bb (patch)
tree501f6d98ce639c4c2e7020a99e6bc4f7d13887dc
parent60e1076d7e08acc38fadd278ac314527647447c3 (diff)
parent3d4226b98abd1765e558dccb8c0cc240f4c5a50a (diff)
Merge "Small refactor for load_balancer v2 vip validation"
-rw-r--r--octavia/api/v2/controllers/load_balancer.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/octavia/api/v2/controllers/load_balancer.py b/octavia/api/v2/controllers/load_balancer.py
index 446da55..bcd061b 100644
--- a/octavia/api/v2/controllers/load_balancer.py
+++ b/octavia/api/v2/controllers/load_balancer.py
@@ -109,24 +109,7 @@ class LoadBalancersController(base.BaseController):
109 "Supplied network does not contain a subnet." 109 "Supplied network does not contain a subnet."
110 )) 110 ))
111 111
112 @wsme_pecan.wsexpose(lb_types.LoadBalancerFullRootResponse, 112 def _validate_vip_request_object(self, load_balancer):
113 body=lb_types.LoadBalancerRootPOST, status_code=201)
114 def post(self, load_balancer):
115 """Creates a load balancer."""
116 load_balancer = load_balancer.loadbalancer
117 context = pecan.request.context.get('octavia_context')
118
119 project_id = context.project_id
120 if context.is_admin or CONF.auth_strategy == constants.NOAUTH:
121 if load_balancer.project_id:
122 project_id = load_balancer.project_id
123
124 if not project_id:
125 raise exceptions.ValidationException(detail=_(
126 "Missing project ID in request where one is required."))
127
128 load_balancer.project_id = project_id
129
130 if not (load_balancer.vip_port_id or 113 if not (load_balancer.vip_port_id or
131 load_balancer.vip_network_id or 114 load_balancer.vip_network_id or
132 load_balancer.vip_subnet_id): 115 load_balancer.vip_subnet_id):
@@ -146,6 +129,25 @@ class LoadBalancersController(base.BaseController):
146 subnet_id=load_balancer.vip_subnet_id) 129 subnet_id=load_balancer.vip_subnet_id)
147 load_balancer.vip_network_id = subnet.network_id 130 load_balancer.vip_network_id = subnet.network_id
148 131
132 @wsme_pecan.wsexpose(lb_types.LoadBalancerFullRootResponse,
133 body=lb_types.LoadBalancerRootPOST, status_code=201)
134 def post(self, load_balancer):
135 """Creates a load balancer."""
136 load_balancer = load_balancer.loadbalancer
137 context = pecan.request.context.get('octavia_context')
138
139 project_id = context.project_id
140 if context.is_admin or CONF.auth_strategy == constants.NOAUTH:
141 if load_balancer.project_id:
142 project_id = load_balancer.project_id
143
144 if not project_id:
145 raise exceptions.ValidationException(detail=_(
146 "Missing project ID in request where one is required."))
147 load_balancer.project_id = project_id
148
149 self._validate_vip_request_object(load_balancer)
150
149 lock_session = db_api.get_session(autocommit=False) 151 lock_session = db_api.get_session(autocommit=False)
150 if self.repositories.check_quota_met( 152 if self.repositories.check_quota_met(
151 context.session, 153 context.session,