hades.agent package

Hades AMQP API agent

hades.agent.create_app(config: Config) Celery[source]

Submodules

hades.agent.notify module

hades.agent.tasks module

exception hades.agent.tasks.ArgumentError(argument: str, message: str)[source]

Bases: Exception

Exception for illegal task arguments

class hades.agent.tasks.RPCTask[source]

Bases: Task

acks_late = True

When enabled messages for this task will be acknowledged after the task has been executed, and not just before (the default behavior).

Please note that this means the task may be executed twice if the worker crashes mid execution.

The application default can be overridden with the task_acks_late setting.

ignore_result = False

If enabled the worker won't store task state and return values for this task. Defaults to the task_ignore_result setting.

priority = None

Default task priority.

rate_limit = None

Rate limit for this task type. Examples: None (no rate limit), '100/s' (hundred tasks a second), '100/m' (hundred tasks a minute),`'100/h'` (hundred tasks an hour)

reject_on_worker_lost = None

Even if acks_late is enabled, the worker will acknowledge tasks when the worker process executing them abruptly exits or is signaled (e.g., KILL/INT, etc).

Setting this to true allows the message to be re-queued instead, so that the task will execute again by the same worker, or another worker.

Warning: Enabling this can cause message loops; make sure you know what you're doing.

request_stack = <celery.utils.threads._LocalStack object>

Task request stack, the current request will be the topmost.

serializer = 'json'

The name of a serializer that are registered with kombu.serialization.registry. Default is 'json'.

store_errors_even_if_ignored = False

When enabled errors will be stored even if the task is otherwise configured to ignore results.

throws = (<class 'hades.agent.tasks.ArgumentError'>,)

Tuple of expected exceptions.

These are errors that are expected in normal operation and that shouldn't be regarded as a real error by the worker. Currently this means that the state will be updated to an error state, but the worker won't log the event as an error.

track_started = False

If enabled the task will report its status as 'started' when the task is executed by a worker. Disabled by default as the normal behavior is to not report that level of granularity. Tasks are either pending, finished, or waiting to be retried.

Having a 'started' status can be useful for when there are long running tasks and there's a need to report what task is currently running.

The application default can be overridden using the task_track_started setting.

typing = True

Enable argument checking. You can set this to false if you don't want the signature to be checked when calling the task. Defaults to app.strict_typing.

class hades.agent.tasks.Task[source]

Bases: Task

ignore_result = False

If enabled the worker won't store task state and return values for this task. Defaults to the task_ignore_result setting.

priority = None

Default task priority.

rate_limit = None

Rate limit for this task type. Examples: None (no rate limit), '100/s' (hundred tasks a second), '100/m' (hundred tasks a minute),`'100/h'` (hundred tasks an hour)

reject_on_worker_lost = None

Even if acks_late is enabled, the worker will acknowledge tasks when the worker process executing them abruptly exits or is signaled (e.g., KILL/INT, etc).

Setting this to true allows the message to be re-queued instead, so that the task will execute again by the same worker, or another worker.

Warning: Enabling this can cause message loops; make sure you know what you're doing.

request_stack = <celery.utils.threads._LocalStack object>

Task request stack, the current request will be the topmost.

serializer = 'json'

The name of a serializer that are registered with kombu.serialization.registry. Default is 'json'.

store_errors_even_if_ignored = False

When enabled errors will be stored even if the task is otherwise configured to ignore results.

track_started = False

If enabled the task will report its status as 'started' when the task is executed by a worker. Disabled by default as the normal behavior is to not report that level of granularity. Tasks are either pending, finished, or waiting to be retried.

Having a 'started' status can be useful for when there are long running tasks and there's a need to report what task is currently running.

The application default can be overridden using the task_track_started setting.

typing = True

Enable argument checking. You can set this to false if you don't want the signature to be checked when calling the task. Defaults to app.strict_typing.

classmethod wrap(f: Callable, kwargs: Dict[str, Any]) Task[source]
hades.agent.tasks.check_int(argument: str, number: Any) int[source]

Try to convert the argument to an integer.

Parameters:
  • argument -- Name of the argument

  • number -- The value to convert

Raises:

ArgumentError -- if the argument is invalid

hades.agent.tasks.check_ip_address(argument: str, ip_address: Any) IPAddress[source]

Try to convert the argument to an IP address.

