Exemple #1
0
 def _get_scheduled_drivers(self, context, instance, action):
     nodes = self._get_instance_nodes(context, instance)
     result = {}
     func = getattr(self.driver_manager, 'schedule_' + action)
     for node in nodes:
         node_context = ctx.get_node_driver_context(self, context, instance,
                                                    node)
         driver = func(node_context)
         if not driver:
             raise exc.NoDriverAvailableForAction(action=action,
                                                  node_id=node['id'])
         result[node['id']] = {}
         result[node['id']]['driver'] = driver
         result[node['id']]['context'] = node_context
         result[node['id']]['plumbing_info'] = driver.get_plumbing_info(
             node_context)
     return result
Exemple #2
0
    def update_servicechain_node(self, context, servicechain_node_id,
                                 servicechain_node):
        """Node Update.

        When a Servicechain Node is updated, all the corresponding instances
        need to be updated as well. This usually results in a node
        reconfiguration.
        """
        session = context.session
        updaters = {}
        with session.begin(subtransactions=True):
            original_sc_node = self.get_servicechain_node(
                context, servicechain_node_id)
            updated_sc_node = super(NodeCompositionPlugin,
                                    self).update_servicechain_node(
                                        context, servicechain_node_id,
                                        servicechain_node)
            self._validate_shared_update(context, original_sc_node,
                                         updated_sc_node, 'servicechain_node')
            instances = self._get_node_instances(context, updated_sc_node)
            for instance in instances:
                node_context = ctx.get_node_driver_context(
                    self, context, instance, updated_sc_node, original_sc_node)
                # TODO(ivar): Validate that the node driver understands the
                # update.
                driver = self.driver_manager.schedule_update(node_context)
                if not driver:
                    raise exc.NoDriverAvailableForAction(
                        action='update', node_id=original_sc_node['id'])
                updaters[instance['id']] = {}
                updaters[instance['id']]['context'] = node_context
                updaters[instance['id']]['driver'] = driver
                updaters[instance['id']]['plumbing_info'] = (
                    driver.get_plumbing_info(node_context))
        # Update the nodes
        for update in updaters.values():
            try:
                update['driver'].update(update['context'])
            except exc.NodeDriverError as ex:
                LOG.error(_LE("Node Update failed, %s"), ex.message)

        return updated_sc_node