Skip to content

Commit a0d0c8d

Browse files
Romain Dartiguesromain-dartigues
authored andcommitted
CLOUDSTACK-9568: slow operations on system VM
1 parent 770397c commit a0d0c8d

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,11 @@ def hasIP(self, ip):
593593
return ip in self.address.values()
594594

595595
def arpPing(self):
596+
if not self.address['gateway'] or self.address['gateway'] == 'None':
597+
return
596598
cmd = "arping -c 1 -I %s -A -U -s %s %s" % (
597599
self.dev, self.address['public_ip'], self.address['gateway'])
598-
CsHelper.execute(cmd)
600+
CsHelper.execute_background(cmd)
599601

600602
# Delete any ips that are configured but not in the bag
601603
def compare(self, bag):

systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@
2424
import os.path
2525
import re
2626
import shutil
27+
28+
try:
29+
from subprocess import DEVNULL # py3k
30+
except ImportError:
31+
import os
32+
DEVNULL = open(os.devnull, 'wb')
33+
2734
from netaddr import *
2835
from pprint import pprint
2936

37+
3038
PUBLIC_INTERFACES = {"router" : "eth2", "vpcrouter" : "eth1"}
3139

3240
STATE_COMMANDS = {"router" : "ip addr | grep eth0 | grep inet | wc -l | xargs bash -c 'if [ $0 == 2 ]; then echo \"MASTER\"; else echo \"BACKUP\"; fi'",
@@ -180,11 +188,35 @@ def get_hostname():
180188

181189

182190
def execute(command):
183-
""" Execute command """
191+
"""Execute a command in a new process and return stdout
192+
193+
The command is executed in a shell (which allow use of pipes and such),
194+
wait for the command to terminate, and return stdout.
195+
196+
:param command: command with arguments to be executed,
197+
see :py:class:`subprocess.Popen`
198+
:type command: str or list or tuple
199+
:return: command stdout
200+
:rtype: list
201+
"""
184202
logging.debug("Executing: %s" % command)
185-
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
186-
result = p.communicate()[0]
187-
return result.splitlines()
203+
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=DEVNULL, shell=True)
204+
return p.communicate()[0].splitlines()
205+
206+
207+
def execute_background(command):
208+
"""Execute a command in a new process
209+
210+
The command is executed in a shell (which allow use of pipes and such).
211+
The function does not wait command completion to return.
212+
213+
:param command: command with arguments to be executed,
214+
see :py:class:`subprocess.Popen`
215+
:type command: str or list or tuple
216+
:return: None
217+
"""
218+
logging.debug("Executing: %s" % command)
219+
subprocess.Popen(command, stdout=DEVNULL, stderr=DEVNULL, shell=True)
188220

189221

190222
def save_iptables(command, iptables_file):

systemvm/patches/debian/config/opt/cloud/bin/merge.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,9 @@ def processCLItem(self, num, nw_type):
230230
dp['add'] = True
231231
dp['one_to_one_nat'] = False
232232
if nw_type == "public":
233-
dp['gateway'] = self.qFile.data['cmd_line']['gateway']
233+
dp['gateway'] = self.qFile.data['cmd_line'].get('gateway', 'None')
234234
else:
235-
if('localgw' in self.qFile.data['cmd_line']):
236-
dp['gateway'] = self.qFile.data['cmd_line']['localgw']
237-
else:
238-
dp['gateway'] = 'None'
235+
dp['gateway'] = self.qFile.data['cmd_line'].get('localgw', 'None')
239236
dp['nic_dev_id'] = num
240237
dp['nw_type'] = nw_type
241238
qf = QueueFile()

0 commit comments

Comments
 (0)