Skip to content

Commit 994a840

Browse files
authored
Merge pull request #451 from kt-cheon/ablestack-diplo
스토리지 클러스터 초기화 시 구성 파일 삭제 코드 추가
2 parents a91d51c + 7d5a5af commit 994a840

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

python/cluster/cluster_config.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,33 @@ def openClusterJson():
7777
def insert(args):
7878
try:
7979
# Network Filter 적용
80-
subprocess.run(["virsh", "nwfilter-define", "--file", "/usr/local/sbin/nwfilter-allow-all.xml"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
81-
subprocess.run(["modprobe", "br_netfilter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
82-
with open("/etc/sysctl.conf", "a") as sysctl_file:
83-
sysctl_file.write("\nnet.bridge.bridge-nf-call-arptables=1")
84-
sysctl_file.write("\nnet.bridge.bridge-nf-call-iptables=1")
85-
sysctl_file.write("\nnet.bridge.bridge-nf-call-ip6tables=1")
80+
# 1. virsh nwfilter 확인 후 정의
81+
result = subprocess.run(["virsh", "nwfilter-list"], capture_output=True, text=True)
82+
if "allow-all" not in result.stdout:
83+
subprocess.run(["virsh", "nwfilter-define", "--file", "/usr/local/sbin/nwfilter-allow-all.xml"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
84+
85+
# 2. br_netfilter 모듈이 로드되지 않았으면 로드
86+
lsmod_result = subprocess.run(["lsmod"], capture_output=True, text=True)
87+
if "br_netfilter" not in lsmod_result.stdout:
88+
subprocess.run(["modprobe", "br_netfilter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
89+
90+
# 3. sysctl.conf에 설정이 없을 때만 추가
91+
settings = [
92+
"net.bridge.bridge-nf-call-arptables=1",
93+
"net.bridge.bridge-nf-call-iptables=1",
94+
"net.bridge.bridge-nf-call-ip6tables=1"
95+
]
96+
97+
try:
98+
with open("/etc/sysctl.conf", "r") as f:
99+
existing_lines = f.read()
100+
except FileNotFoundError:
101+
existing_lines = ""
86102

103+
with open("/etc/sysctl.conf", "a") as sysctl_file:
104+
for line in settings:
105+
if line not in existing_lines:
106+
sysctl_file.write(f"\n{line}")
87107
subprocess.run(["sysctl", "-p"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
88108

89109
# 수정할 cluster.json 파일 읽어오

python/vm/reset_storage_center.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def resetStorageCenter(args):
5151

5252
# 스토리지센터 가상머신 qcow2 템플릿 삭제
5353
os.system("rm -rf /var/lib/libvirt/images/scvm.qcow2")
54+
55+
# 스토리지센터 설정 파일 삭제
56+
os.system("rm -rf /etc/ceph/*")
5457

5558
'''
5659
# cloudinit iso 삭제

tools/makerpm/ablestack.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# 최초 작성일 : 2021. 04. 02
44

55
Name: ablecube
6-
Version: %{?version}%{!?version:4.2}
6+
Version: %{?version}%{!?version:4.3}
77
Release: %{?release}%{!?release:2.wip.el9.noarch}
88
Source0: %{name}-%{version}.tar.gz
99
Summary: ablestack cube package

0 commit comments

Comments
 (0)