Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hcloud support #261

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ information.

It currently provides built-in configuration for Puppets' internal
[vmpooler][vmpooler] hypervisor, [always-be-scheduling][always-be-scheduling]
hypervisor, static (non-provisioned) nodes, and is designed in a way that makes
it possible to easily add support for additional hypervisors
(any hypervisor type supported by [beaker][beaker]).
hypervisor, Vagrant with Virtualbox and Libvirt backend,
[Hetzner cloud](https://www.hetzner.com/cloud), static (non-provisioned) nodes,
and is designed in a way that makes it possible to easily add support for
additional hypervisors (any hypervisor type supported by [beaker][beaker]).

To see the list of built-in hypervisors you can run:
```
Expand Down
4 changes: 3 additions & 1 deletion lib/beaker-hostgenerator/hypervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def self.builtin_hypervisors()
'vagrant' => BeakerHostGenerator::Hypervisor::Vagrant,
'vagrant_libvirt' => BeakerHostGenerator::Hypervisor::Vagrant,
'docker' => BeakerHostGenerator::Hypervisor::Docker,
'abs' => BeakerHostGenerator::Hypervisor::ABS
'abs' => BeakerHostGenerator::Hypervisor::ABS,
'hcloud' => BeakerHostGenerator::Hypervisor::Hcloud,
}
end

Expand Down Expand Up @@ -114,3 +115,4 @@ def base_generate_node(node_info, base_config, bhg_version, *hypervisors)
require 'beaker-hostgenerator/hypervisor/vagrant'
require 'beaker-hostgenerator/hypervisor/docker'
require 'beaker-hostgenerator/hypervisor/abs'
require 'beaker-hostgenerator/hypervisor/hcloud'
26 changes: 26 additions & 0 deletions lib/beaker-hostgenerator/hypervisor/hcloud.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'beaker-hostgenerator/data'
require 'beaker-hostgenerator/hypervisor'

module BeakerHostGenerator
module Hypervisor

class Hcloud < BeakerHostGenerator::Hypervisor::Interface
include BeakerHostGenerator::Data

def generate_node(node_info, base_config, bhg_version)
# split ostype into string and array
# ostype is ubuntu2204, debian10, rocky9
os, version = node_info['ostype'].split(/(\D+)/).reject!(&:empty?)
base_config['image'] = case os
when 'ubuntu'
"#{os}-#{version[0, 2]}.#{version[2,2]}"
when 'centos'
version.to_i == 7 ? "#{os}-#{version}" : "#{os}-stream-#{version}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekohl I reversed the logic and also added a test case for centos7/8 to verify it's working correctly.

else
"#{os}-#{version}"
end
return base_generate_node(node_info, base_config, bhg_version, :hcloud)
end
end
end
end
35 changes: 35 additions & 0 deletions test/fixtures/per-host-settings/hcloud-hypervisor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
arguments_string: --hypervisor hcloud centos7-64m-centos9-64m-debian11-64a-ubuntu2204-64a{hypervisor=hcloud}
environment_variables: {}
expected_hash:
HOSTS:
centos7-64-1:
image: centos-7
platform: el-7-x86_64
hypervisor: hcloud
roles:
- agent
- master
centos9-64-1:
image: centos-stream-9
platform: el-9-x86_64
hypervisor: hcloud
roles:
- agent
- master
debian11-64-1:
image: debian-11
platform: debian-11-amd64
hypervisor: hcloud
roles:
- agent
ubuntu2204-64-1:
image: ubuntu-22.04
platform: ubuntu-22.04-amd64
hypervisor: hcloud
roles:
- agent
CONFIG:
nfs_server: none
consoleport: 443
expected_exception: