class GanetiRapiClient(object):
Ganeti RAPI client.
Method | __init__ |
Initializes this class. |
Method |
|
Activates an instance's disks. |
Method |
|
Adds tags to the cluster. |
Method |
|
Adds a filter rule |
Method |
|
Adds tags to a node group. |
Method |
|
Adds tags to an instance. |
Method |
|
Adds tags to a network. |
Method |
|
Adds tags to a node. |
Method |
|
Assigns nodes to a group. |
Method |
|
Cancels a job. |
Method |
|
Connects a Network to a NodeGroup with the given netparams |
Method |
|
Creates a new node group. |
Method |
|
Creates a new instance. |
Method |
|
Creates a new network. |
Method |
|
Deactivates an instance's disks. |
Method |
|
Deletes tags from the cluster. |
Method |
|
Deletes a filter rule |
Method |
|
Deletes a node group. |
Method |
|
Deletes tags from a node group. |
Method |
|
Deletes an instance. |
Method |
|
Deletes tags from an instance. |
Method |
|
Deletes a network. |
Method |
|
Deletes tags from a network. |
Method |
|
Delete tags from a node. |
Method |
|
Connects a Network to a NodeGroup with the given netparams |
Method |
|
Evacuates instances from a Ganeti node. |
Method |
|
Exports an instance. |
Method |
|
Does a failover of an instance. |
Method |
|
Gets the cluster tags. |
Method |
|
Gets the list of optional features supported by RAPI server. |
Method |
|
Gets information about a filter rule. |
Method |
|
Gets all filter rules in the cluster. |
Method |
|
Gets information about a node group. |
Method |
|
Gets all node groups in the cluster. |
Method |
|
Gets tags for a node group. |
Method |
|
Gets info about the cluster. |
Method |
|
Gets information about an instance. |
Method |
|
Request information for connecting to instance's console. |
Method |
|
Gets information about an instance. |
Method |
|
Gets information about instances on the cluster. |
Method |
|
Gets tags for an instance. |
Method |
|
Gets all jobs for the cluster. |
Method |
|
Gets the status of a job. |
Method |
|
Gets information about a network. |
Method |
|
Gets all networks in the cluster. |
Method |
|
Gets tags for a network. |
Method |
|
Gets information about a node. |
Method |
|
Gets the current role for a node. |
Method |
|
Gets all nodes in the cluster. |
Method |
|
Gets the storage units for a node. |
Method |
|
Gets the tags for a node. |
Method |
|
Gets the Operating Systems running in the Ganeti cluster. |
Method |
|
Gets the Remote API version running on the cluster. |
Method |
|
Grows a disk of an instance. |
Method |
|
Generates an instance allocation as used by multiallocate. |
Method |
|
Tries to allocate multiple instances. |
Method |
|
Migrates an instance. |
Method |
|
Migrates all primary instances from a node. |
Method |
|
Modifies cluster parameters. |
Method |
|
Modifies a node group. |
Method |
|
Modifies an instance. |
Method |
|
Modifies a network. |
Method |
|
Modifies a node. |
Method |
|
Modifies parameters of storage units on the node. |
Method |
|
Powercycles a node. |
Method |
|
Prepares an instance for an export. |
Method |
|
Retrieves information about resources. |
Method |
|
Retrieves available fields for a resource. |
Method |
|
Reboots an instance. |
Method |
|
Recreate an instance's disks. |
Method |
|
Tells the cluster to redistribute its configuration files. |
Method |
|
Reinstalls an instance. |
Method |
|
Changes the name of a node group. |
Method |
|
Changes the name of an instance. |
Method |
|
Changes the name of a network. |
Method |
|
Repairs a storage unit on the node. |
Method |
|
Replaces a filter rule, or creates one if it doesn't already exist |
Method |
|
Replaces disks on an instance. |
Method |
|
Sets the role for a node. |
Method |
|
Shuts down an instance. |
Method |
|
Starts up an instance. |
Method |
|
Waits for job changes. |
Method |
|
Polls cluster for job status until completion. |
Constant | USER |
Undocumented |
Static Method | _ |
Encode query values for RAPI URL. |
Static Method | _ |
Updates the base with params from kwargs. |
Method | _ |
Creates a cURL object. |
Method | _ |
Sends an HTTP request. |
Class Variable | _json |
Undocumented |
Instance Variable | _base |
Undocumented |
Instance Variable | _curl |
Undocumented |
Instance Variable | _curl |
Undocumented |
Instance Variable | _logger |
Undocumented |
Instance Variable | _password |
Undocumented |
Instance Variable | _username |
Undocumented |
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 |
logger | Logging object |
curl | Function to configure pycurl.Curl object |
curl | Undocumented |
Activates an instance's disks.
Parameters | |
instance:string | Instance name |
ignore | Whether to ignore recorded size |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Adds tags to the cluster.
Parameters | |
tags:list of str | tags to add to the cluster |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Adds a filter rule
Parameters | |
priority | Undocumented |
predicates | Undocumented |
action | Undocumented |
reason | the reason trail for executing this operation, or None |
Returns | |
string | filter UUID of the added filter |
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 | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Adds tags to an instance.
Parameters | |
instance:str | instance to add tags to |
tags:list of str | tags to add to the instance |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Adds tags to a network.
Parameters | |
network:str | network to add tags to |
tags:list of string | tags to add to the network |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Adds tags to a node.
Parameters | |
node:str | node to add tags to |
tags:list of str | tags to add to the node |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Assigns nodes to a group.
Parameters | |
group:string | Node group name |
nodes:list of strings | List of nodes to assign to the group |
force | Undocumented |
dry | Undocumented |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Cancels a job.
Parameters | |
job | id of the job to delete |
dry | whether to perform a dry run |
Returns | |
tuple | tuple containing the result, and a message (bool, string) |
Connects a Network to a NodeGroup with the given netparams
Creates a new node group.
Parameters | |
name:str | the name of node group to create |
alloc | the desired allocation policy for the group, if any |
dry | whether to peform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
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 | 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 |
reason:string | the reason for executing this operation |
**kwargs | Undocumented |
dry | whether to perform a dry run |
Returns | |
string | job id |
Creates a new network.
Parameters | |
network | the name of network to create |
network | Undocumented |
gateway | Undocumented |
network6 | Undocumented |
gateway6 | Undocumented |
mac | Undocumented |
add | Undocumented |
tags | Undocumented |
dry | whether to peform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Deactivates an instance's disks.
Parameters | |
instance:string | Instance name |
reason:string | the reason for executing this operation |
force | Undocumented |
Returns | |
string | job id |
Deletes tags from the cluster.
Parameters | |
tags:list of str | tags to delete |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Deletes a node group.
Parameters | |
group:str | the node group to delete |
dry | whether to peform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Deletes tags from a node group.
Parameters | |
group:str | group to delete tags from |
tags:list of string | tags to delete |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Deletes an instance.
Parameters | |
instance:str | the instance to delete |
dry | Undocumented |
reason:string | the reason for executing this operation |
**kwargs | Undocumented |
Returns | |
string | job id |
Deletes tags from an instance.
Parameters | |
instance:str | instance to delete tags from |
tags:list of str | tags to delete |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Deletes a network.
Parameters | |
network:str | the network to delete |
dry | whether to peform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Deletes tags from a network.
Parameters | |
network:str | network to delete tags from |
tags:list of string | tags to delete |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Delete tags from a node.
Parameters | |
node:str | node to remove tags from |
tags:list of str | tags to remove from the node |
dry | whether to perform a dry run |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Evacuates instances from a Ganeti node.
Parameters | |
node:str | node to evacuate |
iallocator:str or None | instance allocator to use |
remote | node to evaucate to |
dry | whether to perform a dry run |
early | whether to enable parallelization |
mode:string | Node evacuation mode |
accept | 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 |
Exports an instance.
Parameters | |
instance:string | Instance name |
mode:string | Export mode |
destination | Undocumented |
shutdown | Undocumented |
remove | Undocumented |
x509 | Undocumented |
destination | Undocumented |
compress | Undocumented |
reason:string | the reason for executing this operation |
Returns | |
string | Job ID |
Does a failover of an instance.
Parameters | |
instance:string | Instance name |
iallocator:string | Iallocator for deciding the target node for shared-storage instances |
ignore | Whether to ignore disk consistency |
target | Target node for shared-storage instances |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Gets the cluster tags.
Parameters | |
reason:string | the reason for executing this operation |
Returns | |
list of str | cluster tags |
Gets information about a filter rule.
Parameters | |
filter | UUID of the filter whose info to return |
Returns | |
dict | info about the filter |
Gets all filter rules 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 filter rules in the cluster, else a list of UUIDs of those filters |
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 |
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 |
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 |
Gets info about the cluster.
Parameters | |
reason:string | the reason for executing this operation |
Returns | |
dict | information about the cluster |
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 |
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 |
Gets information about an instance.
Parameters | |
instance:string | Instance name |
static | Undocumented |
reason:string | the reason for executing this operation |
Returns | |
string | Job ID |
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 |
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 |
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. |
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 |
Gets all networks in the cluster.
Parameters | |
bulk:bool | whether to return all information about the networks |
reason | Undocumented |
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 |
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 |
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 |
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 |
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 |
Gets the storage units for a node.
Parameters | |
node:str | the node whose storage units to return |
storage | storage type whose units to return |
output | storage type fields to return |
reason:string | the reason for executing this operation |
Returns | |
string | job id where results can be retrieved |
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 |
Gets the Operating Systems running in the Ganeti cluster.
Parameters | |
reason:string | the reason for executing this operation |
Returns | |
list of str | operating systems |
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 | Wait for disk to synchronize |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
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 | 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 |
**kwargs | Undocumented |
Returns | |
A dict with the generated entry |
Tries to allocate multiple instances.
More details for parameters can be found in the RAPI documentation.
Parameters | |
instances | A list of InstanceAllocation results |
reason | Undocumented |
**kwargs | Undocumented |
Migrates an instance.
Parameters | |
instance:string | Instance name |
mode:string | Migration mode |
cleanup:bool | Whether to clean up a previously failed migration |
target | Target Node for externally mirrored instances |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
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 | whether to perform a dry run |
iallocator:string | instance allocator to use |
target | Target node for shared-storage instances |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Modifies cluster parameters.
More details for parameters can be found in the RAPI documentation.
Parameters | |
reason:string | the reason for executing this operation |
**kwargs | Undocumented |
Returns | |
string | job id |
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 |
**kwargs | Undocumented |
Returns | |
string | job id |
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 |
**kwargs | Undocumented |
Returns | |
string | job id |
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 |
**kwargs | Undocumented |
Returns | |
string | job id |
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 |
**kwargs | Undocumented |
Returns | |
string | job id |
Modifies parameters of storage units on the node.
Parameters | |
node:str | node whose storage units to modify |
storage | 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 |
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 |
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 |
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 |
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 |
Reboots an instance.
Parameters | |
instance:str | instance to reboot |
reboot | one of: hard, soft, full |
ignore | if True, ignores errors for the secondary node while re-assembling disks (in hard-reboot mode only) |
dry | whether to perform a dry run |
reason:string | the reason for the reboot |
**kwargs | Undocumented |
Returns | |
string | job id |
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 |
iallocator:str or None | instance allocator plugin to use |
Returns | |
string | job id |
Tells the cluster to redistribute its configuration files.
Parameters | |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
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 | Whether to start the instance automatically |
osparams | Undocumented |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Changes the name of a node group.
Parameters | |
group:string | Node group name |
new | New node group name |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Changes the name of an instance.
Parameters | |
instance:string | Instance name |
new | New instance name |
ip | Whether to ensure instance's IP address is inactive |
name | Whether to ensure instance's name is resolvable |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Changes the name of a network.
Parameters | |
network:string | Network name |
new | New network name |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Repairs a storage unit on the node.
Parameters | |
node:str | node whose storage units to repair |
storage | 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 |
Replaces a filter rule, or creates one if it doesn't already exist
Parameters | |
uuid | Undocumented |
priority | Undocumented |
predicates | Undocumented |
action | Undocumented |
reason | the reason trail for executing this operation, or None |
Returns | |
string | filter UUID of the replaced/added filter |
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 | 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 | whether to release locks as soon as possible |
Returns | |
string | job id |
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 | Whether node(s) should be promoted to master candidate if necessary |
reason:string | the reason for executing this operation |
Returns | |
string | job id |
Shuts down an instance.
Parameters | |
instance:str | the instance to shut down |
dry | whether to perform a dry run |
no | if true, will not record the state change |
reason:string | the reason for the shutdown |
**kwargs | Undocumented |
Returns | |
string | job id |
Starts up an instance.
Parameters | |
instance:str | the instance to start up |
dry | whether to perform a dry run |
no | if true, will not record the state change |
reason:string | the reason for the startup |
Returns | |
string | job id |
Waits for job changes.
Parameters | |
job | Job ID for which to wait |
fields | Undocumented |
prev | Undocumented |
prev | Undocumented |
Returns | |
dict | None if no changes have been detected and a dict with two keys, job_info and log_entries otherwise. |
Polls cluster for job status until completion.
Completion is defined as any of the following states listed in JOB_STATUS_FINALIZED
.
Parameters | |
job | 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 |
Unknown Field: deprecated | |
It is recommended to use WaitForJobChange wherever possible; WaitForJobChange returns immediately after a job changed and does not use polling |
Encode query values for RAPI URL.
Parameters | |
query:list of two-tuples | Query arguments |
Returns | |
list | Query list with encoded values |
Updates the base with params from kwargs.
Parameters | |
base | The base dict, filled with required fields |
**kwargs | Undocumented |
Note | |
This is an inplace update of base |
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 urlencode |
content:str or None | HTTP body content |
Returns | |
str | JSON-Decoded response |
Raises | |
CertificateError | If an invalid SSL certificate is found |
GanetiApiError | If an invalid response is returned |