esx_vi_methods.c 28.4 KB
Newer Older
1 2 3 4

/*
 * esx_vi_methods.c: client for the VMware VI API 2.5 to manage ESX hosts
 *
5
 * Copyright (C) 2010 Red Hat, Inc.
6
 * Copyright (C) 2009-2010 Matthias Bolte <matthias.bolte@googlemail.com>
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 */

#include <config.h>

#include "buf.h"
#include "memory.h"
#include "logging.h"
#include "uuid.h"
#include "virterror_internal.h"
#include "esx_vi_methods.h"
#include "esx_util.h"

#define VIR_FROM_THIS VIR_FROM_ESX

36
#define ESX_VI_ERROR(code, ...)                                               \
37
    virReportErrorHelper(NULL, VIR_FROM_ESX, code, __FILE__,  __FUNCTION__,   \
38
                         __LINE__, __VA_ARGS__)
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

#define ESX_VI__SOAP__REQUEST_HEADER                                          \
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"                            \
    "<soapenv:Envelope "                                                      \
      "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "          \
      "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" "          \
      "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "              \
      "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"                       \
    "<soapenv:Body>"

#define ESX_VI__SOAP__REQUEST_FOOTER                                          \
    "</soapenv:Body>"                                                         \
    "</soapenv:Envelope>"



