Ejemplo n.º 1
0
    def __init__(self, **kwargs):
        config = current_config()

        self.client = etcd.Client(
            host=config.get('ETCD_HOST', 'localhost'),
            port=int(config.get('ETCD_PORT', 4001)),
        )
        self.prefix = '{}/obj/'.format(config.get('ETCD_PREFIX', '/kqueen'))
Ejemplo n.º 2
0
def encrypt_password(_password):
    if not _password:
        return None
    config = current_config()
    rounds = config.get('BCRYPT_ROUNDS', 12)
    password = str(_password).encode('utf-8')
    encrypted = bcrypt.hashpw(password, bcrypt.gensalt(rounds)).decode('utf-8')
    return encrypted
Ejemplo n.º 3
0
    def __init__(self, **kwargs):
        config = current_config()

        self.client = etcd.Client(
            host=config.get('ETCD_HOST', 'localhost'),
            port=int(config.get('ETCD_PORT', 4001)),
        )
        self.namespace = kwargs.get('namespace', 'default')
        self.prefix = kwargs.get('prefix', '/kqueen/obj/')
Ejemplo n.º 4
0
def get_auth_instance(name):
    config = current_config()

    auth_config = config.get("AUTH", {}).get(name, {})

    module = importlib.import_module('kqueen.auth')
    auth_class = getattr(module, name)

    if callable(auth_class):
        return auth_class(**auth_config)
Ejemplo n.º 5
0
    def _get_encryption_key(self):
        """
        Read encryption key and format it.

        Returns:
            Encryption key.
        """

        # check for key
        config = current_config()
        key = config.get('SECRET_KEY')

        if key is None:
            raise Exception('Missing SECRET_KEY')

        # calculate hash passowrd
        return hashlib.sha256(key.encode('utf-8')).digest()[:self.bs]
Ejemplo n.º 6
0
def get_auth_instance(name):
    # Default type is local auth

    config = current_config()
    auth_config = config.get("AUTH", {}).get(name, {})

    # If user auth is not specified clearly, use local
    if name == 'local' or name is None:
        auth_config = {'engine': 'LocalAuth', 'param': {}}

    module = importlib.import_module('kqueen.auth')
    auth_engine = auth_config.get('engine')
    if not auth_engine:
        raise Exception('Authentication type is set to {}, but engine class name is not found. '
                        'Please, set it with the "engine" key'.format(name))
    auth_class = getattr(module, auth_engine)

    if callable(auth_class):
        return auth_class(**auth_config.get('param', {}))
Ejemplo n.º 7
0
Archivo: aks.py Proyecto: epcim/kqueen
from kqueen.config import current_config
from kqueen.engines.base import BaseEngine

from azure.common.credentials import ServicePrincipalCredentials
from azure.common.exceptions import AuthenticationError
from azure.mgmt.containerservice import ContainerServiceClient
from azure.mgmt.containerservice.models import ManagedCluster
from msrestazure.azure_exceptions import CloudError

import copy
import logging
import base64
import yaml

logger = logging.getLogger('kqueen_api')
config = current_config()

STATE_MAP = {
    'Creating': config.get('CLUSTER_PROVISIONING_STATE'),
    'Succeeded': config.get('CLUSTER_OK_STATE'),
    'Deleting': config.get('CLUSTER_DEPROVISIONING_STATE'),
    'Failed': config.get('CLUSTER_ERROR_STATE'),
    'Updating': config.get('CLUSTER_RESIZING_STATE')
}


class AksEngine(BaseEngine):
    """
    Azure Container Service
    """
    name = 'aks'