cluster: migrate to using pkg/rings for Addresses [WIP]
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
|
||||
"git.jpi.io/amery/jpictl/pkg/rings"
|
||||
)
|
||||
|
||||
// RingOnePrefix returns the ring 1 subnet of this [Zone].
|
||||
func (z *Zone) RingOnePrefix() netip.Prefix {
|
||||
subnet, err := rings.RingOnePrefix(z.RegionID(), z.ID)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return subnet
|
||||
}
|
||||
|
||||
// RingOnePrefix returns the ring 1 subnet this [Machine] belongs
|
||||
// to.
|
||||
func (m *Machine) RingOnePrefix() netip.Prefix {
|
||||
return m.zone.RingOnePrefix()
|
||||
}
|
||||
|
||||
// RingZeroAddress returns the ring 0 address of the [Machine]
|
||||
// if it can act as gateway.
|
||||
func (m *Machine) RingZeroAddress() (netip.Addr, bool) {
|
||||
addr, err := rings.RingZeroAddress(m.Region(), m.Zone(), m.ID)
|
||||
if err != nil {
|
||||
return netip.Addr{}, false
|
||||
}
|
||||
|
||||
return addr, true
|
||||
}
|
||||
|
||||
// RingOneAddress returns the ring 1 address of the [Machine]
|
||||
func (m *Machine) RingOneAddress() netip.Addr {
|
||||
addr, err := rings.RingOneAddress(m.Region(), m.Zone(), m.ID)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return addr
|
||||
}
|
||||
Reference in New Issue
Block a user