Package ganeti :: Package rapi :: Module client :: Class GanetiRapiClient
[hide private]
[frames] | no frames]

Class GanetiRapiClient

source code


Ganeti RAPI client.

Instance Methods [hide private]
 
__init__(self, host, port=GANETI_RAPI_PORT, username=None, password=None, logger=logging, curl_config_fn=None, curl_factory=None)
Initializes this class.
source code
 
_CreateCurl(self)
Creates a cURL object.
source code
str
_SendRequest(self, method, path, query, content)
Sends an HTTP request.
source code
int
GetVersion(self)
Gets the Remote API version running on the cluster.
source code
list
GetFeatures(self)
Gets the list of optional features supported by RAPI server.
source code
list of str
GetOperatingSystems(self, reason=None)
Gets the Operating Systems running in the Ganeti cluster.
source code
dict
GetInfo(self, reason=None)
Gets info about the cluster.
source code
string
RedistributeConfig(self, reason=None)
Tells the cluster to redistribute its configuration files.
source code
string
ModifyCluster(self, reason=None, **kwargs)
Modifies cluster parameters.
source code
list of str
GetClusterTags(self, reason=None)
Gets the cluster tags.
source code
string
AddClusterTags(self, tags, dry_run=False, reason=None)
Adds tags to the cluster.
source code
string
DeleteClusterTags(self, tags, dry_run=False, reason=None)
Deletes tags from the cluster.
source code
list of dict or list of str
GetInstances(self, bulk=False, reason=None)
Gets information about instances on the cluster.
source code
dict
GetInstance(self, instance, reason=None)
Gets information about an instance.
source code
string
GetInstanceInfo(self, instance, static=None, reason=None)
Gets information about an instance.
source code
 
InstanceAllocation(self, mode, name, disk_template, disks, nics, **kwargs)
Generates an instance allocation as used by multiallocate.
source code
 
