Exemple #1
0
@click.argument("filename", type=click.File('rb'))
@click.argument("key", type=str, required=False)
@click.pass_obj
def put(provider: storage.StorageProvider, filename, key):
    """Put a file at FILENAME into cloud storage, under an optional KEY."""
    key_name = key if key else path.basename(filename.name)
    logging.info(f"Uploading '{filename.name}' to object '{key_name}'")
    provider.store(filename, key_name)


@store.command()
@click.argument("key", type=str, required=False)
@click.pass_obj
def get(provider: storage.StorageProvider, key):
    """Get a file from KEY in cloud storage and print it to stdout."""
    stream = io.BytesIO()
    provider.retrieve(key, stream)
    print(stream.getvalue().decode("utf-8"))


@store.command()
@click.pass_obj
def ls(provider: storage.StorageProvider):
    """List files from cloud storage."""
    for blob in provider.ls():
        print(blob)


# this object is loaded by Victoria and used as the plugin entry point
plugin = Plugin(name="store", cli=store)
Exemple #2
0
    envelope = None
    try:
        loaded_dict = None

        # load the YAML file
        with open(file, 'r') as file_handle:
            loaded_dict = yaml.safe_load(file_handle)

        # scope to the envelope directly with dpath
        raw_envelope = dpath.util.get(loaded_dict, path)

        # load it with the schema
        envelope = EncryptionEnvelopeSchema().load(raw_envelope)
    except (OSError, yaml.YAMLError, ValueError, KeyError,
            ValidationError) as err:
        logging.error(err)
        raise SystemExit(1)

    # now re-encrypt it with the new key
    rotated_envelope = provider.rotate_key(envelope)

    # and print it
    print(f"data: {rotated_envelope.data}")
    print(f"iv: {rotated_envelope.iv}")
    print(f"key: {rotated_envelope.key}")
    print(f"version: {rotated_envelope.version}")


# this object is loaded by Victoria and used as the plugin entry point
plugin = Plugin(name="encrypt", cli=encrypt)
    the void.

    \b
    Usage example:
    $ victoria email recover uksprod -i tx-ids.txt -o localhost:25
    """
    ensure_mailtoil(cfg)
    recover_mail.recover(cfg.mail_toil, cluster, input, output, cfg)


@root_cmd.command()
@click.argument("manifest", nargs=1, type=str)
def send(manifest: str) -> None:
    """Send mail specified by manifest files.

    For information about the manifest format, please see the README:
    https://github.com/glasswall-sre/victoria_email

    \b
    Usage example:
    $ victoria email send uksprod.yaml
    """
    loaded_manifest = send_mail.Manifest.load(manifest)
    send_mail.send_manifest(loaded_manifest)


# plugin entry point
plugin = Plugin(name="email",
                cli=root_cmd,
                config_schema=schemas.EmailConfigSchema())
Exemple #4
0
"""victoria_smoke

A Victoria plugin to perform smoke tests.

Author:
    Sam Gibson <*****@*****.**>
"""
from victoria.plugin import Plugin

from .config import SmokeConfigSchema
from . import cli

plugin = Plugin(name="smoke", cli=cli.smoke, config_schema=SmokeConfigSchema())
Exemple #5
0
"""victoria_config

A Victoria plugin to print the currently loaded config.

Author:
    Sam Gibson 
"""

import click
import yaml
from victoria.plugin import Plugin

# you need to use relative imports for your own modules/packages
from . import functionality
from . import schema

# this object is loaded by Victoria and used as the plugin entry point
plugin = Plugin(name="config",
                cli=functionality.config,
                config_schema=schema.ConfigSchema())
from victoria.plugin import Plugin
from .config import RebuilderSchema
from . import cli

# this object is loaded by Victoria and used as the plugin entry point
plugin = Plugin(name="rebuilder",
                cli=cli.rebuilder,
                config_schema=RebuilderSchema())