Re: [systemd-devel] Launching a unit in response to a D-Bus signal

2012-10-03 Thread Matthew Booth

On 01/10/12 23:53, Mirco Tischler wrote:

2012/10/2 Kok, Auke-jan H auke-jan.h@intel.com:

On Mon, Oct 1, 2012 at 4:58 AM, Matthew Booth mbo...@redhat.com wrote:

I have a requirement to restart squid whenever the VPN goes up or down[1].
Reading around, it seems that the way to do this would be in response to the
relevant D-Bus signal, which seems to be this one:

signal sender=:1.6 - dest=(null destination) serial=269
path=/org/freedesktop/NetworkManager/ActiveConnection/2;
interface=org.freedesktop.NetworkManager.VPN.Connection;
member=VpnStateChanged

I expected that systemd would allow me to do this, but as far as I can tell
it doesn't (I'm using F17). I can obviously write my own daemon to do this,
but it seems to me that a daemon just for this would be a waste. I think
this sounds like a good fit for systemd. Is it anything anybody's looked at?


The problem with listening on a specific DBus message is that it
requires you to implement much more of DBus than systemd internally
can. I'm not sure it's a good idea to put something that complex into
systemd.

Your alternatives are to write a simple DBus frontend, or perhaps a
Network Manager plugin (if there is such a thing, I know connman has
the concept of plugins).

You can certainly socket activate a dummy service that doesn't
actually listen on DBus but instead executes `systemctl restart
squid.service` based on the BusName only. Systemd will likely however
not appreciate the unhandled socket, but it may be worth a try.

Auke

Systemd isn't really the right place to do network related stuff, imo.
Such things are better dealt with in the network connection manager,
where the information is already available.
NetworkManager has a mechanism to execute custom scripts in
/etc/NetworkManager/dispatcher.d on network events. For details take a
look at the man page, support for explicit actions on vpn-up/down is
mentioned there.


Thanks. I've submitted a patch to fix squid's existing dispatcher script 
and this is now working for me.


I'll bow to collective experience on whether systemd is the correct 
place for this, but with a sysadmin hat on it just felt like the right 
place to be putting something which performed an action in response to a 
system event.


Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Launching a unit in response to a D-Bus signal

2012-10-02 Thread Jóhann B. Guðmundsson

On 10/01/2012 10:53 PM, Mirco Tischler wrote:

Systemd isn't really the right place to do network related stuff, imo.
Such things are better dealt with in the network connection manager,
where the information is already available.
NetworkManager has a mechanism to execute custom scripts in
/etc/NetworkManager/dispatcher.d on network events. For details take a
look at the man page, support for explicit actions on vpn-up/down is
mentioned there.


Arguably systemd is the correct place under CoreOS to unite and manage 
network connections


JBG
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Launching a unit in response to a D-Bus signal

2012-10-02 Thread Mirco Tischler
2012/10/2 Jóhann B. Guðmundsson johan...@gmail.com:
 On 10/01/2012 10:53 PM, Mirco Tischler wrote:

 Systemd isn't really the right place to do network related stuff, imo.
 Such things are better dealt with in the network connection manager,
 where the information is already available.
 NetworkManager has a mechanism to execute custom scripts in
 /etc/NetworkManager/dispatcher.d on network events. For details take a
 look at the man page, support for explicit actions on vpn-up/down is
 mentioned there.


 Arguably systemd is the correct place under CoreOS to unite and manage
 network connections

 JBG

How do you do that? systemd doesn't have any support to manage network
connections. It lacks information about the state of the network
devices and cannot configure them as well.
In Matthew's case creating a dispatcher script that issues a
systemctl restart squid.service on vpn state changes looks like a
correct solution to me. Do you have a better idea?

Mirco
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Launching a unit in response to a D-Bus signal

2012-10-02 Thread Jóhann B. Guðmundsson

On 10/02/2012 12:47 PM, Mirco Tischler wrote:

How do you do that? systemd doesn't have any support to manage network
connections. It lacks information about the state of the network
devices and cannot configure them as well.


Today systemd cant but in the future it might depending on how things 
progress.


From my point of view an single network management application should 
be integrated into the init system in this case systemd/CoreOS.


It just begs the question to what extent as to complexity.

In the end the solution what ever it might be needs to be something that 
can be light enough to be on embedded but flexible enough to handle 
complex server environment with the desktop falling somewhere between 
those two.


I'm very well that a lot of people think forking is fun but I just dont 
tend to agree with that for something that is fundamental part of the 
underlying OS as network management is and should be from my pov.


JBG
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Launching a unit in response to a D-Bus signal

2012-10-01 Thread Matthew Booth
I have a requirement to restart squid whenever the VPN goes up or 
down[1]. Reading around, it seems that the way to do this would be in 
response to the relevant D-Bus signal, which seems to be this one:


signal sender=:1.6 - dest=(null destination) serial=269 
path=/org/freedesktop/NetworkManager/ActiveConnection/2; 
interface=org.freedesktop.NetworkManager.VPN.Connection; 
member=VpnStateChanged


I expected that systemd would allow me to do this, but as far as I can 
tell it doesn't (I'm using F17). I can obviously write my own daemon to 
do this, but it seems to me that a daemon just for this would be a 
waste. I think this sounds like a good fit for systemd. Is it anything 
anybody's looked at?


Thanks,

Matt

[1] It's not directly relevant to this post, but the reason is that 
squid doesn't pick up the new nameservers until it's restarted.


P.S. I'm not subscribed.
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Launching a unit in response to a D-Bus signal

2012-10-01 Thread Mirco Tischler
2012/10/2 Kok, Auke-jan H auke-jan.h@intel.com:
 On Mon, Oct 1, 2012 at 4:58 AM, Matthew Booth mbo...@redhat.com wrote:
 I have a requirement to restart squid whenever the VPN goes up or down[1].
 Reading around, it seems that the way to do this would be in response to the
 relevant D-Bus signal, which seems to be this one:

 signal sender=:1.6 - dest=(null destination) serial=269
 path=/org/freedesktop/NetworkManager/ActiveConnection/2;
 interface=org.freedesktop.NetworkManager.VPN.Connection;
 member=VpnStateChanged

 I expected that systemd would allow me to do this, but as far as I can tell
 it doesn't (I'm using F17). I can obviously write my own daemon to do this,
 but it seems to me that a daemon just for this would be a waste. I think
 this sounds like a good fit for systemd. Is it anything anybody's looked at?

 The problem with listening on a specific DBus message is that it
 requires you to implement much more of DBus than systemd internally
 can. I'm not sure it's a good idea to put something that complex into
 systemd.

 Your alternatives are to write a simple DBus frontend, or perhaps a
 Network Manager plugin (if there is such a thing, I know connman has
 the concept of plugins).

 You can certainly socket activate a dummy service that doesn't
 actually listen on DBus but instead executes `systemctl restart
 squid.service` based on the BusName only. Systemd will likely however
 not appreciate the unhandled socket, but it may be worth a try.

 Auke
Systemd isn't really the right place to do network related stuff, imo.
Such things are better dealt with in the network connection manager,
where the information is already available.
NetworkManager has a mechanism to execute custom scripts in
/etc/NetworkManager/dispatcher.d on network events. For details take a
look at the man page, support for explicit actions on vpn-up/down is
mentioned there.

Mirco
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel