Class: Bosh::Bootstrap::KeyPair
- Inherits:
-
Object
- Object
- Bosh::Bootstrap::KeyPair
- Includes:
- FileUtils
- Defined in:
- lib/bosh-bootstrap/key_pair.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#keyname ⇒ Object
readonly
Returns the value of attribute keyname.
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(base_path, keyname, private_key) ⇒ KeyPair
constructor
A new instance of KeyPair.
- #path ⇒ Object
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_path ⇒ Object (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 |
#keyname ⇒ Object (readonly)
Returns the value of attribute keyname.
6 7 8 |
# File 'lib/bosh-bootstrap/key_pair.rb', line 6 def keyname @keyname end |
#private_key ⇒ Object (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 |
#path ⇒ Object
20 21 22 |
# File 'lib/bosh-bootstrap/key_pair.rb', line 20 def path @path ||= File.join(base_path, "ssh", keyname) end |