Пример #1
0
    def test_dont_warn_users_on_supported_deployment_strategies(self):
        # all simple deployment strategies are supported
        input_yaml_1 = {'controller': self.ip_1}
        options_1 = self.default_options.copy()
        options_1['ips'] = input_yaml_1
        layout_1 = NodeLayout(options_1)
        self.assertEquals(True, layout_1.is_supported())

        input_yaml_2 = {'controller': self.ip_1, 'servers': [self.ip_2]}
        options_2 = self.default_options.copy()
        options_2['ips'] = input_yaml_2
        layout_2 = NodeLayout(options_2)
        self.assertEquals(True, layout_2.is_supported())

        input_yaml_3 = {
            'controller': self.ip_1,
            'servers': [self.ip_2, self.ip_3]
        }
        options_3 = self.default_options.copy()
        options_3['ips'] = input_yaml_3
        layout_3 = NodeLayout(options_3)
        self.assertEquals(True, layout_3.is_supported())

        # in advanced deployments, four nodes are ok with the following
        # layout: (1) load balancer, (2) appserver, (3) database,
        # (4) zookeeper
        advanced_yaml_1 = {
            'master': self.ip_1,
            'appengine': self.ip_2,
            'database': self.ip_3,
            'zookeeper': self.ip_4
        }
        options_1 = self.default_options.copy()
        options_1['ips'] = advanced_yaml_1
        advanced_layout_1 = NodeLayout(options_1)
        self.assertEquals(True, advanced_layout_1.is_valid())
        self.assertEquals(True, advanced_layout_1.is_supported())

        # in advanced deployments, eight nodes are ok with the following
        # layout: (1) load balancer, (2) appserver, (3) appserver,
        # (4) database, (5) database, (6) zookeeper, (7) zookeeper,
        # (8) zookeeper
        advanced_yaml_2 = {
            'master': self.ip_1,
            'appengine': [self.ip_2, self.ip_3],
            'database': [self.ip_4, self.ip_5],
            'zookeeper': [self.ip_6, self.ip_7, self.ip_8]
        }
        options_2 = self.default_options.copy()
        options_2['ips'] = advanced_yaml_2
        advanced_layout_2 = NodeLayout(options_2)
        self.assertEquals(True, advanced_layout_2.is_valid())
        self.assertEquals(True, advanced_layout_2.is_supported())
Пример #2
0
  def test_dont_warn_users_on_supported_deployment_strategies(self):
    # all simple deployment strategies are supported
    input_yaml_1 = {'controller' : self.ip_1}
    options_1 = self.default_options.copy()
    options_1['ips'] = input_yaml_1
    layout_1 = NodeLayout(options_1)
    self.assertEquals(True, layout_1.is_supported())

    input_yaml_2 = {'controller' : self.ip_1, 'servers' : [self.ip_2]}
    options_2 = self.default_options.copy()
    options_2['ips'] = input_yaml_2
    layout_2 = NodeLayout(options_2)
    self.assertEquals(True, layout_2.is_supported())

    input_yaml_3 = {'controller' : self.ip_1, 'servers' : [self.ip_2, self.ip_3]}
    options_3 = self.default_options.copy()
    options_3['ips'] = input_yaml_3
    layout_3 = NodeLayout(options_3)
    self.assertEquals(True, layout_3.is_supported())

    # in advanced deployments, four nodes are ok with the following
    # layout: (1) load balancer, (2) appserver, (3) database,
    # (4) zookeeper
    advanced_yaml_1 = {
      'master' : self.ip_1,
      'appengine' : self.ip_2,
      'database' : self.ip_3,
      'zookeeper' : self.ip_4
    }
    options_1 = self.default_options.copy()
    options_1['ips'] = advanced_yaml_1
    advanced_layout_1 = NodeLayout(options_1)
    self.assertEquals(True, advanced_layout_1.is_valid())
    self.assertEquals(True, advanced_layout_1.is_supported())

    # in advanced deployments, eight nodes are ok with the following
    # layout: (1) load balancer, (2) appserver, (3) appserver,
    # (4) database, (5) database, (6) zookeeper, (7) zookeeper,
    # (8) zookeeper
    advanced_yaml_2 = {
      'master' : self.ip_1,
      'appengine' : [self.ip_2, self.ip_3],
      'database' : [self.ip_4, self.ip_5],
      'zookeeper' : [self.ip_6, self.ip_7, self.ip_8]
    }
    options_2 = self.default_options.copy()
    options_2['ips'] = advanced_yaml_2
    advanced_layout_2 = NodeLayout(options_2)
    self.assertEquals(True, advanced_layout_2.is_valid())
    self.assertEquals(True, advanced_layout_2.is_supported())
