linode#

Description#

This plugin can interact with a Linode account and manage node and volumes.

To get your token:

  • Login to <https://cloud.linode.com/>.

  • Go to My Profile -> API Tokens -> Add a Personal Access Token.

  • Select the scopes that you want to provide to your new token.

Configuration#

linode:
  # [Required]
  # Linode API token.
  token:   # type=str

  # [Optional]
  # How often to poll the Linode API
  # (default: 60 seconds).
  # poll_interval: 60.0  # type=float

  # [Optional]
  # How long we should wait for any running
  # threads/processes to stop before exiting (default: 5 seconds).
  # stop_timeout: 5  # type=Optional[float]

  # [Optional]
  # If set to True then the plugin will not monitor
  # for new events. This is useful if you want to run a plugin in
  # stateless mode and only leverage its actions, without triggering any
  # events. Defaults to False.
  # disable_monitor: False  # type=bool

Dependencies#

pip

pip install linode_api4

Triggered events#

Actions#

Module reference#

class platypush.plugins.linode.LinodePlugin(*_, **__)[source]#

Bases: RunnablePlugin, CloudInstanceEntityManager, EnumSwitchEntityManager

This plugin can interact with a Linode account and manage node and volumes.

To get your token:

  • Login to <https://cloud.linode.com/>.

  • Go to My Profile -> API Tokens -> Add a Personal Access Token.

  • Select the scopes that you want to provide to your new token.

__init__(token: str, poll_interval: float = 60.0, **kwargs)[source]#
Parameters:
  • token – Linode API token.

  • poll_interval – How often to poll the Linode API (default: 60 seconds).

boot(instance: str | int | UUID, token: str | None = None, **_)[source]#

Boot an instance.

Parameters:
  • instance – Instance ID, label or host UUID.

  • token – Default access token override.

main()[source]#

Implementation of the main loop of the plugin.

publish_entities(entities: Collection[Any] | None, callback: Callable[[Entity], Any] | None = None, **kwargs) Collection[Entity]#

Publishes a list of entities. The downstream consumers include:

It also accepts an optional callback that will be called when each of the entities in the set is flushed to the database.

You usually don’t need to override this class (but you may want to extend transform_entities() instead if your extension doesn’t natively handle Entity objects).

reboot(instance: str | int | UUID, token: str | None = None, **_)[source]#

Reboot an instance.

Parameters:
  • instance – Instance ID, label or host UUID.

  • token – Default access token override.

set(entity: str, value: str, **kwargs)[source]#

Entity framework compatible method to run an action on the instance through an EnumSwitch.

Parameters:
  • entity – Entity ID, as <instance_id> or <instance_id>:__action__.

  • value – Action to run, one among boot, reboot and shutdown.

shutdown(instance: str | int | UUID, token: str | None = None, **_)[source]#

Shutdown an instance.

Parameters:
  • instance – Instance ID, label or host UUID.

  • token – Default access token override.

start()#

Start the plugin.

status(*_, instance: str | int | UUID | None = None, token: str | None = None, publish_entities: bool = True, **__) List[LinodeInstance][source]#

Get the full status and info of the instances associated to a selected account.

Parameters:
  • token – Override the default access token if you want to query another account.

  • instance – Select only one instance, either by name, ID or host UUID.

  • publish_entities – Whether platypush.message.event.entities.EntityUpdateEvent should be published for all the instances, whether or not their status has changed (default: True).

Returns:

[
  {
    "alerts": {
      "cpu": 90,
      "io": 5000,
      "network_in": 10,
      "network_out": 10,
      "transfer_quota": 80
    },
    "backups": {
      "available": true,
      "enabled": true,
      "last_successful": "2020-01-01T00:00:00Z",
      "schedule": "Backup schedule configuration"
    },
    "created_at": "2020-01-01T00:00:00Z",
    "group": "my-group",
    "hypervisor": "kvm",
    "id": 12345,
    "image": "linode/archlinux2014.04",
    "instance_type": "g6-standard-4",
    "ipv4_addresses": "[\"1.2.3.4\"]",
    "ipv6_address": "1234:5678::9abc:def0:1234:5678/128",
    "name": "my-instance",
    "region": "eu-west",
    "specs": {
      "cpus": 4,
      "disk": 100000,
      "gpus": 62,
      "memory": 8192,
      "transfer": 5000
    },
    "status": "running",
    "tags": "[\"tag1\", \"tag2\"]",
    "updated_at": "2020-01-01T01:00:00Z"
  }
]

stop()#

Stop the plugin.

transform_entities(entities: Collection[dict], **_) Collection[CloudInstance][source]#

This method takes a list of entities in any (plugin-specific) format and converts them into a standardized collection of Entity objects. Since this method is called by publish_entities() before entity updates are published, you may usually want to extend it to pre-process the entities managed by your extension into the standard format before they are stored and published to all the consumers.

wait_stop(timeout=None)#

Wait until a stop event is received.