Skip to content

Commit bca4c83

Browse files
authored
Merge pull request #453 from mincheol-jeong/ablestack-diplo
ovs 사용할 시 nwfilter 적용 해제 및 Cube 호스트 제거 버그 수정
2 parents 994a840 + f98d972 commit bca4c83

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

python/cluster/cluster_config.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,35 @@ def insert(args):
7878
try:
7979
# Network Filter 적용
8080
# 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 = ""
102-
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}")
107-
subprocess.run(["sysctl", "-p"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
81+
openvswitch_service_check = os.system("systemctl is-active openvswitch > /dev/null")
82+
if openvswitch_service_check != 0:
83+
result = subprocess.run(["virsh", "nwfilter-list"], capture_output=True, text=True)
84+
if "allow-all" not in result.stdout:
85+
subprocess.run(["virsh", "nwfilter-define", "--file", "/usr/local/sbin/nwfilter-allow-all.xml"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
86+
87+
# 2. br_netfilter 모듈이 로드되지 않았으면 로드
88+
lsmod_result = subprocess.run(["lsmod"], capture_output=True, text=True)
89+
if "br_netfilter" not in lsmod_result.stdout:
90+
subprocess.run(["modprobe", "br_netfilter"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
91+
92+
# 3. sysctl.conf에 설정이 없을 때만 추가
93+
settings = [
94+
"net.bridge.bridge-nf-call-arptables=1",
95+
"net.bridge.bridge-nf-call-iptables=1",
96+
"net.bridge.bridge-nf-call-ip6tables=1"
97+
]
98+
99+
try:
100+
with open("/etc/sysctl.conf", "r") as f:
101+
existing_lines = f.read()
102+
except FileNotFoundError:
103+
existing_lines = ""
104+
105+
with open("/etc/sysctl.conf", "a") as sysctl_file:
106+
for line in settings:
107+
if line not in existing_lines:
108+
sysctl_file.write(f"\n{line}")
109+
subprocess.run(["sysctl", "-p"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
108110

109111
# 수정할 cluster.json 파일 읽어오
110112
# 기존 file json 데이터를 param 데이터로 교체

python/cluster/remove_cube_host.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def remove(args):
8787
outfile.write('{\n')
8888
outfile.write(' "bootstrap": {\n')
8989
outfile.write(' "scvm": "false",\n')
90-
outfile.write(' "ccvm": "false"\n')
90+
outfile.write(' "ccvm": "false",\n')
9191
outfile.write(' "pfmp": "false"\n')
9292
outfile.write(' },\n')
9393
outfile.write(' "monitoring": {\n')
@@ -98,6 +98,7 @@ def remove(args):
9898
with open(cluster_file_path, 'w') as outfile:
9999
outfile.write('{\n')
100100
outfile.write(' "clusterConfig": {\n')
101+
outfile.write(' "type" : "",\n')
101102
outfile.write(' "ccvm": {\n')
102103
outfile.write(' "ip": ""\n')
103104
outfile.write(' "pn": ""\n')
@@ -129,6 +130,7 @@ def remove(args):
129130
with open(cluster_file_path, 'w') as outfile:
130131
outfile.write('{\n')
131132
outfile.write(' "clusterConfig": {\n')
133+
outfile.write(' "type": "",\n')
132134
outfile.write(' "ccvm": {\n')
133135
outfile.write(' "ip": ""\n')
134136
outfile.write(' },\n')

0 commit comments

Comments
 (0)