Module: Nucleus::Adapters::V1::CloudFoundryV2::Lifecycle

Included in:
Nucleus::Adapters::V1::CloudFoundryV2
Defined in:
lib/nucleus/adapters/v1/cloud_foundry_v2/lifecycle.rb

Instance Method Summary collapse

Instance Method Details

#restart(application_name_or_id) ⇒ Object

See Also:



33
34
35
36
# File 'lib/nucleus/adapters/v1/cloud_foundry_v2/lifecycle.rb', line 33

def restart(application_name_or_id)
  stop(application_name_or_id)
  start(application_name_or_id)
end

#start(application_name_or_id) ⇒ Object

See Also:



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/nucleus/adapters/v1/cloud_foundry_v2/lifecycle.rb', line 7

def start(application_name_or_id)
  app_guid = app_guid(application_name_or_id)
  # fail if there is no deployment
  unless deployed?(app_guid)
    raise Errors::SemanticAdapterRequestError, 'Application must be deployed before it can be started'
  end

  # start by name or id
  start_response = put("/v2/apps/#{app_guid}", body: { state: 'STARTED' })
  to_nucleus_app(start_response.body)
end

#stop(application_name_or_id) ⇒ Object

See Also:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/nucleus/adapters/v1/cloud_foundry_v2/lifecycle.rb', line 20

def stop(application_name_or_id)
  app_guid = app_guid(application_name_or_id)
  # fail if there is no deployment
  unless deployed?(app_guid)
    raise Errors::SemanticAdapterRequestError, 'Application must be deployed before it can be stopped'
  end

  # stop by name or id
  stop_response = put("/v2/apps/#{app_guid}", body: { state: 'STOPPED' })
  to_nucleus_app(stop_response.body)
end