Class: Chef::Knife::VcVappSnapshot

Inherits:
Chef::Knife show all
Includes:
VcCommon, VcVappCommon
Defined in:
lib/chef/knife/vapp/vc_vapp_snapshot.rb

Instance Method Summary collapse

Methods included from VcVappCommon

#get_vapp, included

Methods included from VcCommon

#connection, #deprecation_msg, #generate_key, #get_password, included, #locate_config_value, #locate_org_option, #notice_msg, #out_msg, #pretty_symbol, #sort_by_key, #store_config, #store_password, #wait_task

Instance Method Details

#runObject



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
# File 'lib/chef/knife/vapp/vc_vapp_snapshot.rb', line 27

def run
  $stdout.sync = true

  command_arg = @name_args.shift
  vapp_arg = @name_args.shift

  unless command_arg =~ /create|revert/
    raise ArgumentError, "Invalid command #{command_arg} supplied. Only create and revert are allowed."
  end

  command = command_arg.to_sym

  connection.

  vapp = get_vapp(vapp_arg)

  case command
    when :create
      task_id = connection.create_vapp_snapshot vapp[:id]
      ui.msg "vApp snapshot creation..."
      wait_task(connection, task_id)
    when :revert
      task_id = connection.revert_vapp_snapshot vapp[:id]
      ui.msg "vApp snapshot revert..."
      wait_task(connection, task_id)
  end

  connection.logout
end