示例#1
0
 def new_instance(self, name, team=None, plan_name=None):
     plan = None
     if plan_name:
         plan = self.storage.find_plan(plan_name)
     used, quota = self.storage.find_team_quota(team)
     if len(used) >= quota:
         raise QuotaExceededError(len(used), quota)
     if not self.storage.increment_quota(team, used, name):
         raise Exception("concurrent operations updating team quota")
     lb = LoadBalancer.find(name)
     if lb is not None:
         raise storage.DuplicateError(name)
     self.task_manager.create(name)
     config = copy.deepcopy(self.config)
     metadata = {}
     if plan:
         config.update(plan.config)
         metadata["plan_name"] = plan_name
     metadata[
         "consul_token"] = consul_token = self.consul_manager.generate_token(
             name)
     self.consul_manager.write_healthcheck(name)
     self.storage.store_instance_metadata(name, **metadata)
     self._add_tags(name, config, consul_token)
     task = tasks.NewInstanceTask().delay(config, name)
     self.task_manager.update(name, task.task_id)
示例#2
0
 def _get_address(self, name):
     task = self.storage.find_task(name)
     if task.count() >= 1:
         result = tasks.NewInstanceTask().AsyncResult(task[0]["task_id"])
         if result.status in ["FAILURE", "REVOKED"]:
             return FAILURE
         return PENDING
     lb = LoadBalancer.find(name)
     if lb is None:
         raise storage.InstanceNotFoundError()
     return lb.address
示例#3
0
文件: manager.py 项目: vfiebig/rpaas
 def _get_address(self, name):
     task = self.storage.find_task(name)
     if task:
         result = tasks.NewInstanceTask().AsyncResult(task['task_id'])
         if result.status in ['FAILURE', 'REVOKED']:
             return FAILURE
         return PENDING
     lb = LoadBalancer.find(name)
     if lb is None:
         raise storage.InstanceNotFoundError()
     return lb.address