Пример #3
0
  def test_warn_users_on_unsupported_deployment_strategies(self):
    # don't test simple deployments - those are all supported
    # instead, test out some variations of the supported advanced
    # strategies, as those should not be supported
    advanced_yaml_1 = {
      'master' : self.ip_1,
      'appengine' : self.ip_1,
      'database' : self.ip_2,
      'zookeeper' : self.ip_2
    }
    options_1 = self.default_options.copy()
    options_1['ips'] = advanced_yaml_1
    advanced_layout_1 = NodeLayout(options_1)
    self.assertEquals(True, advanced_layout_1.is_valid())
    self.assertEquals(False, advanced_layout_1.is_supported())

    # four node deployments that don't match the only supported
    # deployment are not supported
    advanced_yaml_2 = {
      'master' : self.ip_1,
      'appengine' : self.ip_2,
      'database' : self.ip_3,
      'zookeeper' : self.ip_3,
      'open' : self.ip_4
    }
    options_2 = self.default_options.copy()
    options_2['ips'] = advanced_yaml_2
    advanced_layout_2 = NodeLayout(options_2)
    self.assertEquals(True, advanced_layout_2.is_valid())
    self.assertEquals(False, advanced_layout_2.is_supported())

    # eight node deployments that don't match the only supported
    # deployment are not supported
    advanced_yaml_3 = {
      'master' : self.ip_1,
      'appengine' : [self.ip_2, self.ip_3],
      'database' : [self.ip_4, self.ip_5],
      'zookeeper' : [self.ip_6, self.ip_7],
      'open' : self.ip_8
    }
    options_3 = self.default_options.copy()
    options_3['ips'] = advanced_yaml_3
    advanced_layout_3 = NodeLayout(options_3)
    self.assertEquals(True, advanced_layout_3.is_valid())
    self.assertEquals(False, advanced_layout_3.is_supported())
Пример #4
0
    def test_warn_users_on_unsupported_deployment_strategies(self):
        # don't test simple deployments - those are all supported
        # instead, test out some variations of the supported advanced
        # strategies, as those should not be supported
        advanced_yaml_1 = {
            'master': self.ip_1,
            'appengine': self.ip_1,
            'database': self.ip_2,
            'zookeeper': self.ip_2
        }
        options_1 = self.default_options.copy()
        options_1['ips'] = advanced_yaml_1
        advanced_layout_1 = NodeLayout(options_1)
        self.assertEquals(True, advanced_layout_1.is_valid())
        self.assertEquals(False, advanced_layout_1.is_supported())

        # four node deployments that don't match the only supported
        # deployment are not supported
        advanced_yaml_2 = {
            'master': self.ip_1,
            'appengine': self.ip_2,
            'database': self.ip_3,
            'zookeeper': self.ip_3,
            'open': self.ip_4
        }
        options_2 = self.default_options.copy()
        options_2['ips'] = advanced_yaml_2
        advanced_layout_2 = NodeLayout(options_2)
        self.assertEquals(True, advanced_layout_2.is_valid())
        self.assertEquals(False, advanced_layout_2.is_supported())

        # eight node deployments that don't match the only supported
        # deployment are not supported
        advanced_yaml_3 = {
            'master': self.ip_1,
            'appengine': [self.ip_2, self.ip_3],
            'database': [self.ip_4, self.ip_5],
            'zookeeper': [self.ip_6, self.ip_7],
            'open': self.ip_8
        }
        options_3 = self.default_options.copy()
        options_3['ips'] = advanced_yaml_3
        advanced_layout_3 = NodeLayout(options_3)
        self.assertEquals(True, advanced_layout_3.is_valid())
        self.assertEquals(False, advanced_layout_3.is_supported())
