Class: Cabal::API::Cluster

Inherits:
Ohm::Model
  • Object
show all
Includes:
Ohm::Callbacks
Defined in:
lib/cabal/api/cluster.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#secret_keyObject

The secret key should not be saved plain, but we want to access it immediately after creation



13
14
15
# File 'lib/cabal/api/cluster.rb', line 13

def secret_key
  @secret_key
end

Class Method Details

.by_cluster_name(name) ⇒ Object



33
34
35
36
# File 'lib/cabal/api/cluster.rb', line 33

def self.by_cluster_name(name)
  name = Cabal::Util.normalize(name)
  find(name: name).first || create(name: name)
end

Instance Method Details

#before_createObject



25
26
27
28
29
30
31
# File 'lib/cabal/api/cluster.rb', line 25

def before_create
  self.name = Cabal::Util.normalize(name)

  sshkey = SSHKey.generate(type: 'RSA', bits: 2048, comment: "#{name}-cabal")
  self.private_key = sshkey.private_key
  self.public_key = sshkey.ssh_public_key
end