class Object

Public Instance Methods

build_interfaces_attributes(networks) click to toggle source
# File lib/foreman_opentofu/provider_types/hetzner.rb, line 42
def build_interfaces_attributes(networks)
  Array(networks).each_with_index.to_h do |net, idx|
    nic = net.respond_to?(:with_indifferent_access) ? net.with_indifferent_access : net
    [idx.to_s, { network_id: nic[:network_id].to_s }]
  end
end
disk_renderer_collection?() click to toggle source
# File lib/foreman_opentofu/provider_types/hetzner.rb, line 8
def disk_renderer_collection?
  true
end
extract_networks(attrs) click to toggle source
# File lib/foreman_opentofu/provider_types/hetzner.rb, line 35
def extract_networks(attrs)
  attrs.dig(:vm, :network) ||
    attrs.dig('vm', 'network') ||
    attrs[:network] ||
    attrs['network']
end
normalize_interfaces(vm_attrs) click to toggle source
# File lib/foreman_opentofu/provider_types/hetzner.rb, line 24
def normalize_interfaces(vm_attrs)
  attrs = vm_attrs.with_indifferent_access
  return attrs if attrs[:interfaces_attributes].present?

  networks = extract_networks(attrs)
  return attrs if networks.blank?

  attrs[:interfaces_attributes] = build_interfaces_attributes(networks)
  attrs
end
provided_attributes() click to toggle source
# File lib/foreman_opentofu/provider_types/hetzner.rb, line 12
def provided_attributes
  {
    ip: :vm_ip_address,
    ip6: :vm_ip6_address,
  }
end
vm_ready(_vm) click to toggle source
# File lib/foreman_opentofu/provider_types/hetzner.rb, line 19
def vm_ready(_vm)
  # always ready ;-)
  true
end