Parameters:
  • argument -- Name of the argument

  • ip_address -- The value to convert

Raises:

ArgumentError -- if the argument is invalid

hades.agent.tasks.check_ip_network(argument: str, ip_network: Any) IPNetwork[source]

Try to convert the argument to an IP network.

Parameters:
  • argument -- Name of the argument

  • ip_network -- The value to convert

Raises:

ArgumentError -- if the argument is invalid

hades.agent.tasks.check_mac(argument: str, mac: Any) EUI[source]

Try to convert the argument to a MAC.

Parameters:
  • argument -- Name of the argument

  • mac -- The value to convert

Raises:

ArgumentError -- if the argument is invalid

hades.agent.tasks.check_positive_int(argument: str, number: Any) int[source]

Try to convert the argument to a positive integer.

Parameters:
  • argument -- Name of the argument

  • number -- The value to convert

Raises:

ArgumentError -- if the argument is invalid

hades.agent.tasks.check_str(argument: str, string: Any) str[source]

Try to convert the argument to a string.

Parameters:
  • argument -- Name of the argument

  • string -- The value to convert

Raises:

ArgumentError -- if the argument is invalid

hades.agent.tasks.check_timestamp_range(argument: str, timestamp_range: Any) Tuple[Optional[datetime], Optional[datetime]][source]

Try to convert the argument to a datetime range (tuple of datetime.datetime objects or None.

Parameters:
  • argument -- Name of the argument

  • timestamp_range -- The value to convert

Raises:

ArgumentError -- if the argument is invalid

hades.agent.tasks.dict_from_attributes(obj: object, attributes: Sequence[str]) Dict[str, Any][source]

Get a given sequence of attributes from a given object and return the results as dictionary.

Parameters:
  • obj -- An object

  • attributes -- A sequence of attributes

Returns:

hades.agent.tasks.get_distribution_metadata(distribution: Distribution) Dict[str, Any][source]

Get metadata of a given distribution and all its dependencies.

Parameters:

distribution -- A distribution object

Returns:

A metadata dictionary

hades.agent.tasks.get_unit_status(unit_name: str) Dict[str, Any][source]

Get the status of a given systemd unit.

Parameters:

unit_name -- The name of the unit.

Returns:

A dictionary of the unit properties

hades.agent.tasks.platform_attributes = ('architecture', 'machine', 'node', 'processor', 'python_build', 'python_compiler', 'python_branch', 'python_implementation', 'python_revision', 'python_version', 'python_version_tuple', 'release', 'system', 'version', 'uname')

The attributes of the Python platform, that should be return by the get_system_information() task.

hades.agent.tasks.rpc_task(*args: Any, **kwargs: Any) Callable[[Callable], Task][source]

A convenience decorator that invokes celery.Celery.task(), but sets the following options, if not explicitly overridden:

Option

Value

acks_late

True

throws

(ArgumentError,)

name

f"hades.agent.rpc.{f.__name__}"

hades.agent.tasks.setup_engine(sender: Any, *args: Any, **kwargs: Any) None[source]
hades.agent.tasks.task_attributes = ('name', 'max_retries', 'default_retry_delay', 'rate_limit', 'time_limit', 'soft_time_limit', 'ignore_result', 'store_errors_even_if_ignored', 'serializer', 'acks_late', 'track_started', 'expires')

The attributes of the Celery tasks, that should be returned by the get_system_information() task.

hades.agent.tasks.units = ('hades-agent.service', 'hades-auth-alternative-dns.service', 'hades-auth-dhcp.service', 'hades-auth-dhcp-leases.service', 'hades-auth-dhcp-leases.socket', 'hades-auth-netns.service', 'hades-auth-pristine-dns.service', 'hades-auth-vrrp.service', 'hades-cleanup.timer', 'hades-database.service', 'hades-deputy.service', 'hades-forced-refresh.timer', 'hades-radius.service', 'hades-refresh.timer', 'hades-root-netns.service', 'hades-root-vrrp.service', 'hades-unauth-dhcp-leases.service', 'hades-unauth-dhcp-leases.socket', 'hades-unauth-dns.service', 'hades-unauth-http.service', 'hades-unauth-netns.service', 'hades-unauth-portal.service', 'hades-unauth-vrrp.service', 'hades.service')

The Hades systemd units that should be reported by the get_systemd_status() task.