mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
use ufw to configure iptable in ubuntu for mgmt server ports
This commit is contained in:
parent
f41b352d36
commit
f19e9252a4
20
python/lib/cloudutils/serviceConfig.py
Normal file → Executable file
20
python/lib/cloudutils/serviceConfig.py
Normal file → Executable file
@ -651,3 +651,23 @@ class firewallConfigServer(firewallConfigBase):
|
|||||||
self.ports = "443 8080 8096 8250 8443 9090".split()
|
self.ports = "443 8080 8096 8250 8443 9090".split()
|
||||||
else:
|
else:
|
||||||
self.ports = "8080 8096 8250 9090".split()
|
self.ports = "8080 8096 8250 9090".split()
|
||||||
|
|
||||||
|
class ubuntuFirewallConfigServer(firewallConfigServer):
|
||||||
|
def allowPort(self, port):
|
||||||
|
status = False
|
||||||
|
try:
|
||||||
|
status = bash("iptables-save|grep INPUT|grep -w %s"%port).isSuccess()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if not status:
|
||||||
|
bash("ufw allow %s/tcp"%port)
|
||||||
|
|
||||||
|
def config(self):
|
||||||
|
try:
|
||||||
|
for port in self.ports:
|
||||||
|
self.allowPort(port)
|
||||||
|
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|||||||
2
python/lib/cloudutils/syscfg.py
Normal file → Executable file
2
python/lib/cloudutils/syscfg.py
Normal file → Executable file
@ -178,4 +178,4 @@ class sysConfigServerUbuntu(sysConfigServer):
|
|||||||
super(sysConfigServerUbuntu, self).__init__(glbEnv)
|
super(sysConfigServerUbuntu, self).__init__(glbEnv)
|
||||||
self.svo = serviceOpsUbuntu()
|
self.svo = serviceOpsUbuntu()
|
||||||
self.services = [sudoersConfig(self),
|
self.services = [sudoersConfig(self),
|
||||||
firewallConfigServer(self)]
|
ubuntuFirewallConfigServer(self)]
|
||||||
|
|||||||
4
python/lib/cloudutils/utilities.py
Normal file → Executable file
4
python/lib/cloudutils/utilities.py
Normal file → Executable file
@ -155,7 +155,7 @@ class serviceOpsRedhat(serviceOps):
|
|||||||
class serviceOpsUbuntu(serviceOps):
|
class serviceOpsUbuntu(serviceOps):
|
||||||
def isServiceRunning(self, servicename):
|
def isServiceRunning(self, servicename):
|
||||||
try:
|
try:
|
||||||
o = bash("service " + servicename + " status")
|
o = bash("/usr/sbin/service " + servicename + " status")
|
||||||
if "running" in o.getStdout() or "start" in o.getStdout():
|
if "running" in o.getStdout() or "start" in o.getStdout():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@ -165,7 +165,7 @@ class serviceOpsUbuntu(serviceOps):
|
|||||||
|
|
||||||
def stopService(self, servicename,force=False):
|
def stopService(self, servicename,force=False):
|
||||||
if self.isServiceRunning(servicename) or force:
|
if self.isServiceRunning(servicename) or force:
|
||||||
return bash("service " + servicename +" stop").isSuccess()
|
return bash("/usr/sbin/service " + servicename +" stop").isSuccess()
|
||||||
|
|
||||||
def disableService(self, servicename):
|
def disableService(self, servicename):
|
||||||
result = self.stopService(servicename)
|
result = self.stopService(servicename)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user