Class: Bosh::Deployer::BoshStub

Inherits:
Object
  • Object
show all
Includes:
Cancun::Highline
Defined in:
lib/bosh-deployer/bosh_stub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = '~/.bosh-deployer/stubs') ⇒ BoshStub

Returns a new instance of BoshStub.



12
13
14
15
# File 'lib/bosh-deployer/bosh_stub.rb', line 12

def initialize(path = '~/.bosh-deployer/stubs')
  path = path[0..-2] if path[-1] == '/'
  @filename = "#{path}/bosh.yml"
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



10
11
12
# File 'lib/bosh-deployer/bosh_stub.rb', line 10

def filename
  @filename
end

Instance Method Details

#default_key_nameObject



88
89
90
91
92
# File 'lib/bosh-deployer/bosh_stub.rb', line 88

def default_key_name
  @default_key_name ||= ask('Key name:') do |q|
    q.default = 'firstbosh'
  end
end

#gatewayObject



74
75
76
77
78
79
# File 'lib/bosh-deployer/bosh_stub.rb', line 74

def gateway
  @gateway ||= ask('Gateway IP for bosh:') do |q|
    #UGLY REPLACE ME WITH A REGEX
    q.default = (static_ip_from.split('.')[0..-2] + ['1']).join('.')
  end
end

#generateObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bosh-deployer/bosh_stub.rb', line 17

def generate
   if File.exists?(filename) and !agree "#{filename} already exists, do you want to overwrite it?"
     say 'Stub generation cancelled!'
     return
   end
  say_bold 'Provide the following information for your bosh configuration:'
  stub = template.result(binding)
  say "Saving stub at #{filename}"
  File.open(filename, 'w') { |f| f.write(stub) }
    
end

#openstack_api_keyObject



50
51
52
53
54
# File 'lib/bosh-deployer/bosh_stub.rb', line 50

def openstack_api_key
  @openstack_api_key ||= ask('Openstack api key:') do |q|
    q.default =  microbosh.provider.credentials.openstack_api_key if microbosh
  end
end

#openstack_auth_urlObject



38
39
40
41
42
# File 'lib/bosh-deployer/bosh_stub.rb', line 38

def openstack_auth_url
  @openstack_auth_url ||= ask('Openstack auth url:') do |q|
    q.default =  microbosh.provider.credentials.openstack_auth_url.gsub('/tokens', '') if microbosh
  end
end

#openstack_tenantObject



56
57
58
59
60
# File 'lib/bosh-deployer/bosh_stub.rb', line 56

def openstack_tenant
  @openstack_tenant ||= ask('Openstack tenant:') do |q|
    q.default =  microbosh.provider.credentials.openstack_tenant if microbosh
  end
end

#openstack_usernameObject



44
45
46
47
48
# File 'lib/bosh-deployer/bosh_stub.rb', line 44

def openstack_username
  @openstack_username ||= ask('Openstack username:') do |q|
    q.default =  microbosh.provider.credentials.openstack_username if microbosh
  end
end

#private_keyObject



94
95
96
97
98
# File 'lib/bosh-deployer/bosh_stub.rb', line 94

def private_key
  @private_key ||= ask('Private key:') do |q|
    q.default = '~/.microbosh/ssh/firstbosh.pem'
  end
end

#rangeObject



81
82
83
84
85
86
# File 'lib/bosh-deployer/bosh_stub.rb', line 81

def range
  @range ||= ask('Gateway IP for bosh:') do |q|
    #UGLY REPLACE ME WITH A REGEX
    q.default = (static_ip_from.split('.')[0..-2] + ['0']).join('.') + '/24'
  end
end

#recursor_ipObject



62
63
64
65
66
# File 'lib/bosh-deployer/bosh_stub.rb', line 62

def recursor_ip
  @recursor_ip ||= ask('Recursor ip or host:') do |q|
    q.default = microbosh.address.ip if microbosh
  end
end

#static_ip_fromObject



29
30
31
# File 'lib/bosh-deployer/bosh_stub.rb', line 29

def static_ip_from
  @static_ip_from ||= ask 'Intial available static ip for deploying bosh:'
end

#static_ip_toObject



33
34
35
# File 'lib/bosh-deployer/bosh_stub.rb', line 33

def static_ip_to
  @static_ip_to ||= ask 'Last available static ip for deploying bosh:'
end

#subnet_idObject



68
69
70
71
72
# File 'lib/bosh-deployer/bosh_stub.rb', line 68

def subnet_id
  @subnet_id ||= ask('Subnet ID where bosh will be deployed:') do |q|
    q.default = microbosh.address.subnet_id if microbosh
  end
end