ffi-vix_disk_lib 1.0.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8c43c07f9524fec53d769fc90299cde4868b8819
4
- data.tar.gz: 165ccea6e0546c6b18cb6f2155adece6dd3efe79
2
+ SHA256:
3
+ metadata.gz: cdb76ad123804d0fff4a0cc551c0c87bf2f19a55dd470d9b117a96d8a54fed41
4
+ data.tar.gz: 9f914959653282a5b4364b5e89ba22c6779e4ffe5bcbdabf9083e1a1590ace03
5
5
  SHA512:
6
- metadata.gz: aabbfae2cb4f45024217ecdda2c70b6f6dd8e8e18e681aa366adeabc5f76562edf255f38d0cf7dae6ce2b38025b7d879f51a9bbd474e7ace69377b2234552a39
7
- data.tar.gz: 580498a16f23a65fe838e5c4912492800a1df8f26307099e9ae190cfaddcba1fada74769bc30a563e99168dbcbca8a85091476c83936b463a0b33e2d22969eab
6
+ metadata.gz: 3d52ab24e0ca7a4af5e3c600b688de6fdec023fccfad5aeff57a2c7695276ee14ad61e54209ba24122ad5ba36493ac3373075d56d1702bf8152e7cef34e8b85e
7
+ data.tar.gz: bd798b4365d6914e2596cd3bc1ae0d4b5b88f9b8416136e479f3b306cedb7cf044246d92d8f7d83db9f84549baa5de11b297d8323fbe25bd3e8f69107954bfa2
@@ -5,43 +5,37 @@ module FFI
5
5
  module API
6
6
  extend FFI::Library
7
7
 
8
- def attach_function(*args)
8
+ def self.attach_function(*args)
9
9
  super
10
10
  rescue FFI::NotFoundError
11
11
  warn "unable to attach #{args.first}"
12
12
  end
13
13
 
14
+ #
15
+ # Maintain backwards compatibility with the previous method
16
+ # of loading libvixDiskLib
17
+ #
14
18
  def self.load_error
15
- @load_error
19
+ nil
16
20
  end
17
21
 
18
- #
19
- # Make sure we load one and only one version of VixDiskLib
20
- #
21
- version_load_order = %w( 6.5.0 6.0.0 5.5.4 5.5.2 5.5.1 5.5.0 5.1.3 5.1.2 5.1.1 5.1.0 5.0.4 5.0.0 1.2.0 1.1.2 )
22
- bad_versions = {}
23
- load_errors = []
24
- loaded_library = ""
25
- version_load_order.each do |version|
26
- begin
27
- loaded_library = ffi_lib ["vixDiskLib.so.#{version}"]
28
- VERSION_MAJOR, VERSION_MINOR = loaded_library.first.name.split(".")[2, 2].collect(&:to_i)
29
- if bad_versions.keys.include?(version)
30
- loaded_library = ""
31
- @load_error = "VixDiskLib #{version} is not supported: #{bad_versions[version]}"
32
- end
33
- break
34
- rescue LoadError => err
35
- load_errors << "ffi-vix_disk_lib: failed to load #{version} version with error: #{err.message}."
36
- next
22
+ candidate_versions = %w[7.0.1 7.0.0 6.7.3 6.7.2 6.7.1 6.7.0 6.5.4 6.5.3 6.5.2 6.5.1 6.5.0 6.0.3 6.0.2 6.0.1 6.0.0 5.5.4 5.5.2 5.5.1 5.5.0 5.1.3 5.1.2 5.1.1 5.1.0 5.0.4 5.0.0 1.2.0 1.1.2]
23
+ candidate_libraries = candidate_versions.map { |v| "vixDiskLib.so.#{v}" }
24
+
25
+ # LD_LIBRARY_PATH is not honored on Mac, so build our own rudimentary version
26
+ if RbConfig::CONFIG["host_os"] =~ /darwin/ && (env = ENV["LD_LIBRARY_PATH"] || ENV["DYLD_LIBRARY_PATH"])
27
+ candidate_libraries = candidate_libraries.product(env.split(":")).flat_map do |n, p|
28
+ [
29
+ File.join(p, n),
30
+ File.join(p, FFI.map_library_name(n).chomp(".dylib")),
31
+ File.join(p, FFI.map_library_name(n))
32
+ ]
37
33
  end
