Пример #1
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
  zk_ips = appscale_info.get_zk_node_ips()
  zk_client = KazooClient(hosts=','.join(zk_ips))
  zk_client.start()
  deployment_config = DeploymentConfig(zk_client)
  setup_env()

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

  http_server.listen(args.port)

  # Make sure this server is accessible from each of the load balancers.
  secret = appscale_info.get_secret()
  for load_balancer in appscale_info.get_load_balancer_ips():
    acc = AppControllerClient(load_balancer, secret)
    acc.add_routing_for_blob_server()

  logger.info('Starting BlobServer on {}'.format(args.port))
  tornado.ioloop.IOLoop.instance().start()
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.
  """
    secret = appscale_info.get_secret()
    acc = AppControllerClient(appscale_info.get_headnode_ip(), 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

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

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

        acc.upload_app(app_path, file_suffix)

    return True
Пример #3
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.
  """
  secret = appscale_info.get_secret()
  acc = AppControllerClient(appscale_info.get_headnode_ip(), 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

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

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

    acc.upload_app(app_path, file_suffix)

  return True
Пример #4
0
def get_appcontroller_client():
    """ Returns an AppControllerClient instance for this deployment. """
    raw_ips = file_io.read('/etc/appscale/load_balancer_ips')
    ips = raw_ips.split('\n')
    head_node = ips[0]

    secret_file = '/etc/appscale/secret.key'
    secret = read_file_contents(secret_file)

    return AppControllerClient(head_node, secret)
Пример #5
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
    zk_ips = appscale_info.get_zk_node_ips()
    zk_client = KazooClient(hosts=','.join(zk_ips))
    zk_client.start()
    deployment_config = DeploymentConfig(zk_client)
    setup_env()

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

    http_server.listen(args.port)

    # Make sure this server is accessible from each of the load balancers.
    secret = appscale_info.get_secret()
    for load_balancer in appscale_info.get_load_balancer_ips():
        acc = AppControllerClient(load_balancer, secret)
        acc.add_routing_for_blob_server()

    logger.info('Starting BlobServer on {}'.format(args.port))
    tornado.ioloop.IOLoop.instance().start()
Пример #6
0
  def get_appcontroller_client(self, server_ip=CONTROLLER_LOCATION):
    """ Retrieves our saved AppController connection, creating a new one if none
    currently exist.

    Args:
      server_ip: An IP address specifying which machine to make AppController
        calls to.
    Returns:
      An AppControllerClient, representing a connection to the AppController.
    """
    if self.appcontroller is None:
      self.appcontroller = AppControllerClient(server_ip, GLOBAL_SECRET_KEY)
    return self.appcontroller