0f2530a032
Signed-off-by: Alejandro Mery <amery@jpi.io>
44 lines
955 B
Go
44 lines
955 B
Go
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
|
|
}
|