55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
#define ESX_VI__METHOD(_name, _parameters, _occurrence, _prolog, _validate,   \
                       _serialize, _deserialize)                              \
    int                                                                       \
    esxVI_##_name _parameters                                                 \
    {                                                                         \
        int result = 0;                                                       \
        const char* method_name = #_name;                                     \
        virBuffer buffer = VIR_BUFFER_INITIALIZER;                            \
        char *request = NULL;                                                 \
        esxVI_Response *response = NULL;                                      \
                                                                              \
        _prolog                                                               \
                                                                              \
        _validate                                                             \
                                                                              \
        virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);               \
        virBufferAddLit(&buffer, "<"#_name" xmlns=\"urn:vim25\">");           \
                                                                              \
        _serialize                                                            \
                                                                              \
        virBufferAddLit(&buffer, "</"#_name">");                              \
        virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_FOOTER);               \
                                                                              \
        if (virBufferError(&buffer)) {                                        \
            virReportOOMError();                                              \
            goto failure;                                                     \
        }                                                                     \
                                                                              \
        request = virBufferContentAndReset(&buffer);                          \
                                                                              \
        if (esxVI_Context_Execute(ctx, #_name, request, &response,            \
                                  esxVI_Occurrence_##_occurrence) < 0) {      \
            goto failure;                                                     \
        }                                                                     \
                                                                              \
        if (response->node != NULL) {                                         \
            _deserialize                                                      \
        }                                                                     \
                                                                              \
      cleanup:                                                                \
        VIR_FREE(request);                                                    \
        esxVI_Response_Free(&response);                                       \
                                                                              \
        return result;                                                        \
                                                                              \
      failure:                                                                \
        virBufferFreeAndReset(&buffer);                                       \
                                                                              \
        result = -1;                                                          \
                                                                              \
        goto cleanup;                                                         \
    }



#define ESX_VI__METHOD__CHECK_SERVICE()                                       \
    if (ctx->service == NULL) {                                               \
        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid call");                 \
        return -1;                                                            \
    }



#define ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(_name)                        \
    if (_name == NULL || *_name != NULL) {                                    \
        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");             \
        return -1;                                                            \
    }



/*
 * A required parameter must be != 0 (NULL for pointers, "undefined" == 0 for
 * enumeration values).
 *
 * To be used as part of ESX_VI__METHOD.
 */
#define ESX_VI__METHOD__PARAMETER__REQUIRE(_name)                             \
    if (_name == 0) {                                                         \
        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,                                  \
                     "Required parameter '%s' is missing for call to %s",     \
                     #_name, method_name);                                    \
        return -1;                                                            \
    }



#define ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(_name)                        \
    if (_name == 0) {                                                         \
        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,                                  \
                     "Required parameter '_this' is missing for call to %s",  \
                     method_name);                                            \
        return -1;                                                            \
    }



#define ESX_VI__METHOD__PARAMETER__SERIALIZE(_type, _name)                    \
    if (esxVI_##_type##_Serialize(_name, #_name, &buffer) < 0) {              \
        goto failure;                                                         \
    }



#define ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(_type, _name)               \
    if (esxVI_##_type##_SerializeList(_name, #_name, &buffer) < 0) {          \
        goto failure;                                                         \
    }



#define ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(_type, _name)              \
    if (esxVI_##_type##_SerializeValue(_name, #_name, &buffer) < 0) {         \
        goto failure;                                                         \
    }



#define ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(_type, _name)               \
    if (esxVI_##_type##_Serialize(_name, "_this", &buffer) < 0) {             \
        goto failure;                                                         \
    }



180 181 182 183 184
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * VI Methods
 */

int
185
esxVI_RetrieveServiceContent(esxVI_Context *ctx,
186 187 188
                             esxVI_ServiceContent **serviceContent)
{
    int result = 0;
189 190 191 192 193 194 195 196 197 198
    const char *request = ESX_VI__SOAP__REQUEST_HEADER
                            "<RetrieveServiceContent xmlns=\"urn:vim25\">"
                              "<_this xmlns=\"urn:vim25\" "
                                     "xsi:type=\"ManagedObjectReference\" "
                                     "type=\"ServiceInstance\">"
                                "ServiceInstance"
                              "</_this>"
                            "</RetrieveServiceContent>"
                          ESX_VI__SOAP__REQUEST_FOOTER;
    esxVI_Response *response = NULL;
199 200

    if (serviceContent == NULL || *serviceContent != NULL) {
201
        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
202 203 204
        return -1;
    }

205
    if (esxVI_Context_Execute(ctx, "RetrieveServiceContent", request,
206
                              &response, esxVI_Occurrence_RequiredItem) < 0 ||
207
        esxVI_ServiceContent_Deserialize(response->node, serviceContent) < 0) {
208 209 210 211
        goto failure;
    }

  cleanup:
212
    esxVI_Response_Free(&response);
213 214 215 216 217 218 219 220 221 222 223

    return result;

  failure:
    result = -1;

    goto cleanup;
}



224 225 226 227 228 229
/* esxVI_Login */
ESX_VI__METHOD(Login,
               (esxVI_Context *ctx,
                const char *userName, const char *password,
                esxVI_UserSession **userSession),
               RequiredItem,
230
{
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(userSession)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
    ESX_VI__METHOD__PARAMETER__REQUIRE(userName)
    ESX_VI__METHOD__PARAMETER__REQUIRE(password)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->sessionManager)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, userName)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, password)
},
{
    if (esxVI_UserSession_Deserialize(response->node, userSession) < 0) {
247 248
        goto failure;
    }
249
})
250 251 252



253 254 255 256 257 258 259 260 261 262 263 264 265 266
/* esxVI_Logout */
ESX_VI__METHOD(Logout, (esxVI_Context *ctx), None,
{
    ESX_VI__METHOD__CHECK_SERVICE()
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->sessionManager)
},
{
})
267 268 269



270 271 272 273 274
/* esxVI_SessionIsActive */
ESX_VI__METHOD(SessionIsActive,
               (esxVI_Context *ctx, const char *sessionID,
                const char *userName, esxVI_Boolean *active),
               RequiredItem,
275
{
276
    ESX_VI__METHOD__CHECK_SERVICE()
277

278 279
    if (active == NULL) {
        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "Invalid argument");
280 281
        return -1;
    }
282 283 284 285 286 287 288 289 290 291 292 293 294 295
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->sessionManager)
    ESX_VI__METHOD__PARAMETER__REQUIRE(sessionID)
    ESX_VI__METHOD__PARAMETER__REQUIRE(userName)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->sessionManager)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, sessionID)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, userName)
},
{
    if (esxVI_Boolean_Deserialize(response->node, active) < 0) {
296 297
        goto failure;
    }
298 299
})

