Example #1
0
  def get_public_ip(self):
    """ Gets the public IP to which the task calls are routed.

    Returns:
      The primary loadbalancer IP/hostname.
    """
    return appscale_info.get_login_ip()
Example #2
0
def deploy_apps(app_paths):
    """ Deploys all apps that reside in /opt/appscale/apps.

  Args:
    app_paths: A list of the full paths of the apps to be deployed.
  Returns:
    True on success, False otherwise.
  """
    uaserver = SOAPpy.SOAPProxy('https://{0}:{1}'.format(
        appscale_info.get_db_master_ip(), UA_SERVER_PORT))

    acc = AppControllerClient(appscale_info.get_login_ip(),
                              appscale_info.get_secret())

    # Wait for Cassandra to come up after a restore.
    time.sleep(15)

    for app_path in app_paths:
        # Extract app ID.
        app_id = app_path[app_path.rfind('/') + 1:app_path.find('.')]
        if not app_id:
            logging.error(
                "Malformed source code archive. Cannot complete "
                "application recovery for '{}'. Aborting...".format(app_path))
            return False

        # Retrieve app admin via uaserver.
        app_data = uaserver.get_app_data(app_id, appscale_info.get_secret())

        app_admin_re = re.search("\napp_owner:(.+)\n", app_data)
        if app_admin_re:
            app_admin = app_admin_re.group(1)
        else:
            logging.error(
                "Missing application data. Cannot complete application "
                "recovery for '{}'. Aborting...".format(app_id))
            return False

        file_suffix = re.search("\.(.*)\Z", app_path).group(1)

        logging.warning(
            "Restoring app '{}', from '{}', with owner '{}'.".format(
                app_id, app_path, app_admin))

        acc.upload_app(app_path, file_suffix, app_admin)

    return True
def deploy_apps(app_paths):
  """ Deploys all apps that reside in /opt/appscale/apps.

  Args:
    app_paths: A list of the full paths of the apps to be deployed.
  Returns:
    True on success, False otherwise.
  """
  uaserver = SOAPpy.SOAPProxy('https://{0}:{1}'.format(
    appscale_info.get_db_master_ip(), UA_SERVER_PORT))

  acc = AppControllerClient(appscale_info.get_login_ip(),
    appscale_info.get_secret())

  # Wait for Cassandra to come up after a restore.
  time.sleep(15)

  for app_path in app_paths:
    # Extract app ID.
    app_id = app_path[app_path.rfind('/')+1:app_path.find('.')]
    if not app_id:
      logging.error("Malformed source code archive. Cannot complete "
        "application recovery for '{}'. Aborting...".format(app_path))
      return False

    # Retrieve app admin via uaserver.
    app_data = uaserver.get_app_data(app_id, appscale_info.get_secret())

    app_admin_re = re.search("\napp_owner:(.+)\n", app_data)
    if app_admin_re:
      app_admin = app_admin_re.group(1)
    else:
      logging.error("Missing application data. Cannot complete application "
        "recovery for '{}'. Aborting...".format(app_id))
      return False

    file_suffix = re.search("\.(.*)\Z", app_path).group(1)

    logging.warning("Restoring app '{}', from '{}', with owner '{}'.".
      format(app_id, app_path, app_admin))

    acc.upload_app(app_path, file_suffix, app_admin)

  return True
Example #4
0
def create_xmpp_user(password, uaserver):
  """ Creates the XMPP account. If the user's email is [email protected], then that
  means their XMPP account name is a@login_ip. """
  username_regex = re.compile('\A(.*)@')
  username = username_regex.match(hermes_constants.USER_EMAIL).groups()[0]
  xmpp_user = "******".format(username, appscale_info.get_login_ip())
  xmpp_pass = appscale_utils.encrypt_password(xmpp_user, password)
  does_user_exist = uaserver.does_user_exist(xmpp_user,
    appscale_info.get_secret())
  if does_user_exist == "true":
    logging.debug("XMPP User {0} already exists, so not creating it again.".
      format(xmpp_user))
    return True
  else:
    if uaserver.commit_new_user(xmpp_user, xmpp_pass,
        hermes_constants.ACCOUNT_TYPE, appscale_info.get_secret()) == "true":
      logging.info("XMPP username is {0}".format(xmpp_user))
      return True
    else:
      logging.error("Error while creating an XMPP user.")
      return False
Example #5
0
def create_xmpp_user(password, uaserver):
  """ Creates the XMPP account. If the user's email is [email protected], then that
  means their XMPP account name is a@login_ip. """
  username_regex = re.compile('\A(.*)@')
  username = username_regex.match(hermes_constants.USER_EMAIL).groups()[0]
  xmpp_user = "******".format(username, appscale_info.get_login_ip())
  xmpp_pass = appscale_utils.encrypt_password(xmpp_user, password)
  does_user_exist = uaserver.does_user_exist(xmpp_user,
    appscale_info.get_secret())
  if does_user_exist == "true":
    logging.debug("XMPP User {0} already exists, so not creating it again.".
      format(xmpp_user))
    return True
  else:
    if uaserver.commit_new_user(xmpp_user, xmpp_pass,
        hermes_constants.ACCOUNT_TYPE, appscale_info.get_secret()) == "true":
      logging.info("XMPP username is {0}".format(xmpp_user))
      return True
    else:
      logging.error("Error while creating an XMPP user.")
      return False