Module: FFI::VixDiskLib::ApiWrapper

Extended by:
API
Defined in:
lib/ffi-vix_disk_lib/api_wrapper.rb

Constant Summary

Constants included from API

FFI::VixDiskLib::API::AdapterType, FFI::VixDiskLib::API::ConnectParams, FFI::VixDiskLib::API::CredType, FFI::VixDiskLib::API::DiskType, FFI::VixDiskLib::API::HWVERSION_CURRENT, FFI::VixDiskLib::API::HWVERSION_ESX30, FFI::VixDiskLib::API::HWVERSION_WORKSTATION_4, FFI::VixDiskLib::API::HWVERSION_WORKSTATION_5, FFI::VixDiskLib::API::HWVERSION_WORKSTATION_6, FFI::VixDiskLib::API::LOADED_LIBRARY, FFI::VixDiskLib::API::VERSION, FFI::VixDiskLib::API::VIXDISKLIB_FLAG_OPEN_READ_ONLY, FFI::VixDiskLib::API::VIXDISKLIB_FLAG_OPEN_SINGLE_LINK, FFI::VixDiskLib::API::VIXDISKLIB_FLAG_OPEN_UNBUFFERED, FFI::VixDiskLib::API::VIXDISKLIB_SECTOR_SIZE, FFI::VixDiskLib::API::VixErrorType

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from API

ProgressFunc, attach_function, enum, evaluate_versioned_connect_params, free_error_text, get_error_text, initEx, load_error, vix_error_code, vix_failed?, vix_succeeded?

Instance Attribute Details

#error_loggerObject (readonly)

Returns the value of attribute error_logger.



17
18
19
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 17

def error_logger
  @error_logger
end

#info_loggerObject (readonly)

Returns the value of attribute info_logger.



17
18
19
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 17

def info_logger
  @info_logger
end

#warn_loggerObject (readonly)

Returns the value of attribute warn_logger.



17
18
19
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 17

def warn_logger
  @warn_logger
end

Class Method Details

.attach(parent_disk_handle, child_disk_handle) ⇒ Object



19
20
21
22
23
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 19

def self.attach(parent_disk_handle, child_disk_handle)
  vix_error = super(parent_disk_handle, child_disk_handle)
  check_error(vix_error, __method__)
  nil
end

.check_repair(connection, file_name, repair) ⇒ Object

The VixDiskLib_CheckRepair method



28
29
30
31
32
33
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 28

def self.check_repair(connection, file_name, repair)
  file_ptr = FFI::MemoryPointer.from_string(file_name)
  vix_error = super(connection, file_ptr, repair)
  check_error(vix_error, __method__)
  nil
end

.cleanup(connect_parms) ⇒ Object

The VixDiskLib_Cleanup method



38
39
40
41
42
43
44
45
46
47
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 38

def self.cleanup(connect_parms)
  safe_parms = SafeConnectParams.new(connect_parms)
  cleaned_up = FFI::MemoryPointer.new :pointer
  remaining = FFI::MemoryPointer.new :pointer
  vix_error = super(safe_parms.connect_params, cleaned_up, remaining)
  num_cleaned_up = cleaned_up.get_uint32(0) unless cleaned_up.nil?
  num_remaining = remaining.get_uint32(0) unless remaining.nil?
  check_error(vix_error, __method__)
  return num_cleaned_up, num_remaining
end

.clone(dest_connection, dest_path, src_connection, src_path, create_parms, over_write) ⇒ Object

The VixDiskLib_Clone method



52
53
54
55
56
57
58
59
60
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 52

def self.clone(dest_connection, dest_path, src_connection, src_path, create_parms, over_write)
  dest_ptr = FFI::MemoryPointer.from_string(dest_path)
  src_ptr = FFI::MemoryPointer.from_string(src_path)
  safe_parms = SafeCreateParams.new(create_parms)
  vix_error = super(dest_connection, dest_ptr, src_connection, src_ptr,
                    safe_parms.create_params, nil, nil, over_write)
  check_error(vix_error, __method__)
  nil
end

.close(disk_handle) ⇒ Object

The VixDiskLib_Close method



65
66
67
68
69
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 65

def self.close(disk_handle)
  vix_error = super(disk_handle)
  check_error(vix_error, __method__)
  nil
