From 34bdffb5c9b5022156dc64dec44be4647bf805a0 Mon Sep 17 00:00:00 2001 From: parmentelat Date: Fri, 7 Dec 2018 15:46:59 +0100 Subject: [PATCH] use systemctl instead of service --- system/TestPlc.py | 23 +++++++++-------------- system/template-qemu/qemu-bridge-init | 15 +++++++-------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/system/TestPlc.py b/system/TestPlc.py index fec7533..bd8580d 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -797,22 +797,18 @@ class TestPlc: utils.system('rm {}'.format(tmpname)) return True - # care only about f>=25 - def start_stop_service(self, service, start_or_stop): - "utility to start/stop an old-fashioned service (plc)" - return self.run_in_guest("service {} {}".format(service, start_or_stop)) == 0 - + # care only about f>=27 def start_stop_systemd(self, service, start_or_stop): "utility to start/stop a systemd-defined service (sfa)" return self.run_in_guest("systemctl {} {}".format(start_or_stop, service)) == 0 def plc_start(self): - "service plc start" - return self.start_stop_service('plc', 'start') + "start plc through systemclt" + return self.start_stop_systemd('plc', 'start') def plc_stop(self): - "service plc stop" - return self.start_stop_service('plc', 'stop') + "stop plc through systemctl" + return self.start_stop_systemd('plc', 'stop') def plcvm_start(self): "start the PLC vserver" @@ -1703,7 +1699,7 @@ class TestPlc: return self.run_in_guest('sfaadmin reg import_registry') == 0 def sfa_start(self): - "service sfa start" + "start SFA through systemctl" return (self.start_stop_systemd('sfa-registry', 'start') and self.start_stop_systemd('sfa-aggregate', 'start')) @@ -1801,7 +1797,7 @@ class TestPlc: def sfa_delete_slice(self): pass def sfa_stop(self): - "service sfa stop" + "stop sfa through systemclt" return (self.start_stop_systemd('sfa-aggregate', 'stop') and self.start_stop_systemd('sfa-registry', 'stop')) @@ -1927,14 +1923,13 @@ class TestPlc: def plc_db_restore(self): 'restore the planetlab5 DB - looks broken, but run -n might help' dump = self.dbfile("planetab5") - ##stop httpd service - self.run_in_guest('service httpd stop') + self.run_in_guest('systemctl stop httpd') # xxx - need another wrapper self.run_in_guest_piped('echo drop database planetlab5', 'psql --user=pgsqluser template1') self.run_in_guest('createdb -U postgres --encoding=UNICODE --owner=pgsqluser planetlab5') self.run_in_guest('psql -U pgsqluser planetlab5 -f ' + dump) ##starting httpd service - self.run_in_guest('service httpd start') + self.run_in_guest('systemctl start httpd') utils.header('Database restored from ' + dump) diff --git a/system/template-qemu/qemu-bridge-init b/system/template-qemu/qemu-bridge-init index e390bfe..ff4198c 100755 --- a/system/template-qemu/qemu-bridge-init +++ b/system/template-qemu/qemu-bridge-init @@ -1,7 +1,7 @@ #!/bin/bash # Thierry Parmentelat -# Copyright (C) 2010 INRIA +# Copyright (C) 2010 INRIA # # Establishment of a runtime environment for a # virtual machine under QEMU, This script allows the host box @@ -31,7 +31,7 @@ for line in file("/proc/net/dev"): print ifname EOF } - + function discover_interface () { for ifname in $(gather_interfaces); do ip link show $ifname | grep -qi 'state UP' && { echo $ifname; return; } @@ -80,7 +80,7 @@ function start () { #Getting host IP/masklen address=$(/sbin/ip address show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $2;}') [ -z "$address" ] && { echo "ERROR: Could not determine IP address for $INTERFACE_LAN" ; exit 1 ; } - + broadcast=$(/sbin/ip address show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $4;}') [ -z "$broadcast" ] && echo "WARNING: Could not determine broadcast address for $INTERFACE_LAN" @@ -120,7 +120,7 @@ function start () { ip address add $address broadcast $broadcast dev $INTERFACE_BRIDGE # turn on bridge interface ip link set dev $INTERFACE_BRIDGE up - ip address del $address dev $INTERFACE_LAN + ip address del $address dev $INTERFACE_LAN sleep 1 #Reconfigure the routing table @@ -133,7 +133,7 @@ function start () { echo "========== $COMMAND: exiting start - end" } -#Adding a new interface to the bridge: this is used by qemu-ifup +#Adding a new interface to the bridge: this is used by qemu-ifup function add () { [[ -z "$@" ]] && { echo "Usage: $COMMAND add ifname" ; exit 1 ; } @@ -170,7 +170,7 @@ function add () { echo "Installed iptables" iptables-save - + echo "========== $COMMAND: exiting add - end" } @@ -190,8 +190,7 @@ function stop () { brctl delif $INTERFACE_BRIDGE $INTERFACE_LAN ip address del $address dev $INTERFACE_BRIDGE brctl delbr $INTERFACE_BRIDGE - /sbin/service network restart - /sbin/service iptables restart + systemctl NetworkManager restart } function main () { -- 2.43.0