InstancesMultiAlloc(self, instances, reason=None, **kwargs)
Tries to allocate multiple instances.
source code
string
CreateInstance(self, mode, name, disk_template, disks, nics, reason=None, **kwargs)
Creates a new instance.
source code
string
DeleteInstance(self, instance, dry_run=False, reason=None, **kwargs)
Deletes an instance.
source code
string
ModifyInstance(self, instance, reason=None, **kwargs)
Modifies an instance.
source code
string
ActivateInstanceDisks(self, instance, ignore_size=None, reason=None)
Activates an instance's disks.
source code
string
DeactivateInstanceDisks(self, instance, reason=None)
Deactivates an instance's disks.
source code
string
RecreateInstanceDisks(self, instance, disks=None, nodes=None, reason=None)
Recreate an instance's disks.
source code
string
GrowInstanceDisk(self, instance, disk, amount, wait_for_sync=None, reason=None)
Grows a disk of an instance.
source code
list of str
GetInstanceTags(self, instance, reason=None)
Gets tags for an instance.
source code
string
AddInstanceTags(self, instance, tags, dry_run=False, reason=None)
Adds tags to an instance.
source code
string
DeleteInstanceTags(self, instance, tags, dry_run=False, reason=None)
Deletes tags from an instance.
source code
string
RebootInstance(self, instance, reboot_type=None, ignore_secondaries=None, dry_run=False, reason=None, **kwargs)
Reboots an instance.
source code
string
ShutdownInstance(self, instance, dry_run=False, no_remember=False, reason=None, **kwargs)
Shuts down an instance.
source code
string
StartupInstance(self, instance, dry_run=False, no_remember=False, reason=None)
Starts up an instance.
source code
string
ReinstallInstance(self, instance, os=None, no_startup=False, osparams=None, reason=None)
Reinstalls an instance.
source code
string
ReplaceInstanceDisks(self, instance, disks=None, mode=REPLACE_DISK_AUTO, remote_node=None, iallocator=None, reason=None, early_release=None)
Replaces disks on an instance.
source code
string
PrepareExport(self, instance, mode, reason=None)
Prepares an instance for an export.
source code
string
ExportInstance(self, instance, mode, destination, shutdown=None, remove_instance=None, x509_key_name=None, destination_x509_ca=None, reason=None)
Exports an instance.
source code
string
MigrateInstance(self, instance, mode=None, cleanup=None, target_node=None, reason=None)
Migrates an instance.
source code
string
FailoverInstance(self, instance, iallocator=None, ignore_consistency=None, target_node=None, reason=None)
Does a failover of an instance.
source code
string
RenameInstance(self, instance, new_name, ip_check=None, name_check=None, reason=None)
Changes the name of an instance.
source code
dict
GetInstanceConsole(self, instance, reason=None)
Request information for connecting to instance's console.
source code
list of int
GetJobs(self, bulk=False)
Gets all jobs for the cluster.
source code
dict
GetJobStatus(self, job_id)
Gets the status of a job.
source code
bool
WaitForJobCompletion(self, job_id, period=5, retries=-1)
Polls cluster for job status until completion.
source code
dict
WaitForJobChange(self, job_id, fields, prev_job_info, prev_log_serial)
Waits for job changes.
source code
tuple
CancelJob(self, job_id, dry_run=False)
Cancels a job.
source code
list of dict or str
GetNodes(self, bulk=False, reason=None)
Gets all nodes in the cluster.
source code
dict
GetNode(self, node, reason=None)
Gets information about a node.
source code
string, or a list for pre-2.5 results
EvacuateNode(self, node, iallocator=None, remote_node=None, dry_run=False, early_release=None, mode=None, accept_old=False, reason=None)
Evacuates instances from a Ganeti node.
source code
string
MigrateNode(self, node, mode=None, dry_run=False, iallocator=None, target_node=None, reason=None)
Migrates all primary instances from a node.
source code
str
GetNodeRole(self, node, reason=None)
Gets the current role for a node.
source code
string
SetNodeRole(self, node, role, force=False, auto_promote=None, reason=None)
Sets the role for a node.
source code
string
PowercycleNode(self, node, force=False, reason=None)
Powercycles a node.
source code
string
ModifyNode(self, node, reason=None, **kwargs)
Modifies a node.
source code
string
GetNodeStorageUnits(self, node, storage_type, output_fields, reason=None)
Gets the storage units for a node.
source code
string
ModifyNodeStorageUnits(self, node, storage_type, name, allocatable=None, reason=None)
Modifies parameters of storage units on the node.
source code
string
RepairNodeStorageUnits(self, node, storage_type, name, reason=None)
Repairs a storage unit on the node.
source code
list of str
GetNodeTags(self, node, reason=None)
Gets the tags for a node.
source code
string
AddNodeTags(self, node, tags, dry_run=False, reason=None)
Adds tags to a node.
source code
string
DeleteNodeTags(self, node, tags, dry_run=False, reason=None)
Delete tags from a node.
source code
list of dict or str
GetNetworks(self, bulk=False, reason=None)
Gets all networks in the cluster.
source code
dict
GetNetwork(self, network, reason=None)
Gets information about a network.
source code
string
CreateNetwork(self, network_name, network, gateway=None, network6=None, gateway6=None, mac_prefix=None, add_reserved_ips=None, tags=None, dry_run=False, reason=None)
Creates a new network.
source code
 
ConnectNetwork(self, network_name, group_name, mode, link, vlan="", dry_run=False, reason=None)
Connects a Network to a NodeGroup with the given netparams
source code
 
