Exemplo n.º 1
0
    def terminate_instances(cls, options):
        """Stops all services running in an AppScale deployment, and in cloud
    deployments, also powers off the instances previously spawned.

    Raises:
      AppScaleException: If AppScale is not running, and thus can't be
      terminated.
    """
        if not os.path.exists(
                LocalState.get_secret_key_location(options.keyname)):
            raise AppScaleException(
                "AppScale is not running with the keyname {0}".format(
                    options.keyname))

        infrastructure = LocalState.get_infrastructure(options.keyname)

        # If the user is on a cloud deployment, and not backing their data to
        # persistent disks, warn them before shutting down AppScale.
        # Also, if we're in developer mode, skip the warning.
        if infrastructure != "xen" and not LocalState.are_disks_used(
                options.keyname) and not options.test:
            LocalState.ensure_user_wants_to_terminate()

        if infrastructure in InfrastructureAgentFactory.VALID_AGENTS:
            RemoteHelper.terminate_cloud_infrastructure(
                options.keyname, options.verbose)
        else:
            RemoteHelper.terminate_virtualized_cluster(options.keyname,
                                                       options.verbose)

        LocalState.cleanup_appscale_files(options.keyname)
        AppScaleLogger.success(
            "Successfully shut down your AppScale deployment.")
    def terminate_instances(cls, options):
        """Stops all services running in an AppScale deployment, and in cloud
    deployments, also powers off the instances previously spawned.

    Raises:
      AppScaleException: If AppScale is not running, and thus can't be
      terminated.
    """
        if not os.path.exists(LocalState.get_secret_key_location(options.keyname)):
            raise AppScaleException("AppScale is not running with the keyname {0}".format(options.keyname))

        infrastructure = LocalState.get_infrastructure(options.keyname)

        # If the user is on a cloud deployment, and not backing their data to
        # persistent disks, warn them before shutting down AppScale.
        # Also, if we're in developer mode, skip the warning.
        if infrastructure != "xen" and not LocalState.are_disks_used(options.keyname) and not options.test:
            LocalState.ensure_user_wants_to_terminate()

        if infrastructure in InfrastructureAgentFactory.VALID_AGENTS:
            RemoteHelper.terminate_cloud_infrastructure(options.keyname, options.verbose)
        else:
            RemoteHelper.terminate_virtualized_cluster(options.keyname, options.verbose)

        LocalState.cleanup_appscale_files(options.keyname)
        AppScaleLogger.success("Successfully shut down your AppScale deployment.")
Exemplo n.º 3
0
    def clean(self):
        """'clean' provides a mechanism that will forcefully shut down all AppScale-
    related services on virtual machines in a cluster deployment.

    Returns:
      A list of the IP addresses where AppScale was shut down.

    Raises:
      AppScalefileException: If there is no AppScalefile in the current working
        directory.
      BadConfigurationException: If this method is invoked and the AppScalefile
        indicates that a cloud deployment is being used.
    """
        contents = self.read_appscalefile()

        contents_as_yaml = yaml.safe_load(contents)
        if 'ips_layout' not in contents_as_yaml:
            raise BadConfigurationException("Cannot use 'appscale clean' in a " \
              "cloud deployment.")

        if 'verbose' in contents_as_yaml and contents_as_yaml[
                'verbose'] == True:
            is_verbose = contents_as_yaml['verbose']
        else:
            is_verbose = False

        if 'keyname' in contents_as_yaml:
            keyname = contents_as_yaml['keyname']
        else:
            keyname = 'appscale'

        all_ips = self.get_all_ips(contents_as_yaml["ips_layout"])

        if 'test' not in contents_as_yaml or contents_as_yaml['test'] != True:
            LocalState.ensure_user_wants_to_terminate()

        for ip in all_ips:
            RemoteHelper.ssh(ip, keyname, self.TERMINATE, is_verbose)

        LocalState.cleanup_appscale_files(keyname)
        AppScaleLogger.success(
            "Successfully shut down your AppScale deployment.")
        return all_ips
Exemplo n.º 4
0
  def clean(self):
    """ 'clean' provides a mechanism that will forcefully shut down all AppScale-
    related services on virtual machines in a cluster deployment.

    Returns:
      A list of the IP addresses where AppScale was shut down.

    Raises:
      AppScalefileException: If there is no AppScalefile in the current working
        directory.
      BadConfigurationException: If this method is invoked and the AppScalefile
        indicates that a cloud deployment is being used.
    """
    contents = self.read_appscalefile()

    contents_as_yaml = yaml.safe_load(contents)
    if 'ips_layout' not in contents_as_yaml:
      raise BadConfigurationException("Cannot use 'appscale clean' in a " \
        "cloud deployment.")

    if 'verbose' in contents_as_yaml and contents_as_yaml['verbose'] == True:
      is_verbose = contents_as_yaml['verbose']
    else:
      is_verbose = False

    if 'keyname' in contents_as_yaml:
      keyname = contents_as_yaml['keyname']
    else:
      keyname = 'appscale'

    all_ips = self.get_all_ips(contents_as_yaml["ips_layout"])

    if 'test' not in contents_as_yaml or contents_as_yaml['test'] != True:
      LocalState.ensure_user_wants_to_terminate()

    for ip in all_ips:
      RemoteHelper.ssh(ip, keyname, self.TERMINATE, is_verbose)

    LocalState.cleanup_appscale_files(keyname)
    AppScaleLogger.success("Successfully shut down your AppScale deployment.")
    return all_ips