You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
955 B
44 lines
955 B
6 months ago
|
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
|
||
|
}
|