DisconnectNetwork(self, network_name, group_name, dry_run=False, reason=None)
Connects a Network to a NodeGroup with the given netparams
source code
string
ModifyNetwork(self, network, reason=None, **kwargs)
Modifies a network.
source code
string
DeleteNetwork(self, network, dry_run=False, reason=None)
Deletes a network.
source code
list of strings
GetNetworkTags(self, network, reason=None)
Gets tags for a network.
source code
string
AddNetworkTags(self, network, tags, dry_run=False, reason=None)
Adds tags to a network.
source code
string
DeleteNetworkTags(self, network, tags, dry_run=False, reason=None)
Deletes tags from a network.
source code
list of dict or str
GetGroups(self, bulk=False, reason=None)
Gets all node groups in the cluster.
source code
dict
GetGroup(self, group, reason=None)
Gets information about a node group.
source code
string
CreateGroup(self, name, alloc_policy=None, dry_run=False, reason=None)
Creates a new node group.
source code
string
ModifyGroup(self, group, reason=None, **kwargs)
Modifies a node group.
source code
string
DeleteGroup(self, group, dry_run=False, reason=None)
Deletes a node group.
source code
string
RenameGroup(self, group, new_name, reason=None)
Changes the name of a node group.
source code
string
AssignGroupNodes(self, group, nodes, force=False, dry_run=False, reason=None)
Assigns nodes to a group.
source code
list of strings
GetGroupTags(self, group, reason=None)
Gets tags for a node group.
source code
string
AddGroupTags(self, group, tags, dry_run=False, reason=None)
Adds tags to a node group.
source code
string
DeleteGroupTags(self, group, tags, dry_run=False, reason=None)
Deletes tags from a node group.
source code
string
Query(self, what, fields, qfilter=None, reason=None)
Retrieves information about resources.
source code
string
QueryFields(self, what, fields=None, reason=None)
Retrieves available fields for a resource.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
list
_EncodeQuery(query)
Encode query values for RAPI URL.
source code
 
_UpdateWithKwargs(base, **kwargs)
Updates the base with params from kwargs.
source code
Class Variables [hide private]
  USER_AGENT = "Ganeti RAPI Client"
  _json_encoder = simplejson.JSONEncoder(sort_keys= True)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, host, port=GANETI_RAPI_PORT, username=None, password=None, logger=logging, curl_config_fn=None, curl_factory=None)
(Constructor)

source code 

Initializes this class.

Parameters:
  • host (string) - the ganeti cluster master to interact with
  • port (int) - the port on which the RAPI is running (default is 5080)
  • username (string) - the username to connect with
  • password (string) - the password to connect with
  • curl_config_fn (callable) - Function to configure pycurl.Curl object
  • logger - Logging object
Overrides: object.__init__

_EncodeQuery(query)
Static Method

source code 

Encode query values for RAPI URL.

Parameters:
  • query (list of two-tuples) - Query arguments
Returns: list
Query list with encoded values

_SendRequest(self, method, path, query, content)

source code 

Sends an HTTP request.

This constructs a full URL, encodes and decodes HTTP bodies, and handles invalid responses in a pythonic way.

Parameters:
  • method (string) - HTTP method to use
  • path (string) - HTTP URL path
  • query (list of two-tuples) - query arguments to pass to urllib.urlencode
  • content (str or None) - HTTP body content
Returns: str
JSON-Decoded response
Raises:

GetVersion(self)

source code 

Gets the Remote API version running on the cluster.

Returns: int
Ganeti Remote API version

GetFeatures(self)

source code 

Gets the list of optional features supported by RAPI server.

Returns: list
List of optional features

GetOperatingSystems(self, reason=None)

source code 

Gets the Operating Systems running in the Ganeti cluster.

Parameters:
  • reason (string) - the reason for executing this operation
Returns: list of str
operating systems

GetInfo(self, reason=None)

source code 

Gets info about the cluster.

Parameters:
  • reason (string) - the reason for executing this operation
Returns: dict
information about the cluster

RedistributeConfig(self, reason=None)

source code 

Tells the cluster to redistribute its configuration files.

Parameters:
  • reason (string) - the reason for executing this operation
Returns: string
job id

ModifyCluster(self, reason=None, **kwargs)

source code 

Modifies cluster parameters.

More details for parameters can be found in the RAPI documentation.

Parameters:
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetClusterTags(self, reason=None)

source code 

Gets the cluster tags.

Parameters:
  • reason (string) - the reason for executing this operation
Returns: list of str
cluster tags

AddClusterTags(self, tags, dry_run=False, reason=None)

source code 

Adds tags to the cluster.