end

.connect(connect_parms) ⇒ Object

The VixDiskLib_Connect method



74
75
76
77
78
79
80
81
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 74

def self.connect(connect_parms)
  connection = FFI::MemoryPointer.new :pointer
  safe_parms = SafeConnectParams.new(connect_parms)
  vix_error = super(safe_parms.connect_params, connection)
  connection = connection.get_pointer(0)
  check_error(vix_error, __method__)
  connection
end

.connect_ex(connect_parms, read_only, snapshot_ref, transport_modes) ⇒ Object

The VixDiskLib_ConnectEx method



86
87
88
89
90
91
92
93
94
95
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 86

def self.connect_ex(connect_parms, read_only, snapshot_ref, transport_modes)
  connection = FFI::MemoryPointer.new :pointer
  safe_parms = SafeConnectParams.new(connect_parms)
  snapshot_ptr = snapshot_ref && FFI::MemoryPointer.from_string(snapshot_ref)
  modes_ptr = transport_modes && FFI::MemoryPointer.from_string(transport_modes)
  vix_error = super(safe_parms.connect_params, read_only, snapshot_ptr, modes_ptr, connection)
  connection = connection.get_pointer(0)
  check_error(vix_error, __method__)
  connection
end

.create(connection, path, create_parms, prog_func = nil, prog_callback_data = nil) ⇒ Object

The VixDiskLib_Create method



100
101
102
103
104
105
106
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 100

def self.create(connection, path, create_parms, prog_func = nil, prog_callback_data = nil)
  safe_parms = SafeCreateParams.new(create_parms)
  path_ptr = FFI::MemoryPointer.from_string(path)
  vix_error = super(connection, path_ptr, safe_parms.create_params, prog_func, prog_callback_data)
  check_error(vix_error, __method)
  nil
end

.create_child(disk_handle, child_path, disk_type, prog_func = nil, prog_callback_data = nil) ⇒ Object

The VixDiskLib_CreateChild method



111
112
113
114
115
116
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 111

def self.create_child(disk_handle, child_path, disk_type, prog_func = nil, prog_callback_data = nil)
  path_ptr = FFI::MemoryPointer.from_string(child_path)
  vix_error = super(disk_handle, path_ptr, disk_type, prog_func, prog_callback_data)
  check_error(vix_error, __method)
  nil
end

.defragment(disk_handle) ⇒ Object

The VixDiskLib_Defragment method



121
122
123
124
125
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 121

def self.defragment(disk_handle)
  vix_error = super(disk_handle, nil, nil)
  check_error(vix_error, __method__)
  nil
end

.disconnect(connection) ⇒ Object

The VixDiskLib_Disconnect method



130
131
132
133
134
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 130

def self.disconnect(connection)
  vix_error = super(connection)
  check_error(vix_error, __method__)
  nil
end

.end_access(connect_parms, identity) ⇒ Object

The VixDiskLib_Access method



139
140
141
142
143
144
145
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 139

def self.end_access(connect_parms, identity)
  safe_parms = SafeConnectParams.new(connect_parms)
  identity_ptr = FFI::MemoryPointer.from_string(identity)
  vix_error = super(safe_parms.connect_params, identity_ptr)
  check_error(vix_error, __method__)
  nil
end

.exitObject

The VixDiskLib_Exit method



150
151
152
153
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 150

def self.exit
  super
  nil
end

.free_connect_params(connect_params) ⇒ Object

The VixDiskLib_FreeConnectParams method



158
159
160
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 158

def self.free_connect_params(connect_params)
  super(connect_params)
end

.get_connect_params(connection) ⇒ Object

The VixDiskLib_GetConnectParams method



165
166
167
168
169
170
171
172
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 165

def self.get_connect_params(connection)
  params_ptr = FFI::MemoryPointer.new :pointer
  vix_error = super(connection, params_ptr)
  check_error(vix_error, __method__)
  ffi_connect_params = params_ptr.get_pointer(0)
  safe_connect_params = SafeConnectParams.read(ffi_connect_params)
  safe_connect_params
end

.get_info(disk_handle) ⇒ Object

The VixDiskLib_GetInfo method



177
178
179
180
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 177

def self.get_info(disk_handle)
  info = DiskInfo.new(disk_handle)
  info.info