Пример #5
0
  def run_instances(cls, options):
    """Starts a new AppScale deployment with the parameters given.

    Args:
      options: A Namespace that has fields for each parameter that can be
        passed in via the command-line interface.
    Raises:
      BadConfigurationException: If the user passes in options that are not
        sufficient to start an AppScale deplyoment (e.g., running on EC2 but
        not specifying the AMI to use), or if the user provides us
        contradictory options (e.g., running on EC2 but not specifying EC2
        credentials).
    """
    LocalState.make_appscale_directory()
    LocalState.ensure_appscale_isnt_running(options.keyname, options.force)

    if options.infrastructure:
      AppScaleLogger.log("Starting AppScale " + APPSCALE_VERSION +
        " over the " + options.infrastructure + " cloud.")
    else:
      AppScaleLogger.log("Starting AppScale " + APPSCALE_VERSION +
        " over a virtualized cluster.")
    my_id = str(uuid.uuid4())
    AppScaleLogger.remote_log_tools_state(options, my_id, "started",
      APPSCALE_VERSION)

    node_layout = NodeLayout(options)
    if not node_layout.is_valid():
      raise BadConfigurationException("There were errors with your " + \
        "placement strategy:\n{0}".format(str(node_layout.errors())))

    if not node_layout.is_supported():
      AppScaleLogger.warn("Warning: This deployment strategy is not " + \
        "officially supported.")

    public_ip, instance_id = RemoteHelper.start_head_node(options, my_id,
      node_layout)
    AppScaleLogger.log("\nPlease wait for AppScale to prepare your machines " +
      "for use.")

    # Write our metadata as soon as possible to let users SSH into those
    # machines via 'appscale ssh'
    LocalState.update_local_metadata(options, node_layout, public_ip,
      instance_id)
    RemoteHelper.copy_local_metadata(public_ip, options.keyname,
      options.verbose)

    acc = AppControllerClient(public_ip, LocalState.get_secret_key(
      options.keyname))
    uaserver_host = acc.get_uaserver_host(options.verbose)

    RemoteHelper.sleep_until_port_is_open(uaserver_host, UserAppClient.PORT,
      options.verbose)

    # Update our metadata again so that users can SSH into other boxes that
    # may have been started.
    LocalState.update_local_metadata(options, node_layout, public_ip,
      instance_id)
    RemoteHelper.copy_local_metadata(public_ip, options.keyname,
      options.verbose)

    AppScaleLogger.log("UserAppServer is at {0}".format(uaserver_host))

    uaserver_client = UserAppClient(uaserver_host,
      LocalState.get_secret_key(options.keyname))

    if options.admin_user and options.admin_pass:
      AppScaleLogger.log("Using the provided admin username/password")
      username, password = options.admin_user, options.admin_pass
    elif options.test:
      AppScaleLogger.log("Using default admin username/password")
      username, password = LocalState.DEFAULT_USER, LocalState.DEFAULT_PASSWORD
    else:
      username, password = LocalState.get_credentials()

    RemoteHelper.create_user_accounts(username, password, uaserver_host,
      options.keyname)
    uaserver_client.set_admin_role(username)

    RemoteHelper.wait_for_machines_to_finish_loading(public_ip, options.keyname)
    # Finally, update our metadata once we know that all of the machines are
    # up and have started all their API services.
    LocalState.update_local_metadata(options, node_layout, public_ip,
      instance_id)
    RemoteHelper.copy_local_metadata(public_ip, options.keyname, options.verbose)

    RemoteHelper.sleep_until_port_is_open(LocalState.get_login_host(
      options.keyname), RemoteHelper.APP_LOAD_BALANCER_PORT, options.verbose)
    AppScaleLogger.success("AppScale successfully started!")
    AppScaleLogger.success("View status information about your AppScale " + \
      "deployment at http://{0}/status".format(LocalState.get_login_host(
      options.keyname)))
    AppScaleLogger.remote_log_tools_state(options, my_id,
      "finished", APPSCALE_VERSION)
