-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjanitor.1
302 lines (298 loc) · 6.26 KB
/
janitor.1
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
.\" Man page generated from reStructuredText.
.
.TH "JANITOR" "1" "May 04, 2021" "0.0.1" "janitor"
.SH NAME
janitor \- janitor Documentation
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.sp
Contents:
.SH MOTIVATION
.sp
I have been using OpenStack continuously since 2014 as a resource to run workloads with the main purpose of
testing software. Manage a healthy Openstack tenant quota is vital when working with CI/CD and a large number of
automated pipelines which run 24/7. A long time ago I and my team were having a lot of headaches with one of internal
Openstack the cluster which at that time had a very limited quota and workload capacity but was important for the
test workflow. With the constant false\-positive for test failing due to lack of public/floating IP, storage/volume,
and even virtual CPU when provisioning new VMs, we got the idea of implementing Janitor, a super simple script/codes
to \fIautomate the clean\-up task of deleting left\-over virtual machines as well network and volume from an Openstack
tenant, all managed by API and remote calls.\fP
.SH EXAMPLES
.sp
USAGE:
.sp
clean up virtual machines and release floating ips for Openstack keep items declared in the whitelist.txt file:
.INDENT 0.0
.IP 1. 3
load your Openstack rc
.IP 2. 3
run janitor
.INDENT 3.0
.INDENT 3.5
.INDENT 0.0
.TP
.B source ~/mytenant\-openrc.sh
janitor –openstack –whitelist /tmp/whitelist.txt
.UNINDENT
.UNINDENT
.UNINDENT
.UNINDENT
.sp
or passing openrc as argument:
.INDENT 0.0
.INDENT 3.5
janitor openstack –openrc /root/openrc.sh –whitelist /var/lib/jenkins/workspace/janitor/janitor_whitelist.txt –keystone v3
.UNINDENT
.UNINDENT
.sp
listing history for your janitor:
.INDENT 0.0
.INDENT 3.5
janitor –history
.UNINDENT
.UNINDENT
.SH INSTALL
.sp
\fBTested on Fedora 24 and AWS Linux version 7.0\fP
.sp
Fedora OS:
.sp
local build:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
make rpm
sudo dnf reinstall rpmbuild/RPMS/x86_64/janitor\-0.1\-1.x86_64.rpm
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
copr repo:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
sudo dnf install copr....
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
AWS Linux OS:
.sp
copr repo:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
sudo yum install copr....
.ft P
.fi
.UNINDENT
.UNINDENT
.SH SETUP DEVELOPMENT ENVIRONMENT
.SS Source Code
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
$ git clone https://github.com/eduardocerqueira/janitor.git
.ft P
.fi
.UNINDENT
.UNINDENT
.SS Installation
.SS Option 1: Start it on RPM
.sp
For development purposes, install following dependencies:
.INDENT 0.0
.IP \(bu 2
python = 2.7
.IP \(bu 2
python\-pip
.IP \(bu 2
Run the following
.INDENT 2.0
.INDENT 3.5
.sp
.nf
.ft C
$ cd janitor
$ pip install \-r requirements/devel.txt
$ pip install \-r requirements/production.txt
.ft P
.fi
.UNINDENT
.UNINDENT
.UNINDENT
.SS Option 2: Start it on Docker
.sp
\fBin progress\fP
.INDENT 0.0
.IP \(bu 2
Install Docker: see the \fI\%official installation
guide\fP for details. Generally, it
might be enough to run install it with \fByum\fP and the run it.
.INDENT 2.0
.INDENT 3.5
.sp
.nf
.ft C
$ sudo yum install docker\-engine
$ sudo service docker start
.ft P
.fi
.UNINDENT
.UNINDENT
.IP \(bu 2
for OS with SELINUX capabilities remember to setenforce 0 before start your docker service
.IP \(bu 2
Use this command to build a new image
.INDENT 2.0
.INDENT 3.5
.sp
.nf
.ft C
$ sudo docker build \-t <YOUR_NAME>/janitor <the directory your Dockerfile is located>
.ft P
.fi
.UNINDENT
.UNINDENT
.IP \(bu 2
Run the container
.INDENT 2.0
.INDENT 3.5
.sp
.nf
.ft C
$ docker run \-it \-d \-P <YOUR_NAME>/janitor /bin/bash
$ janitor \-\-help
.ft P
.fi
.UNINDENT
.UNINDENT
.UNINDENT
.SH BUILD
.SS From your local machine
.INDENT 0.0
.INDENT 3.5
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
$ cd janitor
$ make
Usage: make <target> where <target> is one of
clean clean temp files from local workspace
doc generate sphinx documentation and man pages
test run unit tests locally
tarball generate tarball of project
rpm build source codes and generate rpm file
srpm generate SRPM file
all clean test doc rpm
flake8 check Python style based on flake8
$ make rpm
.ft P
.fi
.UNINDENT
.UNINDENT
.UNINDENT
.UNINDENT
.SS Copr
.INDENT 0.0
.INDENT 3.5
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
Before doing any release, make sure that you have account on both sites and also make sure that you could
access to your fedorapeople space [1] and have enough permissions [2] to build \fIjanitor\fP in \fICopr\fP\&.
.INDENT 0.0
.INDENT 3.5
.INDENT 0.0
.INDENT 3.5
$ make srpm
.UNINDENT
.UNINDENT
.INDENT 0.0
.IP 1. 3
copy rpmbuild/SRPMS/janitor\-0.0.1\-1.src.rpm to janitor/copr
.IP 2. 3
push janitor/copr to github
.UNINDENT
.UNINDENT
.UNINDENT
.sp
\fIcopr\-cli\fP will be used, installed by \fIsudo yum/dnf install copr\-cli\fP and configure it. [3]
.UNINDENT
.UNINDENT
.UNINDENT
.UNINDENT
.sp
Request as \fIBuilder\fP for projects \fIjanitor\fP, wait until admin approves.
.sp
$ copr\-cli build janitor \fI\%https://github.com/eduardocerqueira/janitor/raw/master/copr/janitor\-0.0.1\-1.src.rpm\fP
.sp
Go and grab a cup of tea or coffee, the release build will be come out soon
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
# tag based builds: \(gahttps://copr.fedorainfracloud.org/coprs/eduardocerqueira/janitor/builds/\(ga
.ft P
.fi
.UNINDENT
.UNINDENT
.IP [1] 5
\fI\%https://fedorahosted.org/copr/wiki/HowToEnableRepo\fP
.IP [2] 5
\fI\%http://fedoraproject.org/wiki/Infrastructure/fedorapeople.org#Accessing_Your_fedorapeople.org_Space\fP
.IP [3] 5
\fI\%https://fedorahosted.org/copr/wiki/UserDocs#CanIgiveaccesstomyrepotomyteammate\fP
.IP [4] 5
\fI\%https://copr.fedoraproject.org/api/\fP
.INDENT 0.0
.IP \(bu 2
genindex
.IP \(bu 2
search
.UNINDENT
.SH AUTHOR
janitor Devel Team
.SH COPYRIGHT
2014-2015, janitor Devel Team
.\" Generated by docutils manpage writer.
.