def relocate_app(cls, options):
    """Instructs AppScale to move the named application to a different port.

    Args:
      options: A Namespace that has fields for each parameter that can be passed
        in via the command-line interface.
    Raises:
      AppScaleException: If the named application isn't running in this AppScale
        cloud, if the destination port is in use by a different application, or
        if the AppController rejects the request to relocate the application (in
        which case it includes the reason why the rejection occurred).
    """
    login_host = LocalState.get_login_host(options.keyname)
    acc = AppControllerClient(login_host, LocalState.get_secret_key(
      options.keyname))

    app_info_map = acc.get_app_info_map()
    if options.appname not in app_info_map.keys():
      raise AppScaleException("The given application, {0}, is not currently " \
        "running in this AppScale cloud, so we can't move it to a different " \
        "port.".format(options.appname))

    relocate_result = acc.relocate_app(options.appname, options.http_port,
      options.https_port)
    if relocate_result == "OK":
      AppScaleLogger.success("Successfully issued request to move {0} to " \
        "ports {1} and {2}.".format(options.appname, options.http_port,
        options.https_port))
      AppScaleLogger.success("Your app serves unencrypted traffic at: " +
        "http://{0}:{1}".format(login_host, options.http_port))
      AppScaleLogger.success("Your app serves encrypted traffic at: " +
        "https://{0}:{1}".format(login_host, options.https_port))
    else:
      raise AppScaleException(relocate_result)
    def relocate_app(cls, options):
        """Instructs AppScale to move the named application to a different port.

    Args:
      options: A Namespace that has fields for each parameter that can be passed
        in via the command-line interface.
    Raises:
      AppScaleException: If the named application isn't running in this AppScale
        cloud, if the destination port is in use by a different application, or
        if the AppController rejects the request to relocate the application (in
        which case it includes the reason why the rejection occurred).
    """
        login_host = LocalState.get_login_host(options.keyname)
        acc = AppControllerClient(login_host,
                                  LocalState.get_secret_key(options.keyname))

        app_info_map = acc.get_app_info_map()
        if options.appname not in app_info_map.keys():
            raise AppScaleException("The given application, {0}, is not currently " \
              "running in this AppScale cloud, so we can't move it to a different " \
              "port.".format(options.appname))

        relocate_result = acc.relocate_app(options.appname, options.http_port,
                                           options.https_port)
        if relocate_result == "OK":
            AppScaleLogger.success("Successfully issued request to move {0} to " \
              "ports {1} and {2}.".format(options.appname, options.http_port,
              options.https_port))
            RemoteHelper.sleep_until_port_is_open(login_host,
                                                  options.http_port,
                                                  options.verbose)
            AppScaleLogger.success(
                "Your app serves unencrypted traffic at: " +
                "http://{0}:{1}".format(login_host, options.http_port))
            AppScaleLogger.success(
                "Your app serves encrypted traffic at: " +
                "https://{0}:{1}".format(login_host, options.https_port))
        else:
            raise AppScaleException(relocate_result)