Esempio n. 1
0
def add_routing(app, port):
    """ Tells the AppController to begin routing traffic to an AppServer.

  Args:
    app: A string that contains the application ID.
    port: A string that contains the port that the AppServer listens on.
  """
    logging.info("Waiting for application {} on port {} to be active.".format(
        str(app), str(port)))
    if not wait_on_app(port):
        # In case the AppServer fails we let the AppController to detect it
        # and remove it if it still show in monit.
        logging.warning("AppServer did not come up in time, for {}:{}.".format(
            str(app), str(port)))
        return

    acc = appscale_info.get_appcontroller_client()
    appserver_ip = appscale_info.get_private_ip()

    while True:
        result = acc.add_routing_for_appserver(app, appserver_ip, port)
        if result == AppControllerClient.NOT_READY:
            logging.info('AppController not yet ready to add routing.')
            time.sleep(ROUTING_RETRY_INTERVAL)
        else:
            break

    logging.info('Successfully established routing for {} on port {}'.format(
        app, port))
Esempio n. 2
0
def main():
  global datastore_path
  global deployment_config

  logging.basicConfig(format=LOG_FORMAT, level=logging.INFO)

  parser = argparse.ArgumentParser()
  parser.add_argument('-p', '--port', type=int, default=DEFAULT_PORT,
                      required=True, help="The blobstore server's port")
  parser.add_argument('-d', '--datastore-path', required=True,
                      help='The location of the datastore server')
  args = parser.parse_args()

  datastore_path = args.datastore_path
  deployment_config = DeploymentConfig(appscale_info.get_zk_locations_string())
  setup_env()

  http_server = tornado.httpserver.HTTPServer(
    Application(), max_buffer_size=MAX_REQUEST_BUFF_SIZE)

  http_server.listen(args.port)

  acc = appscale_info.get_appcontroller_client()
  acc.add_routing_for_blob_server()

  logging.info('Starting BlobServer on {}'.format(args.port))
  tornado.ioloop.IOLoop.instance().start()
Esempio n. 3
0
def add_routing(app, port):
  """ Tells the AppController to begin routing traffic to an AppServer.

  Args:
    app: A string that contains the application ID.
    port: A string that contains the port that the AppServer listens on.
  """
  logging.info("Waiting for application {} on port {} to be active.".
    format(str(app), str(port)))
  if not wait_on_app(port):
    # In case the AppServer fails we let the AppController to detect it
    # and remove it if it still show in monit.
    logging.warning("AppServer did not come up in time, for {}:{}.".
      format(str(app), str(port)))
    return

  acc = appscale_info.get_appcontroller_client()
  appserver_ip = appscale_info.get_private_ip()

  while True:
    result = acc.add_routing_for_appserver(app, appserver_ip, port)
    if result == AppControllerClient.NOT_READY:
      logging.info('AppController not yet ready to add routing.')
      time.sleep(ROUTING_RETRY_INTERVAL)
    else:
      break

  logging.info('Successfully established routing for {} on port {}'.
    format(app, port))
Esempio n. 4
0
def main():
  global datastore_path
  global deployment_config

  logging.basicConfig(format=LOG_FORMAT, level=logging.INFO)

  parser = argparse.ArgumentParser()
  parser.add_argument('-p', '--port', type=int, default=DEFAULT_PORT,
                      required=True, help="The blobstore server's port")
  parser.add_argument('-d', '--datastore-path', required=True,
                      help='The location of the datastore server')
  args = parser.parse_args()

  datastore_path = args.datastore_path
  deployment_config = DeploymentConfig(appscale_info.get_zk_locations_string())
  setup_env()

  http_server = tornado.httpserver.HTTPServer(
    Application(), max_buffer_size=MAX_REQUEST_BUFF_SIZE)

  http_server.listen(args.port)

  acc = appscale_info.get_appcontroller_client()
  acc.add_routing_for_blob_server()

  logging.info('Starting BlobServer on {}'.format(args.port))
  tornado.ioloop.IOLoop.instance().start()
Esempio n. 5
0
def remove_routing(app, port):
  """ Tells the AppController to stop routing traffic to an AppServer.

  Args:
    app: A string that contains the application ID.
    port: A string that contains the port that the AppServer listens on.
  """
  acc = appscale_info.get_appcontroller_client()
  appserver_ip = appscale_info.get_private_ip()
  acc.remove_appserver_from_haproxy(app, appserver_ip, port)
Esempio n. 6
0
def remove_routing(app, port):
    """ Tells the AppController to stop routing traffic to an AppServer.

  Args:
    app: A string that contains the application ID.
    port: A string that contains the port that the AppServer listens on.
  """
    acc = appscale_info.get_appcontroller_client()
    appserver_ip = appscale_info.get_private_ip()
    acc.remove_appserver_from_haproxy(app, appserver_ip, port)