38
34
  end
39
35
 
40
- unless @load_error || loaded_library.length > 0
41
- STDERR.puts load_errors.join("\n")
42
- @load_error = "ffi-vix_disk_lib: failed to load any version of VixDiskLib!"
43
- end
44
- LOADED_LIBRARY = loaded_library
36
+ LOADED_LIBRARY = ffi_lib(candidate_libraries)
37
+ VERSION = LOADED_LIBRARY.first.name.chomp(".dylib").split(".").last(3).join(".")
38
+ VERSION_MAJOR, VERSION_MINOR, = VERSION.split(".").map(&:to_i)
45
39
 
46
40
  # An error is a 64-bit value. If there is no error, then the value is
47
41
  # set to VIX_OK. If there is an error, then the least significant bits
@@ -61,6 +55,12 @@ module FFI
61
55
  err != VixErrorType[:VIX_OK]
62
56
  end
63
57
 
58
+ def self.evaluate_versioned_connect_params
59
+ Gem::Version.new(VERSION) >= Gem::Version.new("6.5.0") ? ConnectParams_6_5_0 : ConnectParams_1_0_0
60
+ end
61
+
62
+ ConnectParams = evaluate_versioned_connect_params
63
+
64
64
  callback :GenericLogFunc, [:string, :pointer], :void
65
65
 
66
66
  # Prototype for the progress function called by VixDiskLib.
@@ -57,14 +57,26 @@ module FFI
57
57
  #
58
58
  # Example VM spec:
59
59
  # "MyVm/MyVm.vmx?dcPath=Path/to/MyDatacenter&dsName=storage1"
60
- class ConnectParams < FFI::Struct
61
- layout :vmxSpec, :pointer,
62
- :serverName, :pointer,
63
- :thumbPrint, :pointer,
64
- :privateUse, :long,
60
+ class ConnectParams_1_0_0 < FFI::Struct
61
+ layout :vmxSpec, :pointer, # URL like spec of the VM.
62
+ :serverName, :pointer, # Name or IP address of VC / ESX.
63
+ :thumbPrint, :pointer, # SSL Certificate thumb print.
64
+ :privateUse, :long, # This value is ignored.
65
65
  :credType, CredType,
66
66
  :creds, Creds,
67
- :port, :uint32
67
+ :port, :uint32 # port to use for authenticating with VC/ESXi host
68
+ end
69
+
70
+ class ConnectParams_6_5_0 < FFI::Struct
71
+ layout :vmxSpec, :pointer, # URL like spec of the VM.
72
+ :serverName, :pointer, # Name or IP address of VC / ESX.
73
+ :thumbPrint, :pointer, # SSL Certificate thumb print.
74
+ :privateUse, :long, # This value is ignored.
75
+ :credType, CredType,
76
+ :creds, Creds,
77
+ :port, :uint32, # port to use for authenticating with VC/ESXi host
78
+ :nfcHostPort, :uint32, # port to use for establishing NFC connection to ESXi host
79
+ :vimApiVer, :pointer # VIM API version to use, private
68
80
  end
69
81
 
70
82
  class Info < FFI::Struct
@@ -1,5 +1,5 @@
1
1
  module FFI
2
2
  module VixDiskLib
