4 # Copyright (C) 2006, 2007 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """Inter-node RPC library.
26 # pylint: disable-msg=C0103,R0201,R0904
27 # C0103: Invalid name, since call_ are not valid
28 # R0201: Method could be a function, we keep all rpcs instance methods
29 # as not to change them back and forth between static/instance methods
30 # if they need to start using instance attributes
31 # R0904: Too many public methods
39 from ganeti import utils
40 from ganeti import objects
41 from ganeti import http
42 from ganeti import serializer
43 from ganeti import constants
44 from ganeti import errors
46 import ganeti.http.client
49 # Module level variable
54 """Initializes the module-global HTTP client manager.
56 Must be called before using any RPC function.
61 assert not _http_manager, "RPC module initialized more than once"
63 _http_manager = http.client.HttpClientManager()
67 """Stops the module-global HTTP client manager.
69 Must be called before quitting the program.
75 _http_manager.Shutdown()
79 class RpcResult(object):
82 This class holds an RPC result. It is needed since in multi-node
83 calls we can't raise an exception just because one one out of many
84 failed, and therefore we use this class to encapsulate the result.
86 @ivar data: the data payload, for successfull results, or None
88 @ivar failed: whether the operation failed at RPC level (not
89 application level on the remote node)
90 @ivar call: the name of the RPC call
91 @ivar node: the name of the node to which we made the call
92 @ivar offline: whether the operation failed because the node was
93 offline, as opposed to actual failure; offline=True will always
94 imply failed=True, in order to allow simpler checking if
95 the user doesn't care about the exact failure mode
98 def __init__(self, data=None, failed=False, offline=False,
99 call=None, node=None):
101 self.offline = offline
106 self.error = "Node is marked offline"
107 self.data = self.payload = None
110 self.data = self.payload = None
114 if isinstance(data, (tuple, list)) and len(data) == 2:
115 self.payload = data[1]
120 """If the result has failed, raise an OpExecError.
122 This is used so that LU code doesn't have to check for each
123 result, but instead can call this function.
127 raise errors.OpExecError("Call '%s' to node '%s' has failed: %s" %
128 (self.call, self.node, self.error))
130 def RemoteFailMsg(self):
131 """Check if the remote procedure failed.
133 This is valid only for RPC calls which return result of the form
134 (status, data | error_msg).
136 @return: empty string for succcess, otherwise an error message
140 """Helper to ensure we return a 'True' value for error."""
144 return "No error information"
147 return _EnsureErr(self.error)
148 if not isinstance(self.data, (tuple, list)):
149 return "Invalid result type (%s)" % type(self.data)
150 if len(self.data) != 2:
151 return "Invalid result length (%d), expected 2" % len(self.data)
153 return _EnsureErr(self.data[1])
160 This class, given a (remote) method name, a list of parameters and a
161 list of nodes, will contact (in parallel) all nodes, and return a
162 dict of results (key: node name, value: result).
164 One current bug is that generic failure is still signalled by
165 'False' result, which is not good. This overloading of values can
169 def __init__(self, procedure, body, port):
170 self.procedure = procedure
176 http.HttpSslParams(ssl_key_path=constants.SSL_CERT_FILE,
177 ssl_cert_path=constants.SSL_CERT_FILE)
179 def ConnectList(self, node_list, address_list=None):
180 """Add a list of nodes to the target nodes.
182 @type node_list: list
183 @param node_list: the list of node names to connect
184 @type address_list: list or None
185 @keyword address_list: either None or a list with node addresses,
186 which must have the same length as the node list
189 if address_list is None:
190 address_list = [None for _ in node_list]
192 assert len(node_list) == len(address_list), \
193 "Name and address lists should have the same length"
194 for node, address in zip(node_list, address_list):
195 self.ConnectNode(node, address)
197 def ConnectNode(self, name, address=None):
198 """Add a node to the target list.
201 @param name: the node name
203 @keyword address: the node address, if known
210 http.client.HttpClientRequest(address, self.port, http.HTTP_PUT,
211 "/%s" % self.procedure,
213 ssl_params=self._ssl_params,
214 ssl_verify_peer=True)
216 def GetResults(self):
217 """Call nodes and return results.
220 @returns: List of RPC results
223 assert _http_manager, "RPC module not intialized"
225 _http_manager.ExecRequests(self.nc.values())
229 for name, req in self.nc.iteritems():
230 if req.success and req.resp_status_code == http.HTTP_OK:
231 results[name] = RpcResult(data=serializer.LoadJson(req.resp_body),
232 node=name, call=self.procedure)
235 # TODO: Better error reporting
241 logging.error("RPC error in %s from node %s: %s",
242 self.procedure, name, msg)
243 results[name] = RpcResult(data=msg, failed=True, node=name,
249 class RpcRunner(object):
250 """RPC runner class"""
252 def __init__(self, cfg):
253 """Initialized the rpc runner.
255 @type cfg: C{config.ConfigWriter}
256 @param cfg: the configuration object that will be used to get data
261 self.port = utils.GetNodeDaemonPort()
263 def _InstDict(self, instance):
264 """Convert the given instance to a dict.
266 This is done via the instance's ToDict() method and additionally
267 we fill the hvparams with the cluster defaults.
269 @type instance: L{objects.Instance}
270 @param instance: an Instance object
272 @return: the instance dict, with the hvparams filled with the
276 idict = instance.ToDict()
277 cluster = self._cfg.GetClusterInfo()
278 idict["hvparams"] = cluster.FillHV(instance)
279 idict["beparams"] = cluster.FillBE(instance)
282 def _ConnectList(self, client, node_list, call):
283 """Helper for computing node addresses.
285 @type client: L{Client}
286 @param client: a C{Client} instance
287 @type node_list: list
288 @param node_list: the node list we should connect
290 @param call: the name of the remote procedure call, for filling in
291 correctly any eventual offline nodes' results
294 all_nodes = self._cfg.GetAllNodesInfo()
298 for node in node_list:
299 if node in all_nodes:
300 if all_nodes[node].offline:
301 skip_dict[node] = RpcResult(node=node, offline=True, call=call)
303 val = all_nodes[node].primary_ip
306 addr_list.append(val)
307 name_list.append(node)
309 client.ConnectList(name_list, address_list=addr_list)
312 def _ConnectNode(self, client, node, call):
313 """Helper for computing one node's address.
315 @type client: L{Client}
316 @param client: a C{Client} instance
318 @param node: the node we should connect
320 @param call: the name of the remote procedure call, for filling in
321 correctly any eventual offline nodes' results
324 node_info = self._cfg.GetNodeInfo(node)
325 if node_info is not None:
326 if node_info.offline:
327 return RpcResult(node=node, offline=True, call=call)
328 addr = node_info.primary_ip
331 client.ConnectNode(node, address=addr)
333 def _MultiNodeCall(self, node_list, procedure, args):
334 """Helper for making a multi-node call
337 body = serializer.DumpJson(args, indent=False)
338 c = Client(procedure, body, self.port)
339 skip_dict = self._ConnectList(c, node_list, procedure)
340 skip_dict.update(c.GetResults())
344 def _StaticMultiNodeCall(cls, node_list, procedure, args,
346 """Helper for making a multi-node static call
349 body = serializer.DumpJson(args, indent=False)
350 c = Client(procedure, body, utils.GetNodeDaemonPort())
351 c.ConnectList(node_list, address_list=address_list)
352 return c.GetResults()
354 def _SingleNodeCall(self, node, procedure, args):
355 """Helper for making a single-node call
358 body = serializer.DumpJson(args, indent=False)
359 c = Client(procedure, body, self.port)
360 result = self._ConnectNode(c, node, procedure)
362 # we did connect, node is not offline
363 result = c.GetResults()[node]
367 def _StaticSingleNodeCall(cls, node, procedure, args):
368 """Helper for making a single-node static call
371 body = serializer.DumpJson(args, indent=False)
372 c = Client(procedure, body, utils.GetNodeDaemonPort())
374 return c.GetResults()[node]
378 """Compresses a string for transport over RPC.
380 Small amounts of data are not compressed.
385 @return: Encoded data to send
388 # Small amounts of data are not compressed
390 return (constants.RPC_ENCODING_NONE, data)
392 # Compress with zlib and encode in base64
393 return (constants.RPC_ENCODING_ZLIB_BASE64,
394 base64.b64encode(zlib.compress(data, 3)))
400 def call_volume_list(self, node_list, vg_name):
401 """Gets the logical volumes present in a given volume group.
403 This is a multi-node call.
406 return self._MultiNodeCall(node_list, "volume_list", [vg_name])
408 def call_vg_list(self, node_list):
409 """Gets the volume group list.
411 This is a multi-node call.
414 return self._MultiNodeCall(node_list, "vg_list", [])
416 def call_bridges_exist(self, node, bridges_list):
417 """Checks if a node has all the bridges given.
419 This method checks if all bridges given in the bridges_list are
420 present on the remote node, so that an instance that uses interfaces
421 on those bridges can be started.
423 This is a single-node call.
426 return self._SingleNodeCall(node, "bridges_exist", [bridges_list])
428 def call_instance_start(self, node, instance, extra_args):
429 """Starts an instance.
431 This is a single-node call.
434 return self._SingleNodeCall(node, "instance_start",
435 [self._InstDict(instance), extra_args])
437 def call_instance_shutdown(self, node, instance):
438 """Stops an instance.
440 This is a single-node call.
443 return self._SingleNodeCall(node, "instance_shutdown",
444 [self._InstDict(instance)])
446 def call_migration_info(self, node, instance):
447 """Gather the information necessary to prepare an instance migration.
449 This is a single-node call.
452 @param node: the node on which the instance is currently running
453 @type instance: C{objects.Instance}
454 @param instance: the instance definition
457 return self._SingleNodeCall(node, "migration_info",
458 [self._InstDict(instance)])
460 def call_accept_instance(self, node, instance, info, target):
461 """Prepare a node to accept an instance.
463 This is a single-node call.
466 @param node: the target node for the migration
467 @type instance: C{objects.Instance}
468 @param instance: the instance definition
469 @type info: opaque/hypervisor specific (string/data)
470 @param info: result for the call_migration_info call
472 @param target: target hostname (usually ip address) (on the node itself)
475 return self._SingleNodeCall(node, "accept_instance",
476 [self._InstDict(instance), info, target])
478 def call_finalize_migration(self, node, instance, info, success):
479 """Finalize any target-node migration specific operation.
481 This is called both in case of a successful migration and in case of error
482 (in which case it should abort the migration).
484 This is a single-node call.
487 @param node: the target node for the migration
488 @type instance: C{objects.Instance}
489 @param instance: the instance definition
490 @type info: opaque/hypervisor specific (string/data)
491 @param info: result for the call_migration_info call
492 @type success: boolean
493 @param success: whether the migration was a success or a failure
496 return self._SingleNodeCall(node, "finalize_migration",
497 [self._InstDict(instance), info, success])
499 def call_instance_migrate(self, node, instance, target, live):
500 """Migrate an instance.
502 This is a single-node call.
505 @param node: the node on which the instance is currently running
506 @type instance: C{objects.Instance}
507 @param instance: the instance definition
509 @param target: the target node name
511 @param live: whether the migration should be done live or not (the
512 interpretation of this parameter is left to the hypervisor)
515 return self._SingleNodeCall(node, "instance_migrate",
516 [self._InstDict(instance), target, live])
518 def call_instance_reboot(self, node, instance, reboot_type, extra_args):
519 """Reboots an instance.
521 This is a single-node call.
524 return self._SingleNodeCall(node, "instance_reboot",
525 [self._InstDict(instance), reboot_type,
528 def call_instance_os_add(self, node, inst):
529 """Installs an OS on the given instance.
531 This is a single-node call.
534 return self._SingleNodeCall(node, "instance_os_add",
535 [self._InstDict(inst)])
537 def call_instance_run_rename(self, node, inst, old_name):
538 """Run the OS rename script for an instance.
540 This is a single-node call.
543 return self._SingleNodeCall(node, "instance_run_rename",
544 [self._InstDict(inst), old_name])
546 def call_instance_info(self, node, instance, hname):
547 """Returns information about a single instance.
549 This is a single-node call.
552 @param node: the list of nodes to query
553 @type instance: string
554 @param instance: the instance name
556 @param hname: the hypervisor type of the instance
559 return self._SingleNodeCall(node, "instance_info", [instance, hname])
561 def call_instance_migratable(self, node, instance):
562 """Checks whether the given instance can be migrated.
564 This is a single-node call.
566 @param node: the node to query
567 @type instance: L{objects.Instance}
568 @param instance: the instance to check
572 return self._SingleNodeCall(node, "instance_migratable",
573 [self._InstDict(instance)])
575 def call_all_instances_info(self, node_list, hypervisor_list):
576 """Returns information about all instances on the given nodes.
578 This is a multi-node call.
580 @type node_list: list
581 @param node_list: the list of nodes to query
582 @type hypervisor_list: list
583 @param hypervisor_list: the hypervisors to query for instances
586 return self._MultiNodeCall(node_list, "all_instances_info",
589 def call_instance_list(self, node_list, hypervisor_list):
590 """Returns the list of running instances on a given node.
592 This is a multi-node call.
594 @type node_list: list
595 @param node_list: the list of nodes to query
596 @type hypervisor_list: list
597 @param hypervisor_list: the hypervisors to query for instances
600 return self._MultiNodeCall(node_list, "instance_list", [hypervisor_list])
602 def call_node_tcp_ping(self, node, source, target, port, timeout,
604 """Do a TcpPing on the remote node
606 This is a single-node call.
609 return self._SingleNodeCall(node, "node_tcp_ping",
610 [source, target, port, timeout,
613 def call_node_has_ip_address(self, node, address):
614 """Checks if a node has the given IP address.
616 This is a single-node call.
619 return self._SingleNodeCall(node, "node_has_ip_address", [address])
621 def call_node_info(self, node_list, vg_name, hypervisor_type):
622 """Return node information.
624 This will return memory information and volume group size and free
627 This is a multi-node call.
629 @type node_list: list
630 @param node_list: the list of nodes to query
631 @type vg_name: C{string}
632 @param vg_name: the name of the volume group to ask for disk space
634 @type hypervisor_type: C{str}
635 @param hypervisor_type: the name of the hypervisor to ask for
639 retux = self._MultiNodeCall(node_list, "node_info",
640 [vg_name, hypervisor_type])
642 for result in retux.itervalues():
643 if result.failed or not isinstance(result.data, dict):
648 log_name = "call_node_info"
650 utils.CheckDict(result.data, {
651 'memory_total' : '-',
654 'vg_size' : 'node_unreachable',
659 def call_node_add(self, node, dsa, dsapub, rsa, rsapub, ssh, sshpub):
660 """Add a node to the cluster.
662 This is a single-node call.
665 return self._SingleNodeCall(node, "node_add",
666 [dsa, dsapub, rsa, rsapub, ssh, sshpub])
668 def call_node_verify(self, node_list, checkdict, cluster_name):
669 """Request verification of given parameters.
671 This is a multi-node call.
674 return self._MultiNodeCall(node_list, "node_verify",
675 [checkdict, cluster_name])
678 def call_node_start_master(cls, node, start_daemons):
679 """Tells a node to activate itself as a master.
681 This is a single-node call.
684 return cls._StaticSingleNodeCall(node, "node_start_master",
688 def call_node_stop_master(cls, node, stop_daemons):
689 """Tells a node to demote itself from master status.
691 This is a single-node call.
694 return cls._StaticSingleNodeCall(node, "node_stop_master", [stop_daemons])
697 def call_master_info(cls, node_list):
698 """Query master info.
700 This is a multi-node call.
703 # TODO: should this method query down nodes?
704 return cls._StaticMultiNodeCall(node_list, "master_info", [])
706 def call_version(self, node_list):
707 """Query node version.
709 This is a multi-node call.
712 return self._MultiNodeCall(node_list, "version", [])
714 def call_blockdev_create(self, node, bdev, size, owner, on_primary, info):
715 """Request creation of a given block device.
717 This is a single-node call.
720 return self._SingleNodeCall(node, "blockdev_create",
721 [bdev.ToDict(), size, owner, on_primary, info])
723 def call_blockdev_remove(self, node, bdev):
724 """Request removal of a given block device.
726 This is a single-node call.
729 return self._SingleNodeCall(node, "blockdev_remove", [bdev.ToDict()])
731 def call_blockdev_rename(self, node, devlist):
732 """Request rename of the given block devices.
734 This is a single-node call.
737 return self._SingleNodeCall(node, "blockdev_rename",
738 [(d.ToDict(), uid) for d, uid in devlist])
740 def call_blockdev_assemble(self, node, disk, owner, on_primary):
741 """Request assembling of a given block device.
743 This is a single-node call.
746 return self._SingleNodeCall(node, "blockdev_assemble",
747 [disk.ToDict(), owner, on_primary])
749 def call_blockdev_shutdown(self, node, disk):
750 """Request shutdown of a given block device.
752 This is a single-node call.
755 return self._SingleNodeCall(node, "blockdev_shutdown", [disk.ToDict()])
757 def call_blockdev_addchildren(self, node, bdev, ndevs):
758 """Request adding a list of children to a (mirroring) device.
760 This is a single-node call.
763 return self._SingleNodeCall(node, "blockdev_addchildren",
765 [disk.ToDict() for disk in ndevs]])
767 def call_blockdev_removechildren(self, node, bdev, ndevs):
768 """Request removing a list of children from a (mirroring) device.
770 This is a single-node call.
773 return self._SingleNodeCall(node, "blockdev_removechildren",
775 [disk.ToDict() for disk in ndevs]])
777 def call_blockdev_getmirrorstatus(self, node, disks):
778 """Request status of a (mirroring) device.
780 This is a single-node call.
783 return self._SingleNodeCall(node, "blockdev_getmirrorstatus",
784 [dsk.ToDict() for dsk in disks])
786 def call_blockdev_find(self, node, disk):
787 """Request identification of a given block device.
789 This is a single-node call.
792 return self._SingleNodeCall(node, "blockdev_find", [disk.ToDict()])
794 def call_blockdev_close(self, node, instance_name, disks):
795 """Closes the given block devices.
797 This is a single-node call.
800 params = [instance_name, [cf.ToDict() for cf in disks]]
801 return self._SingleNodeCall(node, "blockdev_close", params)
803 def call_drbd_disconnect_net(self, node_list, nodes_ip, disks):
804 """Disconnects the network of the given drbd devices.
806 This is a multi-node call.
809 return self._MultiNodeCall(node_list, "drbd_disconnect_net",
810 [nodes_ip, [cf.ToDict() for cf in disks]])
812 def call_drbd_attach_net(self, node_list, nodes_ip,
813 disks, instance_name, multimaster):
814 """Disconnects the given drbd devices.
816 This is a multi-node call.
819 return self._MultiNodeCall(node_list, "drbd_attach_net",
820 [nodes_ip, [cf.ToDict() for cf in disks],
821 instance_name, multimaster])
823 def call_drbd_wait_sync(self, node_list, nodes_ip, disks):
824 """Waits for the synchronization of drbd devices is complete.
826 This is a multi-node call.
829 return self._MultiNodeCall(node_list, "drbd_wait_sync",
830 [nodes_ip, [cf.ToDict() for cf in disks]])
833 def call_upload_file(cls, node_list, file_name, address_list=None):
836 The node will refuse the operation in case the file is not on the
839 This is a multi-node call.
841 @type node_list: list
842 @param node_list: the list of node names to upload to
844 @param file_name: the filename to upload
845 @type address_list: list or None
846 @keyword address_list: an optional list of node addresses, in order
847 to optimize the RPC speed
850 file_contents = utils.ReadFile(file_name)
851 data = cls._Compress(file_contents)
852 st = os.stat(file_name)
853 params = [file_name, data, st.st_mode, st.st_uid, st.st_gid,
854 st.st_atime, st.st_mtime]
855 return cls._StaticMultiNodeCall(node_list, "upload_file", params,
856 address_list=address_list)
859 def call_write_ssconf_files(cls, node_list, values):
860 """Write ssconf files.
862 This is a multi-node call.
865 return cls._StaticMultiNodeCall(node_list, "write_ssconf_files", [values])
867 def call_os_diagnose(self, node_list):
868 """Request a diagnose of OS definitions.
870 This is a multi-node call.
873 result = self._MultiNodeCall(node_list, "os_diagnose", [])
875 for node_result in result.values():
876 if not node_result.failed and node_result.data:
877 node_result.data = [objects.OS.FromDict(oss)
878 for oss in node_result.data]
881 def call_os_get(self, node, name):
882 """Returns an OS definition.
884 This is a single-node call.
887 result = self._SingleNodeCall(node, "os_get", [name])
888 if not result.failed and isinstance(result.data, dict):
889 result.data = objects.OS.FromDict(result.data)
892 def call_hooks_runner(self, node_list, hpath, phase, env):
893 """Call the hooks runner.
896 - op: the OpCode instance
897 - env: a dictionary with the environment
899 This is a multi-node call.
902 params = [hpath, phase, env]
903 return self._MultiNodeCall(node_list, "hooks_runner", params)
905 def call_iallocator_runner(self, node, name, idata):
906 """Call an iallocator on a remote node
909 - name: the iallocator name
910 - input: the json-encoded input string
912 This is a single-node call.
915 return self._SingleNodeCall(node, "iallocator_runner", [name, idata])
917 def call_blockdev_grow(self, node, cf_bdev, amount):
918 """Request a snapshot of the given block device.
920 This is a single-node call.
923 return self._SingleNodeCall(node, "blockdev_grow",
924 [cf_bdev.ToDict(), amount])
926 def call_blockdev_snapshot(self, node, cf_bdev):
927 """Request a snapshot of the given block device.
929 This is a single-node call.
932 return self._SingleNodeCall(node, "blockdev_snapshot", [cf_bdev.ToDict()])
934 def call_snapshot_export(self, node, snap_bdev, dest_node, instance,
936 """Request the export of a given snapshot.
938 This is a single-node call.
941 return self._SingleNodeCall(node, "snapshot_export",
942 [snap_bdev.ToDict(), dest_node,
943 self._InstDict(instance), cluster_name, idx])
945 def call_finalize_export(self, node, instance, snap_disks):
946 """Request the completion of an export operation.
948 This writes the export config file, etc.
950 This is a single-node call.
954 for disk in snap_disks:
955 flat_disks.append(disk.ToDict())
957 return self._SingleNodeCall(node, "finalize_export",
958 [self._InstDict(instance), flat_disks])
960 def call_export_info(self, node, path):
961 """Queries the export information in a given path.
963 This is a single-node call.
966 result = self._SingleNodeCall(node, "export_info", [path])
967 if not result.failed and result.data:
968 result.data = objects.SerializableConfigParser.Loads(str(result.data))
971 def call_instance_os_import(self, node, inst, src_node, src_images,
973 """Request the import of a backup into an instance.
975 This is a single-node call.
978 return self._SingleNodeCall(node, "instance_os_import",
979 [self._InstDict(inst), src_node, src_images,
982 def call_export_list(self, node_list):
983 """Gets the stored exports list.
985 This is a multi-node call.
988 return self._MultiNodeCall(node_list, "export_list", [])
990 def call_export_remove(self, node, export):
991 """Requests removal of a given export.
993 This is a single-node call.
996 return self._SingleNodeCall(node, "export_remove", [export])
999 def call_node_leave_cluster(cls, node):
1000 """Requests a node to clean the cluster information it has.
1002 This will remove the configuration information from the ganeti data
1005 This is a single-node call.
1008 return cls._StaticSingleNodeCall(node, "node_leave_cluster", [])
1010 def call_node_volumes(self, node_list):
1011 """Gets all volumes on node(s).
1013 This is a multi-node call.
1016 return self._MultiNodeCall(node_list, "node_volumes", [])
1018 def call_node_demote_from_mc(self, node):
1019 """Demote a node from the master candidate role.
1021 This is a single-node call.
1024 return self._SingleNodeCall(node, "node_demote_from_mc", [])
1026 def call_test_delay(self, node_list, duration):
1027 """Sleep for a fixed time on given node(s).
1029 This is a multi-node call.
1032 return self._MultiNodeCall(node_list, "test_delay", [duration])
1034 def call_file_storage_dir_create(self, node, file_storage_dir):
1035 """Create the given file storage directory.
1037 This is a single-node call.
1040 return self._SingleNodeCall(node, "file_storage_dir_create",
1043 def call_file_storage_dir_remove(self, node, file_storage_dir):
1044 """Remove the given file storage directory.
1046 This is a single-node call.
1049 return self._SingleNodeCall(node, "file_storage_dir_remove",
1052 def call_file_storage_dir_rename(self, node, old_file_storage_dir,
1053 new_file_storage_dir):
1054 """Rename file storage directory.
1056 This is a single-node call.
1059 return self._SingleNodeCall(node, "file_storage_dir_rename",
1060 [old_file_storage_dir, new_file_storage_dir])
1063 def call_jobqueue_update(cls, node_list, address_list, file_name, content):
1064 """Update job queue.
1066 This is a multi-node call.
1069 return cls._StaticMultiNodeCall(node_list, "jobqueue_update",
1070 [file_name, cls._Compress(content)],
1071 address_list=address_list)
1074 def call_jobqueue_purge(cls, node):
1077 This is a single-node call.
1080 return cls._StaticSingleNodeCall(node, "jobqueue_purge", [])
1083 def call_jobqueue_rename(cls, node_list, address_list, rename):
1084 """Rename a job queue file.
1086 This is a multi-node call.
1089 return cls._StaticMultiNodeCall(node_list, "jobqueue_rename", rename,
1090 address_list=address_list)
1093 def call_jobqueue_set_drain(cls, node_list, drain_flag):
1094 """Set the drain flag on the queue.
1096 This is a multi-node call.
1098 @type node_list: list
1099 @param node_list: the list of nodes to query
1100 @type drain_flag: bool
1101 @param drain_flag: if True, will set the drain flag, otherwise reset it.
1104 return cls._StaticMultiNodeCall(node_list, "jobqueue_set_drain",
1107 def call_hypervisor_validate_params(self, node_list, hvname, hvparams):
1108 """Validate the hypervisor params.
1110 This is a multi-node call.
1112 @type node_list: list
1113 @param node_list: the list of nodes to query
1114 @type hvname: string
1115 @param hvname: the hypervisor name
1116 @type hvparams: dict
1117 @param hvparams: the hypervisor parameters to be validated
1120 cluster = self._cfg.GetClusterInfo()
1121 hv_full = cluster.FillDict(cluster.hvparams.get(hvname, {}), hvparams)
1122 return self._MultiNodeCall(node_list, "hypervisor_validate_params",