示例#1
0
    def handle(self, dep_update):
        """handles updating new and extended nodes onto the storage.

        :param dep_update:
        :return: a list of all of the nodes
        (including the non add_node.modification nodes)
        """
        current_nodes = self.sm.list_nodes(
            filters={
                'deployment_id': dep_update.deployment_id
            }).items
        nodes_dict = {node.id: node.to_dict() for node in current_nodes}
        modified_entities = deployment_update_utils.ModifiedEntitiesDict()

        # Iterate over the steps of the deployment update and handle each
        # step according to its operation, passing the deployment update
        # object, step entity type, entity id and a dict of updated nodes.
        # Each handler updated the dict of updated nodes, which enables
        # accumulating changes.
        for step in dep_update.steps:
            if step.entity_type in self._supported_entity_types:
                entity_handler = self._entity_handlers[step.entity_type]
                entity_updater = getattr(entity_handler, step.action)
                entity_context = get_entity_context(dep_update.deployment_plan,
                                                    dep_update.deployment_id,
                                                    step.entity_type,
                                                    step.entity_id)

                entity_id = entity_updater(entity_context, nodes_dict)

                modified_entities[step.entity_type].append(entity_id)

        return modified_entities, nodes_dict.values()
    def handle(self, dep_update):
        """handles updating new and extended nodes onto the storage.

        :param dep_update: deployment update object
        :return: a list of all of the nodes
        (including the non add_node.modification nodes)
        """
        current_nodes = self.sm.list(
            models.Node, filters={'deployment_id': dep_update.deployment_id})
        nodes_dict = {
            node.id: deepcopy(node.to_dict())
            for node in current_nodes
        }
        modified_entities = deployment_update_utils.ModifiedEntitiesDict()

        self._fill_modified_entities(
            dep_update=dep_update,
            supported_entity_types=self._supported_entity_types,
            entity_handlers=self._entity_handlers,
            modified_entities=modified_entities,
            current_entities_dict=nodes_dict)
        return modified_entities, nodes_dict.values()