ovirt-engine-sdk 4.0.1 → 4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.adoc +684 -0
- data/README.adoc +729 -32
- data/ext/ovirtsdk4c/extconf.rb +31 -5
- data/ext/ovirtsdk4c/ov_error.c +9 -2
- data/ext/ovirtsdk4c/ov_error.h +3 -1
- data/ext/ovirtsdk4c/ov_http_client.c +1218 -0
- data/ext/ovirtsdk4c/ov_http_client.h +75 -0
- data/ext/ovirtsdk4c/ov_http_request.c +397 -0
- data/ext/ovirtsdk4c/ov_http_request.h +54 -0
- data/ext/ovirtsdk4c/ov_http_response.c +210 -0
- data/ext/ovirtsdk4c/ov_http_response.h +41 -0
- data/ext/ovirtsdk4c/ov_http_transfer.c +91 -0
- data/ext/ovirtsdk4c/ov_http_transfer.h +47 -0
- data/ext/ovirtsdk4c/ov_module.h +2 -2
- data/ext/ovirtsdk4c/ov_string.c +43 -0
- data/ext/ovirtsdk4c/ov_string.h +25 -0
- data/ext/ovirtsdk4c/ov_xml_reader.c +115 -99
- data/ext/ovirtsdk4c/ov_xml_reader.h +20 -3
- data/ext/ovirtsdk4c/ov_xml_writer.c +95 -77
- data/ext/ovirtsdk4c/ov_xml_writer.h +18 -3
- data/ext/ovirtsdk4c/ovirtsdk4c.c +10 -2
- data/lib/ovirtsdk4/connection.rb +695 -0
- data/lib/ovirtsdk4/errors.rb +70 -0
- data/lib/ovirtsdk4/probe.rb +324 -0
- data/lib/ovirtsdk4/reader.rb +74 -40
- data/lib/ovirtsdk4/readers.rb +3325 -976
- data/lib/ovirtsdk4/service.rb +439 -48
- data/lib/ovirtsdk4/services.rb +29365 -21180
- data/lib/ovirtsdk4/type.rb +20 -6
- data/lib/ovirtsdk4/types.rb +15048 -3198
- data/lib/ovirtsdk4/version.rb +1 -1
- data/lib/ovirtsdk4/writer.rb +108 -13
- data/lib/ovirtsdk4/writers.rb +1373 -294
- data/lib/ovirtsdk4.rb +4 -2
- metadata +88 -36
- data/lib/ovirtsdk4/http.rb +0 -548
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright (c) 2015-
|
2
|
+
Copyright (c) 2015-2017 Red Hat, Inc.
|
3
3
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
you may not use this file except in compliance with the License.
|
@@ -16,7 +16,6 @@ limitations under the License.
|
|
16
16
|
|
17
17
|
#include <ruby.h>
|
18
18
|
|
19
|
-
#include <stdbool.h>
|
20
19
|
#include <libxml/xmlwriter.h>
|
21
20
|
|
22
21
|
#include "ov_module.h"
|
@@ -31,57 +30,76 @@ static ID STRING_ID;
|
|
31
30
|
static ID STRING_IO_ID;
|
32
31
|
static ID WRITE_ID;
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
xmlTextWriterPtr writer;
|
37
|
-
} ov_xml_writer_object;
|
38
|
-
|
39
|
-
static void ov_xml_writer_check_closed(ov_xml_writer_object* object) {
|
40
|
-
if (object->writer == NULL) {
|
33
|
+
static void ov_xml_writer_check_closed(ov_xml_writer_object* ptr) {
|
34
|
+
if (ptr->writer == NULL) {
|
41
35
|
rb_raise(ov_error_class, "The writer is already closed");
|
42
36
|
}
|
43
37
|
}
|
44
38
|
|
45
|
-
static void ov_xml_writer_mark(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
static void ov_xml_writer_mark(void* vptr) {
|
40
|
+
ov_xml_writer_object* ptr;
|
41
|
+
|
42
|
+
ptr = vptr;
|
43
|
+
rb_gc_mark(ptr->io);
|
50
44
|
}
|
51
45
|
|
52
|
-
static void ov_xml_writer_free(
|
46
|
+
static void ov_xml_writer_free(void* vptr) {
|
47
|
+
ov_xml_writer_object* ptr;
|
48
|
+
|
49
|
+
/* Get the pointer: */
|
50
|
+
ptr = vptr;
|
51
|
+
|
53
52
|
/* Free the libxml writer, the buffer is automatically closed: */
|
54
|
-
if (
|
55
|
-
xmlTextWriterPtr tmp =
|
56
|
-
|
53
|
+
if (ptr->writer != NULL) {
|
54
|
+
xmlTextWriterPtr tmp = ptr->writer;
|
55
|
+
ptr->writer = NULL;
|
57
56
|
xmlFreeTextWriter(tmp);
|
58
57
|
}
|
59
58
|
|
60
59
|
/* Free this object: */
|
61
|
-
xfree(
|
60
|
+
xfree(ptr);
|
62
61
|
}
|
63
62
|
|
63
|
+
rb_data_type_t ov_xml_writer_type = {
|
64
|
+
.wrap_struct_name = "OVXMLWRITER",
|
65
|
+
.function = {
|
66
|
+
.dmark = ov_xml_writer_mark,
|
67
|
+
.dfree = ov_xml_writer_free,
|
68
|
+
.dsize = NULL,
|
69
|
+
.reserved = { NULL, NULL }
|
70
|
+
},
|
71
|
+
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
72
|
+
.parent = NULL,
|
73
|
+
.data = NULL,
|
74
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
75
|
+
#endif
|
76
|
+
};
|
77
|
+
|
64
78
|
static VALUE ov_xml_writer_alloc(VALUE klass) {
|
65
|
-
ov_xml_writer_object*
|
79
|
+
ov_xml_writer_object* ptr;
|
66
80
|
|
67
|
-
|
68
|
-
|
69
|
-
|
81
|
+
ptr = ALLOC(ov_xml_writer_object);
|
82
|
+
ptr->io = Qnil;
|
83
|
+
ptr->writer = NULL;
|
84
|
+
return TypedData_Wrap_Struct(klass, &ov_xml_writer_type, ptr);
|
70
85
|
}
|
71
86
|
|
72
87
|
static int ov_xml_writer_callback(void *context, const char *buffer, int length) {
|
73
88
|
VALUE count;
|
74
89
|
VALUE data;
|
75
|
-
ov_xml_writer_object
|
90
|
+
ov_xml_writer_object* ptr;
|
91
|
+
|
92
|
+
/* Get the pointer: */
|
93
|
+
ptr = context;
|
76
94
|
|
77
95
|
/* Do nothing if the writer is already closed: */
|
78
|
-
if (
|
96
|
+
if (ptr->writer == NULL) {
|
79
97
|
return 0;
|
80
98
|
}
|
81
99
|
|
82
100
|
/* Convert the buffer to a Ruby string and write it to the IO object, using the "write" method: */
|
83
101
|
data = rb_str_new(buffer, length);
|
84
|
-
count = rb_funcall(
|
102
|
+
count = rb_funcall(ptr->io, WRITE_ID, 1, data);
|
85
103
|
|
86
104
|
return NUM2INT(count);
|
87
105
|
}
|
@@ -99,11 +117,11 @@ static VALUE ov_xml_writer_initialize(int argc, VALUE* argv, VALUE self) {
|
|
99
117
|
VALUE indent;
|
100
118
|
VALUE io;
|
101
119
|
VALUE io_class;
|
102
|
-
ov_xml_writer_object*
|
103
|
-
xmlOutputBufferPtr buffer
|
120
|
+
ov_xml_writer_object* ptr;
|
121
|
+
xmlOutputBufferPtr buffer;
|
104
122
|
|
105
123
|
/* Get the pointer to the object: */
|
106
|
-
|
124
|
+
ov_xml_writer_ptr(self, ptr);
|
107
125
|
|
108
126
|
/* Get the values of the parameters: */
|
109
127
|
if (argc > 2) {
|
@@ -115,12 +133,12 @@ static VALUE ov_xml_writer_initialize(int argc, VALUE* argv, VALUE self) {
|
|
115
133
|
/* The first parameter can be an IO object or nil. If it is nil then we need to create a IO object where we can
|
116
134
|
write the generated XML. */
|
117
135
|
if (NIL_P(io)) {
|
118
|
-
|
136
|
+
ptr->io = ov_xml_writer_create_string_io();
|
119
137
|
}
|
120
138
|
else {
|
121
139
|
io_class = rb_class_of(io);
|
122
140
|
if (io_class == rb_cIO) {
|
123
|
-
|
141
|
+
ptr->io = io;
|
124
142
|
}
|
125
143
|
else {
|
126
144
|
rb_raise(
|
@@ -132,50 +150,50 @@ static VALUE ov_xml_writer_initialize(int argc, VALUE* argv, VALUE self) {
|
|
132
150
|
}
|
133
151
|
|
134
152
|
/* Create the libxml buffer that writes to the IO object: */
|
135
|
-
buffer = xmlOutputBufferCreateIO(ov_xml_writer_callback, NULL,
|
153
|
+
buffer = xmlOutputBufferCreateIO(ov_xml_writer_callback, NULL, ptr, NULL);
|
136
154
|
if (buffer == NULL) {
|
137
155
|
rb_raise(ov_error_class, "Can't create XML buffer");
|
138
156
|
}
|
139
157
|
|
140
158
|
/* Create the libxml writer: */
|
141
|
-
|
142
|
-
if (
|
159
|
+
ptr->writer = xmlNewTextWriter(buffer);
|
160
|
+
if (ptr->writer == NULL) {
|
143
161
|
xmlOutputBufferClose(buffer);
|
144
162
|
rb_raise(ov_error_class, "Can't create XML writer");
|
145
163
|
}
|
146
164
|
|
147
165
|
/* Enable indentation: */
|
148
166
|
if (RTEST(indent)) {
|
149
|
-
xmlTextWriterSetIndent(
|
150
|
-
xmlTextWriterSetIndentString(
|
167
|
+
xmlTextWriterSetIndent(ptr->writer, 1);
|
168
|
+
xmlTextWriterSetIndentString(ptr->writer, BAD_CAST " ");
|
151
169
|
}
|
152
170
|
|
153
171
|
return self;
|
154
172
|
}
|
155
173
|
|
156
174
|
static VALUE ov_xml_writer_string(VALUE self) {
|
157
|
-
int rc
|
158
|
-
ov_xml_writer_object*
|
175
|
+
int rc;
|
176
|
+
ov_xml_writer_object* ptr;
|
159
177
|
|
160
|
-
|
161
|
-
ov_xml_writer_check_closed(
|
162
|
-
rc = xmlTextWriterFlush(
|
178
|
+
ov_xml_writer_ptr(self, ptr);
|
179
|
+
ov_xml_writer_check_closed(ptr);
|
180
|
+
rc = xmlTextWriterFlush(ptr->writer);
|
163
181
|
if (rc < 0) {
|
164
182
|
rb_raise(ov_error_class, "Can't flush XML writer");
|
165
183
|
}
|
166
|
-
return rb_funcall(
|
184
|
+
return rb_funcall(ptr->io, STRING_ID, 0, NULL);
|
167
185
|
}
|
168
186
|
|
169
187
|
static VALUE ov_xml_writer_write_start(VALUE self, VALUE name) {
|
170
|
-
char* c_name
|
171
|
-
int rc
|
172
|
-
ov_xml_writer_object*
|
188
|
+
char* c_name;
|
189
|
+
int rc;
|
190
|
+
ov_xml_writer_object* ptr;
|
173
191
|
|
174
|
-
|
175
|
-
ov_xml_writer_check_closed(
|
192
|
+
ov_xml_writer_ptr(self, ptr);
|
193
|
+
ov_xml_writer_check_closed(ptr);
|
176
194
|
Check_Type(name, T_STRING);
|
177
195
|
c_name = StringValueCStr(name);
|
178
|
-
rc = xmlTextWriterStartElement(
|
196
|
+
rc = xmlTextWriterStartElement(ptr->writer, BAD_CAST c_name);
|
179
197
|
if (rc < 0) {
|
180
198
|
rb_raise(ov_error_class, "Can't start XML element");
|
181
199
|
}
|
@@ -183,12 +201,12 @@ static VALUE ov_xml_writer_write_start(VALUE self, VALUE name) {
|
|
183
201
|
}
|
184
202
|
|
185
203
|
static VALUE ov_xml_writer_write_end(VALUE self) {
|
186
|
-
int rc
|
187
|
-
ov_xml_writer_object*
|
204
|
+
int rc;
|
205
|
+
ov_xml_writer_object* ptr;
|
188
206
|
|
189
|
-
|
190
|
-
ov_xml_writer_check_closed(
|
191
|
-
rc = xmlTextWriterEndElement(
|
207
|
+
ov_xml_writer_ptr(self, ptr);
|
208
|
+
ov_xml_writer_check_closed(ptr);
|
209
|
+
rc = xmlTextWriterEndElement(ptr->writer);
|
192
210
|
if (rc < 0) {
|
193
211
|
rb_raise(ov_error_class, "Can't end XML element");
|
194
212
|
}
|
@@ -196,18 +214,18 @@ static VALUE ov_xml_writer_write_end(VALUE self) {
|
|
196
214
|
}
|
197
215
|
|
198
216
|
static VALUE ov_xml_writer_write_attribute(VALUE self, VALUE name, VALUE value) {
|
199
|
-
char* c_name
|
200
|
-
char* c_value
|
201
|
-
int rc
|
202
|
-
ov_xml_writer_object*
|
217
|
+
char* c_name;
|
218
|
+
char* c_value;
|
219
|
+
int rc;
|
220
|
+
ov_xml_writer_object* ptr;
|
203
221
|
|
204
|
-
|
205
|
-
ov_xml_writer_check_closed(
|
222
|
+
ov_xml_writer_ptr(self, ptr);
|
223
|
+
ov_xml_writer_check_closed(ptr);
|
206
224
|
Check_Type(name, T_STRING);
|
207
225
|
Check_Type(value, T_STRING);
|
208
226
|
c_name = StringValueCStr(name);
|
209
227
|
c_value = StringValueCStr(value);
|
210
|
-
rc = xmlTextWriterWriteAttribute(
|
228
|
+
rc = xmlTextWriterWriteAttribute(ptr->writer, BAD_CAST c_name, BAD_CAST c_value);
|
211
229
|
if (rc < 0) {
|
212
230
|
rb_raise(ov_error_class, "Can't write attribute with name \"%s\" and value \"%s\"", c_name, c_value);
|
213
231
|
}
|
@@ -215,18 +233,18 @@ static VALUE ov_xml_writer_write_attribute(VALUE self, VALUE name, VALUE value)
|
|
215
233
|
}
|
216
234
|
|
217
235
|
static VALUE ov_xml_writer_write_element(VALUE self, VALUE name, VALUE value) {
|
218
|
-
char* c_name
|
219
|
-
char* c_value
|
220
|
-
int rc
|
221
|
-
ov_xml_writer_object*
|
236
|
+
char* c_name;
|
237
|
+
char* c_value;
|
238
|
+
int rc;
|
239
|
+
ov_xml_writer_object* ptr;
|
222
240
|
|
223
|
-
|
224
|
-
ov_xml_writer_check_closed(
|
241
|
+
ov_xml_writer_ptr(self, ptr);
|
242
|
+
ov_xml_writer_check_closed(ptr);
|
225
243
|
Check_Type(name, T_STRING);
|
226
244
|
Check_Type(value, T_STRING);
|
227
245
|
c_name = StringValueCStr(name);
|
228
246
|
c_value = StringValueCStr(value);
|
229
|
-
rc = xmlTextWriterWriteElement(
|
247
|
+
rc = xmlTextWriterWriteElement(ptr->writer, BAD_CAST c_name, BAD_CAST c_value);
|
230
248
|
if (rc < 0) {
|
231
249
|
rb_raise(ov_error_class, "Can't write element with name \"%s\" and value \"%s\"", c_name, c_value);
|
232
250
|
}
|
@@ -234,12 +252,12 @@ static VALUE ov_xml_writer_write_element(VALUE self, VALUE name, VALUE value) {
|
|
234
252
|
}
|
235
253
|
|
236
254
|
static VALUE ov_xml_writer_flush(VALUE self) {
|
237
|
-
|
238
|
-
|
255
|
+
int rc;
|
256
|
+
ov_xml_writer_object* ptr;
|
239
257
|
|
240
|
-
|
241
|
-
ov_xml_writer_check_closed(
|
242
|
-
rc = xmlTextWriterFlush(
|
258
|
+
ov_xml_writer_ptr(self, ptr);
|
259
|
+
ov_xml_writer_check_closed(ptr);
|
260
|
+
rc = xmlTextWriterFlush(ptr->writer);
|
243
261
|
if (rc < 0) {
|
244
262
|
rb_raise(ov_error_class, "Can't flush XML writer");
|
245
263
|
}
|
@@ -247,12 +265,12 @@ static VALUE ov_xml_writer_flush(VALUE self) {
|
|
247
265
|
}
|
248
266
|
|
249
267
|
static VALUE ov_xml_writer_close(VALUE self) {
|
250
|
-
ov_xml_writer_object*
|
268
|
+
ov_xml_writer_object* ptr;
|
251
269
|
|
252
|
-
|
253
|
-
ov_xml_writer_check_closed(
|
254
|
-
xmlFreeTextWriter(
|
255
|
-
|
270
|
+
ov_xml_writer_ptr(self, ptr);
|
271
|
+
ov_xml_writer_check_closed(ptr);
|
272
|
+
xmlFreeTextWriter(ptr->writer);
|
273
|
+
ptr->writer = NULL;
|
256
274
|
return Qnil;
|
257
275
|
}
|
258
276
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright (c) 2015-
|
2
|
+
Copyright (c) 2015-2017 Red Hat, Inc.
|
3
3
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
you may not use this file except in compliance with the License.
|
@@ -17,10 +17,25 @@ limitations under the License.
|
|
17
17
|
#ifndef __OV_XML_WRITER_H__
|
18
18
|
#define __OV_XML_WRITER_H__
|
19
19
|
|
20
|
-
|
20
|
+
#include <ruby.h>
|
21
|
+
|
22
|
+
#include <libxml/xmlwriter.h>
|
23
|
+
|
24
|
+
/* Data type and class: */
|
25
|
+
extern rb_data_type_t ov_xml_writer_type;
|
21
26
|
extern VALUE ov_xml_writer_class;
|
22
27
|
|
23
|
-
|
28
|
+
/* Content: */
|
29
|
+
typedef struct {
|
30
|
+
VALUE io;
|
31
|
+
xmlTextWriterPtr writer;
|
32
|
+
} ov_xml_writer_object;
|
33
|
+
|
34
|
+
/* Macro to get the pointer: */
|
35
|
+
#define ov_xml_writer_ptr(object, ptr) \
|
36
|
+
TypedData_Get_Struct((object), ov_xml_writer_object, &ov_xml_writer_type, (ptr))
|
37
|
+
|
38
|
+
/* Initialization function: */
|
24
39
|
extern void ov_xml_writer_define(void);
|
25
40
|
|
26
41
|
#endif
|
data/ext/ovirtsdk4c/ovirtsdk4c.c
CHANGED
@@ -18,15 +18,23 @@ limitations under the License.
|
|
18
18
|
|
19
19
|
#include "ov_module.h"
|
20
20
|
#include "ov_error.h"
|
21
|
+
#include "ov_http_client.h"
|
22
|
+
#include "ov_http_request.h"
|
23
|
+
#include "ov_http_response.h"
|
24
|
+
#include "ov_http_transfer.h"
|
21
25
|
#include "ov_xml_reader.h"
|
22
26
|
#include "ov_xml_writer.h"
|
23
27
|
|
24
28
|
void Init_ovirtsdk4c(void) {
|
25
|
-
|
29
|
+
/* Define the module: */
|
26
30
|
ov_module_define();
|
27
31
|
|
28
|
-
|
32
|
+
/* Define the classes: */
|
29
33
|
ov_error_define();
|
34
|
+
ov_http_client_define();
|
35
|
+
ov_http_request_define();
|
36
|
+
ov_http_response_define();
|
37
|
+
ov_http_transfer_define();
|
30
38
|
ov_xml_reader_define();
|
31
39
|
ov_xml_writer_define();
|
32
40
|
}
|