notify PT added/removed for autoscaling
Partially implements blueprint node-centric-chain-plugin Change-Id: I55a615f5cc768f82c5c550c5924ed3c1a16fb405
This commit is contained in:
@@ -145,6 +145,32 @@ class NodeDriverBase(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def update_policy_target_added(self, context, policy_target):
|
||||
"""Update a deployed Service Chain Node on adding of a PT.
|
||||
|
||||
This method can be used for auto scaling some services whenever a
|
||||
Policy Target is added to a relevant PTG.
|
||||
|
||||
:param context: NodeDriverContext instance describing the service chain
|
||||
and the specific node to be processed by this driver.
|
||||
:param policy_target: Dict representing a Policy Target.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def update_policy_target_removed(self, context, policy_target):
|
||||
"""Update a deployed Service Chain Node on removal of a PT.
|
||||
|
||||
This method can be used for auto scaling some services whenever a
|
||||
Policy Target is removed from a relevant PTG.
|
||||
|
||||
:param context: NodeDriverContext instance describing the service chain
|
||||
and the specific node to be processed by this driver.
|
||||
:param policy_target: Dict representing a Policy Target.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractproperty
|
||||
def name(self):
|
||||
pass
|
||||
@@ -48,6 +48,14 @@ class NoopNodeDriver(driver_base.NodeDriverBase):
|
||||
def update(self, context):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def update_policy_target_added(self, context, policy_target):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def update_policy_target_removed(self, context, policy_target):
|
||||
pass
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@@ -232,6 +232,36 @@ class NodeCompositionPlugin(servicechain_db.ServiceChainDbPlugin,
|
||||
updated_profile)
|
||||
return updated_profile
|
||||
|
||||
def update_chains_pt_added(self, context, policy_target):
|
||||
""" Auto scaling function.
|
||||
|
||||
Notify the correct set of node drivers that a new policy target has
|
||||
been added to a relevant PTG.
|
||||
"""
|
||||
self._update_chains_pt_modified(context, policy_target, 'added')
|
||||
|
||||
def update_chains_pt_removed(self, context, policy_target):
|
||||
""" Auto scaling function.
|
||||
|
||||
Notify the correct set of node drivers that a new policy target has
|
||||
been removed from a relevant PTG.
|
||||
"""
|
||||
self._update_chains_pt_modified(context, policy_target, 'removed')
|
||||
|
||||
def _update_chains_pt_modified(self, context, policy_target, action):
|
||||
scis = self._get_instances_from_policy_target(context, policy_target)
|
||||
|
||||
for sci in scis:
|
||||
updaters = self._get_scheduled_drivers(context, sci, 'update')
|
||||
for update in updaters.values():
|
||||
try:
|
||||
getattr(update['driver'],
|
||||
'update_policy_target_' + action)(
|
||||
update['context'], policy_target)
|
||||
except exc.NodeDriverError as ex:
|
||||
LOG.error(_("Node Update on policy target modification "
|
||||
"failed, %s"), ex.message)
|
||||
|
||||
def _get_instance_nodes(self, context, instance):
|
||||
if not instance['servicechain_specs']:
|
||||
return []
|
||||
@@ -303,4 +333,4 @@ class NodeCompositionPlugin(servicechain_db.ServiceChainDbPlugin,
|
||||
raise exc.ServiceProfileInUseByAnInstance(
|
||||
profile_id=original['id'], instance_id=instance.id)
|
||||
self._validate_shared_update(context, original, updated,
|
||||
'service_profile')
|
||||
'service_profile')
|
||||
|
||||
@@ -113,7 +113,8 @@ class NodePlumberBase(object):
|
||||
|
||||
for pt in pts:
|
||||
try:
|
||||
gbp_plugin.delete_policy_target(context, pt.policy_target_id)
|
||||
gbp_plugin.delete_policy_target(context, pt.policy_target_id,
|
||||
notify_sc=False)
|
||||
except group_policy.PolicyTargetNotFound as ex:
|
||||
LOG.debug(ex.message)
|
||||
|
||||
@@ -134,7 +135,8 @@ class NodePlumberBase(object):
|
||||
'name': '', 'port_id': None}
|
||||
data.update(target)
|
||||
pt = gbp_plugin.create_policy_target(context,
|
||||
{'policy_target': data})
|
||||
{'policy_target': data},
|
||||
notify_sc=False)
|
||||
model.set_service_target(part_context, pt['id'], relationship)
|
||||
|
||||
def _sort_deployment(self, deployment):
|
||||
|
||||
Reference in New Issue
Block a user