1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: Copyright (c) 2018 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 <Alexandru.Avadanii@enea.com>
Date: Sat, 29 Dec 2018 23:09:01 +0100
Subject: [PATCH] Implement 'tags' support
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
---
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 28e46c5..f56ed34 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):
@@ -1064,5 +1086,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 %}
|