36
43
def delete(self, context, obj):
46
def successful_completion(self, context, obj, delete=False):
48
Sets the provisioning_status of the load balancer and obj to
49
ACTIVE. Also sets the operating status of obj to ONLINE. Should be
50
called last in the implementor's BaseManagerMixin methods for
53
:param context: neutron context
54
:param obj: instance of a
55
neutron_lbaas.services.loadbalancer.data_model
56
:param delete: set True if being called from a delete method. Will
57
most likely result in the obj being deleted from the db.
59
# TODO(blogan): Will need to decide what to do with all operating
60
# statuses. Update to ONLINE here, or leave the operating status
61
# alone and let health checks update
62
obj_sa_cls = data_models.DATA_MODEL_TO_SA_MODEL_MAP[obj.__class__]
64
self.db_delete_method(context, obj.id)
65
if obj == obj.root_loadbalancer and delete:
66
# Load balancer was deleted and no longer exists
68
lb_op_status = obj.root_loadbalancer.operating_status
69
if obj == obj.root_loadbalancer:
70
lb_op_status = lb_const.ONLINE
71
self.driver.plugin.db.update_status(
72
context, models.LoadBalancer, obj.root_loadbalancer.id,
73
provisioning_status=constants.ACTIVE,
74
operating_status=lb_op_status)
75
if obj == obj.root_loadbalancer or delete:
76
# Do not want to update the status of the load balancer again
77
# Or the obj was deleted from the db so no need to update the
80
obj_op_status = lb_const.ONLINE
81
if isinstance(obj, data_models.HealthMonitor):
82
# Health Monitor does not have an operating status
84
self.driver.plugin.db.update_status(
85
context, obj_sa_cls, obj.id,
86
provisioning_status=constants.ACTIVE,
87
operating_status=obj_op_status)
89
def failed_completion(self, context, obj):
91
Sets the provisioning status of the load balancer and obj to
92
ERROR. Should be called whenever something goes wrong (raised
93
exception) in an implementor's BaseManagerMixin methods.
95
:param context: neutron context
96
:param obj: instance of a
97
neutron_lbaas.services.loadbalancer.data_model
99
# TODO(blogan): Will need to decide what to do with all operating
100
# statuses. Update to ONLINE here, or leave the operating status
101
# alone and let health checks update
102
self.driver.plugin.db.update_status(
103
context, models.LoadBalancer, obj.root_loadbalancer.id,
104
provisioning_status=constants.ERROR)
105
if obj == obj.root_loadbalancer:
106
# Do not want to update the status of the load balancer again
108
obj_sa_cls = data_models.DATA_MODEL_TO_SA_MODEL_MAP[obj.__class__]
109
self.driver.plugin.db.update_status(
110
context, obj_sa_cls, obj.id,
111
provisioning_status=constants.ERROR,
112
operating_status=lb_const.OFFLINE)
40
115
@six.add_metaclass(abc.ABCMeta)
41
116
class BaseRefreshMixin(object):
51
126
@abc.abstractmethod
52
127
def stats(self, context, obj):
56
class BaseStatusUpdateMixin(object):
58
# Status update helpers
59
# Note: You must set self.model_class to an appropriate neutron model
60
# in your base manager class.
62
def active(self, context, model_id):
63
if self.model_class is not None:
64
self.driver.plugin.update_status(context, self.model_class,
65
model_id, constants.ACTIVE)
67
def failed(self, context, model_id):
68
if self.model_class is not None:
69
self.driver.plugin.update_status(context, self.model_class,
70
model_id, constants.ERROR)
73
class BaseHealthMonitorStatusUpdateMixin(object):
75
def active(self, context, health_monitor_id, pool_id):
76
self.driver.plugin.update_pool_health_monitor(context,
81
def failed(self, context, health_monitor_id, pool_id):
82
self.driver.plugin.update_pool_health_monitor(context,