Esempio n. 1
0
def test_load_order_presedence_two(tmp):
    # multiple plugin configs, first plugin conf defines it as enabled,
    # but last read should make it disabled.
    defaults = init_defaults('plugin.myplugin')

    f = open(os.path.join(tmp.dir, 'a.conf'), 'w')
    f.write(CONF1)  # enabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'b.conf'), 'w')
    f.write(CONF2)  # disabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'myplugin.py'), 'w')
    f.write(PLUGIN)
    f.close()

    class MyApp(TestApp):
        class Meta:
            config_defaults = defaults
            config_dirs = [tmp.dir]
            plugin_dir = tmp.dir
            plugin_module = None
            debug = True

    with MyApp() as app:
        app.run()
        print(tmp.dir)
        tmp.cleanup = False
        assert 'myplugin' in app.plugin._disabled_plugins
        assert 'myplugin' not in app.plugin._enabled_plugins
Esempio n. 2
0
def test_load_plugins_from_config(tmp):
    f = open(os.path.join(tmp.dir, 'myplugin.py'), 'w')
    f.write(PLUGIN)
    f.close()

    defaults = init_defaults('plugin.myplugin', 'plugin.myplugin2')
    defaults['plugin.myplugin']['enabled'] = True
    defaults['plugin.myplugin2']['enabled'] = False

    class MyApp(TestApp):
        class Meta:
            config_defaults = defaults
            config_dirs = [tmp.dir]
            plugin_dir = tmp.dir
            plugin_module = None

    with MyApp() as app:
        han = app.handler.get('output', 'my_output_handler')()
        assert han._meta.label == 'my_output_handler'

        # some more checks for coverage

        assert 'myplugin' in app.plugin.get_enabled_plugins()
        assert 'myplugin' in app.plugin.get_loaded_plugins()
        assert 'myplugin2' in app.plugin.get_disabled_plugins()
        assert 'myplugin2' not in app.plugin.get_enabled_plugins()
        assert 'myplugin2' not in app.plugin.get_loaded_plugins()
Esempio n. 3
0
def test_load_order_presedence_two(tmp):
    # multiple plugin configs, first plugin conf defines it as enabled,
    # but last read should make it disabled.
    defaults = init_defaults('plugin.myplugin')

    f = open(os.path.join(tmp.dir, 'a.conf'), 'w')
    f.write(CONF1)  # enabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'b.conf'), 'w')
    f.write(CONF2)  # disabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'myplugin.py'), 'w')
    f.write(PLUGIN)
    f.close()

    class MyApp(TestApp):
        class Meta:
            config_defaults = defaults
            config_dirs = [tmp.dir]
            plugin_dir = tmp.dir
            plugin_module = None
            debug = True

    with MyApp() as app:
        app.run()
        print(tmp.dir)
        tmp.cleanup = False
        assert 'myplugin' in app.plugin._disabled_plugins
        assert 'myplugin' not in app.plugin._enabled_plugins
Esempio n. 4
0
def test_load_plugins_from_config(tmp):
    f = open(os.path.join(tmp.dir, 'myplugin.py'), 'w')
    f.write(PLUGIN)
    f.close()

    defaults = init_defaults('plugin.myplugin', 'plugin.myplugin2')
    defaults['plugin.myplugin']['enabled'] = True
    defaults['plugin.myplugin2']['enabled'] = False

    class MyApp(TestApp):
        class Meta:
            config_defaults = defaults
            config_dirs = [tmp.dir]
            plugin_dir = tmp.dir
            plugin_module = None

    with MyApp() as app:
        han = app.handler.get('output', 'my_output_handler')()
        assert han._meta.label == 'my_output_handler'

        # some more checks for coverage

        assert 'myplugin' in app.plugin.get_enabled_plugins()
        assert 'myplugin' in app.plugin.get_loaded_plugins()
        assert 'myplugin2' in app.plugin.get_disabled_plugins()
        assert 'myplugin2' not in app.plugin.get_enabled_plugins()
        assert 'myplugin2' not in app.plugin.get_loaded_plugins()
Esempio n. 5
0
def _default_config() -> Dict:
    config = init_defaults('tank',
                           'log.logging')

    config['tank'] = {
        'terraform_run_command': '/usr/local/bin/terraform',
        'terraform_inventory_run_command': '/usr/local/bin/terraform-inventory',
    }

    config['log.logging']['level'] = 'WARNING'

    return config
