Example #1
0
    def resize(self, new_capacity):
        """
        Resize the instance group to the new capacity.

        When shrinking, the newest instances will be removed.
        """
        new_template = self._create_template(new_capacity)
        result = self.update_with_template(new_template, {})
        for resource in self.nested():
            if resource.state == ('CREATE', 'FAILED'):
                resource.destroy()
        self._lb_reload()
        return result
Example #2
0
    def resize(self, new_capacity):
        """
        Resize the instance group to the new capacity.

        When shrinking, the newest instances will be removed.
        """
        new_template = self._create_template(new_capacity)
        result = self.update_with_template(new_template, {})
        for resource in self.nested():
            if resource.state == ('CREATE', 'FAILED'):
                resource.destroy()
        self._lb_reload()
        return result
Example #3
0
    def check_create_complete(self, task):
        """
        When stack creation is done, update the load balancer.

        If any instances failed to be created, delete them.
        """
        try:
            done = super(InstanceGroup, self).check_create_complete(task)
        except exception.Error as exc:
            for resource in self.nested():
                if resource.state == ('CREATE', 'FAILED'):
                    resource.destroy()
            raise
        if done and len(self.get_instances()):
            self._lb_reload()
        return done
Example #4
0
    def check_create_complete(self, task):
        """
        When stack creation is done, update the load balancer.

        If any instances failed to be created, delete them.
        """
        try:
            done = super(InstanceGroup, self).check_create_complete(task)
        except exception.Error as exc:
            for resource in self.nested():
                if resource.state == ('CREATE', 'FAILED'):
                    resource.destroy()
            raise
        if done and len(self.get_instances()):
            self._lb_reload()
        return done