Class: Hetzner::PlacementGroup
- Inherits:
-
Object
- Object
- Hetzner::PlacementGroup
- Defined in:
- lib/hetzner/infra/placement_group.rb
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(hetzner_client:, cluster_name:, pool_name: nil) ⇒ PlacementGroup
constructor
A new instance of PlacementGroup.
Constructor Details
#initialize(hetzner_client:, cluster_name:, pool_name: nil) ⇒ PlacementGroup
Returns a new instance of PlacementGroup.
5 6 7 8 9 |
# File 'lib/hetzner/infra/placement_group.rb', line 5 def initialize(hetzner_client:, cluster_name:, pool_name: nil) @hetzner_client = hetzner_client @cluster_name = cluster_name @placement_group_name = pool_name ? "#{cluster_name}-#{pool_name}" : cluster_name end |
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hetzner/infra/placement_group.rb', line 11 def create puts if (placement_group = find_placement_group) puts "Placement group #{placement_group_name} already exists, skipping." puts return placement_group['id'] end puts "Creating placement group #{placement_group_name}..." response = hetzner_client.post('/placement_groups', placement_group_config).body puts "...placement group #{placement_group_name} created." puts JSON.parse(response)['placement_group']['id'] end |
#delete ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hetzner/infra/placement_group.rb', line 30 def delete if (placement_group = find_placement_group) puts "Deleting placement group #{placement_group_name}..." hetzner_client.delete('/placement_groups', placement_group['id']) puts "...placement group #{placement_group_name} deleted." else puts "Placement group #{placement_group_name} no longer exists, skipping." end puts end |