Esempio n. 6
0
def test_argument():
    META = init_defaults('controller.scrub')
    META['controller.scrub']['argument_options'] = ['--not-scrub']
    META['controller.scrub']['argument_help'] = 'not scrub'

    class MyScrubApp(ScrubApp):
        class Meta:
            meta_defaults = META

    with MyScrubApp(argv=['--not-scrub']) as app:
        app.run()
        app.print('foobar foo bar')
        assert app.last_rendered[1] == '$$$*** $$$ ***\n'
Esempio n. 7
0
def _default_config() -> Dict:
    config = init_defaults('tank', 'log.logging')

    config['tank'] = {
        'ansible': {
            'forks': 50,
        },
    }

    config['tank']['monitoring'] = {
        "admin_user": "******",
        "admin_password": "******"
    }

    config['log.logging']['level'] = 'WARNING'
    return config
Esempio n. 8
0
def test_load_order_presedence_three(tmp):
    # Multiple plugin configs, enable -> disabled -> enable
    defaults = init_defaults('plugin.myplugin')

    f = open(os.path.join(tmp.dir, 'a.conf'), 'w')
    f.write(CONF1)  # enabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'b.conf'), 'w')
    f.write(CONF2)  # disabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'c.conf'), 'w')
    f.write(CONF1)  # enabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'd.conf'), 'w')
    f.write(CONF2)  # disabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'e.conf'), 'w')
    f.write(CONF1)  # enabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'myplugin.py'), 'w')
    f.write(PLUGIN)
    f.close()

    class MyApp(TestApp):
        class Meta:
            config_defaults = defaults
            config_dirs = [tmp.dir]
            plugin_dir = tmp.dir
            plugin_module = None

    with MyApp() as app:
        assert 'myplugin' in app.plugin._enabled_plugins
        assert 'myplugin' not in app.plugin._disabled_plugins
Esempio n. 9
0
def test_load_order_presedence_three(tmp):
    # Multiple plugin configs, enable -> disabled -> enable
    defaults = init_defaults('plugin.myplugin')

    f = open(os.path.join(tmp.dir, 'a.conf'), 'w')
    f.write(CONF1)  # enabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'b.conf'), 'w')
    f.write(CONF2)  # disabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'c.conf'), 'w')
    f.write(CONF1)  # enabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'd.conf'), 'w')
    f.write(CONF2)  # disabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'e.conf'), 'w')
    f.write(CONF1)  # enabled config
    f.close()

    f = open(os.path.join(tmp.dir, 'myplugin.py'), 'w')
    f.write(PLUGIN)
    f.close()

    class MyApp(TestApp):
        class Meta:
            config_defaults = defaults
            config_dirs = [tmp.dir]
            plugin_dir = tmp.dir
            plugin_module = None

    with MyApp() as app:
        assert 'myplugin' in app.plugin._enabled_plugins
        assert 'myplugin' not in app.plugin._disabled_plugins
Esempio n. 10
0
def test_logging():
    defaults = init_defaults()
    defaults['log.logging'] = dict(
        file='/dev/null',
        to_console=True
    )
    with TestApp(config_defaults=defaults) as app:
        app.log.info('Info Message')
        app.log.warning('Warning Message')
        app.log.error('Error Message')
        app.log.fatal('Fatal Message')
        app.log.debug('Debug Message')

        # get level
        assert app.log.get_level() == 'INFO'

        # set level
        app.log.set_level('WARNING')
        assert app.log.get_level() == 'WARNING'

        # set a bad level should default to INFO
        app.log.set_level('BOGUS')
        assert app.log.get_level() == 'INFO'
Esempio n. 11
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import OctaviaChickenCheckerError
from .controllers.base import Base
from .controllers.loadbalancer import LoadBalancer
import openstack

# configuration defaults
CONFIG = init_defaults('occ')
CONFIG['occ']['foo'] = 'bar'


def connect_to_openstack(app):
    app.log.info('Connecting to OpenStack')

    cloud = "default"

    app.extend('conn', openstack.connect(cloud=cloud))


def openstack_errors(app):
    app.log.info('Loading openstack exceptions')
    app.extend('err', openstack.exceptions)


class OctaviaChickenChecker(App):
    """Octavia Chicken Checker primary application."""
    class Meta:
        label = 'occ'

        # configuration defaults
Esempio n. 12
0

def another_hook_function(app=None):
    #app.log.debug('Called ANOTHER HOOK')
    return 'Boink!'


def one_more_function(app=None):
    #app.log.debug('Called ONE MORE')
    return 'Second boink!'


