Tag Archives: systemd

A few common operations while testing OpenStack on systemd based distros

While testing OpenStack on Fedora, I had to do some common operations to restart, list services. I started using systemctl — which is used to control & introspect the Systemd services. Noting them here, for reference. These should ideally be scripted, typing such long commands would be cumbersome.

List all enabled systemd unit files for OpenStack services:

$ systemctl list-unit-files --type=service | \
  grep -i openstack | grep -i enabled \
  | awk '{print $1}'

Status of OpenStack services active, inactive:

$ for i in `systemctl list-unit-files --type=service | \
  grep -i openstack |  grep -i enabled | \
  awk '{print $1}'`; do systemctl status $i ; done

Status of all OpenStack services, active:

$ for i in `systemctl list-unit-files --type=service | \
  grep -i openstack | grep -i enabled | awk '{print $1}'`; \
  do systemctl status $i ; done | grep Active -B1

Status of OpenStack services, inactive:

$ for i in `systemctl list-unit-files --type=service | \
  grep -i openstack | grep -i enabled | awk '{print $1}'`; \
  do systemctl status $i ; done | egrep -i 'Active|dead' -B1

Restart existing services. In systemd’s parlance, all enabled OpenStack unit files:

$ for i in `systemctl list-unit-files --type=service | \
  grep -i openstack | grep -i enabled | awk '{print $1}'`; \
  do systemctl restart $i ; done

Update: Updated the title to reflect its applicable for systemd based distros

Advertisement

1 Comment

Filed under Uncategorized

Bridged networking notes with systemctl

Bridged networking gives the ability to make the virtual machines appear as just any other machine on the LAN, and I find it very useful while managing virtual networks. From Fedora 15 on wards, systemd has become the default init system on Fedora. Here is some quick notes on configuring bridging using the systemctl utility to control services on the system:

Disable the NetworkManager service, and turn on the classic network service:

[root@tbox ~]# systemctl disable NetworkManager.service

[root@tbox ~]# systemctl enable network.service 

Create a bridge interface file, and modify your em1 interface(Note that, since ‘Consistent Network Device Naming’ feature is introduced, netowkr interface names have changed to em[1234] (correspondig to physical locations) from ethX

 #----------------------------------------------------------#
[root@tbox network-scripts]# cat ifcfg-em1
DEVICE=em1
BOOTPROTO=dhcp
TYPE=Ethernet
ONBOOT=yes
IPV6INIT=no
NM_CONTROLLED=no
USERCTL=no
PEERDNS=yes
PEERROUTES=yes
BRIDGE=br0
#----------------------------------------------------------#
[root@tbox network-scripts]# cat ifcfg-br0 
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
[root@tbox network-scripts]# 
#----------------------------------------------------------#
 

Restart the network service:

 
[root@tbox ~]# systemctl restart network.service

 

Ensure ‘network’ service is enabled(and NetworkManager is disabled) for the next boot:

#----------------------------------------------------------#
[root@tbox ~]# systemctl is-enabled network.service
network.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig network --level=5
enabled
[root@tbox ~]#
#----------------------------------------------------------#
[root@tbox ~]# systemctl | grep -i network.service
network.service           loaded active running       LSB: Bring up/down networking
[root@tbox ~]# 
#----------------------------------------------------------#
[root@tbox ~]# systemctl is-enabled NetworkManager.service
disabled
[root@tbox ~]#
#----------------------------------------------------------#

End result — Bridge(br0) inteface will have the IP address, and the em1 would lose it, as expected:

#----------------------------------------------------------#
[root@tbox ~]# ifconfig br0
br0       Link encap:Ethernet  HWaddr 00:21:9B:73:E2:65  
          inet addr:ww.xx.yy.zz  Bcast:ww.xx.yy.255  Mask:255.255.255.0
          inet6 addr: 2620:52:0:41c9:221:9bff:fe73:e265/64 Scope:Global
          inet6 addr: fe80::44c0:2bff:fe0d:b38c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26475163 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3031754 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1836168879 (1.7 GiB)  TX bytes:304657564 (290.5 MiB)

[root@tbox ~]# 
#----------------------------------------------------------#
[root@tbox ~]# ifconfig em1
em1       Link encap:Ethernet  HWaddr 00:21:9B:73:E2:65  
          inet6 addr: fe80::221:9bff:fe73:e265/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:28841542 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4659974 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3999390382 (3.7 GiB)  TX bytes:580866999 (553.9 MiB)
          Interrupt:16 
#----------------------------------------------------------#

(NOTE: I just masked out IP with ‘ww.xx.yy.zz’)

UPDATE: I totally forgot to discuss the recent additions like ‘iface-bridge/iface-unbridge’ to libvirt to simplify creating a bridge. If someone wants to try, this should be the sequence to create a bridge:
# virsh iface-begin
# virsh iface-bridge em1 br0
# virsh iface-commit

5 Comments

Filed under Uncategorized