code: def ReinstallInstance(r, instance, os=None, no_startup=False, osparams=None):
      
  
      if INST_REINSTALL_REQV1 in r.features:
          body = {
              "start": not no_startup,
          }
          if os is not None:
              body["os"] = os
          if osparams is not None:
              body["osparams"] = osparams
          return r.request("post", "/2/instances/%s/reinstall" % instance,
                           content=body)
  
      # Use old request format
      if osparams:
          raise GanetiApiError("Server does not support specifying OS"
                               " parameters for instance reinstallation")
  
      query = {
          "nostartup": no_startup,
      }
  
      if os:
          query["os"] = os
  
      return r.request("post", "/2/instances/%s/reinstall" % instance,
                       query=query)
docs: Reinstalls an instance.
  
      @type instance: str
      @param instance: The instance to reinstall
      @type os: str or None
      @param os: The operating system to reinstall. If None, the instance's
              current operating system will be installed again
      @type no_startup: bool
      @param no_startup: Whether to start the instance automatically