1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2018 Mirantis Inc., Enea AB and others.
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
10 Date: Sat, 29 Dec 2018 23:09:01 +0100
11 Subject: [PATCH] Implement 'tags' support
13 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
16 _modules/maas.py | 26 ++++++++++++++++++++++++++
17 maas/region.sls | 8 ++++++++
18 3 files changed, 39 insertions(+)
20 diff --git a/README.rst b/README.rst
21 index 78d8aef..8c35458 100644
24 @@ -181,6 +181,11 @@ Single MAAS region service [single UI/API]:
25 mac: '66:55:44:33:22:11'
26 commissioning_scripts:
27 00-maas-05-simplify-network-interfaces: /etc/maas/files/commisioning_scripts/00-maas-05-simplify-network-interfaces
29 + aarch64_hugepages_1g:
30 + comment: 'Enable 1G pagesizes on aarch64'
31 + definition: '//capability[@id="asimd"]'
32 + kernel_opts: 'default_hugepagesz=1G hugepagesz=1G'
34 # domain: mydomain.local # This function broken
35 http_proxy: http://192.168.0.10:3142
36 diff --git a/_modules/maas.py b/_modules/maas.py
37 index 28e46c5..f56ed34 100644
38 --- a/_modules/maas.py
39 +++ b/_modules/maas.py
40 @@ -876,6 +876,28 @@ class Domain(MaasObject):
44 +class Tags(MaasObject):
46 + super(Tags, self).__init__()
47 + self._all_elements_url = u'api/2.0/tags/'
48 + self._create_url = u'api/2.0/tags/'
49 + self._config_path = 'region.tags'
50 + self._update_url = u'api/2.0/tags/{0}/'
51 + self._update_key = 'name'
53 + def fill_data(self, name, tag_data):
57 + for key in ['comment', 'definition', 'kernel_opts']:
59 + data[key] = tag_data[key]
62 + def update(self, new, old):
66 class MachinesStatus(MaasObject):
68 def execute(cls, objects_name=None):
69 @@ -1064,5 +1086,9 @@ def process_sshprefs():
70 return SSHPrefs().process()
74 + return Tags().process()
77 def wait_for_machine_status(**kwargs):
78 return MachinesStatus.wait_for_machine_status(**kwargs)
79 diff --git a/maas/region.sls b/maas/region.sls
80 index 4a7f6cc..52fb952 100644
83 @@ -444,4 +444,12 @@ maas_sshkey_{{ idx }}:
87 +{%- if region.get('tags', False) %}
90 + - name: maas.process_tags
92 + - cmd: maas_login_admin