1 /* 2 * esx_vi_types.h: client for the VMware VI API 2.5 to manage ESX hosts 3 * 4 * Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte@googlemail.com> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library. If not, see 18 * <http://www.gnu.org/licenses/>. 19 * 20 */ 21 22 #pragma once 23 24 #include "virbuffer.h" 25 26 typedef enum _esxVI_Type esxVI_Type; 27 typedef struct _esxVI_Object esxVI_Object; 28 typedef struct _esxVI_ManagedObject esxVI_ManagedObject; 29 30 31 32 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 33 * XSD 34 */ 35 36 typedef enum _esxVI_Boolean esxVI_Boolean; 37 typedef struct _esxVI_AnyType esxVI_AnyType; 38 typedef struct _esxVI_String esxVI_String; 39 typedef struct _esxVI_Byte esxVI_Byte; 40 typedef struct _esxVI_Int esxVI_Int; 41 typedef struct _esxVI_Long esxVI_Long; 42 typedef struct _esxVI_DateTime esxVI_DateTime; 43 44 45 46 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 47 * SOAP 48 */ 49 50 typedef struct _esxVI_Fault esxVI_Fault; 51 52 53 54 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 55 * VI Objects 56 */ 57 58 typedef struct _esxVI_MethodFault esxVI_MethodFault; 59 typedef struct _esxVI_ManagedObjectReference esxVI_ManagedObjectReference; 60 typedef struct _esxVI_Event esxVI_Event; 61 62 #include "esx_vi_types.generated.typedef" 63 64 65 66 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 67 * Type 68 */ 69 70 enum _esxVI_Type { 71 esxVI_Type_Undefined = 0, 72 esxVI_Type_Boolean, 73 esxVI_Type_AnyType, 74 esxVI_Type_String, 75 esxVI_Type_Byte, 76 esxVI_Type_Short, 77 esxVI_Type_Int, 78 esxVI_Type_Long, 79 esxVI_Type_DateTime, 80 esxVI_Type_Fault, 81 esxVI_Type_MethodFault, 82 esxVI_Type_ManagedObjectReference, 83 esxVI_Type_Event, 84 85 #include "esx_vi_types.generated.typeenum" 86 87 esxVI_Type_Other, 88 }; 89 90 const char *esxVI_Type_ToString(esxVI_Type type); 91 esxVI_Type esxVI_Type_FromString(const char *type); 92 93 94 95 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 96 * Object extends List 97 */ 98 99 struct _esxVI_Object { 100 esxVI_Object *_next; /* optional */ 101 esxVI_Type _type; /* required */ 102 }; 103 104 105 106 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 107 * ManagedObject extends Object 108 */ 109 110 struct _esxVI_ManagedObject { 111 esxVI_ManagedObject *_next; /* optional */ 112 esxVI_Type _type; /* required */ 113 esxVI_ManagedObjectReference *_reference; /* required */ 114 }; 115 116 117 118 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 119 * XSD: Boolean 120 */ 121 122 enum _esxVI_Boolean { 123 esxVI_Boolean_Undefined = 0, 124 esxVI_Boolean_True, 125 esxVI_Boolean_False, 126 }; 127 128 int esxVI_Boolean_Serialize(esxVI_Boolean boolean_, const char *element, 129 virBuffer *output); 130 int esxVI_Boolean_Deserialize(xmlNodePtr node, esxVI_Boolean *boolean_); 131 132 133 134 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 135 * XSD: AnyType 136 */ 137 138 struct _esxVI_AnyType { 139 esxVI_AnyType *_unused; /* optional */ 140 esxVI_Type _type; /* = esxVI_Type_AnyType */ /* required */ 141 142 xmlNodePtr node; /* required */ 143 esxVI_Type type; /* required */ 144 char *other; /* required */ 145 char *value; /* required */ 146 union { 147 esxVI_Boolean boolean; /* optional */ 148 char *string; /* optional */ 149 int8_t int8; /* optional */ 150 int16_t int16; /* optional */ 151 int32_t int32; /* optional */ 152 int64_t int64; /* optional */ 153 }; 154 }; 155 156 int esxVI_AnyType_Alloc(esxVI_AnyType **anyType); 157 void esxVI_AnyType_Free(esxVI_AnyType **anyType); 158 const char *esxVI_AnyType_TypeToString(esxVI_AnyType *anyType); 159 int esxVI_AnyType_ExpectType(esxVI_AnyType *anyType, esxVI_Type type); 160 int esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src); 161 int esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType); 162 163 164 165 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 166 * XSD: String 167 */ 168 169 struct _esxVI_String { 170 esxVI_String *_next; /* optional */ 171 esxVI_Type _type; /* required */ 172 173 char *value; /* required */ 174 }; 175 176 int esxVI_String_Alloc(esxVI_String **string); 177 void esxVI_String_Free(esxVI_String **stringList); 178 int esxVI_String_Validate(esxVI_String *string); 179 bool esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value); 180 int esxVI_String_AppendToList(esxVI_String **stringList, esxVI_String *string); 181 int esxVI_String_AppendValueToList(esxVI_String **stringList, 182 const char *value); 183 int esxVI_String_AppendValueListToList(esxVI_String **stringList, 184 const char *valueList); 185 int esxVI_String_DeepCopy(esxVI_String **dest, esxVI_String *src); 186 int esxVI_String_DeepCopyList(esxVI_String **destList, esxVI_String *srcList); 187 int esxVI_String_DeepCopyValue(char **dest, const char *src); 188 int esxVI_String_CastFromAnyType(esxVI_AnyType *anyType, esxVI_String **string); 189 int esxVI_String_CastValueFromAnyType(esxVI_AnyType *anyType, char **string); 190 int esxVI_String_Serialize(esxVI_String *string, const char *element, 191 virBuffer *output); 192 int esxVI_String_SerializeList(esxVI_String *stringList, const char *element, 193 virBuffer *output); 194 int esxVI_String_SerializeValue(const char *value, const char *element, 195 virBuffer *output); 196 int esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string); 197 int esxVI_String_DeserializeList(xmlNodePtr node, esxVI_String **stringList); 198 int esxVI_String_DeserializeValue(xmlNodePtr node, char **value); 199 200 201 202 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 203 * XSD: Byte 204 */ 205 206 struct _esxVI_Byte { 207 esxVI_Byte *_next; /* optional */ 208 esxVI_Type _type; /* required */ 209 210 int8_t value; /* required */ 211 }; 212 213 int esxVI_Byte_Alloc(esxVI_Byte **number); 214 void esxVI_Byte_Free(esxVI_Byte **numberList); 215 int esxVI_Byte_Validate(esxVI_Byte *number); 216 int esxVI_Byte_AppendToList(esxVI_Byte **numberList, esxVI_Byte *number); 217 int esxVI_Byte_DeepCopy(esxVI_Byte **dest, esxVI_Byte *src); 218 int esxVI_Byte_DeepCopyList(esxVI_Byte **destList, esxVI_Byte *srcList); 219 int esxVI_Byte_Serialize(esxVI_Byte *number, const char *element, 220 virBuffer *output); 221 int esxVI_Byte_SerializeList(esxVI_Byte *numberList, const char *element, 222 virBuffer *output); 223 int esxVI_Byte_Deserialize(xmlNodePtr node, esxVI_Byte **number); 224 225 226 227 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 228 * XSD: Int 229 */ 230 231 struct _esxVI_Int { 232 esxVI_Int *_next; /* optional */ 233 esxVI_Type _type; /* required */ 234 235 int32_t value; /* required */ 236 }; 237 238 int esxVI_Int_Alloc(esxVI_Int **number); 239 void esxVI_Int_Free(esxVI_Int **numberList); 240 int esxVI_Int_Validate(esxVI_Int *number); 241 int esxVI_Int_AppendToList(esxVI_Int **numberList, esxVI_Int *number); 242 int esxVI_Int_DeepCopy(esxVI_Int **dest, esxVI_Int *src); 243 int esxVI_Int_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Int **number); 244 int esxVI_Int_Serialize(esxVI_Int *number, const char *element, 245 virBuffer *output); 246 int esxVI_Int_SerializeList(esxVI_Int *numberList, const char *element, 247 virBuffer *output); 248 int esxVI_Int_Deserialize(xmlNodePtr node, esxVI_Int **number); 249 250 251 252 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 253 * XSD: Long 254 */ 255 256 struct _esxVI_Long { 257 esxVI_Long *_next; /* optional */ 258 esxVI_Type _type; /* required */ 259 260 int64_t value; /* required */ 261 }; 262 263 int esxVI_Long_Alloc(esxVI_Long **number); 264 void esxVI_Long_Free(esxVI_Long **numberList); 265 int esxVI_Long_Validate(esxVI_Long *number); 266 int esxVI_Long_AppendToList(esxVI_Long **numberList, esxVI_Long *number); 267 int esxVI_Long_DeepCopy(esxVI_Long **dest, esxVI_Long *src); 268 int esxVI_Long_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Long **number); 269 int esxVI_Long_Serialize(esxVI_Long *number, const char *element, 270 virBuffer *output); 271 int esxVI_Long_SerializeList(esxVI_Long *numberList, const char *element, 272 virBuffer *output); 273 int esxVI_Long_Deserialize(xmlNodePtr node, esxVI_Long **number); 274 275 276 277 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 278 * XSD: DateTime 279 */ 280 281 struct _esxVI_DateTime { 282 esxVI_DateTime *_unused; /* optional */ 283 esxVI_Type _type; /* required */ 284 285 char *value; /* required */ 286 }; 287 288 int esxVI_DateTime_Alloc(esxVI_DateTime **dateTime); 289 void esxVI_DateTime_Free(esxVI_DateTime **dateTime); 290 int esxVI_DateTime_Validate(esxVI_DateTime *dateTime); 291 int esxVI_DateTime_DeepCopy(esxVI_DateTime **dest, esxVI_DateTime *src); 292 int esxVI_DateTime_Serialize(esxVI_DateTime *dateTime, const char *element, 293 virBuffer *output); 294 int esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime); 295 int esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime, 296 long long *secondsSinceEpoch); 297 298 299 300 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 301 * SOAP: Fault 302 */ 303 304 struct _esxVI_Fault { 305 esxVI_Fault *_unused; /* optional */ 306 esxVI_Type _type; /* required */ 307 308 char *faultcode; /* required */ 309 char *faultstring; /* required */ 310 }; 311 312 int esxVI_Fault_Alloc(esxVI_Fault **fault); 313 void esxVI_Fault_Free(esxVI_Fault **fault); 314 int esxVI_Fault_Validate(esxVI_Fault *fault); 315 int esxVI_Fault_Deserialize(xmlNodePtr node, esxVI_Fault **fault); 316 317 318 319 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 320 * VI Object: MethodFault 321 */ 322 323 /* 324 * FIXME: This is just a minimal implementation of the MethodFault type. 325 * A complete implementation would require to implement dozens of 326 * extending types too. 327 */ 328 struct _esxVI_MethodFault { 329 esxVI_MethodFault *_unused; /* optional */ 330 esxVI_Type _type; /* required */ 331 332 char *_actualType; /* required */ 333 }; 334 335 int esxVI_MethodFault_Alloc(esxVI_MethodFault **methodfault); 336 void esxVI_MethodFault_Free(esxVI_MethodFault **methodFault); 337 int esxVI_MethodFault_Deserialize(xmlNodePtr node, 338 esxVI_MethodFault **methodFault); 339 340 341 342 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 343 * VI Object: ManagedObjectReference 344 */ 345 346 struct _esxVI_ManagedObjectReference { 347 esxVI_ManagedObjectReference *_next; /* optional */ 348 esxVI_Type _type; /* required */ 349 350 char *type; /* required */ 351 char *value; /* required */ 352 }; 353 354 int esxVI_ManagedObjectReference_Alloc 355 (esxVI_ManagedObjectReference **managedObjectReference); 356 void esxVI_ManagedObjectReference_Free 357 (esxVI_ManagedObjectReference **managedObjectReferenceList); 358 int esxVI_ManagedObjectReference_DeepCopy(esxVI_ManagedObjectReference **dest, 359 esxVI_ManagedObjectReference *src); 360 int esxVI_ManagedObjectReference_AppendToList 361 (esxVI_ManagedObjectReference **managedObjectReferenceList, 362 esxVI_ManagedObjectReference *managedObjectReference); 363 int esxVI_ManagedObjectReference_CastFromAnyType 364 (esxVI_AnyType *anyType, 365 esxVI_ManagedObjectReference **managedObjectReference); 366 int esxVI_ManagedObjectReference_CastListFromAnyType 367 (esxVI_AnyType *anyType, 368 esxVI_ManagedObjectReference **managedObjectReferenceList); 369 int esxVI_ManagedObjectReference_Serialize 370 (esxVI_ManagedObjectReference *managedObjectReference, 371 const char *element, virBuffer *output); 372 int esxVI_ManagedObjectReference_SerializeList 373 (esxVI_ManagedObjectReference *managedObjectReference, 374 const char *element, virBuffer *output); 375 int esxVI_ManagedObjectReference_Deserialize 376 (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference); 377 378 379 380 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 381 * VI Type: Event 382 */ 383 384 struct _esxVI_Event { 385 esxVI_Event *_next; /* optional */ 386 esxVI_Type _type; /* required */ 387 char *_actualType; /* required */ 388 389 esxVI_Int *key; /* required */ 390 esxVI_Int *chainId; /* required */ 391 esxVI_DateTime *createdTime; /* required */ 392 char *userName; /* required */ 393 /* FIXME: datacenter is currently ignored */ 394 /* FIXME: computeResource is currently ignored */ 395 /* FIXME: host is currently ignored */ 396 esxVI_VmEventArgument *vm; /* optional */ 397 char *fullFormattedMessage; /* optional */ 398 }; 399 400 int esxVI_Event_Alloc(esxVI_Event **item); 401 void esxVI_Event_Free(esxVI_Event **item); 402 int esxVI_Event_Validate(esxVI_Event *item); 403 int esxVI_Event_AppendToList(esxVI_Event **list, esxVI_Event *item); 404 int esxVI_Event_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Event **item); 405 int esxVI_Event_CastListFromAnyType(esxVI_AnyType *anyType, esxVI_Event **list); 406 int esxVI_Event_Deserialize(xmlNodePtr node, esxVI_Event **item); 407 int esxVI_Event_DeserializeList(xmlNodePtr node, esxVI_Event **list); 408 409 410 411 #include "esx_vi_types.generated.h" 412 413 414 415 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 416 * VI Enum: VirtualMachinePowerState (Additions) 417 */ 418 419 int esxVI_VirtualMachinePowerState_ConvertToLibvirt 420 (esxVI_VirtualMachinePowerState powerState); 421