Class: Bosh::Bootstrap::MicroboshProviders::Base
- Inherits:
-
Object
- Object
- Bosh::Bootstrap::MicroboshProviders::Base
- Includes:
- FileUtils
- Defined in:
- lib/bosh-bootstrap/microbosh_providers/base.rb
Instance Attribute Summary collapse
-
#manifest_path ⇒ Object
readonly
Returns the value of attribute manifest_path.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
- #create_microbosh_yml(settings) ⇒ Object
-
#download_stemcell ⇒ Object
downloads latest stemcell & returns path.
-
#initialize(manifest_path, settings) ⇒ Base
constructor
A new instance of Base.
- #jenkins_bucket ⇒ Object
- #microbosh_name ⇒ Object
- #private_key_path ⇒ Object
- #public_ip ⇒ Object
- #salted_password ⇒ Object
- #stemcell_dir ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(manifest_path, settings) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 13 def initialize(manifest_path, settings) @manifest_path = manifest_path @settings = settings.is_a?(Hash) ? ReadWriteSettings.new(settings) : settings raise "@settings must be ReadWriteSettings (or Hash)" unless @settings.is_a?(ReadWriteSettings) end |
Instance Attribute Details
#manifest_path ⇒ Object (readonly)
Returns the value of attribute manifest_path.
10 11 12 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 10 def manifest_path @manifest_path end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
11 12 13 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 11 def settings @settings end |
Instance Method Details
#create_microbosh_yml(settings) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 19 def create_microbosh_yml(settings) @settings = settings.is_a?(Hash) ? ReadWriteSettings.new(settings) : settings raise "@settings must be ReadWriteSettings (or Hash)" unless @settings.is_a?(ReadWriteSettings) mkdir_p(File.dirname(manifest_path)) File.open(manifest_path, "w") do |f| f << self.to_hash.to_yaml end end |
#download_stemcell ⇒ Object
downloads latest stemcell & returns path
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 56 def download_stemcell mkdir_p(stemcell_dir) chdir(stemcell_dir) do stemcell_path = File.(File.basename(stemcell_uri)) unless File.exists?(stemcell_path) sh "curl -O '#{stemcell_uri}'" end return stemcell_path end end |
#jenkins_bucket ⇒ Object
51 52 53 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 51 def jenkins_bucket "bosh-jenkins-artifacts" end |
#microbosh_name ⇒ Object
34 35 36 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 34 def microbosh_name settings.bosh.name end |
#private_key_path ⇒ Object
47 48 49 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 47 def private_key_path settings.key_pair.path end |
#public_ip ⇒ Object
43 44 45 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 43 def public_ip settings.address.ip end |
#salted_password ⇒ Object
38 39 40 41 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 38 def salted_password # BCrypt::Password.create(settings.bosh.password).to_s.force_encoding("UTF-8") settings.bosh.salted_password end |
#stemcell_dir ⇒ Object
67 68 69 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 67 def stemcell_dir File.dirname(manifest_path) end |
#to_hash ⇒ Object
28 29 30 31 32 |
# File 'lib/bosh-bootstrap/microbosh_providers/base.rb', line 28 def to_hash {"name"=>microbosh_name, "logging"=>{"level"=>"DEBUG"} } end |