Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
40 changes: 36 additions & 4 deletions systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 2 additions & 5 deletions systemvm/patches/debian/config/opt/cloud/bin/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there could be a possibility of having an ipv6 gateway, in that case, we would be looking at ip6gateway.

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()
Expand Down