300 301


302 303 304 305 306
/* esxVI_RetrieveProperties */
ESX_VI__METHOD(RetrieveProperties,
               (esxVI_Context *ctx,
                esxVI_PropertyFilterSpec *specSet, /* list */
                esxVI_ObjectContent **objectContentList),
307
               OptionalList,
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
{
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(objectContentList)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
    ESX_VI__METHOD__PARAMETER__REQUIRE(specSet)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->propertyCollector)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(PropertyFilterSpec, specSet)
},
{
    if (esxVI_ObjectContent_DeserializeList(response->node,
                                            objectContentList) < 0) {
324 325
        goto failure;
    }
326 327
})

328 329


330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
/* esxVI_PowerOnVM_Task */
ESX_VI__METHOD(PowerOnVM_Task,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine,
                esxVI_ManagedObjectReference **task),
               RequiredItem,
{
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
},
{
347
    if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
348 349
        goto failure;
    }
350
})
351 352 353



354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
/* esxVI_PowerOffVM_Task */
ESX_VI__METHOD(PowerOffVM_Task,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine,
                esxVI_ManagedObjectReference **task),
               RequiredItem,
{
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
},
{
371
    if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
372 373 374
        goto failure;
    }
})
375 376 377



378 379 380 381 382 383
/* esxVI_SuspendVM_Task */
ESX_VI__METHOD(SuspendVM_Task,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine,
                esxVI_ManagedObjectReference **task),
               RequiredItem,
384
{
385 386 387 388 389 390 391 392 393 394
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
},
{
395
    if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
396
        goto failure;
397
    }
398
})
399 400 401



402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
/* esxVI_MigrateVM_Task */
ESX_VI__METHOD(MigrateVM_Task,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine,
                esxVI_ManagedObjectReference *pool,
                esxVI_ManagedObjectReference *host,
                esxVI_VirtualMachineMovePriority priority,
                esxVI_VirtualMachinePowerState state,
                esxVI_ManagedObjectReference **task),
               RequiredItem,
{
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
    ESX_VI__METHOD__PARAMETER__REQUIRE(priority)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachineMovePriority, priority)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachinePowerState, state)
},
{
428
    if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
429 430
        goto failure;
    }
431
})
432 433


434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454

/* esxVI_ReconfigVM_Task */
ESX_VI__METHOD(ReconfigVM_Task,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine,
                esxVI_VirtualMachineConfigSpec *spec,
                esxVI_ManagedObjectReference **task),
               RequiredItem,
{
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
    ESX_VI__METHOD__PARAMETER__REQUIRE(spec)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachineConfigSpec, spec)
},
{
455
    if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
456 457
        goto failure;
    }
458 459
})

460 461


462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
/* esxVI_RegisterVM_Task */
ESX_VI__METHOD(RegisterVM_Task,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *folder,
                const char *path, const char *name,
                esxVI_Boolean asTemplate,
                esxVI_ManagedObjectReference *pool,
                esxVI_ManagedObjectReference *host,
                esxVI_ManagedObjectReference **task),
               RequiredItem,
{
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(task)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(folder)
    ESX_VI__METHOD__PARAMETER__REQUIRE(path)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference, folder)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, path)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, name)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, asTemplate)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
},
{
488
    if (esxVI_ManagedObjectReference_Deserialize(response->node, task) < 0) {
489 490
        goto failure;
    }
491
})
492 493 494



495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
/* esxVI_CancelTask */
ESX_VI__METHOD(CancelTask,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *task),
               None,
{
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(task)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference, task)
},
{
})
510 511 512



513 514 515 516 517
/* esxVI_UnregisterVM */
ESX_VI__METHOD(UnregisterVM,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine),
               None,
518
{
519 520 521 522 523 524 525 526 527 528
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
},
{
})
529 530 531



