Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into engine-whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkukral committed Dec 19, 2017
2 parents abc566c + aa697ec commit ac83659
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
recursive-include kqueen/blueprints/ *.html
include kqueen/config/default_policy.json
5 changes: 4 additions & 1 deletion kqueen/blueprints/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,16 @@ def provisioner_engine_list():
module = import_module(module_path)
_class = getattr(module, engine)
parameters = _class.get_parameter_schema()
name = '.'.join([module_path, engine])
engine_cls.append({
'name': '.'.join([module_path, engine]),
'name': name,
'verbose_name': getattr(_class, 'verbose_name', name),
'parameters': parameters
})
except NotImplementedError:
engine_cls.append({
'name': engine,
'verbose_name': engine,
'parameters': {
'provisioner': {},
'cluster': {}
Expand Down
37 changes: 22 additions & 15 deletions kqueen/engines/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class GceEngine(BaseEngine):
"""
name = 'gce'
verbose_name = 'Google Container engine'
# project = 'kqueen-186209'
# TODO: only subset of possible choices for zone is listed in parameter_schema,
# we could add more later, here is the list of possible choices:
# https://cloud.google.com/compute/docs/regions-zones/
Expand All @@ -33,14 +32,34 @@ class GceEngine(BaseEngine):
'type': 'json_file',
'label': 'Service Account File (JSON)',
'validators': {
'required': True
'required': True,
'jsonfile': [
'private_key_id',
'private_key',
'client_email',
'client_id',
'auth_uri',
'token_uri'
]
}
},
'project': {
'type': 'text',
'label': 'Project',
'validators': {
'required': True
'required': True,
}
}
},
'cluster': {
'node_count': {
'type': 'integer',
'label': 'Node Count',
'default': 1,
'validators': {
'required': True,
'min': 1,
'number': True
}
},
'zone': {
Expand All @@ -58,18 +77,6 @@ class GceEngine(BaseEngine):
'required': True
}
}
},
'cluster': {
'node_count': {
'type': 'integer',
'label': 'Node Count',
'default': 1,
'validators': {
'required': True,
'min': 1,
'number': True
}
}
}
}

Expand Down
8 changes: 3 additions & 5 deletions kqueen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def apply(self, resource_text):
class Provisioner(Model, metaclass=ModelMeta):
id = IdField(required=True)
name = StringField(required=True)
verbose_name = StringField(required=False)
engine = StringField(required=True)
state = StringField()
parameters = JSONField()
Expand Down Expand Up @@ -324,10 +325,6 @@ def get_engine_cls(self):
_class = None
return _class

@property
def engine_name(self):
return getattr(self.get_engine_cls(), 'verbose_name', self.engine)

def engine_status(self, save=True):
state = config.get('PROVISIONER_UNKNOWN_STATE')
engine_class = self.get_engine_cls()
Expand All @@ -345,7 +342,7 @@ def alive(self):
def save(self, check_status=True):
if check_status:
self.state = self.engine_status(save=False)

self.verbose_name = getattr(self.get_engine_cls(), 'verbose_name', self.engine)
return super(Provisioner, self).save()


Expand Down Expand Up @@ -375,6 +372,7 @@ class User(Model, metaclass=ModelMeta):
created_at = DatetimeField()
role = StringField(required=True)
active = BoolField(required=True)
metadata = JSONField(required=False)

@property
def namespace(self):
Expand Down
2 changes: 1 addition & 1 deletion kqueen/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from kqueen.engines.__init__ import __all__ as all_engines
from kqueen.engines import __all__ as all_engines
from kqueen.models import Cluster
from kqueen.models import Provisioner
from kqueen.storages.etcd import Field
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

version = '0.12'
version = '0.13'

with open('README.rst') as f:
long_description = ''.join(f.readlines())
Expand Down

0 comments on commit ac83659

Please sign in to comment.