diff --git a/MANIFEST.in b/MANIFEST.in index 5f9d6514..187777ca 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ recursive-include kqueen/blueprints/ *.html +include kqueen/config/default_policy.json diff --git a/kqueen/blueprints/api/views.py b/kqueen/blueprints/api/views.py index 3f03ab48..c3999e9b 100644 --- a/kqueen/blueprints/api/views.py +++ b/kqueen/blueprints/api/views.py @@ -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': {} diff --git a/kqueen/engines/gce.py b/kqueen/engines/gce.py index 92ca46a1..2338b822 100644 --- a/kqueen/engines/gce.py +++ b/kqueen/engines/gce.py @@ -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/ @@ -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': { @@ -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 - } - } } } diff --git a/kqueen/models.py b/kqueen/models.py index 305f0c7f..7bd3078d 100644 --- a/kqueen/models.py +++ b/kqueen/models.py @@ -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() @@ -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() @@ -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() @@ -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): diff --git a/kqueen/tests/test_models.py b/kqueen/tests/test_models.py index 9a9be5af..7ecf28df 100644 --- a/kqueen/tests/test_models.py +++ b/kqueen/tests/test_models.py @@ -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 diff --git a/setup.py b/setup.py index 963f6d92..ce888583 100644 --- a/setup.py +++ b/setup.py @@ -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())