This allows us to remove the :load_balancer option from the VM serializer and the :vms_serialized option from the LoadBalancer serializer. Add some model methods for code that was previously in the serializers. To a better job of testing for expected values on the load balancer show page, instead of using the non-specific have_content for everything.
30 lines
692 B
Ruby
30 lines
692 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Serializers::LoadBalancer < Serializers::Base
|
|
def self.serialize_internal(lb, options = {})
|
|
base = {
|
|
id: lb.ubid,
|
|
name: lb.name,
|
|
location: lb.display_location,
|
|
hostname: lb.hostname,
|
|
algorithm: lb.algorithm,
|
|
stack: lb.stack,
|
|
health_check_endpoint: lb.health_check_endpoint,
|
|
health_check_protocol: lb.health_check_protocol,
|
|
src_port: lb.src_port,
|
|
dst_port: lb.dst_port
|
|
}
|
|
|
|
if options[:include_path]
|
|
base[:path] = lb.path
|
|
end
|
|
|
|
if options[:detailed]
|
|
base[:subnet] = lb.private_subnet.name
|
|
base[:vms] = lb.vms.map { it.ubid } || []
|
|
end
|
|
|
|
base
|
|
end
|
|
end
|