# ===============================================
#   C O N F I G U R A T I O N   D E F A U L T S
# ===============================================
CONFIG = init_defaults('todo', 'log.logging')
CONFIG['todo']['db_file'] = '~/.todo/db.json'
CONFIG['todo']['email'] = '*****@*****.**'
CONFIG['log.logging']['level'] = 'DEBUG'
CONFIG['log.logging']['file'] = '~/.todo/log/todo.log'


# ===============================================
#   M A I N   A P P L I C A T I O N   C L A S S
# ===============================================
class Todo(App):
    """My totally awesome TODO application."""
    class Meta:
        label = 'todo'

        define_hooks = [
Esempio n. 13
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import HydraError
from .controllers.base import Base
from .controllers.devel import Devel
from .controllers.network import Network
from .controllers.client import Client
from .helpers.client import ClientHelper
from .helpers.devel import DevelHelper
from .helpers import UtilsHelper
from .helpers.networks import NetworksHelper
from .helpers.release import ReleaseHelper
import os

# configuration defaults
CONFIG = init_defaults('hydra', 'log.logging', 'release', 'devel', 'provision',
                       'client')
CONFIG['hydra']['workdir'] = os.path.realpath(os.getcwd())
CONFIG['hydra']['project'] = 'shipchain'
CONFIG['hydra']['binary_name'] = '%(project)s'
CONFIG['hydra']['project_source'] = 'https://github.com/shipchain/hydra.git'
CONFIG['hydra'][
    'channel_url'] = 'https://shipchain-network-dist.s3.amazonaws.com'
CONFIG['log.logging']['level'] = 'debug'
CONFIG['release']['distdir'] = './dist'
CONFIG['release']['build_binary_path'] = './loomchain/shipchain'
CONFIG['release']['aws_profile'] = None
CONFIG['release']['aws_s3_dist_bucket'] = 'shipchain-network-dist'
CONFIG['provision']['aws_profile'] = None
CONFIG['provision']['aws_ec2_region'] = 'us-east-1'
CONFIG['provision']['aws_ec2_instance_type'] = 'm5.xlarge'
CONFIG['provision']['aws_ec2_ami_id'] = 'ami-0a313d6098716f372'
Esempio n. 14
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import PairsError
from .controllers.base import Base
import os
from os.path import join, exists
from pathlib import Path

HOME = str(Path.home())

# configuration defaults
cfp = join(HOME, '.config', 'pairs')
if not exists(cfp):
    os.mkdir(cfp)
CONFIG = init_defaults('pairs', 'backtest_daily')
CONFIG['pairs']['config_filepath'] = join(cfp, 'pairs.yml')
CONFIG['backtest_daily']['window_std'] = 10
CONFIG['backtest_daily']['window_corr'] = 10
CONFIG['backtest_daily']['factor_std'] = 1.5
CONFIG['backtest_daily']['factor_profit_std'] = 0.75
CONFIG['backtest_daily']['factor_loss_size'] = 3


class Pairs(App):
    """Pairs primary application."""
    class Meta:
        label = 'pairs'

        # configuration defaults
        config_defaults = CONFIG
Esempio n. 15
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import MyAppError
from .controllers.base import Base
from .controllers.items import Items
from cement.utils import fs
from tinydb import TinyDB
import os

# configuration defaults
CONFIG = init_defaults('IotaCli')

# def extend_tinydb(app):
#     app.log.info('extending IotaCli application with tinydb')
#     db_file = app.config.get('IotaCli', 'db_file')

#     # ensure that we expand the full path
#     db_file = fs.abspath(db_file)
#     app.log.info('tinydb database file is: %s' % db_file)

#     # ensure our parent directory exists
#     db_dir = os.path.dirname(db_file)
#     if not os.path.exists(db_dir):
#         os.makedirs(db_dir)

#     app.extend('db', TinyDB(db_file))


class MyApp(App):
    """Iota Cli App primary application."""
    class Meta:
Esempio n. 16
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import {{ class_name }}Error
from .controllers.base import Base

# configuration defaults
CONFIG = init_defaults('{{ label }}')
CONFIG['{{ label }}']['foo'] = 'bar'


class {{ class_name }}(App):
    """{{ name }} primary application."""

    class Meta:
        label = '{{ label }}'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        close_on_exit = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
Esempio n. 17
0
"""Main app module."""
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal

from .controllers.base import Base
from .controllers.keyvaults import Keyvaults
from .controllers.secrets import Secrets
from .core.exc import AzKVError
from .core.hooks import extend_vault_creds
from .core.log import AzKVLogHandler

# configuration defaults
CONFIG = init_defaults("azkv", "azkv.credentials", "azkv.keyvaults")
CONFIG["azkv"]["credentials"] = {"type": "EnvironmentVariables"}
CONFIG["azkv"]["keyvaults"] = []


class AzKV(App):
    """AzKV primary application."""
    class Meta:
        """Application meta-data."""

        label = "azkv"

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        exit_on_close = True

        # register functions to hooks
Esempio n. 18
0
import pyodbc
import octopart
import os
from pathlib import Path
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import odbtError
from .controllers.base import Base
from .controllers.config import Config
from .controllers.item import Item
from .controllers.table import Table

# configuration defaults
CONFIG = init_defaults('odbt')


def setup_digikey_environment(app):
    try:
        client_id = app.config.get('odbt', 'digikey_client_id')
        client_secret = app.config.get('odbt', 'digikey_client_secret')
        cache_dir = app.config.get('odbt', 'digikey_cache_directory')
    except Exception as e:
        print('Config error: {0}'.format(e))
        print(
            'Please make sure your config file exists and have the digikey setup defined'
        )
        exit(1)
    else:
        os.environ['DIGIKEY_CLIENT_ID'] = client_id
        os.environ['DIGIKEY_CLIENT_SECRET'] = client_secret
Esempio n. 19
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import WebRecordError
from .controllers.base import Base

# configuration defaults
CONFIG = init_defaults('webrec')
CONFIG['webrec']['foo'] = 'bar'


class WebRecord(App):
    """Web Record primary application."""
    class Meta:
        label = 'webrec'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        exit_on_close = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
        config_handler = 'yaml'
Esempio n. 20
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import ZoomCliError
from .controllers.base import Base

# configuration defaults
CONFIG = init_defaults('zoom-cli')
CONFIG['zoom-cli']['foo'] = 'bar'


class ZoomCli(App):
    """Zoom API CLI utility primary application."""
    class Meta:
        label = 'zoom-cli'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        exit_on_close = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
        config_handler = 'yaml'
Esempio n. 21
0
import os
from tinydb import TinyDB
from redminelib import Redmine
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from cement.utils import fs
from .core.exc import MyRedPyError, MissingConfigurationError
from .core.api import Api
from .controllers.base import Base
from .controllers.projects import Projects
from .controllers.time_entries import TimeEntries
# from .controllers.issues import Issues
from .controllers.settings import Settings

# configuration defaults
CONFIG = init_defaults('myredpy', 'log.logging')
CONFIG['myredpy']['redmine_url'] = ''
CONFIG['myredpy']['redmine_key'] = ''
CONFIG['myredpy']['db_file'] = '~/.myredpy/db.json'


def extend_redmine(app):
    app.log.debug('Connecting to redmine...')
    redmine_url = app.config.get('myredpy', 'redmine_url')
    redmine_key = app.config.get('myredpy', 'redmine_key')
    if not redmine_url.strip() or not redmine_key.strip():
        raise MissingConfigurationError(
            'Redmine configuration (url and/or key) not set in config file.')
    redmine = Redmine(redmine_url, key=redmine_key)
    app.extend('redmine', redmine)
Esempio n. 22
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import {{ class_name }}Error
from .controllers.base import Base

# configuration defaults
CONFIG = init_defaults('todo')
CONFIG['todo']['foo'] = 'bar'


class {{ class_name }}(App):
    """{{ name }} primary application."""

    class Meta:
        label = '{{ label }}'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        close_on_exit = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
Esempio n. 23
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import KubeSecretError
from .controllers.base import Base

# configuration defaults
CONFIG = init_defaults('kubesecret')
CONFIG['kubesecret']['foo'] = 'bar'


class KubeSecret(App):
    """KubeSecret primary application."""

    class Meta:
        label = 'kubesecret'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        exit_on_close = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import VoltageMetricsPublisherError
from .controllers.base import Base
from .controllers.voltageMetrics import VoltageMetrics

# configuration defaults
CONFIG = init_defaults('voltagemetricspublisher')
#CONFIG['voltagemetricspublisher']['foo'] = 'bar'


class VoltageMetricsPublisher(App):
    """Voltage Metrics Publisher primary application."""
    class Meta:
        label = 'voltagemetricspublisher'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        exit_on_close = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
        config_handler = 'yaml'
Esempio n. 25
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import TetBanError
from .controllers.base import Base

# configuration defaults
CONFIG = init_defaults('tetban')
CONFIG['tetban']['foo'] = 'bar'


class TetBan(App):
    """Tetration Analytics Ban primary application."""
    class Meta:
        label = 'tetban'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        exit_on_close = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
        config_handler = 'yaml'
Esempio n. 26
0
import os
from os.path import join
import sh
from tinydb import TinyDB
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import MixbytesTankError, TerraformNotAvailable
from .controllers.base import Base
from .controllers.cluster import Cluster
from cement.utils import fs

# configuration defaults
CONFIG = init_defaults('tank', 'digitalocean', 'log.logging')
CONFIG['tank']['state_file'] = '~/.tank/tank.json'
CONFIG['tank']['provider'] = 'digitalocean'
CONFIG['tank']['terraform_run_command'] = 'terraform'
CONFIG['tank'][
    'terraform_inventory_run_command'] = '/usr/local/bin/terraform-inventory'
CONFIG['tank']['blockchain_instances'] = 2
CONFIG['digitalocean']['private_interface'] = 'eth0'
CONFIG['log.logging']['level'] = 'info'


def extend_tinydb(app):
    state_file = app.config.get('tank', 'state_file')
    state_file = fs.abspath(state_file)
    state_dir = os.path.dirname(state_file)
    if not os.path.exists(state_dir):
        os.makedirs(state_dir)

    app.extend('state', TinyDB(state_file))
Esempio n. 27
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal

from .controllers.base import Base
from .controllers.client import Client
from .controllers.devel import Devel
from .controllers.network import Network
from .core.exc import HydraError
from .helpers import UtilsHelper, inject_jinja_globals
from .helpers.client import ClientHelper
from .helpers.devel import DevelHelper
from .helpers.network import NetworkHelper
from .helpers.release import ReleaseHelper

# configuration defaults
CONFIG = init_defaults('hydra', 'log.logging', 'release', 'devel', 'provision',
                       'client', 'loom')
CONFIG['hydra']['workdir'] = os.path.realpath(os.getcwd())
CONFIG['hydra']['project'] = 'shipchain'
CONFIG['hydra']['binary_name'] = '%(project)s'
CONFIG['hydra']['project_source'] = 'https://github.com/shipchain/hydra.git'
CONFIG['hydra'][
    'channel_url'] = 'https://shipchain-network-dist.s3.amazonaws.com'
CONFIG['hydra']['validator_metrics'] = 'true'
CONFIG['log.logging']['level'] = 'debug'
CONFIG['release']['distdir'] = './dist'
CONFIG['release']['build_binary_path'] = './loomchain/shipchain'
CONFIG['release']['aws_profile'] = None
CONFIG['release']['aws_s3_dist_bucket'] = 'shipchain-network-dist'
CONFIG['provision']['aws_profile'] = None
CONFIG['provision']['aws_ec2_region'] = 'us-east-1'
CONFIG['provision']['aws_ec2_instance_type'] = 'm5.xlarge'
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import BedrockError
from .controllers.base import Base

# configuration defaults
CONFIG = init_defaults('bedrock')
CONFIG['bedrock']['foo'] = 'bar'


class Bedrock(App):
    """Bedrock primary application."""
    class Meta:
        label = 'bedrock'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        close_on_exit = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
        config_handler = 'yaml'
Esempio n. 29
0
        }
    }
}


