Revision 2effde8d lib/rpc.py

b/lib/rpc.py
674 674
    idict = self._InstDict(instance, hvp=hvp, bep=bep)
675 675
    return self._SingleNodeCall(node, "instance_start", [idict, startup_paused])
676 676

  
677
  @_RpcTimeout(_TMO_NORMAL)
678
  def call_instance_shutdown(self, node, instance, timeout):
679
    """Stops an instance.
680

  
681
    This is a single-node call.
682

  
683
    """
684
    return self._SingleNodeCall(node, "instance_shutdown",
685
                                [self._InstDict(instance), timeout])
686

  
687
  @_RpcTimeout(_TMO_NORMAL)
688
  def call_migration_info(self, node, instance):
689
    """Gather the information necessary to prepare an instance migration.
690

  
691
    This is a single-node call.
692

  
693
    @type node: string
694
    @param node: the node on which the instance is currently running
695
    @type instance: C{objects.Instance}
696
    @param instance: the instance definition
697

  
698
    """
699
    return self._SingleNodeCall(node, "migration_info",
700
                                [self._InstDict(instance)])
701

  
702
  @_RpcTimeout(_TMO_NORMAL)
703
  def call_accept_instance(self, node, instance, info, target):
704
    """Prepare a node to accept an instance.
705

  
706
    This is a single-node call.
707

  
708
    @type node: string
709
    @param node: the target node for the migration
710
    @type instance: C{objects.Instance}
711
    @param instance: the instance definition
712
    @type info: opaque/hypervisor specific (string/data)
713
    @param info: result for the call_migration_info call
714
    @type target: string
715
    @param target: target hostname (usually ip address) (on the node itself)
716

  
717
    """
718
    return self._SingleNodeCall(node, "accept_instance",
719
                                [self._InstDict(instance), info, target])
720

  
721
  @_RpcTimeout(_TMO_NORMAL)
722
  def call_instance_finalize_migration_dst(self, node, instance, info, success):
723
    """Finalize any target-node migration specific operation.
724

  
725
    This is called both in case of a successful migration and in case of error
726
    (in which case it should abort the migration).
727

  
728
    This is a single-node call.
729

  
730
    @type node: string
731
    @param node: the target node for the migration
732
    @type instance: C{objects.Instance}
733
    @param instance: the instance definition
734
    @type info: opaque/hypervisor specific (string/data)
735
    @param info: result for the call_migration_info call
736
    @type success: boolean
737
    @param success: whether the migration was a success or a failure
738

  
739
    """
740
    return self._SingleNodeCall(node, "instance_finalize_migration_dst",
741
                                [self._InstDict(instance), info, success])
742

  
743
  @_RpcTimeout(_TMO_SLOW)
744
  def call_instance_migrate(self, node, instance, target, live):
745
    """Migrate an instance.
746

  
747
    This is a single-node call.
748

  
749
    @type node: string
750
    @param node: the node on which the instance is currently running
751
    @type instance: C{objects.Instance}
752
    @param instance: the instance definition
753
    @type target: string
754
    @param target: the target node name
755
    @type live: boolean
756
    @param live: whether the migration should be done live or not (the
757
        interpretation of this parameter is left to the hypervisor)
758

  
759
    """
760
    return self._SingleNodeCall(node, "instance_migrate",
761
                                [self._InstDict(instance), target, live])
762

  
763
  @_RpcTimeout(_TMO_SLOW)
764
  def call_instance_finalize_migration_src(self, node, instance, success, live):
765
    """Finalize the instance migration on the source node.
766

  
767
    This is a single-node call.
768

  
769
    @type instance: L{objects.Instance}
770
    @param instance: the instance that was migrated
771
    @type success: bool
772
    @param success: whether the migration succeeded or not
773
    @type live: bool
774
    @param live: whether the user requested a live migration or not
775

  
776
    """
777
    return self._SingleNodeCall(node, "instance_finalize_migration_src",
778
                                [self._InstDict(instance), success, live])
779

  
780
  @_RpcTimeout(_TMO_SLOW)
781
  def call_instance_get_migration_status(self, node, instance):
