Class: Prof::Environment::CloudFoundry

Inherits:
Object
  • Object
show all
Defined in:
lib/prof/environment/cloud_foundry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cloud_foundry_domain: nil, cloud_controller_identity: 'cloud_controller', cloud_controller_password: 'cc-secret', cloud_foundry_username: 'admin', cloud_foundry_password: 'admin', cloud_foundry_api_url: nil, bosh_target: 'https://192.168.50.4:25555', bosh_username: 'admin', bosh_password: 'admin', bosh_ca_cert_path: nil, bosh_env_login: false, ssh_gateway_host: '192.168.50.4', ssh_gateway_username: 'vagrant', ssh_gateway_password: 'vagrant', ssh_gateway_private_key: nil, bosh_service_broker_job_name:, bosh_manifest_path:, use_proxy: true) ⇒ CloudFoundry

Returns a new instance of CloudFoundry.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/prof/environment/cloud_foundry.rb', line 26

def initialize(
  cloud_foundry_domain:      nil,

  cloud_controller_identity: 'cloud_controller',
  cloud_controller_password: 'cc-secret',

  cloud_foundry_username:    'admin',
  cloud_foundry_password:    'admin',
  cloud_foundry_api_url:      nil,

  bosh_target:               'https://192.168.50.4:25555',
  bosh_username:             'admin',
  bosh_password:             'admin',
  bosh_ca_cert_path:         nil,
  bosh_env_login:            false,

  ssh_gateway_host:          '192.168.50.4',
  ssh_gateway_username:      'vagrant',
  ssh_gateway_password:      'vagrant',
  ssh_gateway_private_key:   nil,

  bosh_service_broker_job_name:,
  bosh_manifest_path:,

  use_proxy:                 true
)
  @cloud_foundry_domain = cloud_foundry_domain
  @cloud_controller_identity = cloud_controller_identity
  @cloud_controller_password = cloud_controller_password
  @cloud_foundry_username = cloud_foundry_username
  @cloud_foundry_password = cloud_foundry_password
  @bosh_target = bosh_target
  @bosh_username = bosh_username
  @bosh_password = bosh_password
  @bosh_ca_cert_path = bosh_ca_cert_path
  @bosh_env_login = 
  @ssh_gateway_host = ssh_gateway_host
  @ssh_gateway_username = ssh_gateway_username
  @ssh_gateway_password = ssh_gateway_password
  @ssh_gateway_private_key = ssh_gateway_private_key
  @bosh_service_broker_job_name = bosh_service_broker_job_name
  @bosh_manifest_path = bosh_manifest_path
  @cloud_foundry_api_url = cloud_foundry_api_url
  @use_proxy = use_proxy
end

Instance Attribute Details

#bosh_service_broker_job_nameObject (readonly)

Returns the value of attribute bosh_service_broker_job_name.



24
25
26
# File 'lib/prof/environment/cloud_foundry.rb', line 24

def bosh_service_broker_job_name
  @bosh_service_broker_job_name
end

Instance Method Details

#bosh_directorObject



102
103
104
105
106
107
108
109
110
111
# File 'lib/prof/environment/cloud_foundry.rb', line 102

def bosh_director
  @bosh_director ||= Hula::BoshDirector.new(
    target_url:       bosh_target,
    username:         bosh_username,
    password:         bosh_password,
    manifest_path:    bosh_manifest_path,
    certificate_path: bosh_ca_cert_path,
    env_login:        
  )
end

#bosh_manifestObject



81
82
83
# File 'lib/prof/environment/cloud_foundry.rb', line 81

def bosh_manifest
  @bosh_manifest ||= Hula::BoshManifest.from_file(bosh_manifest_path)
end

#cloud_foundryObject



72
73
74
75
76
77
78
79
# File 'lib/prof/environment/cloud_foundry.rb', line 72

def cloud_foundry
  @cloud_foundry ||= ::Prof::CloudFoundry.new(
    domain:   cloud_foundry_domain,
    username: cloud_foundry_username,
    password: cloud_foundry_password,
    api_url:  cloud_foundry_api_url
  )
end

#cloud_foundry_domainObject



85
86
87
# File 'lib/prof/environment/cloud_foundry.rb', line 85

def cloud_foundry_domain
  @cloud_foundry_domain ||= bosh_manifest.property('cf.domain')
end

#cloud_foundry_uaaObject



128
129
130
131
132
133
134
# File 'lib/prof/environment/cloud_foundry.rb', line 128

def cloud_foundry_uaa
  @cloud_foundry_uaa ||= UAAClient.new(
    cloud_foundry_domain,
    cloud_controller_identity,
    cloud_controller_password
  )
end

#http_proxyObject



144
145
146
# File 'lib/prof/environment/cloud_foundry.rb', line 144

def http_proxy
  @http_proxy ||= Hula::HttpProxyUpstreamSocks.new(socks_proxy: socks4_proxy).tap(&:start)
end

#service_brokerObject



89
90
91
92
93
94
95
96
# File 'lib/prof/environment/cloud_foundry.rb', line 89

def service_broker
  @service_broker ||= Hula::ServiceBroker::Client.new(
    url: URI::HTTPS.build(host: broker_registrar_properties.fetch('host')),
    username: broker_registrar_properties.fetch('username'),
    password: broker_registrar_properties.fetch('password'),
    http_client: http_json_client(use_proxy: use_proxy)
  )
end

#service_broker_nameObject



98
99
100
# File 'lib/prof/environment/cloud_foundry.rb', line 98

def service_broker_name
  broker_registrar_properties.fetch('name')
end

#socks4_proxyObject



136
137
138
139
140
141
142
# File 'lib/prof/environment/cloud_foundry.rb', line 136

def socks4_proxy
  @socks4_proxy ||= Hula::Socks4ProxySsh.new(
    ssh_username: ssh_gateway_username,
    ssh_password: ssh_gateway_password,
    ssh_host:     ssh_gateway_host
  ).tap(&:start)
end

#ssh_gatewayObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/prof/environment/cloud_foundry.rb', line 113

def ssh_gateway
  opts = {
    gateway_host:     ssh_gateway_host,
    gateway_username: ssh_gateway_username,
  }

  if @ssh_gateway_private_key
    opts[:gateway_private_key] = ssh_gateway_private_key
  else
    opts[:gateway_password] = ssh_gateway_password
  end

  @ssh_gateway ||= Prof::SshGateway.new(opts)
end