Parameters:
  • tags (list of str) - tags to add to the cluster
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeleteClusterTags(self, tags, dry_run=False, reason=None)

source code 

Deletes tags from the cluster.

Parameters:
  • tags (list of str) - tags to delete
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetInstances(self, bulk=False, reason=None)

source code 

Gets information about instances on the cluster.

Parameters:
  • bulk (bool) - whether to return all information about all instances
  • reason (string) - the reason for executing this operation
Returns: list of dict or list of str
if bulk is True, info about the instances, else a list of instances

GetInstance(self, instance, reason=None)

source code 

Gets information about an instance.

Parameters:
  • instance (str) - instance whose info to return
  • reason (string) - the reason for executing this operation
Returns: dict
info about the instance

GetInstanceInfo(self, instance, static=None, reason=None)

source code 

Gets information about an instance.

Parameters:
  • instance (string) - Instance name
  • reason (string) - the reason for executing this operation
Returns: string
Job ID

_UpdateWithKwargs(base, **kwargs)
Static Method

source code 

Updates the base with params from kwargs.

Parameters:
  • base - The base dict, filled with required fields

Note: This is an inplace update of base

InstanceAllocation(self, mode, name, disk_template, disks, nics, **kwargs)

source code 

Generates an instance allocation as used by multiallocate.

More details for parameters can be found in the RAPI documentation. It is the same as used by CreateInstance.

Parameters:
  • mode (string) - Instance creation mode
  • name (string) - Hostname of the instance to create
  • disk_template (string) - Disk template for instance (e.g. plain, diskless, file, or drbd)
  • disks (list of dicts) - List of disk definitions
  • nics (list of dicts) - List of NIC definitions
Returns:
A dict with the generated entry

InstancesMultiAlloc(self, instances, reason=None, **kwargs)

source code 

Tries to allocate multiple instances.

More details for parameters can be found in the RAPI documentation.

Parameters:

CreateInstance(self, mode, name, disk_template, disks, nics, reason=None, **kwargs)

source code 

Creates a new instance.

More details for parameters can be found in the RAPI documentation.

Parameters:
  • mode (string) - Instance creation mode
  • name (string) - Hostname of the instance to create
  • disk_template (string) - Disk template for instance (e.g. plain, diskless, file, or drbd)
  • disks (list of dicts) - List of disk definitions
  • nics (list of dicts) - List of NIC definitions
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeleteInstance(self, instance, dry_run=False, reason=None, **kwargs)

source code 

Deletes an instance.

Parameters:
  • instance (str) - the instance to delete
  • reason (string) - the reason for executing this operation
Returns: string
job id

ModifyInstance(self, instance, reason=None, **kwargs)

source code 

Modifies an instance.

More details for parameters can be found in the RAPI documentation.

Parameters:
  • instance (string) - Instance name
  • reason (string) - the reason for executing this operation
Returns: string
job id

ActivateInstanceDisks(self, instance, ignore_size=None, reason=None)

source code 

Activates an instance's disks.

Parameters:
  • instance (string) - Instance name
  • ignore_size (bool) - Whether to ignore recorded size
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeactivateInstanceDisks(self, instance, reason=None)

source code 

Deactivates an instance's disks.

Parameters:
  • instance (string) - Instance name
  • reason (string) - the reason for executing this operation
Returns: string
job id

RecreateInstanceDisks(self, instance, disks=None, nodes=None, reason=None)

source code 

Recreate an instance's disks.

Parameters:
  • instance (string) - Instance name
  • disks (list of int) - List of disk indexes
  • nodes (list of string) - New instance nodes, if relocation is desired
  • reason (string) - the reason for executing this operation
Returns: string
job id

GrowInstanceDisk(self, instance, disk, amount, wait_for_sync=None, reason=None)

source code 

Grows a disk of an instance.

More details for parameters can be found in the RAPI documentation.

Parameters:
  • instance (string) - Instance name
  • disk (integer) - Disk index
  • amount (integer) - Grow disk by this amount (MiB)
  • wait_for_sync (bool) - Wait for disk to synchronize
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetInstanceTags(self, instance, reason=None)

