Exemple #1
0
def delete_asg():
    """
    Method to delete AWS Auto-Scaling Groups via Asgard that are tagged for deletion.
    """
    error = False
    try:
        click.echo("Getting ASGs to delete")
        asgs = get_asgs_pending_delete()
        click.echo("Got ASGs to delete")
        for asg in asgs:
            click.echo("Attempting to delete ASG {0}".format(asg.name))
            try:
                asgard.delete_asg(asg.name, wait_for_deletion=False)
                click.secho("Successfully deleted ASG {0}".format(asg.name),
                            fg='green')
            except Exception as e:  # pylint: disable=broad-except
                click.secho("Unable to delete ASG: {0} - {1}".format(asg, e),
                            fg='red')
                error = True
    except Exception as e:  # pylint: disable=broad-except
        traceback.print_exc()
        click.secho("An error occured while cleaning up ASGs: {0}".format(e),
                    fg='red')
        error = True

    if error:
        sys.exit(1)
    else:
        sys.exit(0)
Exemple #2
0
def delete_asg(asg_name):
    """
    Method to delete a specified Auto-Scaling Group via Asgard.
    """
    asg_name = asg_name.strip()
    try:
        asgard.delete_asg(asg_name, True)
    except Exception as e:  # pylint: disable=broad-except
        traceback.print_exc()
        click.secho("Error Deleting ASG: {0}.\nMessage: {1}".format(asg_name, e.message), fg='red')
        sys.exit(1)

    sys.exit(0)
Exemple #3
0
def delete_asg(asg_name):
    """
    Method to delete a specified Auto-Scaling Group via Asgard.
    """
    asg_name = asg_name.strip()
    try:
        asgard.delete_asg(asg_name, True)
    except Exception as e:  # pylint: disable=broad-except
        traceback.print_exc()
        click.secho("Error Deleting ASG: {0}.\nMessage: {1}".format(
            asg_name, e),
                    fg='red')
        sys.exit(1)

    sys.exit(0)
Exemple #4
0
def delete_asg():
    """
    Method to delete AWS Auto-Scaling Groups via Asgard that are tagged for deletion.
    """
    error = False
    try:
        asgs = get_asgs_pending_delete()
        for asg in asgs:
            try:
                asgard.delete_asg(asg.name)
            except Exception as e:  # pylint: disable=broad-except
                click.secho("Unable to delete ASG: {0} - {1}".format(asg, e.message), fg='red')
                error = True
    except Exception as e:  # pylint: disable=broad-except
        traceback.print_exc()
        click.secho("An error occured while cleaning up ASGs: {0}".format(e.message), fg='red')
        error = True

    if error:
        sys.exit(1)
    else:
        sys.exit(0)
Exemple #5
0
def delete_asg():
    """
    Method to delete AWS Auto-Scaling Groups via Asgard that are tagged for deletion.
    """
    error = False
    try:
        asgs = get_asgs_pending_delete()
        for asg in asgs:
            try:
                asgard.delete_asg(asg.name)
            except Exception as e:  # pylint: disable=broad-except
                click.secho("Unable to delete ASG: {0} - {1}".format(asg, e),
                            fg='red')
                error = True
    except Exception as e:  # pylint: disable=broad-except
        traceback.print_exc()
        click.secho("An error occured while cleaning up ASGs: {0}".format(e),
                    fg='red')
        error = True

    if error:
        sys.exit(1)
    else:
        sys.exit(0)