Files
ubicloud/model/ipsec_tunnel.rb
Jeremy Evans 718370f4c9 Convert ResourceMethods to a plugin
Allow plugin to take an etc_type keyword argument for using the
TYPE_ETC ubid type, and remove the separate definitions in every
model that uses the TYPE_ETC ubid type.

This was the cleanest way to DRY things up.  You cannot extend
the models with a module to do this before including ResourceMethods,
because then ResourceMethods::ClassMethods will override it, and
you cannot extend the models with a module to do this after
including ResourceMethods, because the inclusion will not work
correctly due to the eager definition of @ubid_format.

Best reviewed without whitespace differences.
2025-06-04 04:55:45 +09:00

27 lines
727 B
Ruby

# frozen_string_literal: true
require_relative "../model"
class IpsecTunnel < Sequel::Model
many_to_one :src_nic, key: :src_nic_id, class: :Nic
many_to_one :dst_nic, key: :dst_nic_id, class: :Nic
plugin ResourceMethods
def vm_name(nic)
nic.vm.inhost_name.shellescape
end
end
# Table: ipsec_tunnel
# Columns:
# id | uuid | PRIMARY KEY
# src_nic_id | uuid |
# dst_nic_id | uuid |
# Indexes:
# ipsec_tunnel_pkey | PRIMARY KEY btree (id)
# ipsec_tunnel_src_nic_id_dst_nic_id_key | UNIQUE btree (src_nic_id, dst_nic_id)
# Foreign key constraints:
# ipsec_tunnel_dst_nic_id_fkey | (dst_nic_id) REFERENCES nic(id)
# ipsec_tunnel_src_nic_id_fkey | (src_nic_id) REFERENCES nic(id)