class Chef::Knife::VsphereDatastoreFile

Upload or download a file from a datastore VsphereDatastoreFile extends the BaseVspherecommand

Public Instance Methods

run() click to toggle source

Main run method for datastore_file

# File lib/chef/knife/vsphere_datastore_file.rb, line 38
def run
  $stdout.sync = true

  unless get_config(:upload) || get_config(:download)
    show_usage
    fatal_exit("You must specify either upload or download")
  end
  unless get_config(:local_file) && get_config(:remote_file)
    show_usage
    fatal_exit("You must specify both local-file and remote-file")
  end

  vim_connection
  datastore = find_datastore(@name_args[0])
  if get_config(:upload)
    datastore.upload(get_config(:remote_file), get_config(:local_file))
  elsif get_config(:download)
    datastore.download(get_config(:remote_file), get_config(:local_file))
  end
end