You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/01/13 17:01:54 UTC

[GitHub] romain-dartigues closed pull request #1604: improvement: systemvm slow operations

romain-dartigues closed pull request #1604: improvement: systemvm slow operations
URL: https://github.com/apache/cloudstack/pull/1604
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
index 64ddb2681b7..cff0aaac431 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
@@ -593,9 +593,11 @@ def hasIP(self, ip):
         return ip in self.address.values()
 
     def arpPing(self):
+        if not self.address['gateway'] or self.address['gateway'] == 'None':
+            return
         cmd = "arping -c 1 -I %s -A -U -s %s %s" % (
             self.dev, self.address['public_ip'], self.address['gateway'])
-        CsHelper.execute(cmd)
+        CsHelper.execute_background(cmd)
 
     # Delete any ips that are configured but not in the bag
     def compare(self, bag):
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py
index 1d6baff99e3..c57d68014e3 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py
@@ -24,9 +24,17 @@
 import os.path
 import re
 import shutil
+
+try:
+    from subprocess import DEVNULL # py3k
+except ImportError:
+    import os
+    DEVNULL = open(os.devnull, 'wb')
+
 from netaddr import *
 from pprint import pprint
 
+
 PUBLIC_INTERFACES = {"router" : "eth2", "vpcrouter" : "eth1"}
 
 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():
 
 
 def execute(command):
-    """ Execute command """
+    """Execute a command in a new process and return stdout
+
+    The command is executed in a shell (which allow use of pipes and such),
+    wait for the command to terminate, and return stdout.
+
+    :param command: command with arguments to be executed,
+                    see :py:class:`subprocess.Popen`
+    :type command: str or list or tuple
+    :return: command stdout
+    :rtype: list
+    """
     logging.debug("Executing: %s" % command)
-    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
-    result = p.communicate()[0]
-    return result.splitlines()
+    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=DEVNULL, shell=True)
+    return p.communicate()[0].splitlines()
+
+
+def execute_background(command):
+    """Execute a command in a new process
+
+    The command is executed in a shell (which allow use of pipes and such).
+    The function does not wait command completion to return.
+
+    :param command: command with arguments to be executed,
+                    see :py:class:`subprocess.Popen`
+    :type command: str or list or tuple
+    :return: None
+    """
+    logging.debug("Executing: %s" % command)
+    subprocess.Popen(command, stdout=DEVNULL, stderr=DEVNULL, shell=True)
 
 
 def save_iptables(command, iptables_file):
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/merge.py b/systemvm/patches/debian/config/opt/cloud/bin/merge.py
index 50d9ee9aae8..7e8aa4f1eac 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/merge.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/merge.py
@@ -230,12 +230,9 @@ def processCLItem(self, num, nw_type):
             dp['add'] = True
             dp['one_to_one_nat'] = False
             if nw_type == "public":
-                dp['gateway'] = self.qFile.data['cmd_line']['gateway']
+                dp['gateway'] = self.qFile.data['cmd_line'].get('gateway', 'None')
             else:
-                if('localgw' in self.qFile.data['cmd_line']):
-                    dp['gateway'] = self.qFile.data['cmd_line']['localgw']
-                else:
-                    dp['gateway'] = 'None'
+                dp['gateway'] = self.qFile.data['cmd_line'].get('localgw', 'None')
             dp['nic_dev_id'] = num
             dp['nw_type'] = nw_type
             qf = QueueFile()


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services