end

.get_metadata_keys(disk_handle) ⇒ Object

The VixDiskLib_GetMetadataKeys method



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 185

def self.(disk_handle)
  #
  # Get the size of the buffer required for the metadata keys for the disk.
  #
  len_ptr = FFI::MemoryPointer.new :pointer
  vix_error = super(disk_handle, nil, 0, len_ptr)
  if vix_error != API::VixErrorType[:VIX_OK] && vix_error != API::VixErrorType[:VIX_E_BUFFER_TOOSMALL]
    check_error(vix_error, __method__)
  end
  #
  # Read the metadata keys for the disk into the allocated buffer.
  #
  buf_size = len_ptr.get_uint64(0)
  read_buf = FFI::MemoryPointer.new(buf_size)
  vix_error = super(disk_handle, read_buf, buf_size, nil)
  check_error(vix_error, __method__)
  keys = read_buf.get_bytes(0, buf_size)
  keys.split("\x00")
end

.get_transport_mode(disk_handle) ⇒ Object

The VixDiskLib_GetTransportMode method



208
209
210
211
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 208

def self.get_transport_mode(disk_handle)
  mode = super(disk_handle)
  mode.read_string
end

.grow(connection, path, capacity, update_geometry) ⇒ Object

The VixDiskLib_Grow method



216
217
218
219
220
221
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 216

def self.grow(connection, path, capacity, update_geometry)
  path_ptr = FFI::MemoryPointer.from_string(path)
  vix_error = super(connection, path_ptr, capacity, update_geometry, nil, nil)
  check_error(vix_error, __method__)
  nil
end

.init(info_logger = nil, warn_logger = nil, error_logger = nil, libDir = nil) ⇒ Object

The VixDiskLib_Init method



226
227
228
229
230
231
232
233
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 226

def self.init(info_logger = nil, warn_logger = nil, error_logger = nil, libDir = nil)
  @info_logger, @warn_logger, @error_logger = info_logger, warn_logger, error_logger

  vix_error = super(API::VERSION_MAJOR, API::VERSION_MINOR,
                    logger_for("info"), logger_for("warn"), logger_for("error"), libDir)
  check_error(vix_error, __method__)
  nil
end

.init_ex(info_logger = nil, warn_logger = nil, error_logger = nil, libDir = nil, configFile = nil) ⇒ Object

The VixDiskLib_InitEx method



238
239
240
241
242
243
244
245
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 238

def self.init_ex(info_logger = nil, warn_logger = nil, error_logger = nil, libDir = nil, configFile = nil)
  @info_logger, @warn_logger, @error_logger = info_logger, warn_logger, error_logger

  vix_error = super(API::VERSION_MAJOR, API::VERSION_MINOR,
                    logger_for("info"), logger_for("warn"), logger_for("error"), libDir, configFile)
  check_error(vix_error, __method__)
  nil
end

.is_attach_possible(parent_disk_handle, child_disk_handle) ⇒ Object

The VixDiskLib_IsAttachPossible method



250
251
252
253
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 250

def self.is_attach_possible(parent_disk_handle, child_disk_handle)
  vix_error = super(parent_disk_handle, child_disk_handle)
  VixDiskLib.vix_succeeded?(vix_error)
end

.list_transport_modesObject

The VixDiskLib_ListTransportModes method



258
259
260
261
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 258

def self.list_transport_modes
  list = super
  list.read_string
end

.open(connection, path, flags) ⇒ Object

The VixDiskLib_Open method



266
267
268
269
270
271
272
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 266

def self.open(connection, path, flags)
  path_ptr = FFI::MemoryPointer.from_string(path)
  disk_handle = FFI::MemoryPointer.new :pointer
  vix_error = super(connection, path_ptr, flags, disk_handle)
  check_error(vix_error, __method__)
  disk_handle.get_pointer(0)
end

.prepare_for_access(connect_parms, identity) ⇒ Object

The VixDiskLib_PrepareForAccess method



277
278
279
280
281
282
283
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 277

def self.prepare_for_access(connect_parms, identity)
  safe_parms = SafeConnectParams.new(connect_parms)
  identity_ptr = FFI::MemoryPointer.from_string(identity)
  vix_error = super(safe_parms.connect_params, identity_ptr)
  check_error(vix_error, __method__)
  nil
