def get(self, request, *args, **kwargs): """Return server pools by ids or dict""" if not kwargs.get('obj_ids'): obj_model = facade.get_pool_by_search(self.search) pools = obj_model['query_set'] only_main_property = False else: pool_ids = kwargs['obj_ids'].split(';') pools = facade.get_pool_by_ids(pool_ids) only_main_property = True obj_model = None # serializer pools pool_serializer = serializers.PoolV3Serializer(pools, many=True, fields=self.fields, include=self.include, exclude=self.exclude, kind=self.kind) # prepare serializer with customized properties response = render_to_json(pool_serializer, main_property='server_pools', obj_model=obj_model, request=request, only_main_property=only_main_property) return Response(response, status=status.HTTP_200_OK)
def get(self, request, *args, **kwargs): """Return server pools by ids or dict""" if not kwargs.get('obj_ids'): obj_model = facade.get_pool_by_search(self.search) pools = obj_model['query_set'] only_main_property = False else: pool_ids = kwargs['obj_ids'].split(';') pools = facade.get_pool_by_ids(pool_ids) only_main_property = True obj_model = None # serializer pools pool_serializer = serializers.PoolV3Serializer( pools, many=True, fields=self.fields, include=self.include, exclude=self.exclude, kind=self.kind ) # prepare serializer with customized properties response = render_to_json( pool_serializer, main_property='server_pools', obj_model=obj_model, request=request, only_main_property=only_main_property ) return Response(response, status=status.HTTP_200_OK)
def post(self, request, *args, **kwargs): """ Creates pools by list in equipments """ pool_ids = kwargs['pool_ids'].split(';') pools = facade.get_pool_by_ids(pool_ids) pool_serializer = serializers.PoolV3Serializer(pools, many=True) locks_list = create_lock(pool_serializer.data, LOCK_POOL) try: response = facade_pool_deploy.create_real_pool( pool_serializer.data, request.user) except Exception, exception: log.error(exception) raise rest_exceptions.NetworkAPIException(exception)
def post(self, request, *args, **kwargs): """ Creates pools by list in equipments """ pool_ids = kwargs['obj_ids'].split(';') pools = facade.get_pool_by_ids(pool_ids) pool_serializer = serializers.PoolV3Serializer(pools, many=True) locks_list = create_lock(pool_serializer.data, LOCK_POOL) try: response = facade_pool_deploy.create_real_pool( pool_serializer.data, request.user) except Exception, exception: log.error(exception) raise rest_exceptions.NetworkAPIException(exception)
def delete(self, request, *args, **kwargs): """ Deletes pools by list in equipments :url /api/v3/pool/deploy/<pool_ids>/ :param pool_ids=<pool_ids> """ pool_ids = kwargs['obj_ids'].split(';') pools = facade.get_pool_by_ids(pool_ids) pool_serializer = serializers.PoolV3Serializer(pools, many=True) locks_list = create_lock(pool_serializer.data, LOCK_POOL) try: response = facade_pool_deploy.delete_real_pool( pool_serializer.data, request.user) except Exception, exception: log.error(exception) raise rest_exceptions.NetworkAPIException(exception)
def get(self, request, *args, **kwargs): """ Return server pools by ids or dict """ try: if not kwargs.get('pool_ids'): obj_model = facade.get_pool_by_search(self.search) pools = obj_model['query_set'] only_main_property = False else: pool_ids = kwargs['pool_ids'].split(';') pools = facade.get_pool_by_ids(pool_ids) only_main_property = True obj_model = None self.include = ( 'servicedownaction__details', 'environment__details', 'groups_permissions__details', ) # serializer pools pool_serializer = serializers.PoolV3Serializer( pools, many=True, fields=self.fields, include=self.include, exclude=self.exclude, kind=self.kind) # prepare serializer with customized properties response = render_to_json(pool_serializer, main_property='server_pools', obj_model=obj_model, request=request, only_main_property=only_main_property) return CustomResponse(response, status=status.HTTP_200_OK, request=request) except Exception, exception: log.exception(exception) raise rest_exceptions.NetworkAPIException(exception)
def delete(self, request, *args, **kwargs): """ Deletes pools by list in equipments :url /api/v3/pool/deploy/<pool_ids>/ :param pool_ids=<pool_ids> """ pool_ids = kwargs['obj_ids'].split(';') cleanup = request.GET.get('cleanup') or '0' pools = facade.get_pool_by_ids(pool_ids) pool_serializer = serializers.PoolV3Serializer(pools, many=True) locks_list = create_lock(pool_serializer.data, LOCK_POOL) try: response = facade_pool_deploy.delete_real_pool( pool_serializer.data, request.user, cleanup) except Exception, exception: log.error(exception) raise rest_exceptions.NetworkAPIException(exception)