source code 

Gets tags for an instance.

Parameters:
  • instance (str) - instance whose tags to return
  • reason (string) - the reason for executing this operation
Returns: list of str
tags for the instance

AddInstanceTags(self, instance, tags, dry_run=False, reason=None)

source code 

Adds tags to an instance.

Parameters:
  • instance (str) - instance to add tags to
  • tags (list of str) - tags to add to the instance
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeleteInstanceTags(self, instance, tags, dry_run=False, reason=None)

source code 

Deletes tags from an instance.

Parameters:
  • instance (str) - instance to delete tags from
  • tags (list of str) - tags to delete
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

RebootInstance(self, instance, reboot_type=None, ignore_secondaries=None, dry_run=False, reason=None, **kwargs)

source code 

Reboots an instance.

Parameters:
  • instance (str) - instance to reboot
  • reboot_type (str) - one of: hard, soft, full
  • ignore_secondaries (bool) - if True, ignores errors for the secondary node while re-assembling disks (in hard-reboot mode only)
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for the reboot
Returns: string
job id

ShutdownInstance(self, instance, dry_run=False, no_remember=False, reason=None, **kwargs)

source code 

Shuts down an instance.

Parameters:
  • instance (str) - the instance to shut down
  • dry_run (bool) - whether to perform a dry run
  • no_remember (bool) - if true, will not record the state change
  • reason (string) - the reason for the shutdown
Returns: string
job id

StartupInstance(self, instance, dry_run=False, no_remember=False, reason=None)

source code 

Starts up an instance.

Parameters:
  • instance (str) - the instance to start up
  • dry_run (bool) - whether to perform a dry run
  • no_remember (bool) - if true, will not record the state change
  • reason (string) - the reason for the startup
Returns: string
job id

ReinstallInstance(self, instance, os=None, no_startup=False, osparams=None, reason=None)

source code 

Reinstalls an instance.

Parameters:
  • instance (str) - The instance to reinstall
  • os (str or None) - The operating system to reinstall. If None, the instance's current operating system will be installed again
  • no_startup (bool) - Whether to start the instance automatically
  • reason (string) - the reason for executing this operation
Returns: string
job id

ReplaceInstanceDisks(self, instance, disks=None, mode=REPLACE_DISK_AUTO, remote_node=None, iallocator=None, reason=None, early_release=None)

source code 

Replaces disks on an instance.

Parameters:
  • instance (str) - instance whose disks to replace
  • disks (list of ints) - Indexes of disks to replace
  • mode (str) - replacement mode to use (defaults to replace_auto)
  • remote_node (str or None) - new secondary node to use (for use with replace_new_secondary mode)
  • iallocator (str or None) - instance allocator plugin to use (for use with replace_auto mode)
  • reason (string) - the reason for executing this operation
  • early_release (bool) - whether to release locks as soon as possible
Returns: string
job id

PrepareExport(self, instance, mode, reason=None)

source code 

Prepares an instance for an export.

Parameters:
  • instance (string) - Instance name
  • mode (string) - Export mode
  • reason (string) - the reason for executing this operation
Returns: string
Job ID

ExportInstance(self, instance, mode, destination, shutdown=None, remove_instance=None, x509_key_name=None, destination_x509_ca=None, reason=None)

source code 

Exports an instance.

Parameters:
  • instance (string) - Instance name
  • mode (string) - Export mode
  • reason (string) - the reason for executing this operation
Returns: string
Job ID

MigrateInstance(self, instance, mode=None, cleanup=None, target_node=None, reason=None)

source code 

Migrates an instance.

Parameters:
  • instance (string) - Instance name
  • mode (string) - Migration mode
  • cleanup (bool) - Whether to clean up a previously failed migration
  • target_node (string) - Target Node for externally mirrored instances
  • reason (string) - the reason for executing this operation
Returns: string
job id

FailoverInstance(self, instance, iallocator=None, ignore_consistency=None, target_node=None, reason=None)

source code 

Does a failover of an instance.

