Revision d0834de3 lib/cmdlib.py

b/lib/cmdlib.py
1887 1887
      raise errors.OpPrereqError, ("Instance '%s' is running on the node %s" %
1888 1888
                                   (self.op.instance_name,
1889 1889
                                    instance.primary_node))
1890

  
1891
    self.op.os_type = getattr(self.op, "os_type", None)
1892
    if self.op.os_type is not None:
1893
      # OS verification
1894
      pnode = self.cfg.GetNodeInfo(
1895
        self.cfg.ExpandNodeName(instance.primary_node))
1896
      if pnode is None:
1897
        raise errors.OpPrereqError, ("Primary node '%s' is unknown" %
1898
                                     self.op.pnode)
1899
      os_obj = rpc.call_os_get([pnode.name], self.op.os_type)[pnode.name]
1900
      if not isinstance(os_obj, objects.OS):
1901
        raise errors.OpPrereqError, ("OS '%s' not in supported OS list for"
1902
                                     " primary node"  % self.op.os_type)
1903

  
1890 1904
    self.instance = instance
1891 1905

  
1892 1906
  def Exec(self, feedback_fn):
......
1895 1909
    """
1896 1910
    inst = self.instance
1897 1911

  
1912
    if self.op.os_type is not None:
1913
      feedback_fn("Changing OS to '%s'..." % self.op.os_type)
1914
      inst.os = self.op.os_type
1915
      self.cfg.AddInstance(inst)
1916

  
1898 1917
    _StartInstanceDisks(self.cfg, inst, None)
1899 1918
    try:
1900 1919
      feedback_fn("Running the instance OS create scripts...")

Also available in: Unified diff