Class: ForemanOpentofu::KeyPairs

Inherits:
Array
  • Object
show all
Defined in:
app/services/foreman_opentofu/key_pairs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exec, init_value = []) ⇒ KeyPairs

Returns a new instance of KeyPairs.



5
6
7
8
# File 'app/services/foreman_opentofu/key_pairs.rb', line 5

def initialize(exec, init_value = [])
  self.opentofu_executer = exec
  super init_value unless init_value.nil?
end

Instance Attribute Details

#opentofu_executerObject

Returns the value of attribute opentofu_executer.



3
4
5
# File 'app/services/foreman_opentofu/key_pairs.rb', line 3

def opentofu_executer
  @opentofu_executer
end

Instance Method Details

#create(opts = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'app/services/foreman_opentofu/key_pairs.rb', line 10

def create(opts = {})
  # client.key_pairs.create :name => "foreman-#{id}#{Foreman.uuid}"
  key_pair = TofuKeyPair.new opts[:name]
  key_pair.generate

  opentofu_executer.run_create_key(key_pair)

  key_pair
end

#get(name) ⇒ Object



20
21
22
23
24
# File 'app/services/foreman_opentofu/key_pairs.rb', line 20

def get(name)
  kp = TofuKeyPair.new name
  kp.opentofu_executer = opentofu_executer
  kp
end