Ejemplo n.º 1
0
    def setup(self):
        _user = user()
        create_kwargs_provisioner = {
            'name': 'Testing manual',
            'engine': 'kqueen.engines.ManualEngine',
            'parameters': PROVISIONER_PARAMETERS,
            'owner': _user
        }

        prov = Provisioner(_user.namespace, **create_kwargs_provisioner)
        prov.save(check_status=False)

        self.create_kwargs_cluster = {
            'name': 'Testing cluster for manual provisioner',
            'provisioner': prov,
            'state': 'deployed',
            'kubeconfig': KUBECONFIG,
            'metadata': CLUSTER_METADATA,
            'owner': _user
        }

        self.cluster = Cluster.create(_user.namespace,
                                      **self.create_kwargs_cluster)
        self.engine = ManualEngine(cluster=self.cluster)

        # client setup
        self.auth_header = auth_header(self.client)
        self.namespace = self.auth_header['X-Test-Namespace']
Ejemplo n.º 2
0
def provisioner_engine_list():
    engine_cls = []
    module_path = 'kqueen.engines'

    for engine in Provisioner.list_engines():
        try:
            module = import_module(module_path)
            _class = getattr(module, engine)
            parameters = _class.get_parameter_schema()
            name = '.'.join([module_path, engine])
            engine_cls.append({
                'name': name,
                'verbose_name': getattr(_class, 'verbose_name', name),
                'parameters': parameters
            })
        except NotImplementedError:
            engine_cls.append({
                'name': engine,
                'verbose_name': engine,
                'parameters': {
                    'provisioner': {},
                    'cluster': {}
                }
            })
        except Exception:
            logger.error('Unable to read parameters for engine {}'.format(engine))

    return jsonify(engine_cls)
Ejemplo n.º 3
0
def provisioner():
    """Create dummy manual provisioner."""
    create_kwargs = {
        'name': 'Fixtured provisioner',
        'engine': 'kqueen.engines.ManualEngine',
    }

    return Provisioner.create(**create_kwargs)
Ejemplo n.º 4
0
    def setup(self):
        create_kwargs_provisioner = {
            'name': 'Testing manual',
            'engine': 'kqueen.engines.ManualEngine'
        }

        prov = Provisioner(**create_kwargs_provisioner)
        prov.save(check_status=False)

        create_kwargs_cluster = {
            'name': 'Testing cluster for manual provisioner',
            'provisioner': prov,
            'state': 'deployed',
            'kubeconfig': yaml.load(open('kubeconfig_localhost', 'r').read()),
        }

        self.cluster = Cluster.create(**create_kwargs_cluster)
        self.engine = ManualEngine(cluster=self.cluster)
Ejemplo n.º 5
0
def cluster():
    """Create cluster with manual provisioner."""
    _uuid = uuid.uuid4()

    prov = Provisioner(
        name='Fixtured provisioner',
        engine='kqueen.engines.ManualEngine',
    )
    prov.save(check_status=False)

    create_kwargs = {
        'id': _uuid,
        'name': 'Name for cluster {}'.format(_uuid),
        'provisioner': prov,
        'state': 'deployed',
        'kubeconfig': yaml.load(open('kubeconfig_localhost', 'r').read()),
    }

    return Cluster.create(**create_kwargs)
Ejemplo n.º 6
0
def provisioner():
    """Create dummy manual provisioner."""
    _user = user()

    create_kwargs = {
        'name': 'Fixtured provisioner',
        'engine': 'kqueen.engines.ManualEngine',
        'owner': _user
    }

    return Provisioner.create(_user.namespace, **create_kwargs)
Ejemplo n.º 7
0
    def __init__(self, test_user=None):
        if test_user is None:
            test_user = UserFixture()
        self.test_user = test_user

        owner = test_user.obj
        create_kwargs = {
            'name': 'Fixtured provisioner',
            'engine': 'kqueen.engines.ManualEngine',
            'owner': owner
        }
        self.obj = Provisioner.create(owner.namespace, **create_kwargs)
Ejemplo n.º 8
0
def cluster():
    """Create cluster with manual provisioner."""
    _uuid = uuid.uuid4()
    _user = user()

    prov = Provisioner(_user.namespace,
                       name='Fixtured provisioner',
                       engine='kqueen.engines.ManualEngine',
                       owner=_user)
    prov.save(check_status=False)

    create_kwargs = {
        'id': _uuid,
        'name': 'Name for cluster {}'.format(_uuid),
        'provisioner': prov,
        'state': config.get('CLUSTER_UNKNOWN_STATE'),
        'kubeconfig': yaml.load(open('kubeconfig_localhost', 'r').read()),
        'created_at': datetime.datetime.utcnow().replace(microsecond=0),
        'owner': _user
    }

    return Cluster.create(_user.namespace, **create_kwargs)
Ejemplo n.º 9
0
    def test_load_provisioner(self, user):
        user.save()
        provisioner = Provisioner(
            user.namespace,
            name='Manual provisioner',
            state='OK',
            engine='kqueen.engines.ManualEngine',
            parameters={},
            created_at=datetime.utcnow().replace(microsecond=0),
            owner=user)
        provisioner.save()

        loaded = Provisioner.load(user.namespace, provisioner.id)

        assert loaded.get_dict(True) == provisioner.get_dict(True)
        provisioner.delete()
Ejemplo n.º 10
0
        user = User(
            username='******',
            password='******',
            organization=organization,
        )
        user.save()
    except:
        raise Exception('Adding admin user failed')

    # AWS + Jenkins
    try:
        provisioner = Provisioner(
            id=uuid_provisioner_jenkins,
            name='Jenkins provisioner to AWS',
            state='OK',
            engine='kqueen.engines.JenkinsEngine',
            parameters={
                'username': '******',
                'password': '******'
            }
        )
        provisioner.save(check_status=False)
    except:
        raise Exception('Adding AWS provisioner failed')


    try:
        cluster = Cluster(
            id=uuid_jenkins,
            name='AWS Calico SM 33',
            state='OK',
            provisioner=provisioner,
Ejemplo n.º 11
0
    def test_list_engines(self):
        engines = Provisioner.list_engines()

        assert engines == all_engines
Ejemplo n.º 12
0
                    username='******',
                    password='******',
                    organization=organization,
                    created_at=datetime.utcnow(),
                    active=True)
        user.save()
    except:
        raise Exception('Adding admin user failed')

    # AWS + Jenkins
    try:
        provisioner = Provisioner(user.namespace,
                                  id=uuid_provisioner_jenkins,
                                  name='Jenkins provisioner to AWS',
                                  state='OK',
                                  engine='kqueen.engines.JenkinsEngine',
                                  parameters={
                                      'username': '******',
                                      'password': '******'
                                  },
                                  created_at=datetime.utcnow())
        provisioner.save(check_status=False)
    except:
        raise Exception('Adding AWS provisioner failed')

    # GKE provisioner
    try:
        provisioner = Provisioner(user.namespace,
                                  id=uuid_provisioner_gke,
                                  name='Google Kubernetes engine',
                                  state='OK',
                                  engine='kqueen.engines.GceEngine',