Пример #1
0
 def scale_instance(self, name, quantity):
     self._ensure_ready(name)
     if quantity <= 0:
         raise ScaleError("Can't have 0 instances")
     self.storage.store_task(name)
     config = copy.deepcopy(self.config)
     metadata = self.storage.find_instance_metadata(name)
     if metadata and metadata.get("plan_name"):
         plan = self.storage.find_plan(metadata["plan_name"])
         config.update(plan.config or {})
     self._add_tags(name, config)
     task = tasks.ScaleInstanceTask().delay(config, name, quantity)
     self.storage.update_task(name, task.task_id)
Пример #2
0
 def scale_instance(self, name, quantity):
     self.task_manager.ensure_ready(name)
     if quantity <= 0:
         raise ScaleError("Can't have 0 instances")
     self.task_manager.create(name)
     config = copy.deepcopy(self.config)
     metadata = self.storage.find_instance_metadata(name)
     if not metadata or "consul_token" not in metadata:
         metadata = metadata or {}
         metadata["consul_token"] = self.consul_manager.generate_token(name)
         self.storage.store_instance_metadata(name, **metadata)
     if "plan_name" in metadata:
         plan = self.storage.find_plan(metadata["plan_name"])
         config.update(plan.config or {})
     self._add_tags(name, config, metadata["consul_token"])
     task = tasks.ScaleInstanceTask().delay(config, name, quantity)
     self.task_manager.update(name, task.task_id)