-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·206 lines (180 loc) · 8.52 KB
/
Makefile
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
VERSION = 0.3
.PHONY: all clean modules
PKGPATH=pkg
CURDIR=$(shell pwd)
PYDIR=$(shell which python3)
PREFIX ?= /usr
LIBEXEC ?= libexec
BINDIR = $(DESTDIR)$(PREFIX)/bin
SYSTEMDDIR = $(DESTDIR)$(PREFIX)/lib/systemd/system
SRCVERSION = $(shell git rev-parse --short HEAD 2>/dev/null)
ATUNEVERSION = $(VERSION)$(if $(SRCVERSION),($(SRCVERSION)))
SHELL = /bin/bash
GOLDFLAGS += -X gitee.com/openeuler/A-Tune/common/config.Version=$(ATUNEVERSION)
GOFLAGS = -ldflags '-s -w -extldflags "-static" -extldflags "-zrelro" -extldflags "-znow" -extldflags "-ftrapv" $(GOLDFLAGS)'
CERT_PATH=$(DESTDIR)/etc/atuned
GRPC_CERT_PATH=$(CERT_PATH)/grpc_certs
REST_CERT_PATH=$(CERT_PATH)/rest_certs
ENGINE_CERT_PATH=$(CERT_PATH)/engine_certs
REST_IP_ADDR=localhost
ENGINE_IP_ADDR=localhost
all: abs-python modules atune-adm atuned db
abs-python:
@if [ $(PYDIR) ] ; then \
sed -i "s?ExecStart=python3?ExecStart=$(PYDIR)?g" $(CURDIR)/misc/atune-engine.service; \
else \
echo "no python3 exists."; \
fi
atune-adm:
go build -mod=vendor -v $(GOFLAGS) -o $(PKGPATH)/atune-adm cmd/atune-adm/*.go
atuned:
go build -mod=vendor -v $(GOFLAGS) -o $(PKGPATH)/atuned cmd/atuned/*.go
modules:
cd ${CURDIR}/modules/server/profile/ && go build -mod=vendor -v $(GOFLAGS) -buildmode=plugin -o ${CURDIR}/pkg/daemon_profile_server.so *.go
clean:
rm -rf $(PKGPATH)/*
cleanall: clean
rm -rf $(DESTDIR)/etc/atuned/
rm -rf $(DESTDIR)$(PREFIX)/lib/atuned/
rm -rf $(DESTDIR)$(PREFIX)/share/atuned/
rm -rf $(DESTDIR)$(PREFIX)/$(LIBEXEC)/atuned/
rm -rf $(DESTDIR)/var/lib/atuned/
rm -rf $(DESTDIR)/var/run/atuned/
rm -rf $(DESTDIR)/var/atuned/
db:
sqlite3 database/atuned.db ".read database/init.sql"
install: libinstall models restcerts enginecerts yaml-generator
collector-install:
@echo "BEGIN INSTALL A-Tune-Collector..."
! pip3 show atune-collector || pip3 uninstall atune-collector -y
rm -rf collector
git clone https://gitee.com/openeuler/A-Tune-Collector.git collector
cd collector && python3 setup.py install
@echo "END INSTALL A-Tune-Collector..."
libinstall:
@echo "BEGIN INSTALL A-Tune..."
mkdir -p $(BINDIR)
mkdir -p $(SYSTEMDDIR)
rm -rf $(DESTDIR)/etc/atuned/
rm -rf $(DESTDIR)$(PREFIX)/lib/atuned/
rm -rf $(DESTDIR)$(PREFIX)/share/atuned/
rm -rf $(DESTDIR)$(PREFIX)/$(LIBEXEC)/atuned/
rm -rf $(DESTDIR)/var/lib/atuned/
rm -rf $(DESTDIR)/var/run/atuned/
rm -rf $(DESTDIR)/var/atuned/
mkdir -p $(DESTDIR)/etc/atuned/tuning
mkdir -p $(DESTDIR)/etc/atuned/rules
mkdir -p $(DESTDIR)/etc/atuned/training
mkdir -p $(DESTDIR)/etc/atuned/classification
mkdir -p $(DESTDIR)$(PREFIX)/lib/atuned/modules
mkdir -p $(DESTDIR)$(PREFIX)/lib/atuned/profiles
mkdir -p $(DESTDIR)$(PREFIX)/lib/atuned/training
mkdir -p $(DESTDIR)$(PREFIX)/share/atuned
mkdir -p $(DESTDIR)$(PREFIX)/$(LIBEXEC)/atuned/analysis/models
mkdir -p $(DESTDIR)/var/lib/atuned
mkdir -p $(DESTDIR)/var/run/atuned
mkdir -p $(DESTDIR)/var/atuned
mkdir -p $(DESTDIR)$(PREFIX)/share/bash-completion/completions
install -m 640 pkg/daemon_profile_server.so $(DESTDIR)$(PREFIX)/lib/atuned/modules
install -m 750 pkg/atune-adm $(BINDIR)
install -m 750 pkg/atuned $(BINDIR)
install -m 640 misc/atuned.service $(SYSTEMDDIR)
install -m 640 misc/atuned.cnf $(DESTDIR)/etc/atuned/
install -m 640 misc/engine.cnf $(DESTDIR)/etc/atuned/
install -m 640 misc/batch_algo.yaml $(DESTDIR)/etc/atuned/
install -m 640 rules/tuning/tuning_rules.grl $(DESTDIR)/etc/atuned/rules
install -m 640 misc/atune-engine.service $(SYSTEMDDIR)
install -m 640 database/atuned.db $(DESTDIR)/var/lib/atuned/
install -m 640 misc/atune-adm $(DESTDIR)$(PREFIX)/share/bash-completion/completions/
\cp -rf analysis/* $(DESTDIR)$(PREFIX)/$(LIBEXEC)/atuned/analysis/
chmod -R 750 $(DESTDIR)$(PREFIX)/$(LIBEXEC)/atuned/analysis/
\cp -rf profiles/* $(DESTDIR)$(PREFIX)/lib/atuned/profiles/
chmod -R 750 $(DESTDIR)$(PREFIX)/lib/atuned/profiles/
@echo "END INSTALL A-Tune"
rpm:
cd .. && tar -zcvf v$(VERSION).tar.gz A-Tune
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mv ../v$(VERSION).tar.gz ~/rpmbuild/SOURCES
rpmbuild -ba misc/atune.spec
models:
cd ${CURDIR}/tools/ && python3 generate_models.py --model_path $(DESTDIR)$(PREFIX)/$(LIBEXEC)/atuned/analysis/models
search:
cd ${CURDIR}/tools/ && python3 generate_models.py --search=True --model_path $(DESTDIR)$(PREFIX)/$(LIBEXEC)/atuned/analysis/models
grpccerts:
@echo "BEGIN GENERATE GRPC CERTS..."
mkdir -p $(GRPC_CERT_PATH)
openssl genrsa -out $(GRPC_CERT_PATH)/ca.key 2048
openssl req -new -x509 -days 3650 -subj "/CN=ca" -key $(GRPC_CERT_PATH)/ca.key -out $(GRPC_CERT_PATH)/ca.crt
@for name in server client; do \
openssl genrsa -out $(GRPC_CERT_PATH)/$$name.key 2048; \
openssl req -new -subj "/CN=$$name" -key $(GRPC_CERT_PATH)/$$name.key -out $(GRPC_CERT_PATH)/$$name.csr; \
openssl x509 -req -sha256 -CA $(GRPC_CERT_PATH)/ca.crt -CAkey $(GRPC_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
-in $(GRPC_CERT_PATH)/$$name.csr -out $(GRPC_CERT_PATH)/$$name.crt; \
done
rm -rf $(GRPC_CERT_PATH)/*.srl $(GRPC_CERT_PATH)/*.csr
@echo "END GENERATE GRPC CERTS"
restcerts:
@echo "BEGIN GENERATE REST CERTS..."
mkdir -p $(REST_CERT_PATH)
openssl genrsa -out $(REST_CERT_PATH)/ca.key 2048
openssl req -new -x509 -days 3650 -subj "/CN=ca" -key $(REST_CERT_PATH)/ca.key -out $(REST_CERT_PATH)/ca.crt
openssl genrsa -out $(REST_CERT_PATH)/server.key 2048
cp /etc/pki/tls/openssl.cnf $(REST_CERT_PATH)
@if test $(REST_IP_ADDR) == localhost; then \
echo "[SAN]\nsubjectAltName=DNS:$(REST_IP_ADDR)" >> $(REST_CERT_PATH)/openssl.cnf; \
echo "subjectAltName=DNS:$(REST_IP_ADDR)" > $(REST_CERT_PATH)/extfile.cnf; \
else \
echo "[SAN]\nsubjectAltName=IP:$(REST_IP_ADDR)" >> $(REST_CERT_PATH)/openssl.cnf; \
echo "subjectAltName=IP:$(REST_IP_ADDR)" > $(REST_CERT_PATH)/extfile.cnf; \
fi
openssl req -new -subj "/CN=$(REST_IP_ADDR)" -config $(REST_CERT_PATH)/openssl.cnf \
-key $(REST_CERT_PATH)/server.key -out $(REST_CERT_PATH)/server.csr
openssl x509 -req -sha256 -CA $(REST_CERT_PATH)/ca.crt -CAkey $(REST_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
-extfile $(REST_CERT_PATH)/extfile.cnf -in $(REST_CERT_PATH)/server.csr -out $(REST_CERT_PATH)/server.crt
rm -rf $(REST_CERT_PATH)/*.srl $(REST_CERT_PATH)/*.csr $(REST_CERT_PATH)/*.cnf
@echo "END GENERATE REST CERTS"
enginecerts:
@echo "BEGIN GENERATE ENGINE CERTS..."
mkdir -p $(ENGINE_CERT_PATH)
@if test ! -f $(ENGINE_CERT_PATH)/ca.key; then \
openssl genrsa -out $(ENGINE_CERT_PATH)/ca.key 2048; \
openssl req -new -x509 -days 3650 -subj "/CN=ca" -key $(ENGINE_CERT_PATH)/ca.key -out $(ENGINE_CERT_PATH)/ca.crt; \
fi
cp /etc/pki/tls/openssl.cnf $(ENGINE_CERT_PATH)
@if test $(ENGINE_IP_ADDR) == localhost; then \
echo "[SAN]\nsubjectAltName=DNS:$(ENGINE_IP_ADDR)" >> $(ENGINE_CERT_PATH)/openssl.cnf; \
echo "subjectAltName=DNS:$(ENGINE_IP_ADDR)" > $(ENGINE_CERT_PATH)/extfile.cnf; \
else \
echo "[SAN]\nsubjectAltName=IP:$(ENGINE_IP_ADDR)" >> $(ENGINE_CERT_PATH)/openssl.cnf; \
echo "subjectAltName=IP:$(ENGINE_IP_ADDR)" > $(ENGINE_CERT_PATH)/extfile.cnf; \
fi
@for name in server client; do \
openssl genrsa -out $(ENGINE_CERT_PATH)/$$name.key 2048; \
openssl req -new -subj "/CN=$(ENGINE_IP_ADDR)" -config $(ENGINE_CERT_PATH)/openssl.cnf \
-key $(ENGINE_CERT_PATH)/$$name.key -out $(ENGINE_CERT_PATH)/$$name.csr; \
openssl x509 -req -sha256 -CA $(ENGINE_CERT_PATH)/ca.crt -CAkey $(ENGINE_CERT_PATH)/ca.key -CAcreateserial -days 3650 \
-extfile $(ENGINE_CERT_PATH)/extfile.cnf -in $(ENGINE_CERT_PATH)/$$name.csr -out $(ENGINE_CERT_PATH)/$$name.crt; \
done
rm -rf $(ENGINE_CERT_PATH)/*.srl $(ENGINE_CERT_PATH)/*.csr $(ENGINE_CERT_PATH)/*.cnf
@echo "END GENERATE ENGINE CERTS"
env:
@echo "BEGIN SET ENVIRONMENT VARIABLES..."
@echo "export ATUNED_TLS=yes" > $(GRPC_CERT_PATH)/env
@echo "export ATUNED_CACERT=$(GRPC_CERT_PATH)/ca.crt" >> $(CERT_PATH)/env
@echo "export ATUNED_CLIENTCERT=$(GRPC_CERT_PATH)/client.crt" >> $(CERT_PATH)/env
@echo "export ATUNED_CLIENTKEY=$(GRPC_CERT_PATH)/client.key" >> $(CERT_PATH)/env
@echo "export ATUNED_SERVERCN=server" >> $(CERT_PATH)/env
@echo "END SET ENVIRONMENT VARIABLES"
startup:
systemctl daemon-reload
systemctl restart atuned
systemctl restart atune-engine
yaml-generator:
\cp -rf tuning/yamls/* $(DESTDIR)/etc/atuned/tuning
chmod -R 750 $(DESTDIR)/etc/atuned/tuning
cd ${CURDIR}/tools/ && python3 generate_tuning_file.py -d $(DESTDIR)/etc/atuned/tuning
run: all collector-install install startup
check: run
cd ${CURDIR}/tests && sh run_tests.sh
authors:
git shortlog --summary --numbered --email|grep -v openeuler-ci-bot|sed 's/<root@localhost.*//'| awk '{$$1=null;print $$0}'|sed 's/^[ ]*//g' > AUTHORS