Discussion:
Plugin hook for network changed
Pat Riehecky
2016-08-17 14:45:00 UTC
Permalink
Looking at
https://github.com/rhinstaller/anaconda/blob/master/pyanaconda/ui/gui/spokes/network.py#L1529

Is there a way I can have my anaconda plugin also act based on changes
to the networking_changed parameter?

Pat
--
Pat Riehecky

Fermi National Accelerator Laboratory
www.fnal.gov
www.scientificlinux.org
Jiří Konečný
2016-08-18 10:11:20 UTC
Permalink
Hello Pat,

this can be tricky, we don't support getting spoke object anywhere on
the code, spokes are isolated. Therefore you can't just look on the
variable here.

As I see it, you have two options here:
1) You can register callback on the PayloadManager
pyanaconda.packaging.payloadMgr
- Problem is that you don't know if it was restarted by the Source
spoke or by Network spoke.

2) Register callback on the NetworkManager
- You can do this in the similar way as we do. 

You can write it similar to this example (not tested):

```
from gi.repository import NM

nmclient = NM.Client.new()

for dev in nmclient.get_all_devices():
    device.connect("state-changed", self.on_device_state_changed)

nmclient.connect("device-added", self.on_device_added)

def on_device_added(self, client, device):
    device.connect("state-changed", self.on_device_state_changed)

def on_device_state_changed(self):
   # test state and do what you need to do
```

I hope this will help you,
Jirka
Looking at 
https://github.com/rhinstaller/anaconda/blob/master/pyanaconda/ui/gui
/spokes/network.py#L1529
Is there a way I can have my anaconda plugin also act based on
changes 
to the networking_changed parameter?
Pat
Loading...