serializer = serializer_class(node, data=data) if serializer.is_valid(): kwargs.update(serializer.process_post()) else: errors.update(serializer.errors) if errors: raise exceptions.ParseError(detail=errors) # initialize firmware configuration base_image = BaseImage.objects.get(pk=kwargs.pop('base_image_id')) async = True success_status = status.HTTP_202_ACCEPTED # allow asynchronous requests if '201-created' == request.META.get('HTTP_EXPECT', None): async = False success_status = status.HTTP_201_CREATED # call firmware build task try: build = Build.build(node, base_image, async=async, **kwargs) except ConcurrencyError as e: raise exceptions.Throttled(detail=e.message) serializer = self.serializer_class(build) return Response(serializer.data, status=success_status) insert_ctl(NodeDetail, Firmware) api.register(BaseImageList, BaseImageDetail)
This resource lists the sliver [templates](http://wiki.confine-project.eu/ arch:rest-api#template_at_registry) available in the testbed and provides API URIs to navigate to them. """ model = Template serializer_class = TemplateSerializer class TemplateDetail(generics.RetrieveUpdateDestroyAPIView): """ **Media type:** [`application/json; profile="http://confine-project.eu/schema/registry/v1/template"`]( http://wiki.confine-project.eu/arch:rest-api#template_at_registry) This resource describes a template available in the testbed for [slices]( http://wiki.confine-project.eu/arch:rest-api#slice_at_registry) and [slivers](http://wiki.confine-project.eu/arch:rest-api#sliver_at_registry) to use. """ model = Template serializer_class = TemplateSerializer renderer_classes = [TemplateProfileRenderer, BrowsableAPIRenderer] ctl = [ make_upload_file(Template, 'image', 'image'), ] api.register(SliceList, SliceDetail) api.register(SliverList, SliverDetail) api.register(TemplateList, TemplateDetail)
This resource lists odd [hosts](http://wiki.confine-project.eu/arch:rest- api#host_at_registry) connected to the testbed (through the management network) and provides API URIs to navigate to them. """ model = Host add_serializer_class = HostCreateSerializer serializer_class = HostSerializer def pre_save(self, obj): """ Set the object's owner, based on the incoming request. """ obj.owner = self.request.user class HostDetail(generics.RetrieveUpdateDestroyAPIView): """ **Media type:** [`application/json; profile="http://confine-project.eu/schema/registry/v1/host"`]( http://wiki.confine-project.eu/arch:rest-api#host_at_registry) This resource describes an odd host computer connected to the testbed (through the management network) with a known administrator. """ model = Host serializer_class = HostSerializer renderer_classes = [HostProfileRenderer, BrowsableAPIRenderer] ctl = [UploadPubkey] api.register(HostList, HostDetail)
http://wiki.confine-project.eu/arch:rest-api#island_at_registry) This resource lists the network [islands](http://wiki.confine-project.eu/ arch:rest-api#island_at_registry) supported by the testbed and provides API URIs to navigate to them. """ model = Island serializer_class = IslandSerializer class IslandDetail(generics.RetrieveUpdateDestroyAPIView): """ **Media type:** [`application/json; profile="http://confine-project.eu/schema/registry/v0/island"`]( http://wiki.confine-project.eu/arch:rest-api#island_at_registry) This resource describes a network island, i.e. a possibly disconnected part of a community network. The usage of islands is mainly orientative: it can be used to signal user interfaces whether a node may see any servers, or whether modifying a gateway may leave some nodes disconnected from the testbed management network. """ model = Island serializer_class = IslandSerializer renderer_classes = [IslandProfileRenderer, BrowsableAPIRenderer] api.register(NodeList, NodeDetail) api.register(ServerList, ServerDetail) api.register(IslandList, IslandDetail)
class HostDetail(generics.RetrieveUpdateDestroyAPIView): """ **Media type:** [`application/json; profile="http://confine-project.eu/schema/registry/v0/host"`]( http://wiki.confine-project.eu/arch:rest-api#host_at_registry) This resource describes an odd host computer connected to the testbed (through the management network) with a known administrator. """ model = Host serializer_class = HostSerializer renderer_classes = [HostProfileRenderer, BrowsableAPIRenderer] ctl = [UploadPubkey] api.register(HostList, HostDetail) # backwards compatibility #245 note-42 import json from api import ApiRoot from api.utils import link_header from controller.utils import get_project_root from django.core.urlresolvers import reverse from django.http import Http404 from os import path from rest_framework.decorators import api_view def get_headers(request): base_link = [
This resource lists the sliver [templates](http://wiki.confine-project.eu/ arch:rest-api#template_at_registry) available in the testbed and provides API URIs to navigate to them. """ model = Template serializer_class = TemplateSerializer class TemplateDetail(generics.RetrieveUpdateDestroyAPIView): """ **Media type:** [`application/json; profile="http://confine-project.eu/schema/registry/v1/template"`]( http://wiki.confine-project.eu/arch:rest-api#template_at_registry) This resource describes a template available in the testbed for [slices]( http://wiki.confine-project.eu/arch:rest-api#slice_at_registry) and [slivers](http://wiki.confine-project.eu/arch:rest-api#sliver_at_registry) to use. """ model = Template serializer_class = TemplateSerializer renderer_classes = [TemplateProfileRenderer, BrowsableAPIRenderer] ctl = [make_upload_file(Template, "image", "image")] api.register(SliceList, SliceDetail) api.register(SliverList, SliverDetail) api.register(TemplateList, TemplateDetail)
This resource lists the [groups](http://wiki.confine-project.eu/arch:rest- api#group_at_registry) present in the testbed and provides API URIs to navigate to them. """ model = Group add_serializer_class = GroupCreateSerializer serializer_class = GroupSerializer def post_save(self, obj, created=False): """ user that creates a group becomes its admin """ Roles.objects.get_or_create(user=self.request.user, group=obj, is_group_admin=True) class GroupDetail(generics.RetrieveUpdateDestroyAPIView): """ **Media type:** [`application/json; profile="http://confine-project.eu/schema/registry/v1/group"`]( http://wiki.confine-project.eu/arch:rest-api#group_at_registry) This resource describes a group of users using the testbed. """ model = Group serializer_class = GroupSerializer fields_superuser = ['allow_nodes', 'allow_slices'] renderer_classes = [GroupProfileRenderer, BrowsableAPIRenderer] api.register(UserList, UserDetail) api.register(GroupList, GroupDetail)
http://wiki.confine-project.eu/arch:rest-api#island_at_registry) This resource lists the network [islands](http://wiki.confine-project.eu/ arch:rest-api#island_at_registry) supported by the testbed and provides API URIs to navigate to them. """ model = Island serializer_class = IslandSerializer class IslandDetail(generics.RetrieveUpdateDestroyAPIView): """ **Media type:** [`application/json; profile="http://confine-project.eu/schema/registry/v1/island"`]( http://wiki.confine-project.eu/arch:rest-api#island_at_registry) This resource describes a network island, i.e. a possibly disconnected part of a community network. The usage of islands is mainly orientative: it can be used to signal user interfaces whether a node may see any servers, or whether modifying a gateway may leave some nodes disconnected from the testbed management network. """ model = Island serializer_class = IslandSerializer renderer_classes = [IslandProfileRenderer, BrowsableAPIRenderer] api.register(NodeList, NodeDetail) api.register(ServerList, ServerDetail) api.register(IslandList, IslandDetail)