Skip to content

Commit

Permalink
Changing network restart to ifdown -a && ifup -a incase of 14.04
Browse files Browse the repository at this point in the history
Change-Id: I3946c255ba0a27f1d72d2357b593612db4af5dd1
Closes-Bug: #1414226
  • Loading branch information
msenthil committed Jan 24, 2015
1 parent d945cbc commit 301aa08
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions contrail_provisioning/common/staticroute_setup.py
Expand Up @@ -15,13 +15,15 @@
import argparse
import socket
import struct
import subprocess
from netaddr import IPNetwork
from tempfile import NamedTemporaryFile
from distutils.version import LooseVersion

logging.basicConfig(format='%(asctime)-15s:: %(funcName)s:%(levelname)s:: %(message)s',
level=logging.INFO)
log = logging.getLogger(__name__)
PLATFORM = platform.dist()[0]
(PLATFORM, VERSION, EXTRA) = platform.linux_distribution()

class StaticRoute(object):
'''Base class containing common methods for configuring static routes
Expand Down Expand Up @@ -106,8 +108,11 @@ class UbuntuStaticRoute(StaticRoute):
def restart_service(self):
'''Restart network service for Ubuntu'''
log.info('Restarting Network Services...')
os.system('sudo /etc/init.d/networking restart')
time.sleep(3)
if LooseVersion(VERSION) < LooseVersion("14.04"):
subprocess.call('sudo /etc/init.d/networking restart', shell=True)
else:
subprocess.call('sudo ifdown -a && sudo ifup -a', shell=True)
time.sleep(5)

def write_network_script(self):
'''Add route to ifup-parts dir and set the correct permission'''
Expand Down

0 comments on commit 301aa08

Please sign in to comment.