Package ganeti :: Package rapi :: Module rlib2
[hide private]
[frames] | no frames]

Module rlib2

source code

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.

Classes [hide private]
  R_version
/version resource.
  R_2_info
/2/info resource.
  R_2_features
/2/features resource.
  R_2_os
/2/os resource.
  R_2_redist_config
/2/redistribute-config resource.
  R_2_cluster_modify
/2/modify resource.
  R_2_jobs
/2/jobs resource.
  R_2_jobs_id
/2/jobs/[job_id] resource.
  R_2_jobs_id_wait
/2/jobs/[job_id]/wait resource.
  R_2_nodes
/2/nodes resource.
  R_2_nodes_name
/2/nodes/[node_name] resource.
  R_2_nodes_name_role
/2/nodes/[node_name]/role resource.
  R_2_nodes_name_evacuate
/2/nodes/[node_name]/evacuate resource.
  R_2_nodes_name_migrate
/2/nodes/[node_name]/migrate resource.
  R_2_nodes_name_storage
/2/nodes/[node_name]/storage resource.
  R_2_nodes_name_storage_modify
/2/nodes/[node_name]/storage/modify resource.
  R_2_nodes_name_storage_repair
/2/nodes/[node_name]/storage/repair resource.
  R_2_groups
/2/groups resource.
  R_2_groups_name
/2/groups/[group_name] resource.
  R_2_groups_name_modify
/2/groups/[group_name]/modify resource.
  R_2_groups_name_rename
/2/groups/[group_name]/rename resource.
  R_2_groups_name_assign_nodes
/2/groups/[group_name]/assign-nodes resource.
  R_2_instances
/2/instances resource.
  R_2_instances_name
/2/instances/[instance_name] resource.
  R_2_instances_name_info
/2/instances/[instance_name]/info resource.
  R_2_instances_name_reboot
/2/instances/[instance_name]/reboot resource.
  R_2_instances_name_startup
/2/instances/[instance_name]/startup resource.
  R_2_instances_name_shutdown
/2/instances/[instance_name]/shutdown resource.
  R_2_instances_name_reinstall
/2/instances/[instance_name]/reinstall resource.
  R_2_instances_name_replace_disks
/2/instances/[instance_name]/replace-disks resource.
  R_2_instances_name_activate_disks
/2/instances/[instance_name]/activate-disks resource.
  R_2_instances_name_deactivate_disks
/2/instances/[instance_name]/deactivate-disks resource.
  R_2_instances_name_prepare_export
/2/instances/[instance_name]/prepare-export resource.
  R_2_instances_name_export
/2/instances/[instance_name]/export resource.
  R_2_instances_name_migrate
/2/instances/[instance_name]/migrate resource.
  R_2_instances_name_failover
/2/instances/[instance_name]/failover resource.
  R_2_instances_name_rename
/2/instances/[instance_name]/rename resource.
  R_2_instances_name_modify
/2/instances/[instance_name]/modify resource.
  R_2_instances_name_disk_grow
/2/instances/[instance_name]/disk/[disk_index]/grow resource.
  R_2_instances_name_console
/2/instances/[instance_name]/console resource.
  R_2_query
/2/query/[resource] resource.
  R_2_query_fields
/2/query/[resource]/fields resource.
  _R_Tags
Quasiclass for tagging resources
  R_2_instances_name_tags
/2/instances/[instance_name]/tags resource.
  R_2_nodes_name_tags
/2/nodes/[node_name]/tags resource.
  R_2_groups_name_tags
/2/groups/[group_name]/tags resource.
  R_2_tags
/2/tags resource.
Functions [hide private]
opcodes.OpGroupAdd
_ParseCreateGroupRequest(data, dry_run)
Parses a request for creating a node group.
source code
opcodes.OpGroupSetParams
_ParseModifyGroupRequest(name, data)
Parses a request for modifying a node group.
source code
opcodes.OpGroupRename
_ParseRenameGroupRequest(name, data, dry_run)
Parses a request for renaming a node group.
source code
opcodes.OpInstanceCreate
_ParseInstanceCreateRequestVersion1(data, dry_run)
Parses an instance creation request version 1.
source code
opcodes.OpInstanceShutdown
_ParseShutdownInstanceRequest(name, data, dry_run, no_remember)
Parses a request for an instance shutdown.
source code
 
_ParseInstanceReinstallRequest(name, data)
Parses a request for reinstalling an instance.
source code
opcodes.OpInstanceReplaceDisks
_ParseInstanceReplaceDisksRequest(name, data)
Parses a request for an instance export.
source code
opcodes.OpBackupExport
_ParseExportInstanceRequest(name, data)
Parses a request for an instance export.
source code
opcodes.OpInstanceMigrate
_ParseMigrateInstanceRequest(name, data)
Parses a request for an instance migration.
source code
opcodes.OpInstanceRename
_ParseRenameInstanceRequest(name, data)
Parses a request for renaming an instance.
source code
opcodes.OpInstanceSetParams
_ParseModifyInstanceRequest(name, data)
Parses a request for modifying an instance.
source code
 
_GetQueryFields(args) source code
 
