node package

Submodules

node.admin module

class node.admin.NodeAdmin(model, admin_site)

Bases: django.contrib.admin.options.ModelAdmin

list_display = (u'hostname', u'is_paused', u'pause_reason', u'is_active', u'deprecated')
media

node.apps module

class node.apps.NodeConfig(app_name, app_module)

Bases: django.apps.config.AppConfig

Configuration for the node app

label = u'node'
name = u'node'
verbose_name = u'Node'

node.models module

Defines the database model for a node

class node.models.Node(*args, **kwargs)

Bases: django.db.models.base.Model

Represents a cluster node on which jobs can be run

Parameters:
  • hostname (django.db.models.CharField) – The full domain-qualified hostname of the node
  • pause_reason (django.db.models.CharField) – User or system specified reason why this node is paused. Should be used for display only.
  • is_paused (django.db.models.BooleanField()) – True if the node is currently paused and should not accept new jobs
  • is_active (django.db.models.BooleanField()) – True if the node is currently active or is deprecated for historical purposes
  • created (django.db.models.DateTimeField) – When the node model was created
  • deprecated (django.db.models.DateTimeField) – When the node was deprecated (no longer active)
  • last_offer_received (django.db.models.DateTimeField) – When mesos last offered resources for this node
  • last_modified (django.db.models.DateTimeField) – When the node model was last modified
ALPHABETIZE_FIELDS = [u'hostname', u'pause_reason']
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

created

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deprecated

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_created(*moreargs, **morekwargs)
get_next_by_last_modified(*moreargs, **morekwargs)
get_next_by_last_offer_received(*moreargs, **morekwargs)
get_previous_by_created(*moreargs, **morekwargs)
get_previous_by_last_modified(*moreargs, **morekwargs)
get_previous_by_last_offer_received(*moreargs, **morekwargs)
hostname

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_paused

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

job_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

jobexecution_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

jobexecutionend_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

last_modified

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_offer_received

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <node.models.NodeManager object>
pause_reason

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class node.models.NodeManager

Bases: django.db.models.manager.Manager

Provides additional methods for handling nodes

create_nodes(hostnames)

Creates and returns new nodes with the given host names

Parameters:hostnames (list()) – The list of host names
Returns:The list of new nodes
Return type:list()
get_details(node_id)

Gets additional details for the given node model based on related model attributes.

The additional fields include: job executions.

Parameters:node_id (int) – The unique identifier of the node.
Returns:The node with extra related attributes.
Return type:node.models.Node
get_nodes(started=None, ended=None, order=None, is_active=None)

Returns a list of nodes within the given time range.

Parameters:
  • started (datetime.datetime) – Query nodes updated after this amount of time.
  • ended (datetime.datetime) – Query nodes updated before this amount of time.
  • order ([string]) – A list of fields to control the sort order.
  • is_active (boolean) – Include only active nodes, only inactive nodes or both?
Returns:

The list of nodes that match the time range.

Return type:

[node.models.Node]

get_nodes_running_jobs()

Returns a list of nodes that are currently running jobs.

Returns:The list of node ids running jobs
Return type:list()
get_scheduler_nodes(hostnames)

Returns a list of all nodes that either have one of the given host names or is active.

Parameters:hostnames (list()) – The list of host names
Returns:The list of nodes for the scheduler
Return type:list()
update_node(*args, **kwargs)

Update the data for a node.

Parameters:
  • new_data (dict) – Updated data for the node
  • node_id (int) – The ID of the node to modify
update_node_offers(*args, **kwargs)

Update the last_offer_received field for nodes.

Parameters:
  • hostnames ([string]) – List of hostnames to be updated
  • when (datetime) – The datetime to be set as the last offer received

node.serializers module

Defines the serializers for nodes

class node.serializers.NodeBaseSerializer(instance=None, data=<class rest_framework.fields.empty>, **kwargs)

Bases: util.rest.ModelIdSerializer

Converts node model fields to REST output.

class node.serializers.NodeDetailsSerializer(instance=None, data=<class rest_framework.fields.empty>, **kwargs)

Bases: node.serializers.NodeSerializer

Converts node model fields to REST output.

class node.serializers.NodeSerializer(instance=None, data=<class rest_framework.fields.empty>, **kwargs)

Bases: node.serializers.NodeBaseSerializer

Converts node model fields to REST output.

node.urls module

Defines the URLs for the RESTful node services

node.views module

Node Views

class node.views.NodeDetailsView(**kwargs)

Bases: rest_framework.generics.GenericAPIView

This view is the endpoint for viewing and modifying a node

get(request, node_id)

Determine api version and call specific method

Parameters:request (rest_framework.request.Request) – the HTTP POST request
Return type:rest_framework.response.Response
Returns:the HTTP response to send back to the user
get_impl(request, node_id)

Gets node info

Parameters:
  • request (rest_framework.request.Request) – the HTTP GET request
  • node_id (str) – The ID for the node.
Return type:

rest_framework.response.Response

Returns:

the HTTP response to send back to the user

patch(request, node_id)

Determine api version and call specific method

Parameters:request (rest_framework.request.Request) – the HTTP PATCH request
Return type:rest_framework.response.Response
Returns:the HTTP response to send back to the user
patch_v6(request, node_id)

Modify node info with a subset of fields

Parameters:
  • request (rest_framework.request.Request) – the HTTP GET request
  • node_id (str) – The ID for the node.
Return type:

rest_framework.response.Response

Returns:

the HTTP response to send back to the user

queryset
serializer_class

alias of NodeDetailsSerializer

update_fields = (u'pause_reason', u'is_paused', u'is_active')
class node.views.NodesView(**kwargs)

Bases: rest_framework.generics.ListAPIView

This view is the endpoint for viewing a list of nodes with metadata

list(request)

Determine api version and call specific method

Parameters:request (rest_framework.request.Request) – the HTTP POST request
Return type:rest_framework.response.Response
Returns:the HTTP response to send back to the user
list_impl(request)

Retrieves the list of all nodes and returns it in JSON form

Parameters:request (rest_framework.request.Request) – the HTTP GET request
Return type:rest_framework.response.Response
Returns:the HTTP response to send back to the user
queryset
serializer_class

alias of NodeSerializer

Module contents