pyfarm.models.agent module¶
Agent Models¶
Models and interface classes related to the agent.
-
class
pyfarm.models.agent.
Agent
(**kwargs)[source]¶ Bases:
flask_sqlalchemy.Model
,pyfarm.models.core.mixins.ValidatePriorityMixin
,pyfarm.models.core.mixins.ValidateWorkStateMixin
,pyfarm.models.core.mixins.UtilityMixins
,pyfarm.models.core.mixins.ReprMixin
Stores information about an agent include its network address, state, allocation configuration, etc.
Note
This table enforces two forms of uniqueness. The
id
column must be unique and the combination of these columns must also be unique to limit the frequency of duplicate data:-
MAX_CPUS
= 256¶
-
MAX_PORT
= 65535¶
-
MAX_RAM
= 262144¶
-
MIN_CPUS
= 1¶
-
MIN_PORT
= 1024¶
-
MIN_RAM
= 16¶
-
REPR_COLUMNS
= ('id', 'hostname', 'port', 'state', 'remote_ip', 'cpus', 'ram', 'free_ram')¶
-
REPR_CONVERT_COLUMN
= {'remote_ip': <function repr_ip at 0x7f04edb25d90>}¶
-
STATE_DEFAULT
= 'online'¶
-
STATE_ENUM
= MappedEnum(OFFLINE='offline', RUNNING='running', DISABLED='disabled', ONLINE='online')¶
-
URL_TEMPLATE
= 'http://{host}:{port}/api/v1'¶
-
api_url
()[source]¶ Returns the base url which should be used to access the api of this specific agent.
Raises ValueError: Raised if this function is called while the agent’s use_address
column is set toPASSIVE
-
cpu_allocation
¶ The total amount of cpu space an agent is allowed to process work in. A value of 1.0 would mean an agent can handle as much work as the system could handle given the requirements of a task. For example if an agent has 8 cpus, cpu_allocation is .5, and a task requires 4 cpus then only that task will run on the system.
-
cpu_name
¶ The make and model of CPUs in this agents
-
cpus
¶ The number of logical CPU cores installed on the agent
-
disks
¶ The known disks available to this agent
-
failed_tasks
¶ The tasks this agents failed to execute
-
free_ram
¶ The amount of ram which was last considered free
-
gpus
¶ The graphics cards that are installed in this agent
-
hostname
¶ The hostname we should use to talk to this host. Preferably this value will be the fully qualified name instead of the base hostname alone.
-
id
¶ Provides an id for the current row. This value should never be directly relied upon and it’s intended for use by relationships.
-
last_heard_from
¶ Time we last had contact with this agent
-
last_polled
¶ Time we last tried to contact the agent
-
last_success_on
¶ The last time this agent has set a task to done
-
mac_addresses
¶ The MAC addresses this agent has
-
notes
¶ Free form notes about this agent
-
os_class
¶ The type of operating system running on the agent; ‘linux’, ‘windows’, or ‘mac’.
-
os_fullname
¶ The full human-readable name of the agent’s OS, as returned by platform.platform()
-
port
¶ The port the agent is currently running on
-
ram
¶ The amount of ram installed on the agent in megabytes
-
ram_allocation
¶ The amount of ram the agent is allowed to allocate towards work. A value of 1.0 would mean to let the agent use all of the memory installed on the system when assigning work.
-
remote_ip
¶ the remote address which came in with the request
-
restart_requested
¶ If True, the agent will be restarted
-
software_versions
¶ software this agent has installed or is configured for
-
state
¶ Stores the current state of the host. This value can be changed either by a master telling the host to do something with a task or from the host via REST api.
Tags associated with this agent
-
task_logs
¶
-
time_offset
¶ The offset in seconds the agent is from an official time server
-
upgrade_to
¶ The version this agent should upgrade to.
-
use_address
¶ The address we should use when communicating with the agent
-
classmethod
validate_hostname
(key, value)[source]¶ Ensures that the hostname provided by value matches a regular expression that expresses what a valid hostname is.
-
classmethod
validate_ipv4_address
(_, value)[source]¶ Ensures the
ip
address is valid. This checks to ensure that the value provided is:
-
validate_numeric_column
(key, value)[source]¶ Validates several numerical columns. Columns such as ram, cpus and port a are validated with this method.
-
classmethod
validate_resource
(key, value)[source]¶ Ensure the
value
provided forkey
is within an expected range. This classmethod retrieves the min and max values from theAgent
class directory using:>>> min_value = getattr(Agent, "MIN_%s" % key.upper()) >>> max_value = getattr(Agent, "MAX_%s" % key.upper())
-
version
¶ The pyfarm version number this agent is running.
-