Revision 16ad1a83 lib/rpc.py
b/lib/rpc.py | ||
---|---|---|
180 | 180 |
c.run() |
181 | 181 |
return c.getresult() |
182 | 182 |
|
183 |
|
|
184 | 183 |
def call_bridges_exist(self, node, bridges_list): |
185 | 184 |
"""Checks if a node has all the bridges given. |
186 | 185 |
|
... | ... | |
196 | 195 |
c.run() |
197 | 196 |
return c.getresult().get(node, False) |
198 | 197 |
|
199 |
|
|
200 | 198 |
def call_instance_start(self, node, instance, extra_args): |
201 | 199 |
"""Starts an instance. |
202 | 200 |
|
... | ... | |
208 | 206 |
c.run() |
209 | 207 |
return c.getresult().get(node, False) |
210 | 208 |
|
211 |
|
|
212 | 209 |
def call_instance_shutdown(self, node, instance): |
213 | 210 |
"""Stops an instance. |
214 | 211 |
|
... | ... | |
220 | 217 |
c.run() |
221 | 218 |
return c.getresult().get(node, False) |
222 | 219 |
|
223 |
|
|
224 | 220 |
def call_instance_migrate(self, node, instance, target, live): |
225 | 221 |
"""Migrate an instance. |
226 | 222 |
|
... | ... | |
242 | 238 |
c.run() |
243 | 239 |
return c.getresult().get(node, False) |
244 | 240 |
|
245 |
|
|
246 | 241 |
def call_instance_reboot(self, node, instance, reboot_type, extra_args): |
247 | 242 |
"""Reboots an instance. |
248 | 243 |
|
... | ... | |
254 | 249 |
c.run() |
255 | 250 |
return c.getresult().get(node, False) |
256 | 251 |
|
257 |
|
|
258 | 252 |
def call_instance_os_add(self, node, inst, osdev, swapdev): |
259 | 253 |
"""Installs an OS on the given instance. |
260 | 254 |
|
... | ... | |
267 | 261 |
c.run() |
268 | 262 |
return c.getresult().get(node, False) |
269 | 263 |
|
270 |
|
|
271 | 264 |
def call_instance_run_rename(self, node, inst, old_name, osdev, swapdev): |
272 | 265 |
"""Run the OS rename script for an instance. |
273 | 266 |
|
... | ... | |
280 | 273 |
c.run() |
281 | 274 |
return c.getresult().get(node, False) |
282 | 275 |
|
283 |
|
|
284 | 276 |
def call_instance_info(self, node, instance, hname): |
285 | 277 |
"""Returns information about a single instance. |
286 | 278 |
|
... | ... | |
294 | 286 |
@param hname: the hypervisor type of the instance |
295 | 287 |
|
296 | 288 |
""" |
297 |
c = Client("instance_info", [instance]) |
|
289 |
c = Client("instance_info", [instance, hname])
|
|
298 | 290 |
c.connect(node) |
299 | 291 |
c.run() |
300 | 292 |
return c.getresult().get(node, False) |
301 | 293 |
|
302 |
|
|
303 | 294 |
def call_all_instances_info(self, node_list, hypervisor_list): |
304 | 295 |
"""Returns information about all instances on the given nodes. |
305 | 296 |
|
... | ... | |
316 | 307 |
c.run() |
317 | 308 |
return c.getresult() |
318 | 309 |
|
319 |
|
|
320 | 310 |
def call_instance_list(self, node_list, hypervisor_list): |
321 | 311 |
"""Returns the list of running instances on a given node. |
322 | 312 |
|
... | ... | |
333 | 323 |
c.run() |
334 | 324 |
return c.getresult() |
335 | 325 |
|
336 |
|
|
337 | 326 |
def call_node_tcp_ping(self, node, source, target, port, timeout, |
338 | 327 |
live_port_needed): |
339 | 328 |
"""Do a TcpPing on the remote node |
... | ... | |
397 | 386 |
) |
398 | 387 |
return retux |
399 | 388 |
|
400 |
|
|
401 | 389 |
def call_node_add(self, node, dsa, dsapub, rsa, rsapub, ssh, sshpub): |
402 | 390 |
"""Add a node to the cluster. |
403 | 391 |
|
... | ... | |
410 | 398 |
c.run() |
411 | 399 |
return c.getresult().get(node, False) |
412 | 400 |
|
413 |
|
|
414 | 401 |
def call_node_verify(self, node_list, checkdict, cluster_name): |
415 | 402 |
"""Request verification of given parameters. |
416 | 403 |
|
... | ... | |
422 | 409 |
c.run() |
423 | 410 |
return c.getresult() |
424 | 411 |
|
425 |
|
|
426 | 412 |
@staticmethod |
427 | 413 |
def call_node_start_master(node, start_daemons): |
428 | 414 |
"""Tells a node to activate itself as a master. |
... | ... | |
435 | 421 |
c.run() |
436 | 422 |
return c.getresult().get(node, False) |
437 | 423 |
|
438 |
|
|
439 | 424 |
@staticmethod |
440 | 425 |
def call_node_stop_master(node, stop_daemons): |
441 | 426 |
"""Tells a node to demote itself from master status. |
... | ... | |
448 | 433 |
c.run() |
449 | 434 |
return c.getresult().get(node, False) |
450 | 435 |
|
451 |
|
|
452 | 436 |
@staticmethod |
453 | 437 |
def call_master_info(node_list): |
454 | 438 |
"""Query master info. |
... | ... | |
462 | 446 |
c.run() |
463 | 447 |
return c.getresult() |
464 | 448 |
|
465 |
|
|
466 | 449 |
def call_version(self, node_list): |
467 | 450 |
"""Query node version. |
468 | 451 |
|
... | ... | |
474 | 457 |
c.run() |
475 | 458 |
return c.getresult() |
476 | 459 |
|
477 |
|
|
478 | 460 |
def call_blockdev_create(self, node, bdev, size, owner, on_primary, info): |
479 | 461 |
"""Request creation of a given block device. |
480 | 462 |
|
... | ... | |
487 | 469 |
c.run() |
488 | 470 |
return c.getresult().get(node, False) |
489 | 471 |
|
490 |
|
|
491 | 472 |
def call_blockdev_remove(self, node, bdev): |
492 | 473 |
"""Request removal of a given block device. |
493 | 474 |
|
... | ... | |
499 | 480 |
c.run() |
500 | 481 |
return c.getresult().get(node, False) |
501 | 482 |
|
502 |
|
|
503 | 483 |
def call_blockdev_rename(self, node, devlist): |
504 | 484 |
"""Request rename of the given block devices. |
505 | 485 |
|
... | ... | |
512 | 492 |
c.run() |
513 | 493 |
return c.getresult().get(node, False) |
514 | 494 |
|
515 |
|
|
516 | 495 |
def call_blockdev_assemble(self, node, disk, owner, on_primary): |
517 | 496 |
"""Request assembling of a given block device. |
518 | 497 |
|
... | ... | |
525 | 504 |
c.run() |
526 | 505 |
return c.getresult().get(node, False) |
527 | 506 |
|
528 |
|
|
529 | 507 |
def call_blockdev_shutdown(self, node, disk): |
530 | 508 |
"""Request shutdown of a given block device. |
531 | 509 |
|
... | ... | |
537 | 515 |
c.run() |
538 | 516 |
return c.getresult().get(node, False) |
539 | 517 |
|
540 |
|
|
541 | 518 |
def call_blockdev_addchildren(self, node, bdev, ndevs): |
542 | 519 |
"""Request adding a list of children to a (mirroring) device. |
543 | 520 |
|
... | ... | |
550 | 527 |
c.run() |
551 | 528 |
return c.getresult().get(node, False) |
552 | 529 |
|
553 |
|
|
554 | 530 |
def call_blockdev_removechildren(self, node, bdev, ndevs): |
555 | 531 |
"""Request removing a list of children from a (mirroring) device. |
556 | 532 |
|
... | ... | |
563 | 539 |
c.run() |
564 | 540 |
return c.getresult().get(node, False) |
565 | 541 |
|
566 |
|
|
567 | 542 |
def call_blockdev_getmirrorstatus(self, node, disks): |
568 | 543 |
"""Request status of a (mirroring) device. |
569 | 544 |
|
... | ... | |
576 | 551 |
c.run() |
577 | 552 |
return c.getresult().get(node, False) |
578 | 553 |
|
579 |
|
|
580 | 554 |
def call_blockdev_find(self, node, disk): |
581 | 555 |
"""Request identification of a given block device. |
582 | 556 |
|
... | ... | |
588 | 562 |
c.run() |
589 | 563 |
return c.getresult().get(node, False) |
590 | 564 |
|
591 |
|
|
592 | 565 |
def call_blockdev_close(self, node, disks): |
593 | 566 |
"""Closes the given block devices. |
594 | 567 |
|
... | ... | |
601 | 574 |
c.run() |
602 | 575 |
return c.getresult().get(node, False) |
603 | 576 |
|
604 |
|
|
605 |
@staticmethod |
|
606 |
def call_upload_file(node_list, file_name): |
|
607 |
"""Upload a file. |
|
608 |
|
|
609 |
The node will refuse the operation in case the file is not on the |
|
610 |
approved file list. |
|
611 |
|
|
612 |
This is a multi-node call. |
|
613 |
|
|
614 |
""" |
|
615 |
fh = file(file_name) |
|
616 |
try: |
|
617 |
data = fh.read() |
|
618 |
finally: |
|
619 |
fh.close() |
|
620 |
st = os.stat(file_name) |
|
621 |
params = [file_name, data, st.st_mode, st.st_uid, st.st_gid, |
|
622 |
st.st_atime, st.st_mtime] |
|
623 |
c = Client("upload_file", params) |
|
624 |
c.connect_list(node_list) |
|
625 |
c.run() |
|
626 |
return c.getresult() |
|
627 |
|
|
628 | 577 |
@staticmethod |
629 | 578 |
def call_upload_file(node_list, file_name): |
630 | 579 |
"""Upload a file. |
... | ... | |
667 | 616 |
new_result[node_name] = nr |
668 | 617 |
return new_result |
669 | 618 |
|
670 |
|
|
671 | 619 |
def call_os_get(self, node, name): |
672 | 620 |
"""Returns an OS definition. |
673 | 621 |
|
... | ... | |
683 | 631 |
else: |
684 | 632 |
return result |
685 | 633 |
|
686 |
|
|
687 | 634 |
def call_hooks_runner(self, node_list, hpath, phase, env): |
688 | 635 |
"""Call the hooks runner. |
689 | 636 |
|
... | ... | |
701 | 648 |
result = c.getresult() |
702 | 649 |
return result |
703 | 650 |
|
704 |
|
|
705 | 651 |
def call_iallocator_runner(self, node, name, idata): |
706 | 652 |
"""Call an iallocator on a remote node |
707 | 653 |
|
... | ... | |
719 | 665 |
result = c.getresult().get(node, False) |
720 | 666 |
return result |
721 | 667 |
|
722 |
|
|
723 | 668 |
def call_blockdev_grow(self, node, cf_bdev, amount): |
724 | 669 |
"""Request a snapshot of the given block device. |
725 | 670 |
|
... | ... | |
731 | 676 |
c.run() |
732 | 677 |
return c.getresult().get(node, False) |
733 | 678 |
|
734 |
|
|
735 | 679 |
def call_blockdev_snapshot(self, node, cf_bdev): |
736 | 680 |
"""Request a snapshot of the given block device. |
737 | 681 |
|
... | ... | |
743 | 687 |
c.run() |
744 | 688 |
return c.getresult().get(node, False) |
745 | 689 |
|
746 |
|
|
747 | 690 |
def call_snapshot_export(self, node, snap_bdev, dest_node, instance, |
748 | 691 |
cluster_name): |
749 | 692 |
"""Request the export of a given snapshot. |
... | ... | |
757 | 700 |
c.run() |
758 | 701 |
return c.getresult().get(node, False) |
759 | 702 |
|
760 |
|
|
761 | 703 |
def call_finalize_export(self, node, instance, snap_disks): |
762 | 704 |
"""Request the completion of an export operation. |
763 | 705 |
|
... | ... | |
775 | 717 |
c.run() |
776 | 718 |
return c.getresult().get(node, False) |
777 | 719 |
|
778 |
|
|
779 | 720 |
def call_export_info(self, node, path): |
780 | 721 |
"""Queries the export information in a given path. |
781 | 722 |
|
... | ... | |
790 | 731 |
return result |
791 | 732 |
return objects.SerializableConfigParser.Loads(str(result)) |
792 | 733 |
|
793 |
|
|
794 | 734 |
def call_instance_os_import(self, node, inst, osdev, swapdev, |
795 | 735 |
src_node, src_image, cluster_name): |
796 | 736 |
"""Request the import of a backup into an instance. |
... | ... | |
804 | 744 |
c.run() |
805 | 745 |
return c.getresult().get(node, False) |
806 | 746 |
|
807 |
|
|
808 | 747 |
def call_export_list(self, node_list): |
809 | 748 |
"""Gets the stored exports list. |
810 | 749 |
|
... | ... | |
817 | 756 |
result = c.getresult() |
818 | 757 |
return result |
819 | 758 |
|
820 |
|
|
821 | 759 |
def call_export_remove(self, node, export): |
822 | 760 |
"""Requests removal of a given export. |
823 | 761 |
|
... | ... | |
829 | 767 |
c.run() |
830 | 768 |
return c.getresult().get(node, False) |
831 | 769 |
|
832 |
|
|
833 | 770 |
@staticmethod |
834 | 771 |
def call_node_leave_cluster(node): |
835 | 772 |
"""Requests a node to clean the cluster information it has. |
... | ... | |
845 | 782 |
c.run() |
846 | 783 |
return c.getresult().get(node, False) |
847 | 784 |
|
848 |
|
|
849 | 785 |
def call_node_volumes(self, node_list): |
850 | 786 |
"""Gets all volumes on node(s). |
851 | 787 |
|
... | ... | |
857 | 793 |
c.run() |
858 | 794 |
return c.getresult() |
859 | 795 |
|
860 |
|
|
861 | 796 |
def call_test_delay(self, node_list, duration): |
862 | 797 |
"""Sleep for a fixed time on given node(s). |
863 | 798 |
|
... | ... | |
869 | 804 |
c.run() |
870 | 805 |
return c.getresult() |
871 | 806 |
|
872 |
|
|
873 | 807 |
def call_file_storage_dir_create(self, node, file_storage_dir): |
874 | 808 |
"""Create the given file storage directory. |
875 | 809 |
|
... | ... | |
881 | 815 |
c.run() |
882 | 816 |
return c.getresult().get(node, False) |
883 | 817 |
|
884 |
|
|
885 | 818 |
def call_file_storage_dir_remove(self, node, file_storage_dir): |
886 | 819 |
"""Remove the given file storage directory. |
887 | 820 |
|
... | ... | |
893 | 826 |
c.run() |
894 | 827 |
return c.getresult().get(node, False) |
895 | 828 |
|
896 |
|
|
897 | 829 |
def call_file_storage_dir_rename(self, node, old_file_storage_dir, |
898 | 830 |
new_file_storage_dir): |
899 | 831 |
"""Rename file storage directory. |
... | ... | |
907 | 839 |
c.run() |
908 | 840 |
return c.getresult().get(node, False) |
909 | 841 |
|
910 |
|
|
911 | 842 |
@staticmethod |
912 | 843 |
def call_jobqueue_update(node_list, file_name, content): |
913 | 844 |
"""Update job queue. |
... | ... | |
921 | 852 |
result = c.getresult() |
922 | 853 |
return result |
923 | 854 |
|
924 |
|
|
925 | 855 |
@staticmethod |
926 | 856 |
def call_jobqueue_purge(node): |
927 | 857 |
"""Purge job queue. |
... | ... | |
934 | 864 |
c.run() |
935 | 865 |
return c.getresult().get(node, False) |
936 | 866 |
|
937 |
|
|
938 | 867 |
@staticmethod |
939 | 868 |
def call_jobqueue_rename(node_list, old, new): |
940 | 869 |
"""Rename a job queue file. |
Also available in: Unified diff