Пример #6
0
    def run_instances(cls, options):
        """Starts a new AppScale deployment with the parameters given.

    Args:
      options: A Namespace that has fields for each parameter that can be
        passed in via the command-line interface.
    Raises:
      AppControllerException: If the AppController on the head node crashes.
        When this occurs, the message in the exception contains the reason why
        the AppController crashed.
      BadConfigurationException: If the user passes in options that are not
        sufficient to start an AppScale deployment (e.g., running on EC2 but
        not specifying the AMI to use), or if the user provides us
        contradictory options (e.g., running on EC2 but not specifying EC2
        credentials).
    """
        LocalState.make_appscale_directory()
        LocalState.ensure_appscale_isnt_running(options.keyname, options.force)

        if options.infrastructure:
            if not options.disks and not options.test and not options.force:
                LocalState.ensure_user_wants_to_run_without_disks()
            AppScaleLogger.log("Starting AppScale " + APPSCALE_VERSION +
                               " over the " + options.infrastructure +
                               " cloud.")
        else:
            AppScaleLogger.log("Starting AppScale " + APPSCALE_VERSION +
                               " over a virtualized cluster.")
        my_id = str(uuid.uuid4())
        AppScaleLogger.remote_log_tools_state(options, my_id, "started",
                                              APPSCALE_VERSION)

        node_layout = NodeLayout(options)
        if not node_layout.is_valid():
            raise BadConfigurationException("There were errors with your " + \
              "placement strategy:\n{0}".format(str(node_layout.errors())))

        if not node_layout.is_supported():
            AppScaleLogger.warn("Warning: This deployment strategy is not " + \
              "officially supported.")

        public_ip, instance_id = RemoteHelper.start_head_node(
            options, my_id, node_layout)
        AppScaleLogger.log(
            "\nPlease wait for AppScale to prepare your machines " +
            "for use.")

        # Write our metadata as soon as possible to let users SSH into those
        # machines via 'appscale ssh'
        LocalState.update_local_metadata(options, node_layout, public_ip,
                                         instance_id)
        RemoteHelper.copy_local_metadata(public_ip, options.keyname,
                                         options.verbose)

        acc = AppControllerClient(public_ip,
                                  LocalState.get_secret_key(options.keyname))
        try:
            uaserver_host = acc.get_uaserver_host(options.verbose)
        except Exception:
            message = RemoteHelper.collect_appcontroller_crashlog(
                public_ip, options.keyname, options.verbose)
            raise AppControllerException(message)

        RemoteHelper.sleep_until_port_is_open(uaserver_host,
                                              UserAppClient.PORT,
                                              options.verbose)

        # Update our metadata again so that users can SSH into other boxes that
        # may have been started.
        LocalState.update_local_metadata(options, node_layout, public_ip,
                                         instance_id)
        RemoteHelper.copy_local_metadata(public_ip, options.keyname,
                                         options.verbose)

        AppScaleLogger.log("UserAppServer is at {0}".format(uaserver_host))

        uaserver_client = UserAppClient(
            uaserver_host, LocalState.get_secret_key(options.keyname))

        if options.admin_user and options.admin_pass:
            AppScaleLogger.log("Using the provided admin username/password")
            username, password = options.admin_user, options.admin_pass
        elif options.test:
            AppScaleLogger.log("Using default admin username/password")
            username, password = LocalState.DEFAULT_USER, LocalState.DEFAULT_PASSWORD
        else:
            username, password = LocalState.get_credentials()

        RemoteHelper.create_user_accounts(username, password, uaserver_host,
                                          options.keyname,
                                          options.clear_datastore)
        uaserver_client.set_admin_role(username)

        RemoteHelper.wait_for_machines_to_finish_loading(
            public_ip, options.keyname)
        # Finally, update our metadata once we know that all of the machines are
        # up and have started all their API services.
        LocalState.update_local_metadata(options, node_layout, public_ip,
                                         instance_id)
        RemoteHelper.copy_local_metadata(public_ip, options.keyname,
                                         options.verbose)

        RemoteHelper.sleep_until_port_is_open(
            LocalState.get_login_host(options.keyname),
            RemoteHelper.APP_DASHBOARD_PORT, options.verbose)
        AppScaleLogger.success("AppScale successfully started!")
        AppScaleLogger.success("View status information about your AppScale " + \
          "deployment at http://{0}:{1}/status".format(LocalState.get_login_host(
          options.keyname), RemoteHelper.APP_DASHBOARD_PORT))
        AppScaleLogger.remote_log_tools_state(options, my_id, "finished",
                                              APPSCALE_VERSION)