|
|
|
@ -50,6 +50,31 @@ func (z *Zone) ForEachMachine(fn func(*Machine) bool) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SetGateway configures a machine to be the zone's ring0 gateway
|
|
|
|
|
func (z *Zone) SetGateway(gatewayID int, enabled bool) error { |
|
|
|
|
var err error |
|
|
|
|
var found bool |
|
|
|
|
|
|
|
|
|
z.ForEachMachine(func(p *Machine) bool { |
|
|
|
|
if p.ID == gatewayID { |
|
|
|
|
found = true |
|
|
|
|
err = p.SetGateway(enabled) |
|
|
|
|
|
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
return false |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
switch { |
|
|
|
|
case err != nil: |
|
|
|
|
return err |
|
|
|
|
case !found: |
|
|
|
|
return fs.ErrNotExist |
|
|
|
|
default: |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Zones represents all zones in a cluster
|
|
|
|
|
type Zones struct { |
|
|
|
|
dir fs.FS |
|
|
|
|