782
    """Report migration status.
783

  
784
    This is a single-node call that must be executed on the source node.
785

  
786
    @type instance: L{objects.Instance}
787
    @param instance: the instance that is being migrated
788
    @rtype: L{objects.MigrationStatus}
789
    @return: the status of the current migration (one of
790
             L{constants.HV_MIGRATION_VALID_STATUSES}), plus any additional
791
             progress info that can be retrieved from the hypervisor
792

  
793
    """
794
    result = self._SingleNodeCall(node, "instance_get_migration_status",
795
                                  [self._InstDict(instance)])
796
    if not result.fail_msg and result.payload is not None:
797
      result.payload = objects.MigrationStatus.FromDict(result.payload)
798
    return result
799

  
800
  @_RpcTimeout(_TMO_NORMAL)
801
  def call_instance_reboot(self, node, inst, reboot_type, shutdown_timeout):
802
    """Reboots an instance.
803

  
804
    This is a single-node call.
805

  
806
    """
807
    return self._SingleNodeCall(node, "instance_reboot",
808
                                [self._InstDict(inst), reboot_type,
809
                                 shutdown_timeout])
810

  
811 677
  @_RpcTimeout(_TMO_1DAY)
812 678
  def call_instance_os_add(self, node, inst, reinstall, debug, osparams=None):
813 679
    """Installs an OS on the given instance.
......
819 685
                                [self._InstDict(inst, osp=osparams),
820 686
                                 reinstall, debug])
821 687

  
822
  @_RpcTimeout(_TMO_SLOW)
823
  def call_instance_run_rename(self, node, inst, old_name, debug):
824
    """Run the OS rename script for an instance.
825

  
826
    This is a single-node call.
827

  
828
    """
829
    return self._SingleNodeCall(node, "instance_run_rename",
830
                                [self._InstDict(inst), old_name, debug])
831

  
832
  @_RpcTimeout(_TMO_URGENT)
833
  def call_instance_info(self, node, instance, hname):
834
    """Returns information about a single instance.
835

  
836
    This is a single-node call.
837

  
838
    @type node: list
839
    @param node: the list of nodes to query
840
    @type instance: string
841
    @param instance: the instance name
842
    @type hname: string
843
    @param hname: the hypervisor type of the instance
844

  
845
    """
846
    return self._SingleNodeCall(node, "instance_info", [instance, hname])
847

  
848
  @_RpcTimeout(_TMO_NORMAL)
849
  def call_instance_migratable(self, node, instance):
850
    """Checks whether the given instance can be migrated.
851

  
852
    This is a single-node call.
853

  
854
    @param node: the node to query
855
    @type instance: L{objects.Instance}
856
    @param instance: the instance to check
857

  
858

  
859
    """
860
    return self._SingleNodeCall(node, "instance_migratable",
861
                                [self._InstDict(instance)])
862

  
863
  @_RpcTimeout(_TMO_URGENT)
864
  def call_all_instances_info(self, node_list, hypervisor_list):
865
    """Returns information about all instances on the given nodes.
866

  
867
    This is a multi-node call.
868

  
869
    @type node_list: list
870
    @param node_list: the list of nodes to query
871
    @type hypervisor_list: list
872
    @param hypervisor_list: the hypervisors to query for instances
873

  
874
    """
875
    return self._MultiNodeCall(node_list, "all_instances_info",
876
                               [hypervisor_list])
877

  
878
  @_RpcTimeout(_TMO_URGENT)
879
  def call_instance_list(self, node_list, hypervisor_list):
880
    """Returns the list of running instances on a given node.
881

  
882
    This is a multi-node call.
883

  
884
    @type node_list: list
885
    @param node_list: the list of nodes to query
886
    @type hypervisor_list: list
887
    @param hypervisor_list: the hypervisors to query for instances
888

  
889
    """
890
    return self._MultiNodeCall(node_list, "instance_list", [hypervisor_list])
891

  
892 688
  @classmethod
893 689
  @_RpcTimeout(_TMO_FAST)
894 690
  def call_node_start_master_daemons(cls, node, no_voting):

Also available in: Unified diff