3
- VERSION = "1.0.3"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,3 @@
1
+ *.o
2
+ *.d
3
+ *.so*
data/spec/ext/Makefile ADDED
@@ -0,0 +1,30 @@
1
+ CC=gcc
2
+ CFLAGS=-I.
3
+ CFLAGS = -fPIC -O0 -g
4
+ LDFLAGS = -shared
5
+ LN = ln -sf
6
+ SRCS = vixDiskLib.c
7
+ OBJS = ${SRCS:.c=.o}
8
+ TARGET_LIB = libvixDiskLib.so
9
+ MAJOR_VERSION = $(shell echo ${VDDK_VERSION} | cut -f1 -d.)
10
+ VDDK_VERSION ?= 6.7.0
11
+
12
+ .PHONY: all
13
+ all: ${TARGET_LIB}.${VDDK_VERSION}
14
+
15
+ ${SRCS:.c=.d}:%.d:%.c
16
+ ${CC} ${CFLAGS} -MM $< >$@
17
+
18
+ ${TARGET_LIB}.${MAJOR_VERSION}: ${TARGET_LIB}
19
+ ${LN} $^ $@
20
+ ${TARGET_LIB}.${VDDK_VERSION}: ${TARGET_LIB}.${MAJOR_VERSION}
21
+ ${LN} $^ $@
22
+
23
+ ${TARGET_LIB}: ${OBJS}
24
+ ${CC} ${LDFLAGS} -o $@ $^
25
+
26
+ include ${SRCS:.c=.d}
27
+
28
+ .PHONY: clean
29
+ clean:
30
+ -${RM} ${TARGET_LIB} ${TARGET_LIB}.${MAJOR_VERSION} ${TARGET_LIB}.${VDDK_VERSION} ${OBJS} ${SRCS:.c=.d}
@@ -0,0 +1,456 @@
1
+ #include <stdlib.h>
2
+ #include <stddef.h>
3
+ #include <stdarg.h>
4
+ #include <stdint.h>
5
+
6
+ typedef uint64_t uint64;
7
+ typedef int64_t int64;
8
+ typedef uint32_t uint32;
9
+ typedef int32_t int32;
10
+ typedef uint16_t uint16;
11
+ typedef int16_t int16;
12
+ typedef uint8_t uint8;
13
+ typedef int8_t int8;
14
+ typedef char Bool;
15
+ typedef uint64 VixError;
16
+
17
+ enum {
18
+ VIX_OK = 0,
19
+ };
20
+
21
+ typedef struct VixDiskLibHandleStruct VixDiskLibHandleStruct;
22
+ typedef VixDiskLibHandleStruct *VixDiskLibHandle;
23
+ typedef void (VixDiskLibGenericLogFunc)(const char *fmt, va_list args);
24
+ struct VixDiskLibConnectParam;
25
+ typedef struct VixDiskLibConnectParam *VixDiskLibConnection;
26
+ typedef Bool (*VixDiskLibProgressFunc)(void *progressData,
27
+ int percentCompleted);
28
+ typedef void (*VixDiskLibCompletionCB)(void *cbData, VixError result);
29
+ typedef enum {
30
+ VIXDISKLIB_DISK_UNKNOWN = 256
31
+ } VixDiskLibDiskType;
32
+
33
+ typedef enum {
34
+ VIXDISKLIB_ADAPTER_UNKNOWN = 256
35
+ } VixDiskLibAdapterType;
36
+
37
+ typedef uint64 VixDiskLibSectorType;
38
+
39
+ typedef struct {
40
+ VixDiskLibDiskType diskType;
41
+ VixDiskLibAdapterType adapterType;
42
+ uint16 hwVersion;
43
+ VixDiskLibSectorType capacity;
44
+ } VixDiskLibCreateParams;
45
+
46
+ typedef enum {
47
+ VIXDISKLIB_CRED_UNKNOWN = 256
48
+ } VixDiskLibCredType;
49
+
50
+ typedef struct {
51
+ uint32 cylinders;
52
+ uint32 heads;
53
+ uint32 sectors;
54
+ } VixDiskLibGeometry;
55
+
56
+ typedef struct {
57
+ VixDiskLibGeometry biosGeo; // BIOS geometry for booting and partitioning
58
+ VixDiskLibGeometry physGeo; // physical geometry
59
+ VixDiskLibSectorType capacity; // total capacity in sectors
60
+ VixDiskLibAdapterType adapterType; // adapter type
61
+ int numLinks; // number of links (i.e. base disk + redo logs)
62
+ char *parentFileNameHint; // parent file for a redo log
63
+ char *uuid; // disk UUID
64
+ } VixDiskLibInfo;
65
+
66
+ typedef struct VixDiskLibConnectParamsState VixDiskLibConnectParamsState;
67
+
68
+ typedef struct {
69
+ VixDiskLibSectorType offset; // offset in sectors
70
+ VixDiskLibSectorType length;
71
+ } VixDiskLibBlock;
72
+
73
+ typedef struct {
74
+ uint32 numBlocks;
75
+ VixDiskLibBlock blocks[1];
76
+ } VixDiskLibBlockList;
77
+
78
+ typedef struct {
79
+ char *id;
80
+ char *datastoreMoRef;
81
+ char *ssId;
82
+ } VixDiskLibVStorageObjectSpec;
83
+
84
+ typedef enum {
85
+ VIXDISKLIB_SPEC_UNKNOWN = 2
86
+ } VixDiskLibSpecType;
87
+
88
+ typedef struct {
89
+ char *vmxSpec; // URL like spec of the VM.
90
+ char *serverName; // Name or IP address of VC / ESX.
91
+ char *thumbPrint; // SSL Certificate thumb print.
92
+ long privateUse; // This value is ignored.
93
+ VixDiskLibCredType credType;
94
+
95
+ union VixDiskLibCreds {
96
+ struct VixDiskLibUidPasswdCreds {
97
+ char *userName; // User id and password on the
98
+ char *password; // VC/ESX host.
99
+ } uid;
100
+ struct VixDiskLibSessionIdCreds { // Not supported in 1.0
101
+ char *cookie;
102
+ char *userName;
103
+ char *key;
104
+ } sessionId;
105
+ struct VixDiskLibTicketIdCreds *ticketId; // Internal use only.
106
+ } creds;
107
+
108
+ uint32 port; // port to use for authenticating with VC/ESXi host
109
+ uint32 nfcHostPort; // port to use for establishing NFC connection to ESXi host
110
+
111
+ char *vimApiVer; // not used
112
+ char reserved[8]; // internal use only
113
+ VixDiskLibConnectParamsState *state; // internal use only
114
+
115
+ union {
116
+ VixDiskLibVStorageObjectSpec vStorageObjSpec;
117
+ } spec;
118
+ VixDiskLibSpecType specType; // disk or VM spec
119
+ } VixDiskLibConnectParams;
120
+
121
+ VixError
122
+ VixDiskLib_InitEx(uint32 majorVersion,
123
+ uint32 minorVersion,
124
+ VixDiskLibGenericLogFunc *log,
125
+ VixDiskLibGenericLogFunc *warn,
126
+ VixDiskLibGenericLogFunc *panic,
127
+ const char* libDir,
128
+ const char* configFile)
129
+ {
130
+ return VIX_OK;
131
+ }
132
+
133
+ VixError
134
+ VixDiskLib_Init(uint32 majorVersion,
135
+ uint32 minorVersion,
136
+ VixDiskLibGenericLogFunc *log,
137
+ VixDiskLibGenericLogFunc *warn,
138
+ VixDiskLibGenericLogFunc *panic,
139
+ const char* libDir)
140
+ {
141
+ return VIX_OK;
142
+ }
143
+
144
+ void
145
+ VixDiskLib_Exit(void)
146
+ {
147
+ }
148
+
149
+ const char *
150
+ VixDiskLib_ListTransportModes(void)
151
+ {
152
+ return "";
153
+ }
154
+
155
+ VixError
156
+ VixDiskLib_Cleanup(const VixDiskLibConnectParams *connectParams,
157
+ uint32 *numCleanedUp, uint32 *numRemaining)
158
+ {
159
+ return VIX_OK;
160
+ }
161
+
162
+ VixError
163
+ VixDiskLib_Connect(const VixDiskLibConnectParams *connectParams,
164
+ VixDiskLibConnection *connection)
165
+ {
166
+ return VIX_OK;
167
+ }
168
+
169
+ VixError
170
+ VixDiskLib_PrepareForAccess(const VixDiskLibConnectParams *connectParams,
171
+ const char *identity)
172
+ {
173
+ return VIX_OK;
174
+ }
175
+
176
+ VixError
177
+ VixDiskLib_ConnectEx(const VixDiskLibConnectParams *connectParams,
178
+ Bool readOnly,
179
+ const char *snapshotRef,
180
+ const char *transportModes,
181
+ VixDiskLibConnection *connection)
182
+ {
183
+ return VIX_OK;
184
+ }
185
+
186
+ VixError
187
+ VixDiskLib_Disconnect(VixDiskLibConnection connection)
188
+ {
189
+ return VIX_OK;
190
+ }
191
+
192
+ VixError
193
+ VixDiskLib_EndAccess(const VixDiskLibConnectParams *connectParams,
194
+ const char *identity)
195
+ {
196
+ return VIX_OK;
197
+ }
198
+
199
+ VixError
200
+ VixDiskLib_Create(const VixDiskLibConnection connection,
201
+ const char *path,
202
+ const VixDiskLibCreateParams *createParams,
203
+ VixDiskLibProgressFunc progressFunc,
204
+ void *progressCallbackData)
205
+ {
206
+ return VIX_OK;
207
+ }
208
+
209
+ VixError
210
+ VixDiskLib_CreateChild(VixDiskLibHandle diskHandle,
211
+ const char *childPath,
212
+ VixDiskLibDiskType diskType,
213
+ VixDiskLibProgressFunc progressFunc,
214
+ void *progressCallbackData)
215
+ {
216
+ return VIX_OK;
217
+ }
218
+
219
+ VixError
220
+ VixDiskLib_Open(const VixDiskLibConnection connection,
221
+ const char *path,
222
+ uint32 flags,
223
+ VixDiskLibHandle *diskHandle)
224
+ {
225
+ return VIX_OK;
226
+ }
227
+
228
+ VixError
229
+ VixDiskLib_QueryAllocatedBlocks(VixDiskLibHandle diskHandle,
230
+ VixDiskLibSectorType startSector,
231
+ VixDiskLibSectorType numSectors,
232
+ VixDiskLibSectorType chunkSize,
233
+ VixDiskLibBlockList **blockList)
234
+ {
235
+ return VIX_OK;
236
+ }
237
+
238
+ VixError
239
+ VixDiskLib_FreeBlockList(VixDiskLibBlockList *blockList)
240
+ {
241
+ return VIX_OK;
242
+ }
243
+
244
+ VixError
245
+ VixDiskLib_GetInfo(VixDiskLibHandle diskHandle,
246
+ VixDiskLibInfo **info)
247
+ {
248
+ return VIX_OK;
249
+ }
250
+
251
+ void
252
+ VixDiskLib_FreeInfo(VixDiskLibInfo *info)
253
+ {
254
+ }
255
+
256
+ const char *
257
+ VixDiskLib_GetTransportMode(VixDiskLibHandle diskHandle)
258
+ {
259
+ return "";
260
+ }
261
+
262
+ VixError
263
+ VixDiskLib_Close(VixDiskLibHandle diskHandle)
264
+ {
265
+ return VIX_OK;
266
+ }
267
+
268
+ VixError
269
+ VixDiskLib_Read(VixDiskLibHandle diskHandle,
270
+ VixDiskLibSectorType startSector,
271
+ VixDiskLibSectorType numSectors,
272
+ uint8 *readBuffer)
273
+ {
274
+ return VIX_OK;
275
+ }
276
+
277
+ VixError
278
+ VixDiskLib_ReadAsync(VixDiskLibHandle diskHandle,
279
+ VixDiskLibSectorType startSector,
280
+ VixDiskLibSectorType numSectors,
281
+ uint8 *readBuffer,
282
+ VixDiskLibCompletionCB callback,
283
+ void *cbData)
284
+ {
285
+ return VIX_OK;
286
+ }
287
+
288
+ VixError
289
+ VixDiskLib_Write(VixDiskLibHandle diskHandle,
290
+ VixDiskLibSectorType startSector,
291
+ VixDiskLibSectorType numSectors,
292
+ const uint8 *writeBuffer)
293
+ {
294
+ return VIX_OK;
295
+ }
296
+
297
+ VixError
298
+ VixDiskLib_WriteAsync(VixDiskLibHandle diskHandle,
299
+ VixDiskLibSectorType startSector,
300
+ VixDiskLibSectorType numSectors,
301
+ const uint8 *writeBuffer,
302
+ VixDiskLibCompletionCB callback,
303
+ void *cbData)
304
+ {
305
+ return VIX_OK;
306
+ }
307
+
308
+ VixError
309
+ VixDiskLib_Flush(VixDiskLibHandle diskHandle)
310
+ {
311
+ return VIX_OK;
312
+ }
313
+
314
+ VixError
315
+ VixDiskLib_Wait(VixDiskLibHandle diskHandle)
316
+ {
317
+ return VIX_OK;
318
+ }
319
+
320
+ VixError
321
+ VixDiskLib_ReadMetadata(VixDiskLibHandle diskHandle,
322
+ const char *key,
323
+ char *buf,
324
+ size_t bufLen,
325
+ size_t *requiredLen)
326
+ {
327
+ return VIX_OK;
328
+ }
329
+
330
+ VixError
331
+ VixDiskLib_WriteMetadata(VixDiskLibHandle diskHandle,
332
+ const char *key,
333
+ const char *val)
334
+ {
335
+ return VIX_OK;
336
+ }
337
+
338
+ VixError
339
+ VixDiskLib_GetMetadataKeys(VixDiskLibHandle diskHandle,
340
+ char *keys,
341
+ size_t maxLen,
342
+ size_t *requiredLen)
343
+ {
344
+ return VIX_OK;
345
+ }
346
+
347
+ VixError
348
+ VixDiskLib_Unlink(VixDiskLibConnection connection,
349
+ const char *path)
350
+ {
351
+ return VIX_OK;
352
+ }
353
+
354
+ VixError
355
+ VixDiskLib_Grow(VixDiskLibConnection connection,
356
+ const char *path,
357
+ VixDiskLibSectorType capacity,
358
+ Bool updateGeometry,
359
+ VixDiskLibProgressFunc progressFunc,
360
+ void *progressCallbackData)
361
+ {
362
+ return VIX_OK;
363
+ }
364
+
365
+ VixError
366
+ VixDiskLib_Shrink(VixDiskLibHandle diskHandle,
367
+ VixDiskLibProgressFunc progressFunc,
368
+ void *progressCallbackData)
369
+ {
370
+ return VIX_OK;
371
+ }
372
+
373
+ VixError
374
+ VixDiskLib_Defragment(VixDiskLibHandle diskHandle,
375
+ VixDiskLibProgressFunc progressFunc,
376
+ void *progressCallbackData)
377
+ {
378
+ return VIX_OK;
379
+ }
380
+
381
+ VixError
382
+ VixDiskLib_Rename(const char *srcFileName,
383
+ const char *dstFileName)
384
+ {
385
+ return VIX_OK;
386
+ }
387
+
388
+ VixError
389
+ VixDiskLib_Clone(const VixDiskLibConnection dstConnection,
390
+ const char *dstPath,
391
+ const VixDiskLibConnection srcConnection,
392
+ const char *srcPath,
393
+ const VixDiskLibCreateParams *vixCreateParams,
394
+ VixDiskLibProgressFunc progressFunc,
395
+ void *progressCallbackData,
396
+ Bool overWrite)
397
+ {
398
+ return VIX_OK;
399
+ }
400
+
401
+ char *
402
+ VixDiskLib_GetErrorText(VixError err, const char *locale)
403
+ {
404
+ return NULL;
405
+ }
406
+
407
+ void
408
+ VixDiskLib_FreeErrorText(char* errMsg)
409
+ {
410
+ }
411
+
412
+ VixError
413
+ VixDiskLib_IsAttachPossible(VixDiskLibHandle parent, VixDiskLibHandle child)
414
+ {
415
+ return VIX_OK;
416
+ }
417
+
418
+ VixError
419
+ VixDiskLib_Attach(VixDiskLibHandle parent, VixDiskLibHandle child)
420
+ {
421
+ return VIX_OK;
422
+ }
423
+
424
+ VixError
425
+ VixDiskLib_SpaceNeededForClone(VixDiskLibHandle diskHandle,
426
+ VixDiskLibDiskType cloneDiskType,
427
+ uint64* spaceNeeded)
428
+ {
429
+ return VIX_OK;
430
+ }
431
+
432
+ VixError
433
+ VixDiskLib_CheckRepair(const VixDiskLibConnection connection,
434
+ const char *filename,
435
+ Bool repair)
436
+ {
437
+ return VIX_OK;
438
+ }
439
+
440
+ VixError
441
+ VixDiskLib_GetConnectParams(const VixDiskLibConnection connection,
442
+ VixDiskLibConnectParams** connectParams)
443
+ {
444
+ return VIX_OK;
445
+ }
446
+
447
+ void
448
+ VixDiskLib_FreeConnectParams(VixDiskLibConnectParams* connectParams)
449
+ {
450
+ }
451
+
452
+ VixDiskLibConnectParams *
453
+ VixDiskLib_AllocateConnectParams()
454
+ {
455
+ return NULL;
456
+ }
@@ -0,0 +1,38 @@
1
+ describe FFI::VixDiskLib::API do
2
+ let(:log) { lambda { |_string, _pointer| } }
3
+ let(:lib_dir) { nil }
4
+ let(:version) { ENV.fetch("VDDK_VERSION", "6.7.0") }
5
+
6
+ it "VERSION" do
7
+ expect(described_class::VERSION).to eq version
8
+ end
9
+
10
+ it "VERSION_MAJOR" do
11
+ expect(described_class::VERSION_MAJOR).to eq Gem::Version.new(version).segments[0]
12
+ end
13
+
14
+ it "VERSION_MINOR" do
15
+ expect(described_class::VERSION_MINOR).to eq Gem::Version.new(version).segments[1]
16
+ end
17
+
18
+ describe ".init" do
19
+ it "initializes successfully" do
20
+ err = described_class.init(described_class::VERSION_MAJOR, described_class::VERSION_MINOR, log, log, log, lib_dir)
21
+ expect(err).to eq(described_class::VixErrorType[:VIX_OK])
22
+ end
23
+ end
24
+
25
+ describe "ConnectParams" do
26
+ context "with #{described_class::VERSION}" do
27
+ if Gem::Version.new(described_class::VERSION) >= Gem::Version.new("6.5.0")
28
+ it "has vimApiVer" do
29
+ expect(described_class::ConnectParams.members).to include(:vimApiVer)
30
+ end
31
+ else
32
+ it "doesn't have vimApiVer" do
33
+ expect(described_class::ConnectParams.members).to_not include(:vimApiVer)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ require 'ffi-vix_disk_lib/api_wrapper'
2
+
3
+ describe FFI::VixDiskLib::ApiWrapper do
4
+ context "connect" do
5
+ before do
6
+ described_class.init
7
+ end
8
+
9
+ it "returns a connection" do
10
+ connect_params = {}
11
+ connection = described_class.connect(connect_params)
12
+ expect(connection).not_to be_nil
13
+ end
14
+ end
15
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,17 +1,6 @@
1
- require 'minitest'
2
- require 'minitest/autorun'
1
+ ENV["LD_LIBRARY_PATH"] ||= File.expand_path("ext", __dir__)
3
2
 
