initialize: restart networkd before other units

This commit is contained in:
Alex Crawford 2014-12-02 17:21:31 -08:00
parent c628bef666
commit 5c059b66f0
2 changed files with 19 additions and 4 deletions

View File

@ -265,8 +265,13 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error
} }
if restartNetworkd { if restartNetworkd {
log.Printf("Restarting systemd-networkd")
networkd := system.Unit{Unit: config.Unit{Name: "systemd-networkd.service"}} networkd := system.Unit{Unit: config.Unit{Name: "systemd-networkd.service"}}
actions = append(actions, action{networkd, "restart"}) res, err := um.RunUnitCommand(networkd, "restart")
if err != nil {
return err
}
log.Printf("Restarted systemd-networkd (%s)", res)
} }
for _, action := range actions { for _, action := range actions {
@ -275,7 +280,7 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error
if err != nil { if err != nil {
return err return err
} }
log.Printf("Result of %q on %q': %s", action.command, action.unit.Name, res) log.Printf("Result of %q on %q: %s", action.command, action.unit.Name, res)
} }
return nil return nil

View File

@ -86,17 +86,27 @@ func TestProcessUnits(t *testing.T) {
}, },
{ {
units: []system.Unit{ units: []system.Unit{
system.Unit{Unit: config.Unit{
Name: "baz.service",
Content: "[Service]\nExecStart=/bin/baz",
Command: "start",
}},
system.Unit{Unit: config.Unit{ system.Unit{Unit: config.Unit{
Name: "foo.network", Name: "foo.network",
Content: "[Network]\nFoo=true",
}}, }},
system.Unit{Unit: config.Unit{ system.Unit{Unit: config.Unit{
Name: "bar.network", Name: "bar.network",
Content: "[Network]\nBar=true",
}}, }},
}, },
result: TestUnitManager{ result: TestUnitManager{
placed: []string{"baz.service", "foo.network", "bar.network"},
commands: []UnitAction{ commands: []UnitAction{
UnitAction{"systemd-networkd.service", "restart"}, UnitAction{"systemd-networkd.service", "restart"},
UnitAction{"baz.service", "start"},
}, },
reload: true,
}, },
}, },
{ {