示例#1
0
文件: api.py 项目: jerryrwu/alcazard
 async def post_clients(self, request):
     data = await request.json()
     with DB.atomic():
         realm = Realm.select().where(Realm.name == data['realm']).first()
         if not realm:
             realm = Realm.create(name=data['realm'])
         try:
             instance = self.orchestrator.add_instance(
                 realm=realm,
                 instance_type=data['instance_type'],
                 config_kwargs=data.get('config', {}),
             )
         except asyncio.TimeoutError:
             return JsonResponse(
                 data={'detail': 'Alcazar is busy performing another action. Try again later.'},
                 status=503,
             )
     return JsonResponse(instance.get_info_dict())
示例#2
0
文件: api.py 项目: jerryrwu/alcazard
 async def put_config(self, request):
     data = await request.json()
     with DB.atomic():
         self.config.update_from_dict(data)
         self.config.save()
     return JsonResponse(self.config.to_dict())