4
- begin
5
- require 'ffi-vix_disk_lib'
6
- rescue LoadError
7
- STDERR.puts <<-EOMSG
3
+ require 'ffi-vix_disk_lib'
8
4
 
9
- The VMware VDDK must be installed in order to run specs.
10
-
11
- The VMware VDDK is not redistributable, and not available on MacOSX.
12
- See https://www.vmware.com/support/developer/vddk/ for more information.
13
-
14
- EOMSG
15
-
16
- exit 1
5
+ RSpec.configure do |config|
17
6
  end
metadata CHANGED
@@ -1,31 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-vix_disk_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry Keselman
8
8
  - Rich Oliveri
9
9
  - Jason Frey
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-04-06 00:00:00.000000000 Z
13
+ date: 2021-02-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '1.3'
21
+ version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: manageiq-style
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
27
34
  - !ruby/object:Gem::Version
28
- version: '1.3'
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
29
43
  - !ruby/object:Gem::Dependency
30
44
  name: rake
31
45
  requirement: !ruby/object:Gem::Requirement
@@ -41,7 +55,7 @@ dependencies:
41
55
  - !ruby/object:Gem::Version
42
56
  version: '0'
43
57
  - !ruby/object:Gem::Dependency
44
- name: minitest
58
+ name: rspec
45
59
  requirement: !ruby/object:Gem::Requirement
