Class: Bosh::AwsCliPlugin::MicroboshManifest

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh_cli_plugin_aws/microbosh_manifest.rb

Direct Known Subclasses

BatManifest, BoshManifest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vpc_receipt, route53_receipt, options = {}) ⇒ MicroboshManifest

Returns a new instance of MicroboshManifest.


8
9
10
11
12
13
14
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 8

def initialize(vpc_receipt, route53_receipt, options={})
  @vpc_receipt = vpc_receipt
  @route53_receipt = route53_receipt
  @hm_director_user = options[:hm_director_user]
  @hm_director_password = options[:hm_director_password]
  @keep_unreachable_vms = options.fetch(:keep_unreachable_vms, false)
end

Instance Attribute Details

#hm_director_passwordObject (readonly)

Returns the value of attribute hm_director_password.


6
7
8
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 6

def hm_director_password
  @hm_director_password
end

#hm_director_userObject (readonly)

Returns the value of attribute hm_director_user.


6
7
8
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 6

def hm_director_user
  @hm_director_user
end

#keep_unreachable_vmsObject (readonly)

Returns the value of attribute keep_unreachable_vms.


6
7
8
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 6

def keep_unreachable_vms
  @keep_unreachable_vms
end

#route53_receiptObject (readonly)

Returns the value of attribute route53_receipt.


6
7
8
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 6

def route53_receipt
  @route53_receipt
end

#vpc_receiptObject (readonly)

Returns the value of attribute vpc_receipt.


6
7
8
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 6

def vpc_receipt
  @vpc_receipt
end

Instance Method Details

#access_key_idObject


48
49
50
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 48

def access_key_id
  vpc_config['aws']['access_key_id'] || warning('Missing aws access_key_id field')
end

#availability_zoneObject


44
45
46
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 44

def availability_zone
  vpc_config['vpc']['subnets']['bosh1']['availability_zone'] || warning('Missing availability zone in vpc.subnets.bosh')
end

#cache_access_key_idObject


72
73
74
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 72

def cache_access_key_id
  vpc_config['compiled_package_cache']['access_key_id'] || warning('Missing compiled_package_cache access_key_id field')
end

#cache_bucket_nameObject


80
81
82
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 80

def cache_bucket_name
  vpc_config['compiled_package_cache']['bucket_name'] || warning('Missing compiled_package_cache bucket_name field')
end

#cache_secret_access_keyObject


76
77
78
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 76

def cache_secret_access_key
  vpc_config['compiled_package_cache']['secret_access_key'] || warning('Missing compiled_package_cache secret_access_key field')
end

#certificateObject


92
93
94
95
96
97
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 92

def certificate
  @cert if @cert
  key_path = director_ssl['private_key_path'] || 'director.key'
  cert_path = director_ssl['certificate_path'] || 'director.pem'
  @cert = Bosh::Ssl::Certificate.new(key_path, cert_path, "*.#{vpc_config['vpc']['domain']}").load_or_create
end

#compiled_package_cache?Boolean

Returns:

  • (Boolean)

68
69
70
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 68

def compiled_package_cache?
  !!vpc_config['compiled_package_cache']
end

#deployment_nameObject


20
21
22
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 20

def deployment_name
  "micro"
end

#director_sslObject


99
100
101
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 99

def director_ssl
  ssl_certs['director_cert'] || {}
end

#director_ssl_certObject


88
89
90
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 88

def director_ssl_cert
  certificate.certificate.gsub("\n", "\n          ")
end

#director_ssl_keyObject


84
85
86
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 84

def director_ssl_key
  certificate.key.gsub("\n", "\n          ")
end

#file_nameObject


16
17
18
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 16

def file_name
  "micro_bosh.yml"
end

#get_template(template) ⇒ Object


117
118
119
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 117

def get_template(template)
  File.expand_path("../../../templates/#{template}", __FILE__)
end

#key_pair_nameObject


60
61
62
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 60

def key_pair_name
  vpc_config['key_pairs'].any? ? vpc_config['key_pairs'].keys[0] : warning("Missing key_pairs field, must have at least 1 keypair")
end

#nameObject


28
29
30
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 28

def name
  vpc_config['name'] || warning('Missing name field')
end

#network_typeObject


40
41
42
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 40

def network_type
  subnet ? 'manual' : 'dynamic'
end

#private_key_pathObject


64
65
66
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 64

def private_key_path
  vpc_config['key_pairs'].any? ? vpc_config['key_pairs'].values[0].gsub(/\.pub$/, '') : warning("Missing key_pairs field, must have at least 1 keypair")
end

#regionObject


56
57
58
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 56

def region
  vpc_config['aws']['region'] || warning('Missing aws region field')
end

#secret_access_keyObject


52
53
54
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 52

def secret_access_key
  vpc_config['aws']['secret_access_key'] || warning('Missing aws secret_access_key field')
end

#ssl_certsObject


103
104
105
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 103

def ssl_certs
  vpc_config['ssl_certs'] || {}
end

#subnetObject


36
37
38
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 36

def subnet
  vpc_receipt['vpc']['subnets']['bosh1'] || warning('Missing bosh subnet field')
end

#to_yObject

RSpec overloads to_yaml when you set up expectations on an object; so to_y is just a way to get directly at the to_yaml implementation without fighting RSpec.


109
110
111
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 109

def to_y
  ERB.new(File.read(get_template("micro_bosh.yml.erb"))).result(binding)
end

#to_yamlObject


113
114
115
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 113

def to_yaml
  to_y
end

#vipObject


32
33
34
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 32

def vip
  route53_receipt['elastic_ips']['micro']['ips'][0] || warning('Missing vip field')
end

#vpc_configObject


24
25
26
# File 'lib/bosh_cli_plugin_aws/microbosh_manifest.rb', line 24

def vpc_config
  vpc_receipt['original_configuration']
end