Class: Bosh::Cli::VmState

Inherits:
Object show all
Defined in:
lib/cli/vm_state.rb

Instance Method Summary collapse

Constructor Details

#initialize(command, force) ⇒ VmState

Returns a new instance of VmState.



3
4
5
6
# File 'lib/cli/vm_state.rb', line 3

def initialize(command, force)
  @command = command
  @force = force
end

Instance Method Details

#change(job, index, new_state, operation_desc) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cli/vm_state.rb', line 8

def change(job, index, new_state, operation_desc)
  command.say("You are about to #{operation_desc.make_green}")
  manifest = command.prepare_deployment_manifest
  manifest_yaml = Psych.dump(manifest)

  if command.interactive?
    check_if_manifest_changed(manifest)

    unless command.confirmed?("#{operation_desc.capitalize}?")
      command.cancel_deployment
    end
  end

  command.nl
  command.say("Performing `#{operation_desc}'...")
  command.director.change_job_state(manifest['name'], manifest_yaml, job, index, new_state)
end