532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
/* esxVI_AnswerVM */
ESX_VI__METHOD(AnswerVM,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine,
                const char *questionId,
                const char *answerChoice),
               None,
{
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
    ESX_VI__METHOD__PARAMETER__REQUIRE(questionId)
    ESX_VI__METHOD__PARAMETER__REQUIRE(answerChoice)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, questionId)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, answerChoice)
},
{
})
554 555 556



557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
/* esxVI_CreateFilter */
ESX_VI__METHOD(CreateFilter,
               (esxVI_Context *ctx,
                esxVI_PropertyFilterSpec *spec,
                esxVI_Boolean partialUpdates,
                esxVI_ManagedObjectReference **propertyFilter),
               RequiredItem,
{
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(propertyFilter)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
    ESX_VI__METHOD__PARAMETER__REQUIRE(spec)
    ESX_VI__METHOD__PARAMETER__REQUIRE(partialUpdates)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->propertyCollector)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(PropertyFilterSpec, spec)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, partialUpdates)
},
{
580 581
    if (esxVI_ManagedObjectReference_Deserialize(response->node,
                                                 propertyFilter) < 0) {
582 583
        goto failure;
    }
584
})
585 586 587



588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
/* esxVI_DestroyPropertyFilter */
ESX_VI__METHOD(DestroyPropertyFilter,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *propertyFilter),
               None,
{
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(propertyFilter)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              propertyFilter)
},
{
})
604 605 606



607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
/* esxVI_WaitForUpdates */
ESX_VI__METHOD(WaitForUpdates,
               (esxVI_Context *ctx,
                const char *version,
                esxVI_UpdateSet **updateSet),
               RequiredItem,
{
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(updateSet)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->propertyCollector)
    ESX_VI__METHOD__PARAMETER__REQUIRE(version)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->propertyCollector)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, version)
},
{
    if (esxVI_UpdateSet_Deserialize(response->node, updateSet) < 0) {
        goto failure;
    }
})
631 632 633



634 635 636 637 638
/* esxVI_RebootGuest */
ESX_VI__METHOD(RebootGuest,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine),
               None,
639
{
640 641 642 643 644 645 646 647 648 649
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
},
{
})
650 651 652



653 654 655 656 657
/* esxVI_ShutdownGuest */
ESX_VI__METHOD(ShutdownGuest,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *virtualMachine),
               None,
658
{
659 660 661 662 663 664 665 666 667 668
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(virtualMachine)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              virtualMachine)
},
{
})
669 670 671



672 673 674 675 676 677 678 679 680
/* esxVI_ValidateMigration */
ESX_VI__METHOD(ValidateMigration,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *vm, /* list */
                esxVI_VirtualMachinePowerState state,
                esxVI_String *testType, /* list */
                esxVI_ManagedObjectReference *pool,
                esxVI_ManagedObjectReference *host,
                esxVI_Event **eventList),
681
               OptionalList,
682
{
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(eventList)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE(vm)
},
{
    virBufferAddLit(&buffer, "<_this xmlns=\"urn:vim25\" "
                                    "xsi:type=\"ManagedObjectReference\" "
                                    "type=\"ServiceInstance\">"
                               "ServiceInstance"
                             "</_this>");
    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(ManagedObjectReference, vm)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(VirtualMachinePowerState, state)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(String, testType)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, pool)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, host)
},
{
    if (esxVI_Event_DeserializeList(response->node, eventList) < 0) {
        goto failure;
    }
})
705 706 707



708 709 710 711 712 713 714 715
/* esxVI_FindByIp */
ESX_VI__METHOD(FindByIp,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *datacenter,
                const char *ip,
                esxVI_Boolean vmSearch,
                esxVI_ManagedObjectReference **managedObjectReference),
               OptionalItem,