Parameters:
  • instance (string) - Instance name
  • iallocator (string) - Iallocator for deciding the target node for shared-storage instances
  • ignore_consistency (bool) - Whether to ignore disk consistency
  • target_node (string) - Target node for shared-storage instances
  • reason (string) - the reason for executing this operation
Returns: string
job id

RenameInstance(self, instance, new_name, ip_check=None, name_check=None, reason=None)

source code 

Changes the name of an instance.

Parameters:
  • instance (string) - Instance name
  • new_name (string) - New instance name
  • ip_check (bool) - Whether to ensure instance's IP address is inactive
  • name_check (bool) - Whether to ensure instance's name is resolvable
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetInstanceConsole(self, instance, reason=None)

source code 

Request information for connecting to instance's console.

Parameters:
  • instance (string) - Instance name
  • reason (string) - the reason for executing this operation
Returns: dict
dictionary containing information about instance's console

GetJobs(self, bulk=False)

source code 

Gets all jobs for the cluster.

Parameters:
  • bulk (bool) - Whether to return detailed information about jobs.
Returns: list of int
List of job ids for the cluster or list of dicts with detailed information about the jobs if bulk parameter was true.

GetJobStatus(self, job_id)

source code 

Gets the status of a job.

Parameters:
  • job_id (string) - job id whose status to query
Returns: dict
job status

WaitForJobCompletion(self, job_id, period=5, retries=-1)

source code 

Polls cluster for job status until completion.

Completion is defined as any of the following states listed in JOB_STATUS_FINALIZED.

Parameters:
  • job_id (string) - job id to watch
  • period (int) - how often to poll for status (optional, default 5s)
  • retries (int) - how many time to poll before giving up (optional, default -1 means unlimited)
Returns: bool
True if job succeeded or False if failed/status timeout

Deprecated: It is recommended to use WaitForJobChange wherever possible; WaitForJobChange returns immediately after a job changed and does not use polling

WaitForJobChange(self, job_id, fields, prev_job_info, prev_log_serial)

source code 

Waits for job changes.

Parameters:
  • job_id (string) - Job ID for which to wait
Returns: dict
None if no changes have been detected and a dict with two keys, job_info and log_entries otherwise.

CancelJob(self, job_id, dry_run=False)

source code 

Cancels a job.

Parameters:
  • job_id (string) - id of the job to delete
  • dry_run (bool) - whether to perform a dry run
Returns: tuple
tuple containing the result, and a message (bool, string)

GetNodes(self, bulk=False, reason=None)

source code 

Gets all nodes in the cluster.

Parameters:
  • bulk (bool) - whether to return all information about all instances
  • reason (string) - the reason for executing this operation
Returns: list of dict or str
if bulk is true, info about nodes in the cluster, else list of nodes in the cluster

GetNode(self, node, reason=None)

source code 

Gets information about a node.

Parameters:
  • node (str) - node whose info to return
  • reason (string) - the reason for executing this operation
Returns: dict
info about the node

EvacuateNode(self, node, iallocator=None, remote_node=None, dry_run=False, early_release=None, mode=None, accept_old=False, reason=None)

source code 

Evacuates instances from a Ganeti node.

Parameters:
  • node (str) - node to evacuate
  • iallocator (str or None) - instance allocator to use
  • remote_node (str) - node to evaucate to
  • dry_run (bool) - whether to perform a dry run
  • early_release (bool) - whether to enable parallelization
  • mode (string) - Node evacuation mode
  • accept_old (bool) - Whether caller is ready to accept old-style (pre-2.5) results
  • reason (string) - the reason for executing this operation
Returns: string, or a list for pre-2.5 results
Job ID or, if accept_old is set and server is pre-2.5, list of (job ID, instance name, new secondary node); if dry_run was specified, then the actual move jobs were not submitted and the job IDs will be None
Raises:
  • GanetiApiError - if an iallocator and remote_node are both specified

MigrateNode(self, node, mode=None, dry_run=False, iallocator=None, target_node=None, reason=None)

source code 

