mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 11302: more efficient caching of keyword
This commit is contained in:
parent
c05903b2d0
commit
a51ee064ee
@ -405,6 +405,9 @@ def can_bridge_firewall(session, args):
|
||||
allow_egress_traffic(session)
|
||||
if not os.path.exists('/var/run/cloud'):
|
||||
os.makedirs('/var/run/cloud')
|
||||
if not os.path.exists('/var/cache/cloud'):
|
||||
os.makedirs('/var/cache/cloud')
|
||||
get_ipset_keyword()
|
||||
|
||||
cleanup_rules_for_dead_vms(session)
|
||||
cleanup_rules(session, args)
|
||||
@ -1152,9 +1155,8 @@ def inflate_rules (zipped):
|
||||
return zlib.decompress(base64.b64decode(zipped))
|
||||
|
||||
@echo
|
||||
def get_ipset_keyword():
|
||||
def cache_ipset_keyword():
|
||||
tmpname = 'ipsetqzvxtmp'
|
||||
keyword = 'match-set'
|
||||
try:
|
||||
util.pread2(['/bin/bash', '-c', 'ipset -N ' + tmpname + ' iptreemap'])
|
||||
except:
|
||||
@ -1171,6 +1173,32 @@ def get_ipset_keyword():
|
||||
util.pread2(['/bin/bash', '-c', 'ipset -X ' + tmpname])
|
||||
except:
|
||||
pass
|
||||
|
||||
cachefile = "/var/cache/cloud/ipset.keyword"
|
||||
util.SMlog("Writing ipset keyword to " + cachefile)
|
||||
cachef = open(cachefile, 'w')
|
||||
try:
|
||||
cachef.write(keyword)
|
||||
cachef.write('\n')
|
||||
except:
|
||||
util.SMlog("Failed to write to cache file " + cachef)
|
||||
|
||||
cachef.close()
|
||||
return keyword
|
||||
|
||||
@echo
|
||||
def get_ipset_keyword():
|
||||
cachefile = "/var/cache/cloud/ipset.keyword"
|
||||
keyword = 'match-set'
|
||||
|
||||
if not os.path.exists(cachefile):
|
||||
util.SMlog("Failed to find ipset keyword cachefile %s" %cachefile)
|
||||
keyword = cache_ipset_keyword()
|
||||
else:
|
||||
lines = (line.rstrip() for line in open(cachefile))
|
||||
for line in lines:
|
||||
keyword = line
|
||||
break
|
||||
|
||||
return keyword
|
||||
|
||||
|
||||
1395
scripts/vm/hypervisor/xenserver/vmops.orig
Executable file
1395
scripts/vm/hypervisor/xenserver/vmops.orig
Executable file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user