module documentation

Remote API resource implementations.

PUT or POST?

According to RFC2616 the main difference between PUT and POST is that POST can create new resources but PUT can only create the resource the URI was pointing to on the PUT request.

In the context of this module POST on ``/2/instances`` to change an existing entity is legitimate, while PUT would not be. PUT creates a new entity (e.g. a new instance) with a name specified in the request.

Quoting from RFC2616, section 9.6:

  The fundamental difference between the POST and PUT requests is reflected in
  the different meaning of the Request-URI. The URI in a POST request
  identifies the resource that will handle the enclosed entity. That resource
  might be a data-accepting process, a gateway to some other protocol, or a
  separate entity that accepts annotations. In contrast, the URI in a PUT
  request identifies the entity enclosed with the request -- the user agent
  knows what URI is intended and the server MUST NOT attempt to apply the
  request to some other resource. If the server desires that the request be
  applied to a different URI, it MUST send a 301 (Moved Permanently) response;
  the user agent MAY then make its own decision regarding whether or not to
  redirect the request.

So when adding new methods, if they are operating on the URI entity itself, PUT should be prefered over POST.

Class R_2 /2 resource.
Class R_2_cluster_modify /2/modify resource.
Class R_2_features /2/features resource.
Class R_2_filters /2/filters resource.
Class R_2_filters_uuid /2/filters/[filter_uuid] resource.
Class R_2_groups /2/groups resource.
Class R_2_groups_name /2/groups/[group_name] resource.
Class R_2_groups_name_assign_nodes /2/groups/[group_name]/assign-nodes resource.
Class R_2_groups_name_modify /2/groups/[group_name]/modify resource.
Class R_2_groups_name_rename /2/groups/[group_name]/rename resource.
Class R_2_groups_name_tags /2/groups/[group_name]/tags resource.
Class R_2_info /2/info resource.
Class R_2_instances /2/instances resource.
Class R_2_instances_multi_alloc /2/instances-multi-alloc resource.
Class R_2_instances_name /2/instances/[instance_name] resource.
Class R_2_instances_name_activate_disks /2/instances/[instance_name]/activate-disks resource.
Class R_2_instances_name_console /2/instances/[instance_name]/console resource.
Class R_2_instances_name_deactivate_disks /2/instances/[instance_name]/deactivate-disks resource.
Class R_2_instances_name_disk_grow /2/instances/[instance_name]/disk/[disk_index]/grow resource.
Class R_2_instances_name_export /2/instances/[instance_name]/export resource.
Class R_2_instances_name_failover /2/instances/[instance_name]/failover resource.
Class R_2_instances_name_info /2/instances/[instance_name]/info resource.
Class R_2_instances_name_migrate /2/instances/[instance_name]/migrate resource.
Class R_2_instances_name_modify /2/instances/[instance_name]/modify resource.
Class R_2_instances_name_prepare_export /2/instances/[instance_name]/prepare-export resource.
Class R_2_instances_name_reboot /2/instances/[instance_name]/reboot resource.
Class R_2_instances_name_recreate_disks /2/instances/[instance_name]/recreate-disks resource.
Class R_2_instances_name_reinstall /2/instances/[instance_name]/reinstall resource.
Class R_2_instances_name_rename /2/instances/[instance_name]/rename resource.
Class R_2_instances_name_replace_disks /2/instances/[instance_name]/replace-disks resource.
Class R_2_instances_name_shutdown /2/instances/[instance_name]/shutdown resource.
Class R_2_instances_name_startup /2/instances/[instance_name]/startup resource.
Class R_2_instances_name_tags /2/instances/[instance_name]/tags resource.
Class R_2_jobs /2/jobs resource.
Class R_2_jobs_id /2/jobs/[job_id] resource.
Class R_2_jobs_id_wait /2/jobs/[job_id]/wait resource.
Class R_2_networks /2/networks resource.
Class R_2_networks_name /2/networks/[network_name] resource.
Class R_2_networks_name_connect /2/networks/[network_name]/connect resource.
Class R_2_networks_name_disconnect /2/networks/[network_name]/disconnect resource.
Class R_2_networks_name_modify /2/networks/[network_name]/modify resource.
Class R_2_networks_name_rename /2/networks/[network_name]/rename resource.
Class R_2_networks_name_tags /2/networks/[network_name]/tags resource.
Class R_2_nodes /2/nodes resource.
Class R_2_nodes_name /2/nodes/[node_name] resource.
Class R_2_nodes_name_evacuate /2/nodes/[node_name]/evacuate resource.
Class R_2_nodes_name_migrate /2/nodes/[node_name]/migrate resource.
Class R_2_nodes_name_modify /2/nodes/[node_name]/modify resource.
Class R_2_nodes_name_powercycle /2/nodes/[node_name]/powercycle resource.
Class R_2_nodes_name_role /2/nodes/[node_name]/role resource.
Class R_2_nodes_name_storage /2/nodes/[node_name]/storage resource.
Class R_2_nodes_name_storage_modify /2/nodes/[node_name]/storage/modify resource.
Class R_2_nodes_name_storage_repair /2/nodes/[node_name]/storage/repair resource.
Class R_2_nodes_name_tags /2/nodes/[node_name]/tags resource.
Class R_2_os /2/os resource.
Class R_2_query /2/query/[resource] resource.
Class R_2_query_fields /2/query/[resource]/fields resource.
Class R_2_redist_config /2/redistribute-config resource.
Class R_2_tags /2/tags resource.
Class R_root / resource.
Class R_version /version resource.
Function checkFilterParameters Checks and extracts filter rule parameters from a request body.
Constant ALL_FEATURES Undocumented
Constant FILTER_RULE_FIELDS Undocumented
Constant G_FIELDS Undocumented
Constant I_FIELDS Undocumented
Constant J_FIELDS Undocumented
Constant J_FIELDS_BULK Undocumented
Constant N_FIELDS Undocumented
Constant NET_FIELDS Undocumented
Class _R_Tags Quasiclass for tagging resources.
Function _CheckIfConnectionDropped Utility function to monitor the state of an open connection.
Function _ConvertUsbDevices Convert in place the usb_devices string to the proper format.
Function _GetQueryFields Tries to extract fields query parameter.
Function _ParseInstanceReinstallRequest Parses a request for reinstalling an instance.
Function _SplitQueryFields Splits fields as given for a query request.
Function _UpdateBeparams Updates the beparams dict of inst to support the memory field.
Constant _COMMON_FIELDS Undocumented
Constant _INST_CREATE_REQV1 Undocumented
Constant _INST_REINSTALL_REQV1 Undocumented
Constant _NODE_EVAC_RES1 Undocumented
Constant _NODE_MIGRATE_REQV1 Undocumented
Constant _NR_DRAINED Undocumented
Constant _NR_MAP Undocumented
Constant _NR_MASTER Undocumented
Constant _NR_MASTER_CANDIDATE Undocumented
Constant _NR_OFFLINE Undocumented
Constant _NR_REGULAR Undocumented
Constant _REQ_DATA_VERSION Undocumented
Constant _WFJC_TIMEOUT Undocumented
def checkFilterParameters(data):

