- List of arguments as tuples
- Name as string
- - Wrapper code ("%s" is replaced with argument name, see L{OBJECT_TO_DICT})
+ - Argument kind used for encoding/decoding
- Description for docstring (can be C{None})
- Return value wrapper (e.g. for deserializing into L{objects}-based objects)
SINGLE = "single-node"
MULTI = "multi-node"
-OBJECT_TO_DICT = "%s.ToDict()"
-OBJECT_LIST_TO_DICT = "map(lambda d: d.ToDict(), %s)"
-INST_TO_DICT = "self._InstDict(%s)"
-
-NODE_TO_DISK_DICT = \
- ("dict((name, %s) for name, disks in %%s.items())" %
- (OBJECT_LIST_TO_DICT % "disks"))
+# Constants for encoding/decoding
+(ED_OBJECT_DICT,
+ ED_OBJECT_DICT_LIST,
+ ED_INST_DICT,
+ ED_INST_DICT_HVP_BEP,
+ ED_NODE_TO_DISK_DICT,
+ ED_INST_DICT_OSP,
+ ED_IMPEXP_IO,
+ ED_FILE_DETAILS,
+ ED_FINALIZE_EXPORT_DISKS,
+ ED_COMPRESS,
+ ED_BLOCKDEV_RENAME) = range(1, 12)
_FILE_STORAGE_CALLS = [
("file_storage_dir_create", SINGLE, TMO_FAST, [
("hypervisor_list", None, "Hypervisors to query for instances"),
], None, "Returns the list of running instances on the given nodes"),
("instance_reboot", SINGLE, TMO_NORMAL, [
- ("inst", INST_TO_DICT, "Instance object"),
+ ("inst", ED_INST_DICT, "Instance object"),
("reboot_type", None, None),
("shutdown_timeout", None, None),
], None, "Returns the list of running instances on the given nodes"),
("instance_shutdown", SINGLE, TMO_NORMAL, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
("timeout", None, None),
], None, "Stops an instance"),
("instance_run_rename", SINGLE, TMO_SLOW, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
("old_name", None, None),
("debug", None, None),
], None, "Run the OS rename script for an instance"),
("instance_migratable", SINGLE, TMO_NORMAL, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
], None, "Checks whether the given instance can be migrated"),
("migration_info", SINGLE, TMO_NORMAL, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
], None,
"Gather the information necessary to prepare an instance migration"),
("accept_instance", SINGLE, TMO_NORMAL, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
("info", None, "Result for the call_migration_info call"),
("target", None, "Target hostname (usually an IP address)"),
], None, "Prepare a node to accept an instance"),
("instance_finalize_migration_dst", SINGLE, TMO_NORMAL, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
("info", None, "Result for the call_migration_info call"),
("success", None, "Whether the migration was a success or failure"),
], None, "Finalize any target-node migration specific operation"),
("instance_migrate", SINGLE, TMO_SLOW, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
("target", None, "Target node name"),
("live", None, "Whether the migration should be done live or not"),
], None, "Migrate an instance"),
("instance_finalize_migration_src", SINGLE, TMO_SLOW, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
("success", None, "Whether the migration succeeded or not"),
("live", None, "Whether the user requested a live migration or not"),
], None, "Finalize the instance migration on the source node"),
("instance_get_migration_status", SINGLE, TMO_SLOW, [
- ("instance", INST_TO_DICT, "Instance object"),
+ ("instance", ED_INST_DICT, "Instance object"),
], "self._MigrationStatusPostProc", "Report migration status"),
("instance_start", SINGLE, TMO_NORMAL, [
- ("instance_hvp_bep", "self._InstDictHvpBep(%s)", None),
+ ("instance_hvp_bep", ED_INST_DICT_HVP_BEP, None),
("startup_paused", None, None),
], None, "Starts an instance"),
("instance_os_add", SINGLE, TMO_1DAY, [
- ("instance_osp", "self._InstDictOsp(%s)", None),
+ ("instance_osp", ED_INST_DICT_OSP, None),
("reinstall", None, None),
("debug", None, None),
], None, "Starts an instance"),
_IMPEXP_CALLS = [
("import_start", SINGLE, TMO_NORMAL, [
- ("opts", OBJECT_TO_DICT, None),
- ("instance", INST_TO_DICT, None),
+ ("opts", ED_OBJECT_DICT, None),
+ ("instance", ED_INST_DICT, None),
("component", None, None),
- ("dest", None, None),
- ("dest_args", "self._EncodeImportExportIO(dest, %s)", None),
+ ("dest", ED_IMPEXP_IO, "Import destination"),
], None, "Starts an import daemon"),
("export_start", SINGLE, TMO_NORMAL, [
- ("opts", OBJECT_TO_DICT, None),
+ ("opts", ED_OBJECT_DICT, None),
("host", None, None),
("port", None, None),
- ("instance", INST_TO_DICT, None),
+ ("instance", ED_INST_DICT, None),
("component", None, None),
- ("source", None, None),
- ("source_args", "self._EncodeImportExportIO(source, %s)", None),
+ ("source", ED_IMPEXP_IO, "Export source"),
], None, "Starts an export daemon"),
("impexp_status", SINGLE, TMO_FAST, [
("names", None, "Import/export names"),
("path", None, None),
], None, "Queries the export information in a given path"),
("finalize_export", SINGLE, TMO_NORMAL, [
- ("instance", INST_TO_DICT, None),
- ("snap_disks", "self._PrepareFinalizeExportDisks(%s)", None),
+ ("instance", ED_INST_DICT, None),
+ ("snap_disks", ED_FINALIZE_EXPORT_DISKS, None),
], None, "Request the completion of an export operation"),
("export_list", MULTI, TMO_FAST, [], None, "Gets the stored exports list"),
("export_remove", SINGLE, TMO_FAST, [
("devices", None, None),
], None, "Gets the sizes of requested block devices present on a node"),
("blockdev_create", SINGLE, TMO_NORMAL, [
- ("bdev", OBJECT_TO_DICT, None),
+ ("bdev", ED_OBJECT_DICT, None),
("size", None, None),
("owner", None, None),
("on_primary", None, None),
("info", None, None),
], None, "Request creation of a given block device"),
("blockdev_wipe", SINGLE, TMO_SLOW, [
- ("bdev", OBJECT_TO_DICT, None),
+ ("bdev", ED_OBJECT_DICT, None),
("offset", None, None),
("size", None, None),
], None,
"Request wipe at given offset with given size of a block device"),
("blockdev_remove", SINGLE, TMO_NORMAL, [
- ("bdev", OBJECT_TO_DICT, None),
+ ("bdev", ED_OBJECT_DICT, None),
], None, "Request removal of a given block device"),
("blockdev_pause_resume_sync", SINGLE, TMO_NORMAL, [
- ("disks", OBJECT_LIST_TO_DICT, None),
+ ("disks", ED_OBJECT_DICT_LIST, None),
("pause", None, None),
], None, "Request a pause/resume of given block device"),
("blockdev_assemble", SINGLE, TMO_NORMAL, [
- ("disk", OBJECT_TO_DICT, None),
+ ("disk", ED_OBJECT_DICT, None),
("owner", None, None),
("on_primary", None, None),
("idx", None, None),
], None, "Request assembling of a given block device"),
("blockdev_shutdown", SINGLE, TMO_NORMAL, [
- ("disk", OBJECT_TO_DICT, None),
+ ("disk", ED_OBJECT_DICT, None),
], None, "Request shutdown of a given block device"),
("blockdev_addchildren", SINGLE, TMO_NORMAL, [
- ("bdev", OBJECT_TO_DICT, None),
- ("ndevs", OBJECT_LIST_TO_DICT, None),
+ ("bdev", ED_OBJECT_DICT, None),
+ ("ndevs", ED_OBJECT_DICT_LIST, None),
], None, "Request adding a list of children to a (mirroring) device"),
("blockdev_removechildren", SINGLE, TMO_NORMAL, [
- ("bdev", OBJECT_TO_DICT, None),
- ("ndevs", OBJECT_LIST_TO_DICT, None),
+ ("bdev", ED_OBJECT_DICT, None),
+ ("ndevs", ED_OBJECT_DICT_LIST, None),
], None, "Request removing a list of children from a (mirroring) device"),
("blockdev_close", SINGLE, TMO_NORMAL, [
("instance_name", None, None),
- ("disks", OBJECT_LIST_TO_DICT, None),
+ ("disks", ED_OBJECT_DICT_LIST, None),
], None, "Closes the given block devices"),
("blockdev_getsize", SINGLE, TMO_NORMAL, [
- ("disks", OBJECT_LIST_TO_DICT, None),
+ ("disks", ED_OBJECT_DICT_LIST, None),
], None, "Returns the size of the given disks"),
("drbd_disconnect_net", MULTI, TMO_NORMAL, [
("nodes_ip", None, None),
- ("disks", OBJECT_LIST_TO_DICT, None),
+ ("disks", ED_OBJECT_DICT_LIST, None),
], None, "Disconnects the network of the given drbd devices"),
("drbd_attach_net", MULTI, TMO_NORMAL, [
("nodes_ip", None, None),
- ("disks", OBJECT_LIST_TO_DICT, None),
+ ("disks", ED_OBJECT_DICT_LIST, None),
("instance_name", None, None),
("multimaster", None, None),
], None, "Connects the given DRBD devices"),
("drbd_wait_sync", MULTI, TMO_SLOW, [
("nodes_ip", None, None),
- ("disks", OBJECT_LIST_TO_DICT, None),
+ ("disks", ED_OBJECT_DICT_LIST, None),
], None, "Waits for the synchronization of drbd devices is complete"),
("blockdev_grow", SINGLE, TMO_NORMAL, [
- ("cf_bdev", OBJECT_TO_DICT, None),
+ ("cf_bdev", ED_OBJECT_DICT, None),
("amount", None, None),
("dryrun", None, None),
], None, "Request a snapshot of the given block device"),
("blockdev_export", SINGLE, TMO_1DAY, [
- ("cf_bdev", OBJECT_TO_DICT, None),
+ ("cf_bdev", ED_OBJECT_DICT, None),
("dest_node", None, None),
("dest_path", None, None),
("cluster_name", None, None),
], None, "Export a given disk to another node"),
("blockdev_snapshot", SINGLE, TMO_NORMAL, [
- ("cf_bdev", OBJECT_TO_DICT, None),
+ ("cf_bdev", ED_OBJECT_DICT, None),
], None, "Export a given disk to another node"),
("blockdev_rename", SINGLE, TMO_NORMAL, [
- ("devlist", "[(d.ToDict(), uid) for d, uid in %s]", None),
+ ("devlist", ED_BLOCKDEV_RENAME, None),
], None, "Request rename of the given block devices"),
("blockdev_find", SINGLE, TMO_NORMAL, [
- ("disk", OBJECT_TO_DICT, None),
+ ("disk", ED_OBJECT_DICT, None),
], "self._BlockdevFindPostProc",
"Request identification of a given block device"),
("blockdev_getmirrorstatus", SINGLE, TMO_NORMAL, [
- ("disks", OBJECT_LIST_TO_DICT, None),
+ ("disks", ED_OBJECT_DICT_LIST, None),
], "self._BlockdevGetMirrorStatusPostProc",
"Request status of a (mirroring) device"),
("blockdev_getmirrorstatus_multi", MULTI, TMO_NORMAL, [
- ("node_disks", NODE_TO_DISK_DICT, None),
+ ("node_disks", ED_NODE_TO_DISK_DICT, None),
], "self._BlockdevGetMirrorStatusMultiPostProc",
"Request status of (mirroring) devices from multiple nodes"),
]
"RpcClientJobQueue": [
("jobqueue_update", MULTI, TMO_URGENT, [
("file_name", None, None),
- ("content", "self._Compress(%s)", None),
+ ("content", ED_COMPRESS, None),
], None, "Update job queue file"),
("jobqueue_purge", SINGLE, TMO_NORMAL, [], None, "Purge job queue"),
("jobqueue_rename", MULTI, TMO_URGENT, [
],
"RpcClientConfig": [
("upload_file", MULTI, TMO_NORMAL, [
- ("file_name", "self._PrepareFileUpload(%s)", None),
+ ("file_name", ED_FILE_DETAILS, None),
], None, "Upload a file"),
("write_ssconf_files", MULTI, TMO_NORMAL, [
("values", None, None),