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', ssh_gateway_host: '192.168.50.4', ssh_gateway_username: 'vagrant', ssh_gateway_password: 'vagrant', 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
# 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',

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

  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
  @ssh_gateway_host = ssh_gateway_host
  @ssh_gateway_username = ssh_gateway_username
  @ssh_gateway_password = ssh_gateway_password
  @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



96
97
98
99
100
101
102
103
# File 'lib/prof/environment/cloud_foundry.rb', line 96

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

#bosh_manifestObject



75
76
77
# File 'lib/prof/environment/cloud_foundry.rb', line 75

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

#cloud_foundryObject



66
67
68
69
70
71
72
73
# File 'lib/prof/environment/cloud_foundry.rb', line 66

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



79
80
81
# File 'lib/prof/environment/cloud_foundry.rb', line 79

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

#cloud_foundry_uaaObject



113
114
115
116
117
118
119
# File 'lib/prof/environment/cloud_foundry.rb', line 113

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

#http_proxyObject



129
130
131
# File 'lib/prof/environment/cloud_foundry.rb', line 129

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

#service_brokerObject



83
84
85
86
87
88
89
90
# File 'lib/prof/environment/cloud_foundry.rb', line 83

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



92
93
94
# File 'lib/prof/environment/cloud_foundry.rb', line 92

def service_broker_name
  broker_registrar_properties.fetch('name')
end

#socks4_proxyObject



121
122
123
124
125
126
127
# File 'lib/prof/environment/cloud_foundry.rb', line 121

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



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

def ssh_gateway
  @ssh_gateway ||= SshGateway.new(
    gateway_host:     ssh_gateway_host,
    gateway_username: ssh_gateway_username,
    gateway_password: ssh_gateway_password
  )
end