Support compute node restart on CentOS 49/31649/3
authorliyuenan <liyuenan@huawei.com>
Fri, 24 Mar 2017 03:03:57 +0000 (11:03 +0800)
committerliyuenan <liyuenan@huawei.com>
Fri, 24 Mar 2017 06:38:56 +0000 (14:38 +0800)
JIRA: -

Openvswitch service in Ubuntu named openvswitch-switch, but it named
openvswitch in CentOS.

Change-Id: I2a4d3d0ae0a646971696bae798b623da059a3781
Signed-off-by: liyuenan <liyuenan@huawei.com>
deploy/adapters/ansible/roles/setup-network/files/setup_networks/setup_networks.py

index ab13e08..64c0469 100644 (file)
@@ -10,6 +10,8 @@
 import yaml
 import netaddr
 import os
+import platform
+import re
 import log as logging
 
 LOG = logging.getLogger("net-init")
@@ -88,6 +90,11 @@ def main(config):
     setup_ips(config["ip_settings"], config["sys_intf_mappings"])
 
 if __name__ == "__main__":
-    os.system("service openvswitch-switch status|| service openvswitch-switch start")  # noqa
+    if re.search('Ubuntu', platform.platform()):
+        os.system("service openvswitch-switch start")
+    elif re.search('redhat|centos', platform.platform()):
+        os.system("service openvswitch start")
+    else:
+        os.system("echo 'ERROR: no service named openvswitch'")
     config = yaml.load(open(config_path))
     main(config)