Esempio n. 1
0
    def deploy(self, app, project_id=None):
        """ 'deploy' is a more accessible way to tell an AppScale deployment to run a
    Google App Engine application than 'appscale-upload-app'. It calls that
    command with the configuration options found in the AppScalefile in the
    current working directory.

    Args:
      app: The path (absolute or relative) to the Google App Engine application
        that should be uploaded.
      project_id: Which project ID to use to deploy the application.
    Returns:
      A tuple containing the host and port where the application is serving
        traffic from.
    Raises:
      AppScalefileException: If there is no AppScalefile in the current working
      directory.
    """
        contents = self.read_appscalefile()

        # Construct an upload-app command from the file's contents
        command = []
        contents_as_yaml = yaml.safe_load(contents)
        if 'keyname' in contents_as_yaml:
            command.append("--keyname")
            command.append(contents_as_yaml['keyname'])

        if 'test' in contents_as_yaml and contents_as_yaml['test'] == True:
            command.append("--test")

        if 'verbose' in contents_as_yaml and contents_as_yaml[
                'verbose'] == True:
            command.append("--verbose")

        command.append("--file")
        command.append(app)

        if project_id is not None:
            command.append("--project")
            command.append(project_id)

        # Finally, exec the command. Don't worry about validating it -
        # appscale-upload-app will do that for us.
        options = ParseArgs(command, "appscale-upload-app").args
        login_host, http_port = AppScaleTools.upload_app(options)
        AppScaleTools.update_indexes(options.file, options.keyname,
                                     options.project)
        AppScaleTools.update_cron(options.file, options.keyname,
                                  options.project)
        AppScaleTools.update_queues(options.file, options.keyname,
                                    options.project)
        try:
            AppScaleTools.update_dispatch(options.file, options.keyname,
                                          options.project)
        except (AdminError, AppScaleException) as e:
            AppScaleLogger.warn(
                'Request to update dispatch failed, if your '
                'dispatch references undeployed services, ignore '
                'this exception: {}'.format(e))
        return login_host, http_port
Esempio n. 2
0
  def deploy(self, app, project_id=None):
    """ 'deploy' is a more accessible way to tell an AppScale deployment to run a
    Google App Engine application than 'appscale-upload-app'. It calls that
    command with the configuration options found in the AppScalefile in the
    current working directory.

    Args:
      app: The path (absolute or relative) to the Google App Engine application
        that should be uploaded.
      project_id: Which project ID to use to deploy the application.
    Returns:
      A tuple containing the host and port where the application is serving
        traffic from.
    Raises:
      AppScalefileException: If there is no AppScalefile in the current working
      directory.
    """
    contents = self.read_appscalefile()

    # Construct an upload-app command from the file's contents
    command = []
    contents_as_yaml = yaml.safe_load(contents)
    if 'keyname' in contents_as_yaml:
      command.append("--keyname")
      command.append(contents_as_yaml['keyname'])

    if 'test' in contents_as_yaml and contents_as_yaml['test'] == True:
      command.append("--test")

    if 'verbose' in contents_as_yaml and contents_as_yaml['verbose'] == True:
      command.append("--verbose")

    command.append("--file")
    command.append(app)

    if project_id is not None:
      command.append("--project")
      command.append(project_id)

    # Finally, exec the command. Don't worry about validating it -
    # appscale-upload-app will do that for us.
    options = ParseArgs(command, "appscale-upload-app").args
    login_host, http_port = AppScaleTools.upload_app(options)
    AppScaleTools.update_cron(options.file, options.keyname)
    AppScaleTools.update_queues(options.file, options.keyname)
    return login_host, http_port