Esempio n. 7
0
def get_cluster_stats():
  """ Collects platform stats from all deployment nodes.

  Returns:
    A dictionary containing all the monitoring stats, if all nodes are
    accessible. {"success": False, "error": message} otherwise.
  """
  acc = appscale_info.get_appcontroller_client()
  nodes_stats = acc.get_cluster_stats()
  return {node["public_ip"]: node for node in nodes_stats}
Esempio n. 8
0
def get_deployment_id():
  """ Retrieves the deployment ID for this AppScale deployment.

  Returns:
    A str, the secret key used for registering this deployment with the
    AppScale Portal. None if the deployment is not registered.
  """
  acc = appscale_info.get_appcontroller_client()
  if acc.deployment_id_exists():
    return acc.get_deployment_id()
  return None
Esempio n. 9
0
def get_deployment_id():
  """ Retrieves the deployment ID for this AppScale deployment.

  Returns:
    A str, the secret key used for registering this deployment with the
    AppScale Portal. None if the deployment is not registered.
  """
  try:
    acc = appscale_info.get_appcontroller_client()
    if acc.deployment_id_exists():
      return acc.get_deployment_id()
  except AppControllerException:
    logging.exception("AppControllerException while querying for deployment "
      "ID.")
    return None
Esempio n. 10
0
def get_deployment_id():
  """ Retrieves the deployment ID for this AppScale deployment.

  Returns:
    A str, the secret key used for registering this deployment with the
    AppScale Portal. None if the deployment is not registered.
  """
  try:
    acc = appscale_info.get_appcontroller_client()
    if acc.deployment_id_exists():
      return acc.get_deployment_id()
  except AppControllerException:
    logging.exception("AppControllerException while querying for deployment "
      "ID.")
    return None
Esempio n. 11
0
def main(port):
    """ Initialization code of the blobstore server. 
  
   Args:
     port: The port to bind to for this service.
  """
    setup_env()

    http_server = tornado.httpserver.HTTPServer(
        Application(), max_buffer_size=MAX_REQUEST_BUFF_SIZE)
    http_server.listen(int(port))

    acc = appscale_info.get_appcontroller_client()
    acc.add_routing_for_blob_server()
    logging.info('Added routing for BlobServer'.format(port))

    logging.info('Starting BlobServer on {}'.format(port))
    tornado.ioloop.IOLoop.instance().start()
Esempio n. 12
0
def main(port):
  """ Initialization code of the blobstore server. 
  
   Args:
     port: The port to bind to for this service.
  """
  setup_env()

  http_server = tornado.httpserver.HTTPServer(Application(),
    max_buffer_size=MAX_REQUEST_BUFF_SIZE)
  http_server.listen(int(port))

  acc = appscale_info.get_appcontroller_client()
  acc.add_routing_for_blob_server()
  logging.info('Added routing for BlobServer'.format(port))

  logging.info('Starting BlobServer on {}'.format(port))
  tornado.ioloop.IOLoop.instance().start()
Esempio n. 13
0
def add_routing(app, port):
    """ Tells the AppController to begin routing traffic to an AppServer.

  Args:
    app: A string that contains the application ID.
    port: A string that contains the port that the AppServer listens on.
  """
    acc = appscale_info.get_appcontroller_client()
    appserver_ip = appscale_info.get_private_ip()

    while True:
        result = acc.add_routing_for_appserver(app, appserver_ip, port)
        if result == NOT_READY:
            logging.info("AppController not yet ready to add routing.")
            time.sleep(ROUTING_RETRY_INTERVAL)
        else:
            break

    logging.info("Successfully established routing for {} on port {}".format(app, port))
Esempio n. 14
0
def add_routing(app, port):
    """ Tells the AppController to begin routing traffic to an AppServer.

  Args:
    app: A string that contains the application ID.
    port: A string that contains the port that the AppServer listens on.
  """
    acc = appscale_info.get_appcontroller_client()
    appserver_ip = appscale_info.get_private_ip()

    while True:
        result = acc.add_routing_for_appserver(app, appserver_ip, port)
        if result == AppControllerClient.NOT_READY:
            logging.info('AppController not yet ready to add routing.')
            time.sleep(ROUTING_RETRY_INTERVAL)
        else:
            break

    logging.info('Successfully established routing for {} on port {}'.format(
        app, port))