_SplitQueryFields(fields) source code
Variables [hide private]
  _COMMON_FIELDS = ["ctime", "mtime", "uuid", "serial_no", "tags"]
  I_FIELDS = ["name", "admin_state", "os", "pnode", "snodes", "d...
  N_FIELDS = ["name", "offline", "master_candidate", "drained", ...
  G_FIELDS = ["alloc_policy", "name", "node_cnt", "node_list",]+...
  J_FIELDS_BULK = ["id", "ops", "status", "summary", "opstatus",...
  J_FIELDS = J_FIELDS_BULK+ ["oplog", "opresult",]
  _NR_DRAINED = "drained"
  _NR_MASTER_CANDIATE = "master-candidate"
  _NR_MASTER = "master"
  _NR_OFFLINE = "offline"
  _NR_REGULAR = "regular"
  _NR_MAP = {constants.NR_MASTER: _NR_MASTER, constants.NR_MCAND...
  _REQ_DATA_VERSION = "__version__"
  _INST_CREATE_REQV1 = "instance-create-reqv1"
  _INST_REINSTALL_REQV1 = "instance-reinstall-reqv1"
  _NODE_MIGRATE_REQV1 = "node-migrate-reqv1"
  _NODE_EVAC_RES1 = "node-evac-res1"
  ALL_FEATURES = frozenset([_INST_CREATE_REQV1, _INST_REINSTALL_...
  _WFJC_TIMEOUT = 10

Imports: opcodes, http, constants, cli, rapi, ht, compat, baserlib


Function Details [hide private]

_ParseCreateGroupRequest(data, dry_run)

source code 

Parses a request for creating a node group.

Returns: opcodes.OpGroupAdd
Group creation opcode

_ParseModifyGroupRequest(name, data)

source code 

Parses a request for modifying a node group.

Returns: opcodes.OpGroupSetParams
Group modify opcode

_ParseRenameGroupRequest(name, data, dry_run)

source code 

Parses a request for renaming a node group.

Parameters:
  • name (string) - name of the node group to rename
  • data (dict) - the body received by the rename request
  • dry_run (bool) - whether to perform a dry run
Returns: opcodes.OpGroupRename
Node group rename opcode

_ParseInstanceCreateRequestVersion1(data, dry_run)

source code 

Parses an instance creation request version 1.

Returns: opcodes.OpInstanceCreate
Instance creation opcode

_ParseShutdownInstanceRequest(name, data, dry_run, no_remember)

source code 

Parses a request for an instance shutdown.

Returns: opcodes.OpInstanceShutdown
Instance shutdown opcode

_ParseInstanceReplaceDisksRequest(name, data)

source code 

Parses a request for an instance export.

Returns: opcodes.OpInstanceReplaceDisks
Instance export opcode

_ParseExportInstanceRequest(name, data)

source code 

Parses a request for an instance export.

Returns: opcodes.OpBackupExport
Instance export opcode

_ParseMigrateInstanceRequest(name, data)

source code 

Parses a request for an instance migration.

Returns: opcodes.OpInstanceMigrate
Instance migration opcode

_ParseRenameInstanceRequest(name, data)

source code 

Parses a request for renaming an instance.

Returns: opcodes.OpInstanceRename
Instance rename opcode

_ParseModifyInstanceRequest(name, data)

source code 

Parses a request for modifying an instance.

Returns: opcodes.OpInstanceSetParams
Instance modify opcode

Variables Details [hide private]

I_FIELDS

Value:
["name", "admin_state", "os", "pnode", "snodes", "disk_template", "nic\
.ips", "nic.macs", "nic.modes", "nic.links", "nic.bridges", "network_p\
ort", "disk.sizes", "disk_usage", "beparams", "hvparams", "oper_state"\
, "oper_ram", "oper_vcpus", "status", "custom_hvparams", "custom_bepar\
ams", "custom_nicparams",]+ _COMMON_FIELDS

N_FIELDS

Value:
["name", "offline", "master_candidate", "drained", "dtotal", "dfree", \
"mtotal", "mnode", "mfree", "pinst_cnt", "sinst_cnt", "ctotal", "cnode\
s", "csockets", "pip", "sip", "role", "pinst_list", "sinst_list", "mas\
ter_capable", "vm_capable", "group.uuid",]+ _COMMON_FIELDS

G_FIELDS

Value:
["alloc_policy", "name", "node_cnt", "node_list",]+ _COMMON_FIELDS

J_FIELDS_BULK

Value:
["id", "ops", "status", "summary", "opstatus", "received_ts", "start_t\
s", "end_ts",]

_NR_MAP

Value:
{constants.NR_MASTER: _NR_MASTER, constants.NR_MCANDIDATE: _NR_MASTER_\
CANDIATE, constants.NR_DRAINED: _NR_DRAINED, constants.NR_OFFLINE: _NR\
_OFFLINE, constants.NR_REGULAR: _NR_REGULAR,}

ALL_FEATURES

Value:
frozenset([_INST_CREATE_REQV1, _INST_REINSTALL_REQV1, _NODE_MIGRATE_RE\
QV1, _NODE_EVAC_RES1,])