Checks and extracts filter rule parameters from a request body.

Returns
the checked parameters: (priority, predicates, action).
FILTER_RULE_FIELDS: list[str] =

Undocumented

Value
['watermark', 'priority', 'predicates', 'action', 'reason_trail', 'uuid']
G_FIELDS =

Undocumented

Value
['alloc_policy',
 'name',
 'node_cnt',
 'node_list',
 'ipolicy',
 'custom_ipolicy',
 'diskparams',
...
I_FIELDS =

Undocumented

Value
['name',
 'admin_state',
 'os',
 'pnode',
 'snodes',
 'disk_template',
 'nic.ips',
...
J_FIELDS =

Undocumented

Value
J_FIELDS_BULK+['oplog', 'opresult']
J_FIELDS_BULK: list[str] =

Undocumented

Value
['id',
 'ops',
 'status',
 'summary',
 'opstatus',
 'received_ts',
 'start_ts',
...
N_FIELDS =

Undocumented

Value
['name',
 'offline',
 'master_candidate',
 'drained',
 'dtotal',
 'dfree',
 'sptotal',
...
NET_FIELDS =

Undocumented

Value
['name',
 'network',
 'gateway',
 'network6',
 'gateway6',
 'mac_prefix',
 'free_count',
...
def _CheckIfConnectionDropped(sock):

Utility function to monitor the state of an open connection.

Parameters
sockConnection's open socket
Returns
True if the connection was remotely closed, otherwise False
def _ConvertUsbDevices(data):

Convert in place the usb_devices string to the proper format.

In Ganeti 2.8.4 the separator for the usb_devices hvparam was changed from comma to space because commas cannot be accepted on the command line (they already act as the separator between different hvparams). RAPI should be able to accept commas for backwards compatibility, but we want it to also accept the new space separator. Therefore, we convert spaces into commas here and keep the old parsing logic elsewhere.

def _GetQueryFields(args):

Tries to extract fields query parameter.

Parameters
args:dictionaryUndocumented
Returns
list of stringUndocumented
Raises
http.HttpBadRequestWhen parameter can't be found
def _ParseInstanceReinstallRequest(name, data):

Parses a request for reinstalling an instance.

def _SplitQueryFields(fields):

Splits fields as given for a query request.

Parameters
fields:stringUndocumented
Returns
list of stringUndocumented
def _UpdateBeparams(inst):

Updates the beparams dict of inst to support the memory field.

Parameters
instInst dict
Returns
Updated inst dict
_COMMON_FIELDS: list[str] =

Undocumented

Value
['ctime', 'mtime', 'uuid', 'serial_no', 'tags']
_INST_CREATE_REQV1: str =

Undocumented

Value
'instance-create-reqv1'
_INST_REINSTALL_REQV1: str =

Undocumented

Value
'instance-reinstall-reqv1'
_NODE_EVAC_RES1: str =

Undocumented

Value
'node-evac-res1'
_NODE_MIGRATE_REQV1: str =

Undocumented

Value
'node-migrate-reqv1'
_NR_DRAINED: str =

Undocumented

Value
'drained'
_NR_MASTER: str =

Undocumented

Value
'master'
_NR_MASTER_CANDIDATE: str =

Undocumented

Value
'master-candidate'
_NR_OFFLINE: str =

Undocumented

Value
'offline'
_NR_REGULAR: str =

Undocumented

Value
'regular'
_REQ_DATA_VERSION: str =

Undocumented

Value
'__version__'
_WFJC_TIMEOUT: int =

Undocumented

Value
10