end

.read(disk_handle, start_sector, num_sectors) ⇒ Object

The VixDiskLib_Read method



288
289
290
291
292
293
294
295
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 288

def self.read(disk_handle, start_sector, num_sectors)
  buf_size = num_sectors * API::VIXDISKLIB_SECTOR_SIZE
  read_buf = FFI::MemoryPointer.new(buf_size)
  read_buf.clear
  vix_error = super(disk_handle, start_sector, num_sectors, read_buf)
  check_error(vix_error, __method__)
  read_buf.get_bytes(0, buf_size)
end

.read_metadata(disk_handle, key) ⇒ Object

The VixDiskLib_ReadMetadata method



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 300

def self.(disk_handle, key)
  key_ptr = FFI::MemoryPointer.from_string(key)
  #
  # Get the size of the buffer required for the metadata key for this disk.
  #
  len_ptr = FFI::MemoryPointer.new :pointer
  vix_error = super(disk_handle, key_ptr, nil, 0, len_ptr)
  if vix_error != API::VixErrorType[:VIX_OK] && vix_error != API::VixErrorType[:VIX_E_BUFFER_TOOSMALL]
    check_error(vix_error, __method__)
  end
  #
  # Read the metadata key for the disk into the allocated buffer.
  #
  buf_size = len_ptr.get_uint64(0)
  read_buf = FFI::MemoryPointer.new(buf_size)
  vix_error = super(disk_handle, key_ptr, read_buf, buf_size, nil)
  check_error(vix_error, __method__)
  read_buf.get_bytes(0, buf_size)
end

.rename(src_path, dest_path) ⇒ Object

The VixDiskLib_Rename method



323
324
325
326
327
328
329
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 323

def self.rename(src_path, dest_path)
  src_ptr = FFI::MemoryPointer.from_string(src_path)
  dest_ptr = FFI::MemoryPointer.from_string(dest_path)
  vix_error = super(src_ptr, dest_ptr)
  check_error(vix_error, __method__)
  nil
end

.shrink(disk_handle, prog_func = nil, prog_callback_data = nil) ⇒ Object

The VixDiskLib_Shrink method



334
335
336
337
338
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 334

def self.shrink(disk_handle, prog_func = nil, prog_callback_data = nil)
  vix_error = super(disk_handle, prog_func, prog_callback_data)
  check_error(vix_error, __method__)
  nil
end

.space_needed_for_clone(disk_handle, disk_type) ⇒ Object

The VixDiskLib_SpaceNeededForClone method



343
344
345
346
347
348
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 343

def self.space_needed_for_clone(disk_handle, disk_type)
  needed_ptr = FFI::MemoryPointer.new :pointer
  vix_error = super(disk_handle, disk_type, needed_ptr)
  check_error(vix_error, __method__)
  needed_ptr.get_uint64(0)
end

The VixDiskLib_Unlink method



353
354
355
356
357
358
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 353

def self.unlink(connection, path)
  path_ptr = FFI::MemoryPointer.from_string(path)
  vix_error = super(connection, path_ptr)
  check_error(vix_error, __method__)
  nil
end

.write(disk_handle, start_sector, num_sectors, buf) ⇒ Object

The VixDiskLib_Write method



363
364
365
366
367
368
369
370
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 363

def self.write(disk_handle, start_sector, num_sectors, buf)
  buf_size = num_sectors * :VIXDISKLIB_SECTOR_SIZE
  buf_ptr = FFI::MemoryPointer.new(buf_size)
  buf_ptr.write_bytes(buf, 0, buf_size)
  vix_error = super(disk_handle, start_sector, num_sectors, buf_ptr)
  check_error(vix_error, __method__)
  nil
end

.write_metadata(disk_handle, key, value) ⇒ Object

The VixDiskLib_WriteMetadata method



375
376
377
378
379
380
381
# File 'lib/ffi-vix_disk_lib/api_wrapper.rb', line 375

def self.(disk_handle, key, value)
  key_ptr = FFI::MemoryPointer.from_string(key)
  val_ptr = FFI::MemoryPointer.from_string(value)
  vix_error = super(disk_handle, key_ptr, val_ptr)
  check_error(vix_error, __method__)
  nil
end