Files
ubicloud/model/hetzner_host.rb
Furkan Sahin 1c75bfdb8e Introduce Hetzner API support for IPv4
This PR integrates the IPv4 address creation for Hetzner with their provided
APIs. This way, we don't need to manually add the ip ranges, controlplane
figures out itself at the host creation time.

The API for ip addresses on Hetzner has a some bits need more explanation.
First of all bought IP addresses are billed/assigned to the servers. Doesn't
matter if it's a failover IP address or not, they are connected even if you
perform a reassignment. If we need to perform a proper failover and disconnect
all the relationship of the ip from the originating server, we have to open a
support ticket. So, we need to treat carefully and use the failover ip ranges
properly.

Failure scenarios;
1. In this PR, when we are looking for failover ip ranges for the vm_host, we pull
all the ips and look for the ones assigned to the created vm_host from the field
active_server_ip. There is also server_ip which means the ip address of the
server that the ip range is first bought for. We fail if that server is not in
our control with an error message.

2. In relation to above scenario, in case we discover an ip range that is created
before for another vm_host and we now discover that it's actually routed to the
new vm_host, we update the routed_to_host_id property of the address object. If
there is already a VM that's using an ip address from that range, that means
there is a bug because the range is now routed to a new vm_host and the vm ip4
setup is broken. In that case, we fail with an error message.
2023-06-19 13:12:05 +02:00

26 lines
380 B
Ruby

# frozen_string_literal: true
require_relative "../model"
class HetznerHost < Sequel::Model
one_to_one :vm_host, key: :id
PROVIDER_NAME = "hetzner"
def api
@api ||= Hosting::HetznerApis.new(self)
end
def connection_string
Config.hetzner_connection_string
end
def user
Config.hetzner_user
end
def password
Config.hetzner_password
end
end