Migrates all primary instances from a node.

Parameters:
  • node (str) - node to migrate
  • mode (string) - if passed, it will overwrite the live migration type, otherwise the hypervisor default will be used
  • dry_run (bool) - whether to perform a dry run
  • iallocator (string) - instance allocator to use
  • target_node (string) - Target node for shared-storage instances
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetNodeRole(self, node, reason=None)

source code 

Gets the current role for a node.

Parameters:
  • node (str) - node whose role to return
  • reason (string) - the reason for executing this operation
Returns: str
the current role for a node

SetNodeRole(self, node, role, force=False, auto_promote=None, reason=None)

source code 

Sets the role for a node.

Parameters:
  • node (str) - the node whose role to set
  • role (str) - the role to set for the node
  • force (bool) - whether to force the role change
  • auto_promote (bool) - Whether node(s) should be promoted to master candidate if necessary
  • reason (string) - the reason for executing this operation
Returns: string
job id

PowercycleNode(self, node, force=False, reason=None)

source code 

Powercycles a node.

Parameters:
  • node (string) - Node name
  • force (bool) - Whether to force the operation
  • reason (string) - the reason for executing this operation
Returns: string
job id

ModifyNode(self, node, reason=None, **kwargs)

source code 

Modifies a node.

More details for parameters can be found in the RAPI documentation.

Parameters:
  • node (string) - Node name
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetNodeStorageUnits(self, node, storage_type, output_fields, reason=None)

source code 

Gets the storage units for a node.

Parameters:
  • node (str) - the node whose storage units to return
  • storage_type (str) - storage type whose units to return
  • output_fields (str) - storage type fields to return
  • reason (string) - the reason for executing this operation
Returns: string
job id where results can be retrieved

ModifyNodeStorageUnits(self, node, storage_type, name, allocatable=None, reason=None)

source code 

Modifies parameters of storage units on the node.

Parameters:
  • node (str) - node whose storage units to modify
  • storage_type (str) - storage type whose units to modify
  • name (str) - name of the storage unit
  • allocatable (bool or None) - Whether to set the "allocatable" flag on the storage unit (None=no modification, True=set, False=unset)
  • reason (string) - the reason for executing this operation
Returns: string
job id

RepairNodeStorageUnits(self, node, storage_type, name, reason=None)

source code 

Repairs a storage unit on the node.

Parameters:
  • node (str) - node whose storage units to repair
  • storage_type (str) - storage type to repair
  • name (str) - name of the storage unit to repair
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetNodeTags(self, node, reason=None)

source code 

Gets the tags for a node.

Parameters:
  • node (str) - node whose tags to return
  • reason (string) - the reason for executing this operation
Returns: list of str
tags for the node

AddNodeTags(self, node, tags, dry_run=False, reason=None)

source code 

Adds tags to a node.

Parameters:
  • node (str) - node to add tags to
  • tags (list of str) - tags to add to the node
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeleteNodeTags(self, node, tags, dry_run=False, reason=None)

source code 

Delete tags from a node.

Parameters:
  • node (str) - node to remove tags from
  • tags (list of str) - tags to remove from the node
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetNetworks(self, bulk=False, reason=None)

source code 

Gets all networks in the cluster.

Parameters:
  • bulk (bool) - whether to return all information about the networks
Returns: list of dict or str
if bulk is true, a list of dictionaries with info about all networks in the cluster, else a list of names of those networks

GetNetwork(self, network, reason=None)

source code 

Gets information about a network.

Parameters:
  • network (str) - name of the network whose info to return
  • reason (string) - the reason for executing this operation
Returns: dict
info about the network

CreateNetwork(self, network_name, network, gateway=None, network6=None, gateway6=None, mac_prefix=None, add_reserved_ips=None, tags=None, dry_run=False, reason=None)

source code 

Creates a new network.

Parameters:
  • network_name (str) - the name of network to create
  • dry_run (bool) - whether to peform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

ModifyNetwork(self, network, reason=None, **kwargs)

source code 

Modifies a network.

More details for parameters can be found in the RAPI documentation.