716
{
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(managedObjectReference)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->searchIndex)
    ESX_VI__METHOD__PARAMETER__REQUIRE(ip)
    ESX_VI__METHOD__PARAMETER__REQUIRE(vmSearch)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->searchIndex)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, datacenter)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, ip)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, vmSearch)
},
{
733 734
    if (esxVI_ManagedObjectReference_Deserialize(response->node,
                                                 managedObjectReference) < 0) {
735 736
        goto failure;
    }
737 738
})

739 740


741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
/* esxVI_FindByUuid */
ESX_VI__METHOD(FindByUuid,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *datacenter,
                const char *uuid, /* string */
                esxVI_Boolean vmSearch,
                esxVI_ManagedObjectReference **managedObjectReference),
               OptionalItem,
{
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(managedObjectReference)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->searchIndex)
    ESX_VI__METHOD__PARAMETER__REQUIRE(uuid)
    ESX_VI__METHOD__PARAMETER__REQUIRE(vmSearch)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->searchIndex)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, datacenter)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_VALUE(String, uuid)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(Boolean, vmSearch)
},
{
766 767
    if (esxVI_ManagedObjectReference_Deserialize(response->node,
                                                 managedObjectReference) < 0) {
768 769
        goto failure;
    }
770
})
771 772


773 774 775 776 777 778 779 780 781

/* esxVI_QueryAvailablePerfMetric */
ESX_VI__METHOD(QueryAvailablePerfMetric,
               (esxVI_Context *ctx,
                esxVI_ManagedObjectReference *entity,
                esxVI_DateTime *beginTime,
                esxVI_DateTime *endTime,
                esxVI_Int *intervalId,
                esxVI_PerfMetricId **perfMetricIdList),
782
               OptionalList,
783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
{
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfMetricIdList)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
    ESX_VI__METHOD__PARAMETER__REQUIRE(entity)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->perfManager)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(ManagedObjectReference, entity)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(DateTime, beginTime)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(DateTime, endTime)
    ESX_VI__METHOD__PARAMETER__SERIALIZE(Int, intervalId)
},
{
    if (esxVI_PerfMetricId_DeserializeList(response->node,
                                           perfMetricIdList) < 0) {
802 803
        goto failure;
    }
804
})
805 806 807



808 809 810 811 812
/* esxVI_QueryPerfCounter */
ESX_VI__METHOD(QueryPerfCounter,
               (esxVI_Context *ctx,
                esxVI_Int *counterId, /* list */
                esxVI_PerfCounterInfo **perfCounterInfoList),
813
               OptionalList,
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
{
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfCounterInfoList)
},
{
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
    ESX_VI__METHOD__PARAMETER__REQUIRE(counterId)
},
{
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->perfManager)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(Int, counterId)
},
{
    if (esxVI_PerfCounterInfo_DeserializeList(response->node,
                                              perfCounterInfoList) < 0) {
        goto failure;
    }
})
833 834 835



836 837 838 839 840
/* esxVI_QueryPerf */
ESX_VI__METHOD(QueryPerf,
               (esxVI_Context *ctx,
                esxVI_PerfQuerySpec *querySpec, /* list */
                esxVI_PerfEntityMetric **perfEntityMetricList),
841
               OptionalList,
842
{
843 844 845
    ESX_VI__METHOD__CHECK_SERVICE()
    ESX_VI__METHOD__PARAMETER__CHECK_OUTPUT(perfEntityMetricList)
},
846
{
847 848 849
    ESX_VI__METHOD__PARAMETER__REQUIRE_THIS(ctx->service->perfManager)
    ESX_VI__METHOD__PARAMETER__REQUIRE(querySpec)
},
850
{
851 852 853 854
    ESX_VI__METHOD__PARAMETER__SERIALIZE_THIS(ManagedObjectReference,
                                              ctx->service->perfManager)
    ESX_VI__METHOD__PARAMETER__SERIALIZE_LIST(PerfQuerySpec, querySpec)
},
855
{
856
    if (esxVI_PerfEntityMetric_DeserializeList(response->node,
857
                                               perfEntityMetricList) < 0) {
858 859
        goto failure;
    }
860
})