Files
ubicloud/serializers/nic.rb
mohi-kalantari b40f71eda8 Fix LB healthchecks by finding the correct ip for subnet allocated K8s VMs
LB Healthcheck was not using the right private ipv4. now it supports VMs
with bigger subnet than /32.

Also nic serializer had the same issue. now based on the provided netmask,
it returns the right address.
2025-02-05 15:35:49 +01:00

14 lines
393 B
Ruby

# frozen_string_literal: true
class Serializers::Nic < Serializers::Base
def self.serialize_internal(nic, options = {})
{
id: nic.ubid,
name: nic.name,
private_ipv4: (nic.private_ipv4.netmask.prefix_len == 32) ? nic.private_ipv4.network.to_s : nic.private_ipv4.nth(1).to_s,
private_ipv6: nic.private_ipv6.nth(2).to_s,
vm_name: nic.vm&.name
}
end
end