Parameters:
  • network (string) - Network name
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeleteNetwork(self, network, dry_run=False, reason=None)

source code 

Deletes a network.

Parameters:
  • network (str) - the network to delete
  • dry_run (bool) - whether to peform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetNetworkTags(self, network, reason=None)

source code 

Gets tags for a network.

Parameters:
  • network (string) - Node group whose tags to return
  • reason (string) - the reason for executing this operation
Returns: list of strings
tags for the network

AddNetworkTags(self, network, tags, dry_run=False, reason=None)

source code 

Adds tags to a network.

Parameters:
  • network (str) - network to add tags to
  • tags (list of string) - tags to add to the network
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeleteNetworkTags(self, network, tags, dry_run=False, reason=None)

source code 

Deletes tags from a network.

Parameters:
  • network (str) - network to delete tags from
  • tags (list of string) - tags to delete
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetGroups(self, bulk=False, reason=None)

source code 

Gets all node groups in the cluster.

Parameters:
  • bulk (bool) - whether to return all information about the groups
  • reason (string) - the reason for executing this operation
Returns: list of dict or str
if bulk is true, a list of dictionaries with info about all node groups in the cluster, else a list of names of those node groups

GetGroup(self, group, reason=None)

source code 

Gets information about a node group.

Parameters:
  • group (str) - name of the node group whose info to return
  • reason (string) - the reason for executing this operation
Returns: dict
info about the node group

CreateGroup(self, name, alloc_policy=None, dry_run=False, reason=None)

source code 

Creates a new node group.

Parameters:
  • name (str) - the name of node group to create
  • alloc_policy (str) - the desired allocation policy for the group, if any
  • dry_run (bool) - whether to peform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

ModifyGroup(self, group, reason=None, **kwargs)

source code 

Modifies a node group.

More details for parameters can be found in the RAPI documentation.

Parameters:
  • group (string) - Node group name
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeleteGroup(self, group, dry_run=False, reason=None)

source code 

Deletes a node group.

Parameters:
  • group (str) - the node group to delete
  • dry_run (bool) - whether to peform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

RenameGroup(self, group, new_name, reason=None)

source code 

Changes the name of a node group.

Parameters:
  • group (string) - Node group name
  • new_name (string) - New node group name
  • reason (string) - the reason for executing this operation
Returns: string
job id

AssignGroupNodes(self, group, nodes, force=False, dry_run=False, reason=None)

source code 

Assigns nodes to a group.

Parameters:
  • group (string) - Node group name
  • nodes (list of strings) - List of nodes to assign to the group
  • reason (string) - the reason for executing this operation
Returns: string
job id

GetGroupTags(self, group, reason=None)

source code 

Gets tags for a node group.

Parameters:
  • group (string) - Node group whose tags to return
  • reason (string) - the reason for executing this operation
Returns: list of strings
tags for the group

AddGroupTags(self, group, tags, dry_run=False, reason=None)

source code 

Adds tags to a node group.

Parameters:
  • group (str) - group to add tags to
  • tags (list of string) - tags to add to the group
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

DeleteGroupTags(self, group, tags, dry_run=False, reason=None)

source code 

Deletes tags from a node group.

Parameters:
  • group (str) - group to delete tags from
  • tags (list of string) - tags to delete
  • dry_run (bool) - whether to perform a dry run
  • reason (string) - the reason for executing this operation
Returns: string
job id

Query(self, what, fields, qfilter=None, reason=None)

source code 

Retrieves information about resources.

Parameters:
  • what (string) - Resource name, one of constants.QR_VIA_RAPI
  • fields (list of string) - Requested fields
  • qfilter (None or list) - Query filter
  • reason (string) - the reason for executing this operation
Returns: string
job id

QueryFields(self, what, fields=None, reason=None)

source code 

Retrieves available fields for a resource.

Parameters:
  • what (string) - Resource name, one of constants.QR_VIA_RAPI
  • fields (list of string) - Requested fields
  • reason (string) - the reason for executing this operation
Returns: string
job id