class BearerAuth(AuthBase):
    def __init__(self, token):
        self.token = token

    def __call__(self, req):
        req.headers['Authorization'] = 'Bearer ' + self.token
        return req


# Configuration Defaults
CONFIG = init_defaults('flight_action', 'log.logging')
CONFIG['flight_action']['base_url'] = 'http://localhost:6304'
CONFIG['flight_action']['jwt_token'] = ''
CONFIG['log.logging']['level'] = 'info'


class ActionApp(App):
    """Action Client primary application."""
    class Meta:
        # Defines the config paths of the label (among other things)
        label = 'flight-action'

        # look for configs under the user facing key
        config_section = 'flight_action'

        # configuration defaults
Esempio n. 30
0
from cement.core.exc import CaughtSignal
from .core.exc import TetrationCLIError
from .controllers.base import Base
from .controllers.agents import Agents
from .controllers.swiches import Switches
from .controllers.scopes import Scopes
from .controllers.roles import Roles
from .controllers.users import Users
from .controllers.applications import Applications
from .controllers.vrfs import VRFs
from .controllers.inventory import Inventory



# configuration defaults
CONFIG = init_defaults('tetrationcli')
CONFIG['tetrationcli']['api_endpoint'] = 'https://<UI_VIP_OR_DNS_FOR_TETRATION_DASHBOARD>'
CONFIG['tetrationcli']['api_credentials'] = '~/.config/tetrationcli/api_credentials.json'

