:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: : Copyright (c) 2019 Mirantis Inc., Enea AB and others. : : All rights reserved. This program and the accompanying materials : are made available under the terms of the Apache License, Version 2.0 : which accompanies this distribution, and is available at : http://www.apache.org/licenses/LICENSE-2.0 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: From: Alexandru Avadanii Date: Sat, 29 Dec 2018 23:09:01 +0100 Subject: [PATCH] Implement 'tags' support Signed-off-by: Alexandru Avadanii --- README.rst | 5 +++++ _modules/maas.py | 26 ++++++++++++++++++++++++++ maas/region.sls | 8 ++++++++ 3 files changed, 39 insertions(+) diff --git a/README.rst b/README.rst index 78d8aef..8c35458 100644 --- a/README.rst +++ b/README.rst @@ -181,6 +181,11 @@ Single MAAS region service [single UI/API]: mac: '66:55:44:33:22:11' commissioning_scripts: 00-maas-05-simplify-network-interfaces: /etc/maas/files/commisioning_scripts/00-maas-05-simplify-network-interfaces + tags: + aarch64_hugepages_1g: + comment: 'Enable 1G pagesizes on aarch64' + definition: '//capability[@id="asimd"]' + kernel_opts: 'default_hugepagesz=1G hugepagesz=1G' maas_config: # domain: mydomain.local # This function broken http_proxy: http://192.168.0.10:3142 diff --git a/_modules/maas.py b/_modules/maas.py index bb70576..0cda8dd 100644 --- a/_modules/maas.py +++ b/_modules/maas.py @@ -876,6 +876,28 @@ class Domain(MaasObject): return ret +class Tags(MaasObject): + def __init__(self): + super(Tags, self).__init__() + self._all_elements_url = u'api/2.0/tags/' + self._create_url = u'api/2.0/tags/' + self._config_path = 'region.tags' + self._update_url = u'api/2.0/tags/{0}/' + self._update_key = 'name' + + def fill_data(self, name, tag_data): + data = { + 'name': name, + } + for key in ['comment', 'definition', 'kernel_opts']: + if key in tag_data: + data[key] = tag_data[key] + return data + + def update(self, new, old): + return new + + class MachinesStatus(MaasObject): @classmethod def execute(cls, objects_name=None): @@ -1065,5 +1087,9 @@ def process_sshprefs(): return SSHPrefs().process() +def process_tags(): + return Tags().process() + + def wait_for_machine_status(**kwargs): return MachinesStatus.wait_for_machine_status(**kwargs) diff --git a/maas/region.sls b/maas/region.sls index 4a7f6cc..52fb952 100644 --- a/maas/region.sls +++ b/maas/region.sls @@ -444,4 +444,12 @@ maas_sshkey_{{ idx }}: {% endfor %} {%- endif %} +{%- if region.get('tags', False) %} +maas_tags: + module.run: + - name: maas.process_tags + - require: + - cmd: maas_login_admin +{%- endif %} + {%- endif %}