From 74640555aab13753770e585465e589d797630a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kukr=C3=A1l?= Date: Tue, 19 Dec 2017 13:56:05 +0100 Subject: [PATCH 1/3] include default_policy.json in package --- MANIFEST.in | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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/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()) From ab0b0910e0152f4001e1c64a20250afe576c3f55 Mon Sep 17 00:00:00 2001 From: Adam Tengler Date: Tue, 19 Dec 2017 15:11:28 +0100 Subject: [PATCH 2/3] Engine API improvements and GCE validation improvements --- kqueen/blueprints/api/views.py | 5 ++++- kqueen/engines/gce.py | 37 ++++++++++++++++++++-------------- kqueen/models.py | 7 ++----- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/kqueen/blueprints/api/views.py b/kqueen/blueprints/api/views.py index 2851dcc3..d5fa2ee1 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 2e6c4f16..3a98136d 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() @@ -312,10 +313,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() @@ -333,7 +330,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() From 155f0a3a4dfe4f3f53813d7553d279d3ffa8b41a Mon Sep 17 00:00:00 2001 From: Adam Tengler Date: Tue, 19 Dec 2017 15:36:36 +0100 Subject: [PATCH 3/3] User metadata attribute --- kqueen/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/kqueen/models.py b/kqueen/models.py index 2e6c4f16..3ff4e876 100644 --- a/kqueen/models.py +++ b/kqueen/models.py @@ -363,6 +363,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):