46
60
  requirements:
47
61
  - - ">="
@@ -91,13 +105,17 @@ files:
91
105
  - lib/ffi-vix_disk_lib/safe_create_params.rb
92
106
  - lib/ffi-vix_disk_lib/struct.rb
93
107
  - lib/ffi-vix_disk_lib/version.rb
108
+ - spec/ext/.gitignore
109
+ - spec/ext/Makefile
110
+ - spec/ext/vixDiskLib.c
111
+ - spec/ffi-vix_disk_lib/api_spec.rb
112
+ - spec/ffi-vix_disk_lib/api_wrapper_spec.rb
94
113
  - spec/spec_helper.rb
95
- - spec/version_spec.rb
96
114
  homepage: http://github.com/ManageIQ/ffi-vix_disk_lib
97
115
  licenses:
98
- - APL 2.0
116
+ - Apache-2.0
99
117
  metadata: {}
100
- post_install_message:
118
+ post_install_message:
101
119
  rdoc_options: []
102
120
  require_paths:
103
121
  - lib
@@ -112,11 +130,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
130
  - !ruby/object:Gem::Version
113
131
  version: '0'
114
132
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.4.5.1
117
- signing_key:
133
+ rubygems_version: 3.2.5
134
+ signing_key:
118
135
  specification_version: 4
119
136
  summary: Ruby FFI Binding to VMware VixDiskLib.
120
137
  test_files:
138
+ - spec/ext/.gitignore
139
+ - spec/ext/Makefile
140
+ - spec/ext/vixDiskLib.c
141
+ - spec/ffi-vix_disk_lib/api_spec.rb
142
+ - spec/ffi-vix_disk_lib/api_wrapper_spec.rb
121
143
  - spec/spec_helper.rb
122
- - spec/version_spec.rb
data/spec/version_spec.rb DELETED
@@ -1,7 +0,0 @@
1
- require_relative './spec_helper'
2
-
3
- describe FFI::VixDiskLib::VERSION do
4
- it "must be defined" do
5
- FFI::VixDiskLib::VERSION.wont_be_nil
6
- end
7
- end