Esempio n. 1
0
    def _update_usage_from_container(self,
                                     context,
                                     container,
                                     is_removed=False):
        """Update usage for a single container."""

        uuid = container.uuid
        is_new_container = uuid not in self.tracked_containers
        is_removed_container = not is_new_container and is_removed

        if is_new_container:
            self.tracked_containers[uuid] = \
                obj_base.obj_to_primitive(container)
            sign = 1

        if is_removed_container:
            self.tracked_containers.pop(uuid)
            sign = -1

        if is_new_container or is_removed_container:
            if self.pci_tracker:
                self.pci_tracker.update_pci_for_container(context,
                                                          container,
                                                          sign=sign)

            # new container, update compute node resource usage:
            self._update_usage(self._get_usage_dict(container), sign=sign)
Esempio n. 2
0
 def _update_usage_from_container_update(self, context, new_container,
                                         old_container):
     """Update usage for a container update."""
     uuid = new_container.uuid
     self.tracked_containers[uuid] = obj_base.obj_to_primitive(
         new_container)
     # update compute node resource usage
     self._update_usage(self._get_usage_dict(old_container), sign=-1)
     self._update_usage(self._get_usage_dict(new_container))
Esempio n. 3
0
 def _update_usage_from_container_update(self, context, new_container,
                                         old_container):
     """Update usage for a container update."""
     uuid = new_container.uuid
     self.tracked_containers[uuid] = obj_base.obj_to_primitive(
         new_container)
     # update compute node resource usage
     self._update_usage(self._get_usage_dict(old_container), sign=-1)
     self._update_usage(self._get_usage_dict(new_container))
Esempio n. 4
0
    def _update_usage_from_container(self, container, is_removed=False):
        """Update usage for a single container."""

        uuid = container.uuid
        is_new_container = uuid not in self.tracked_containers
        is_removed_container = not is_new_container and is_removed

        if is_new_container:
            self.tracked_containers[uuid] = \
                obj_base.obj_to_primitive(container)
            sign = 1

        if is_removed_container:
            self.tracked_containers.pop(uuid)
            sign = -1

        if is_new_container or is_removed_container:
            # TODO(Shunli): Handle pci, scheduler allocation here.

            # new container, update compute node resource usage:
            self._update_usage(self._get_usage_dict(container), sign=sign)
Esempio n. 5
0
    def _update_usage_from_container(self, context, container,
                                     is_removed=False):
        """Update usage for a single container."""

        uuid = container.uuid
        is_new_container = uuid not in self.tracked_containers
        is_removed_container = not is_new_container and is_removed

        if is_new_container:
            self.tracked_containers[uuid] = \
                obj_base.obj_to_primitive(container)
            sign = 1

        if is_removed_container:
            self.tracked_containers.pop(uuid)
            sign = -1

        if is_new_container or is_removed_container:
            if self.pci_tracker:
                self.pci_tracker.update_pci_for_container(context, container,
                                                          sign=sign)

            # new container, update compute node resource usage:
            self._update_usage(self._get_usage_dict(container), sign=sign)
Esempio n. 6
0
 def to_dict(self):
     pci_pool = base.obj_to_primitive(self)
     tags = pci_pool.pop('tags', {})
     for k, v in tags.items():
         pci_pool[k] = v
     return pci_pool
Esempio n. 7
0
 def to_dict(self):
     pci_pool = base.obj_to_primitive(self)
     tags = pci_pool.pop('tags', {})
     for k, v in tags.items():
         pci_pool[k] = v
     return pci_pool