aboutsummaryrefslogtreecommitdiffstats
path: root/mcp/patches/salt-formula-maas/0003-Add-machines.delete-co-pxe_nat-sls.patch
blob: 9f13c4616c977b197d7686852d021a59324b2294 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Date: Sun, 19 Aug 2018 05:38:27 +0200
Subject: [PATCH] Add machines.delete & co, pxe_nat sls

Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
---
 maas/machines/delete.sls                  | 20 ++++++++++++
 maas/machines/mark_broken_fixed.sls       | 20 ++++++++++++
 maas/machines/override_failed_testing.sls | 20 ++++++++++++
 maas/pxe_nat.sls                          | 37 +++++++++++++++++++++++
 4 files changed, 97 insertions(+)
 create mode 100644 maas/machines/delete.sls
 create mode 100644 maas/machines/mark_broken_fixed.sls
 create mode 100644 maas/machines/override_failed_testing.sls
 create mode 100644 maas/pxe_nat.sls

diff --git a/maas/machines/delete.sls b/maas/machines/delete.sls
new file mode 100644
index 0000000..2903f92
--- /dev/null
+++ b/maas/machines/delete.sls
@@ -0,0 +1,20 @@
+##############################################################################
+# Copyright (c) 2017 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 "maas/map.jinja" import region with context %}
+
+maas_login_admin:
+  cmd.run:
+  - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials"
+  - unless: 'test -e /var/lib/maas/.maas_credentials'
+
+# TODO: implement delete_machine via _modules/maas.py
+delete_machine:
+  cmd.run:
+  - name: "maas login {{ region.admin.username }} http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && maas opnfv machine delete {{ pillar['system_id'] }}"
+  - require:
+    - cmd: maas_login_admin
diff --git a/maas/machines/mark_broken_fixed.sls b/maas/machines/mark_broken_fixed.sls
new file mode 100644
index 0000000..46691bb
--- /dev/null
+++ b/maas/machines/mark_broken_fixed.sls
@@ -0,0 +1,20 @@
+##############################################################################
+# Copyright (c) 2017 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 "maas/map.jinja" import region with context %}
+
+maas_login_admin:
+  cmd.run:
+  - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials"
+  - unless: 'test -e /var/lib/maas/.maas_credentials'
+
+# TODO: implement mark_broken_fixed_machine via _modules/maas.py
+mark_broken_fixed_machine:
+  cmd.run:
+  - name: "maas login {{ region.admin.username }} http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && maas opnfv machine mark-broken {{ pillar['system_id'] }} && sleep 10 && maas opnfv machine mark-fixed {{ pillar['system_id'] }} && maas opnfv machine test {{ pillar['system_id'] }} testing_scripts=fio"
+  - require:
+    - cmd: maas_login_admin
diff --git a/maas/machines/override_failed_testing.sls b/maas/machines/override_failed_testing.sls
new file mode 100644
index 0000000..e7fe1d2
--- /dev/null
+++ b/maas/machines/override_failed_testing.sls
@@ -0,0 +1,20 @@
+##############################################################################
+# 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 "maas/map.jinja" import region with context %}
+
+maas_login_admin:
+  cmd.run:
+  - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials"
+  - unless: 'test -e /var/lib/maas/.maas_credentials'
+
+# TODO: implement override_failed_testing via _modules/maas.py
+mark_broken_fixed_machine:
+  cmd.run:
+  - name: "maas login {{ region.admin.username }} http://{{ region.bind.host }}:5240/MAAS/api/2.0 - < /var/lib/maas/.maas_credentials && maas opnfv machine override-failed-testing {{ pillar['system_id'] }}"
+  - require:
+    - cmd: maas_login_admin
diff --git a/maas/pxe_nat.sls b/maas/pxe_nat.sls
new file mode 100644
index 0000000..8a03c4f
--- /dev/null
+++ b/maas/pxe_nat.sls
@@ -0,0 +1,37 @@
+##############################################################################
+# Copyright (c) 2017 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
+##############################################################################
+net.ipv4.ip_forward:
+  sysctl.present:
+    - value: 1
+
+iptables_pxe_nat:
+  iptables.append:
+    - table: nat
+    - chain: POSTROUTING
+    - jump: MASQUERADE
+    - destination: 0/0
+    - source: {{ salt['pillar.get']('_param:single_address') }}/{{ salt['pillar.get']('_param:opnfv_net_admin_mask') }}
+    - save: True
+
+iptables_pxe_source:
+  iptables.append:
+    - table: filter
+    - chain: INPUT
+    - jump: ACCEPT
+    - destination: 0/0
+    - source: {{ salt['pillar.get']('_param:single_address') }}/{{ salt['pillar.get']('_param:opnfv_net_admin_mask') }}
+    - save: True
+
+iptables_pxe_destination:
+  iptables.append:
+    - table: filter
+    - chain: INPUT
+    - jump: ACCEPT
+    - destination: {{ salt['pillar.get']('_param:single_address') }}/{{ salt['pillar.get']('_param:opnfv_net_admin_mask') }}
+    - source: 0/0
+    - save: True