Changeset View
Changeset View
Standalone View
Standalone View
swh/icinga_plugins/cli.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
# WARNING: do not import unnecessary things here to keep cli startup time under | |||||
# control | |||||
import sys | import sys | ||||
import click | import click | ||||
from swh.core.cli import CONTEXT_SETTINGS | from swh.core.cli import CONTEXT_SETTINGS | ||||
from .deposit import DepositCheck | |||||
from .vault import VaultCheck | |||||
@click.group(name='icinga_plugins', context_settings=CONTEXT_SETTINGS) | @click.group(name='icinga_plugins', context_settings=CONTEXT_SETTINGS) | ||||
@click.option('-w', '--warning', type=int, | @click.option('-w', '--warning', type=int, | ||||
help='Warning threshold.') | help='Warning threshold.') | ||||
@click.option('-c', '--critical', type=int, | @click.option('-c', '--critical', type=int, | ||||
help='Critical threshold.') | help='Critical threshold.') | ||||
@click.pass_context | @click.pass_context | ||||
def cli(ctx, warning, critical): | def cli(ctx, warning, critical): | ||||
Show All 19 Lines | def check_vault(ctx, **kwargs): | ||||
ctx.obj.update(kwargs) | ctx.obj.update(kwargs) | ||||
@check_vault.command(name='directory') | @check_vault.command(name='directory') | ||||
@click.pass_context | @click.pass_context | ||||
def check_vault_directory(ctx): | def check_vault_directory(ctx): | ||||
"""Picks a random directory, requests its cooking via swh-web, | """Picks a random directory, requests its cooking via swh-web, | ||||
and waits for completion.""" | and waits for completion.""" | ||||
from .vault import VaultCheck | |||||
sys.exit(VaultCheck(ctx.obj).main()) | sys.exit(VaultCheck(ctx.obj).main()) | ||||
@cli.group(name='check-deposit') | @cli.group(name='check-deposit') | ||||
@click.option('--server', type=str, | @click.option('--server', type=str, | ||||
default='https://deposit.softwareheritage.org/1', | default='https://deposit.softwareheritage.org/1', | ||||
help='URL to the SWORD server to test') | help='URL to the SWORD server to test') | ||||
@click.option('--username', type=str, required=True, | @click.option('--username', type=str, required=True, | ||||
Show All 13 Lines | |||||
@check_deposit.command(name='single') | @check_deposit.command(name='single') | ||||
@click.option('--archive', type=click.Path(), required=True, | @click.option('--archive', type=click.Path(), required=True, | ||||
help='Software artefact to upload') | help='Software artefact to upload') | ||||
@click.option('--metadata', type=click.Path(), required=True, | @click.option('--metadata', type=click.Path(), required=True, | ||||
help='Metadata file for the software artefact.') | help='Metadata file for the software artefact.') | ||||
@click.pass_context | @click.pass_context | ||||
def check_deposit_single(ctx, **kwargs): | def check_deposit_single(ctx, **kwargs): | ||||
"""Checks the provided archive and metadata file and be deposited.""" | """Checks the provided archive and metadata file and be deposited.""" | ||||
from .deposit import DepositCheck | |||||
ctx.obj.update(kwargs) | ctx.obj.update(kwargs) | ||||
sys.exit(DepositCheck(ctx.obj).main()) | sys.exit(DepositCheck(ctx.obj).main()) |