mirror of https://github.com/apache/cloudstack.git
Change security_group_agent python side in line with default
security group rules change in 4.2
This commit is contained in:
parent
e5e39577c0
commit
59406cf225
|
|
@ -323,6 +323,14 @@ class SGAgent(object):
|
|||
|
||||
@staticmethod
|
||||
def start():
|
||||
|
||||
def create_rule_if_not_exists(rule):
|
||||
out = sglib.ShellCmd('iptables-save')()
|
||||
if rule in out:
|
||||
return
|
||||
|
||||
sglib.ShellCmd('iptables %s' % rule)()
|
||||
|
||||
def prepare_default_rules():
|
||||
sglib.ShellCmd('iptables --policy INPUT DROP')()
|
||||
name = 'default-chain'
|
||||
|
|
@ -330,7 +338,9 @@ class SGAgent(object):
|
|||
sglib.ShellCmd('iptables -F %s' % name)()
|
||||
except Exception:
|
||||
sglib.ShellCmd('iptables -N %s' % name)()
|
||||
sglib.ShellCmd('iptables -I INPUT -p tcp --dport 9988 -j ACCEPT')()
|
||||
|
||||
create_rule_if_not_exists('-I INPUT -p tcp --dport 9988 -j ACCEPT')
|
||||
create_rule_if_not_exists('-I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT')
|
||||
|
||||
|
||||
prepare_default_rules()
|
||||
|
|
|
|||
Loading…
Reference in New Issue