class TetrationCLI(App):
    """Tetration Command Line Interaction primary application."""

    class Meta:
        label = 'tetrationcli'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        close_on_exit = True
Esempio n. 31
0
from cement import App, TestApp, init_defaults
from cement.core.exc import CaughtSignal
from .core.exc import Notes2FlashcardsError
from .controllers.base import Base
from .controllers.formats import Formats

# configuration defaults
CONFIG = init_defaults('notes2flashcards')
CONFIG['notes2flashcards']['foo'] = 'bar'


class Notes2Flashcards(App):
    """notes2flashcards primary application."""
    class Meta:
        label = 'notes2flashcards'

        # configuration defaults
        config_defaults = CONFIG

        # call sys.exit() on close
        exit_on_close = True

        # load additional framework extensions
        extensions = [
            'yaml',
            'colorlog',
            'jinja2',
        ]

        # configuration handler
        config_handler = 'yaml'
Esempio n. 32
0
from esper.controllers.enterprise.enterprise import Enterprise
from esper.controllers.enterprise.group import EnterpriseGroup
from esper.controllers.pipeline.execute import Execution
from esper.controllers.pipeline.operation import Operation
from esper.controllers.pipeline.pipeline import Pipeline
from esper.controllers.pipeline.stage import Stage
from esper.controllers.secureadb.secureadb import SecureADB
from esper.controllers.telemetry.telemetry import Telemetry
from esper.controllers.token.token import Token
from esper.core.exc import EsperError
from esper.core.output_handler import EsperOutputHandler
from esper.ext.certs import init_certs
from esper.ext.utils import extend_tinydb

