Merge "Change render_unsets default to False"
This commit is contained in:
commit
de0cbfa1a4
@ -104,7 +104,7 @@ class HealthMonitorController(base.BaseController):
|
|||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
pass
|
pass
|
||||||
hm_dict = db_prepare.create_health_monitor(
|
hm_dict = db_prepare.create_health_monitor(
|
||||||
health_monitor.to_dict(), self.pool_id)
|
health_monitor.to_dict(render_unsets=True), self.pool_id)
|
||||||
self._test_lb_and_listener_statuses(context.session)
|
self._test_lb_and_listener_statuses(context.session)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -78,7 +78,7 @@ class L7PolicyController(base.BaseController):
|
|||||||
"""Creates a l7policy on a listener."""
|
"""Creates a l7policy on a listener."""
|
||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
l7policy_dict = validate.sanitize_l7policy_api_args(
|
l7policy_dict = validate.sanitize_l7policy_api_args(
|
||||||
l7policy.to_dict(), create=True)
|
l7policy.to_dict(render_unsets=True), create=True)
|
||||||
# Make sure any pool specified by redirect_pool_id exists
|
# Make sure any pool specified by redirect_pool_id exists
|
||||||
if 'redirect_pool_id' in l7policy_dict.keys():
|
if 'redirect_pool_id' in l7policy_dict.keys():
|
||||||
self._get_db_pool(
|
self._get_db_pool(
|
||||||
|
@ -89,8 +89,8 @@ class L7RuleController(base.BaseController):
|
|||||||
raise exceptions.L7RuleValidation(error=e)
|
raise exceptions.L7RuleValidation(error=e)
|
||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
self._check_l7policy_max_rules(context.session)
|
self._check_l7policy_max_rules(context.session)
|
||||||
l7rule_dict = db_prepare.create_l7rule(l7rule.to_dict(),
|
l7rule_dict = db_prepare.create_l7rule(
|
||||||
self.l7policy_id)
|
l7rule.to_dict(render_unsets=True), self.l7policy_id)
|
||||||
self._test_lb_and_listener_statuses(context.session)
|
self._test_lb_and_listener_statuses(context.session)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -127,11 +127,9 @@ class L7RuleController(base.BaseController):
|
|||||||
"""Updates a l7rule."""
|
"""Updates a l7rule."""
|
||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
db_l7rule = self._get_db_l7rule(context.session, id)
|
db_l7rule = self._get_db_l7rule(context.session, id)
|
||||||
new_l7rule_dict = db_l7rule.to_dict()
|
new_l7rule = db_l7rule.to_dict()
|
||||||
for k, v in l7rule.to_dict().items():
|
new_l7rule.update(l7rule.to_dict())
|
||||||
if v is not None:
|
new_l7rule = data_models.L7Rule.from_dict(new_l7rule)
|
||||||
new_l7rule_dict.update({k: v})
|
|
||||||
new_l7rule = data_models.L7Rule(**new_l7rule_dict)
|
|
||||||
try:
|
try:
|
||||||
validate.l7rule_data(new_l7rule)
|
validate.l7rule_data(new_l7rule)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -160,7 +160,7 @@ class ListenersController(base.BaseController):
|
|||||||
self._secure_data(listener)
|
self._secure_data(listener)
|
||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
listener_dict = db_prepare.create_listener(
|
listener_dict = db_prepare.create_listener(
|
||||||
listener.to_dict(), self.load_balancer_id)
|
listener.to_dict(render_unsets=True), self.load_balancer_id)
|
||||||
if listener_dict['default_pool_id']:
|
if listener_dict['default_pool_id']:
|
||||||
self._validate_pool(context.session,
|
self._validate_pool(context.session,
|
||||||
listener_dict['default_pool_id'])
|
listener_dict['default_pool_id'])
|
||||||
@ -181,7 +181,7 @@ class ListenersController(base.BaseController):
|
|||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
db_listener = self._get_db_listener(context.session, id)
|
db_listener = self._get_db_listener(context.session, id)
|
||||||
listener_dict = listener.to_dict()
|
listener_dict = listener.to_dict()
|
||||||
if listener_dict['default_pool_id']:
|
if listener_dict.get('default_pool_id'):
|
||||||
self._validate_pool(context.session,
|
self._validate_pool(context.session,
|
||||||
listener_dict['default_pool_id'])
|
listener_dict['default_pool_id'])
|
||||||
self._test_lb_and_listener_statuses(context.session, id=id)
|
self._test_lb_and_listener_statuses(context.session, id=id)
|
||||||
|
@ -74,7 +74,7 @@ class LoadBalancersController(base.BaseController):
|
|||||||
|
|
||||||
def _create_load_balancer_graph(self, context, load_balancer):
|
def _create_load_balancer_graph(self, context, load_balancer):
|
||||||
prepped_lb = db_prepare.create_load_balancer_tree(
|
prepped_lb = db_prepare.create_load_balancer_tree(
|
||||||
load_balancer.to_dict())
|
load_balancer.to_dict(render_unsets=True))
|
||||||
try:
|
try:
|
||||||
db_lb = self.repositories.create_load_balancer_tree(
|
db_lb = self.repositories.create_load_balancer_tree(
|
||||||
context.session, prepped_lb)
|
context.session, prepped_lb)
|
||||||
@ -100,7 +100,9 @@ class LoadBalancersController(base.BaseController):
|
|||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
if load_balancer.listeners:
|
if load_balancer.listeners:
|
||||||
return self._create_load_balancer_graph(context, load_balancer)
|
return self._create_load_balancer_graph(context, load_balancer)
|
||||||
lb_dict = db_prepare.create_load_balancer(load_balancer.to_dict())
|
lb_dict = db_prepare.create_load_balancer(load_balancer.to_dict(
|
||||||
|
render_unsets=True
|
||||||
|
))
|
||||||
vip_dict = lb_dict.pop('vip', {})
|
vip_dict = lb_dict.pop('vip', {})
|
||||||
try:
|
try:
|
||||||
db_lb = self.repositories.create_load_balancer_and_vip(
|
db_lb = self.repositories.create_load_balancer_and_vip(
|
||||||
|
@ -91,7 +91,8 @@ class MembersController(base.BaseController):
|
|||||||
def post(self, member):
|
def post(self, member):
|
||||||
"""Creates a pool member on a pool."""
|
"""Creates a pool member on a pool."""
|
||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
member_dict = db_prepare.create_member(member.to_dict(), self.pool_id)
|
member_dict = db_prepare.create_member(member.to_dict(
|
||||||
|
render_unsets=True), self.pool_id)
|
||||||
self._test_lb_and_listener_statuses(context.session)
|
self._test_lb_and_listener_statuses(context.session)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -140,7 +140,7 @@ class PoolsController(base.BaseController):
|
|||||||
# For some API requests the listener_id will be passed in the
|
# For some API requests the listener_id will be passed in the
|
||||||
# pool_dict:
|
# pool_dict:
|
||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
pool_dict = db_prepare.create_pool(pool.to_dict())
|
pool_dict = db_prepare.create_pool(pool.to_dict(render_unsets=True))
|
||||||
if 'listener_id' in pool_dict:
|
if 'listener_id' in pool_dict:
|
||||||
if pool_dict['listener_id'] is not None:
|
if pool_dict['listener_id'] is not None:
|
||||||
self.listener_id = pool_dict.pop('listener_id')
|
self.listener_id = pool_dict.pop('listener_id')
|
||||||
|
@ -65,7 +65,7 @@ class BaseType(wtypes.Base):
|
|||||||
"""
|
"""
|
||||||
return cls(**data_model.to_dict())
|
return cls(**data_model.to_dict())
|
||||||
|
|
||||||
def to_dict(self, render_unsets=True):
|
def to_dict(self, render_unsets=False):
|
||||||
"""Converts Octavia WSME type to dictionary.
|
"""Converts Octavia WSME type to dictionary.
|
||||||
|
|
||||||
:param render_unsets: If True, will convert items that are WSME Unset
|
:param render_unsets: If True, will convert items that are WSME Unset
|
||||||
@ -79,9 +79,10 @@ class BaseType(wtypes.Base):
|
|||||||
if value and callable(value):
|
if value and callable(value):
|
||||||
continue
|
continue
|
||||||
if value and isinstance(value, BaseType):
|
if value and isinstance(value, BaseType):
|
||||||
value = value.to_dict()
|
value = value.to_dict(render_unsets=render_unsets)
|
||||||
if value and isinstance(value, list):
|
if value and isinstance(value, list):
|
||||||
value = [val.to_dict() if isinstance(val, BaseType) else val
|
value = [val.to_dict(render_unsets=render_unsets)
|
||||||
|
if isinstance(val, BaseType) else val
|
||||||
for val in value]
|
for val in value]
|
||||||
if isinstance(value, wtypes.UnsetType):
|
if isinstance(value, wtypes.UnsetType):
|
||||||
if render_unsets:
|
if render_unsets:
|
||||||
|
Loading…
Reference in New Issue
Block a user