Esempio n. 15
0
def deploy_sensor_app():
    """ Uploads the sensor app for registered deployments. """

    deployment_id = helper.get_deployment_id()
    #If deployment is not registered, then do nothing.
    if not deployment_id:
        return

    uaserver = SOAPpy.SOAPProxy('https://{0}:{1}'.format(
        appscale_info.get_db_master_ip(), hermes_constants.UA_SERVER_PORT))

    # If the appscalesensor app is already running, then do nothing.
    is_app_enabled = uaserver.is_app_enabled(hermes_constants.APPSCALE_SENSOR,
                                             appscale_info.get_secret())
    if is_app_enabled == "true":
        return

    pwd = appscale_utils.encrypt_password(
        hermes_constants.USER_EMAIL,
        appscale_utils.random_password_generator())
    if create_appscale_user(pwd, uaserver) and create_xmpp_user(pwd, uaserver):
        logging.debug("Created new user and now tarring app to be deployed.")
        file_path = os.path.join(os.path.dirname(__file__), '../Apps/sensor')
        app_dir_location = os.path.join(hermes_constants.APP_DIR_LOCATION,
                                        hermes_constants.APPSCALE_SENSOR)
        archive = tarfile.open(app_dir_location, "w|gz")
        archive.add(file_path, arcname=hermes_constants.APPSCALE_SENSOR)
        archive.close()

        try:
            logging.info(
                "Deploying the sensor app for registered deployments.")
            acc = appscale_info.get_appcontroller_client()
            acc.upload_app(app_dir_location, hermes_constants.FILE_SUFFIX,
                           hermes_constants.USER_EMAIL)
        except AppControllerException:
            logging.exception("AppControllerException while trying to deploy "
                              "appscalesensor app.")
    else:
        logging.error("Error while creating or accessing the user to deploy "
                      "appscalesensor app.")
Esempio n. 16
0
def deploy_sensor_app():
  """ Uploads the sensor app for registered deployments. """

  deployment_id = helper.get_deployment_id()
  #If deployment is not registered, then do nothing.
  if not deployment_id:
    return

  uaserver = SOAPpy.SOAPProxy('https://{0}:{1}'.format(
    appscale_info.get_db_master_ip(), hermes_constants.UA_SERVER_PORT))

  # If the appscalesensor app is already running, then do nothing.
  is_app_enabled = uaserver.is_app_enabled(hermes_constants.APPSCALE_SENSOR,
    appscale_info.get_secret())
  if is_app_enabled == "true":
    return

  pwd = appscale_utils.encrypt_password(hermes_constants.USER_EMAIL,
    appscale_utils.random_password_generator())
  if create_appscale_user(pwd, uaserver) and create_xmpp_user(pwd, uaserver):
    logging.debug("Created new user and now tarring app to be deployed.")
    file_path = os.path.join(os.path.dirname(__file__), '../Apps/sensor')
    app_dir_location = os.path.join(hermes_constants.APP_DIR_LOCATION,
      hermes_constants.APPSCALE_SENSOR)
    archive = tarfile.open(app_dir_location, "w|gz")
    archive.add(file_path, arcname= hermes_constants.APPSCALE_SENSOR)
    archive.close()

    try:
      logging.info("Deploying the sensor app for registered deployments.")
      acc = appscale_info.get_appcontroller_client()
      acc.upload_app(app_dir_location, hermes_constants.FILE_SUFFIX,
        hermes_constants.USER_EMAIL)
    except AppControllerException:
      logging.exception("AppControllerException while trying to deploy "
        "appscalesensor app.")
  else:
    logging.error("Error while creating or accessing the user to deploy "
      "appscalesensor app.")
Esempio n. 17
0
  A string containing 'on' or 'off'.
Returns:
  A string indicating whether or not the operation was a success.
"""

import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), "../lib/"))
import appscale_info

if __name__ == '__main__':
  make_active = False
  if len(sys.argv) < 2 or sys.argv[1] not in ['on', 'off']:
    print('Please give a value of "on" or "off".')
    sys.exit(1)

  if sys.argv[1] == 'on':
    make_active = True

  acc = appscale_info.get_appcontroller_client()
  result = acc.set_read_only(str(make_active).lower())
  if result != 'OK':
    print(result)
    sys.exit(1)

  if make_active:
    print('Datastore writes are now disabled.')
  else:
    print('Datastore writes are now enabled.')
Esempio n. 18
0
        return
      else:
        self.finish(UPLOAD_ERROR + "</br>" + str(e.hdrs) + "</br>" + str(e))
        return


if __name__ == "__main__":
  logging.basicConfig(format=LOG_FORMAT, level=logging.INFO)

  parser = argparse.ArgumentParser()
  parser.add_argument('-p', '--port', type=int, default=DEFAULT_PORT,
                      required=True, help="The blobstore server's port")
  parser.add_argument('-d', '--datastore-path', required=True,
                      help='The location of the datastore server')
  args = parser.parse_args()

  datastore_path = args.datastore_path
  deployment_config = DeploymentConfig(appscale_info.get_zk_locations_string())
  setup_env()

  http_server = tornado.httpserver.HTTPServer(
    Application(), max_buffer_size=MAX_REQUEST_BUFF_SIZE)

  http_server.listen(args.port)

  acc = appscale_info.get_appcontroller_client()
  acc.add_routing_for_blob_server()

  logging.info('Starting BlobServer on {}'.format(args.port))
  tornado.ioloop.IOLoop.instance().start()