# configuration defaults
CONFIG = init_defaults('esper')
CONFIG['esper']['debug'] = False
CONFIG['esper']['creds_file'] = '~/.esper/db/creds.json'
CONFIG['esper']['certs_folder'] = '~/.esper/certs'
CONFIG['esper']['local_key'] = '~/.esper/certs/local.key'
CONFIG['esper']['local_cert'] = '~/.esper/certs/local.pem'
CONFIG['esper']['device_cert'] = '~/.esper/certs/device.pem'

# meta defaults
META = init_defaults('log.colorlog')
META['log.colorlog']['file'] = '~/.esper/logs/esper.log'
META['log.colorlog']['level'] = 'debug'
META['log.colorlog']['to_console'] = False
META['log.colorlog']['rotate'] = False
META['log.colorlog']['max_bytes'] = 512000
META['log.colorlog']['max_files'] = 4
from xrdsst.controllers.status import StatusController
from xrdsst.controllers.timestamp import TimestampController
from xrdsst.controllers.init import InitServerController
from xrdsst.controllers.token import TokenController
from xrdsst.controllers.user import UserController
from xrdsst.controllers.endpoint import EndpointController
from xrdsst.core.util import revoke_api_key
from xrdsst.core.validator import validate_config_init, validate_config_timestamp_init, validate_config_token_login, \
    validate_config_token_init_keys, validate_config_cert_import, validate_config_cert_register, validate_config_cert_activate, \
    validate_config_client_add_or_register, validate_config_service_desc, validate_config_service_access, \
    validate_config_service_desc_service, validate_config_service_desc_service_endpoints, \
    validate_config_service_desc_service_endpoints_access
from xrdsst.models import TokenInitStatus, TokenStatus, PossibleAction
from xrdsst.resources.texts import texts

META = init_defaults('output.json', 'output.tabulate')
META['output.json']['overridable'] = True
META['output.tabulate']['overridable'] = True

# Operation dependency graph representation for simple topological ordering
OP_GRAPH = networkx.DiGraph()
OP_DEPENDENCY_LIST = []

OP_INIT = "INIT"
OP_TOKEN_LOGIN = "******"
OP_TIMESTAMP_ENABLE = "TIMESTAMPING"
OP_GENKEYS_CSRS = "KEYS AND CSR\nGENERATION"
OP_IMPORT_CERTS = "CERTIFICATE\nIMPORT"
OP_REGISTER_AUTH_CERT = "REGISTER\nAUTH CERT"
OP_ACTIVATE_AUTH_CERT = "ACTIVATE\nAUTH CERT"
OP_ADD_CLIENT = "ADD CLIENT"