Ejemplo n.º 1
0
    def save(self, **kwargs):
        # while used in async method, app context is not available by default and needs to be imported
        from flask import current_app as app
        from kqueen.server import create_app
        try:
            if not app.testing:
                app = create_app()
        except RuntimeError:
            app = create_app()

        with app.app_context():
            return super().save(**kwargs)
Ejemplo n.º 2
0
def etcd_setup():
    _app = create_app()

    try:
        _app.db.client.delete(_app.config['ETCD_PREFIX'], recursive=True)
    except etcd.EtcdKeyNotFound:
        pass
Ejemplo n.º 3
0
    def save(self, check_status=True, **kwargs):
        # while used in async method, app context is not available by default and needs to be imported
        from flask import current_app as app
        from kqueen.server import create_app
        try:
            if not app.testing:
                app = create_app()
        except RuntimeError:
            app = create_app()

        with app.app_context():
            if check_status:
                self.state = self.engine_status(save=False)
            self.verbose_name = getattr(self.get_engine_cls(), 'verbose_name',
                                        self.engine)
            return super().save(**kwargs)
Ejemplo n.º 4
0
def app():
    """Prepare app."""
    global current_app
    current_app = create_app()
    current_app.testing = True

    return current_app
Ejemplo n.º 5
0
def main():
    args = parser.parse_args()
    app = create_app()
    with app.app_context():
        # Organization and user
        try:
            organization = Organization(
                id=organization_id,
                name=args.organization,
                namespace=args.namespace,
                created_at=datetime.utcnow()
            )
            organization.save()
            print('Organization {} successfully created!'.format(organization.name))
        except Exception:
            raise Exception('Adding {} organization failed'.format(args.organization))
        try:
            user = User.create(
                None,
                id=user_id,
                username=args.username,
                password=args.password,
                email='*****@*****.**',
                organization=organization,
                created_at=datetime.utcnow(),
                role='superadmin',
                active=True
            )
            user.save()
            print('User {} successfully created!'.format(user.username))
        except Exception:
            raise Exception('Adding {} user failed'.format(args.username))
Ejemplo n.º 6
0
def app():
    """Prepare app."""
    app = create_app()

    return app
Ejemplo n.º 7
0
def app():
    """Prepare app."""
    app = create_app()
    app.testing = True

    return app
Ejemplo n.º 8
0
import requests
import yaml

uuid_organization = '22d8df64-4ac9-4be0-89a7-c45ea0fc85da'

uuid_jenkins = 'c88b05d6-a107-4636-a3cc-eb5c90562f8f'
uuid_local = '2d51891a-adac-4bbc-a725-eed20cc67849'

uuid_provisioner_jenkins = 'e8de24b0-43d1-4a3c-af55-7b1d3f700554'
uuid_provisioner_local = '203c50d6-3d09-4789-8b8b-1ecb00814436'
uuid_provisioner_kubespray = '689de9a2-50e0-4fcd-b6a6-96930b5fadc9'

kubeconfig_url = 'https://ci.mcp.mirantis.net/job/deploy-aws-k8s_ha_calico_sm/33/artifact/kubeconfig'

app = create_app()
with app.app_context():
    # Organization and user
    try:
        organization = Organization(
            id=uuid_organization,
            name='DemoOrg',
            namespace='demoorg'
        )
        organization.save()
    except:
        raise Exception('Adding DemoOrg organization failed')

    try:
        user = User(
            username='******',
Ejemplo n.º 9
0
    def test_env_var_in_app(self, monkeypatch):
        monkeypatch.setenv('KQUEEN_DUMMY', '123')

        app = create_app()

        assert app.config.get('DUMMY') == '123'
Ejemplo n.º 10
0
def test_app_config():
    app = create_app(config_file='nonexistent_file.py')
    assert hasattr(app, 'config')
Ejemplo n.º 11
0
def app():
    app = create_app()
    return app
Ejemplo n.º 12
0
def test_app_config():
    app = create_app()
    assert hasattr(app, 'config')
Ejemplo n.º 13
0
def app():
    """Prepare app."""
    app = create_app(config_file=config_file)

    return app