Class: Bosh::Bootstrap::KeyPair

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/bosh-bootstrap/key_pair.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_path, keyname, private_key) ⇒ KeyPair

Returns a new instance of KeyPair.



8
9
10
# File 'lib/bosh-bootstrap/key_pair.rb', line 8

def initialize(base_path, keyname, private_key)
  @base_path, @keyname, @private_key = base_path, keyname, private_key
end

Instance Attribute Details

#base_pathObject (readonly)

Returns the value of attribute base_path.



6
7
8
# File 'lib/bosh-bootstrap/key_pair.rb', line 6

def base_path
  @base_path
end

#keynameObject (readonly)

Returns the value of attribute keyname.



6
7
8
# File 'lib/bosh-bootstrap/key_pair.rb', line 6

def keyname
  @keyname
end

#private_keyObject (readonly)

Returns the value of attribute private_key.



6
7
8
# File 'lib/bosh-bootstrap/key_pair.rb', line 6

def private_key
  @private_key
end

Instance Method Details

#execute!Object



12
13
14
15
16
17
18
# File 'lib/bosh-bootstrap/key_pair.rb', line 12

def execute!
  mkdir_p(File.dirname(path))
  chmod(0700, File.dirname(path))

  File.open(path, "w") { |file| file << private_key }
  chmod(0600, path)
end

#pathObject



20
21
22
# File 'lib/bosh-bootstrap/key_pair.rb', line 20

def path
  @path ||= File.join(base_path, "ssh", keyname)
end