- Timestamp:
- Sep 23, 2021 12:21:53 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 147005
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageCloudMachine.cpp
r91320 r91338 28 28 29 29 30 struct CMachineHandlerArg 31 : public HandlerArg 32 { 33 ComPtr<ICloudClient> pClient; 34 35 const char *pcszSpec; /* RTGETOPTUNION::psz, points inside argv */ 36 enum { GUESS, ID, NAME } enmSpecKind; 37 ComPtr<ICloudMachine> pMachine; 38 39 explicit CMachineHandlerArg(const HandlerArg &a) 40 : HandlerArg(a), pcszSpec(NULL), enmSpecKind(GUESS) {} 41 }; 42 43 30 44 static int selectCloudProvider(ComPtr<ICloudProvider> &pProvider, 31 45 const ComPtr<IVirtualBox> &pVirtualBox, … … 34 48 const ComPtr<ICloudProvider> &pProvider, 35 49 const char *pszProviderName); 36 static int getCloudClient(ComPtr<ICloudClient> &aClient, 37 HandlerArg *a, 50 static int getCloudClient(CMachineHandlerArg &a, 38 51 const char *pcszProviderName, 39 52 const char *pcszProfileName); … … 42 55 const ComPtr<ICloudClient> &pClient); 43 56 44 static HRESULT getMachineById(ComPtr<ICloudMachine> &pMachineOut, 45 const ComPtr<ICloudClient> &pClient, 46 const char *pcszId); 47 static HRESULT getMachineByName(ComPtr<ICloudMachine> &pMachineOut, 48 const ComPtr<ICloudClient> &pClient, 49 const char *pcszName); 50 static HRESULT getMachineByGuess(ComPtr<ICloudMachine> &pMachineOut, 51 const ComPtr<ICloudClient> &pClient, 52 const char *pcszWhatever); 53 54 struct MachineSpec { 55 const char *pcszSpec; 56 enum { GUESS, ID, NAME } enmKind; 57 58 MachineSpec() 59 : pcszSpec(NULL), enmKind(GUESS) {} 60 }; 61 62 static int checkMachineSpecArgument(MachineSpec &aMachineSpec, 57 static HRESULT getMachineBySpec(CMachineHandlerArg *a); 58 static HRESULT getMachineById(CMachineHandlerArg *a); 59 static HRESULT getMachineByName(CMachineHandlerArg *a); 60 static HRESULT getMachineByGuess(CMachineHandlerArg *a); 61 62 static int checkMachineSpecArgument(CMachineHandlerArg *a, 63 63 int ch, const RTGETOPTUNION &Val); 64 static HRESULT getMachineBySpec(ComPtr<ICloudMachine> &pMachineOut, 65 const ComPtr<ICloudClient> &pClient, 66 const MachineSpec &aMachineSpec); 67 68 69 static RTEXITCODE handleCloudMachineImpl(HandlerArg *a, int iFirst, 70 const ComPtr<ICloudClient> &pClient); 71 72 static RTEXITCODE handleCloudMachineStart(HandlerArg *a, int iFirst, 73 const ComPtr<ICloudClient> &pClient); 74 static RTEXITCODE handleCloudMachineReboot(HandlerArg *a, int iFirst, 75 const ComPtr<ICloudClient> &pClient); 76 static RTEXITCODE handleCloudMachineShutdown(HandlerArg *a, int iFirst, 77 const ComPtr<ICloudClient> &pClient); 78 static RTEXITCODE handleCloudMachinePowerdown(HandlerArg *a, int iFirst, 79 const ComPtr<ICloudClient> &pClient); 80 static RTEXITCODE handleCloudMachineTerminate(HandlerArg *a, int iFirst, 81 const ComPtr<ICloudClient> &pClient); 82 83 static RTEXITCODE handleCloudMachineConsoleHistory(HandlerArg *a, int iFirst, 84 const ComPtr<ICloudClient> &pClient); 85 86 static RTEXITCODE listCloudMachinesImpl(HandlerArg *a, int iFirst, 87 const ComPtr<ICloudClient> &pClient); 88 static RTEXITCODE handleCloudMachineInfo(HandlerArg *a, int iFirst, 89 const ComPtr<ICloudClient> &pClient); 64 65 66 static RTEXITCODE handleCloudMachineImpl(CMachineHandlerArg *a, int iFirst); 67 68 static RTEXITCODE handleCloudMachineStart(CMachineHandlerArg *a, int iFirst); 69 static RTEXITCODE handleCloudMachineReboot(CMachineHandlerArg *a, int iFirst); 70 static RTEXITCODE handleCloudMachineShutdown(CMachineHandlerArg *a, int iFirst); 71 static RTEXITCODE handleCloudMachinePowerdown(CMachineHandlerArg *a, int iFirst); 72 static RTEXITCODE handleCloudMachineTerminate(CMachineHandlerArg *a, int iFirst); 73 74 static RTEXITCODE handleCloudMachineConsoleHistory(CMachineHandlerArg *a, int iFirst); 75 76 static RTEXITCODE listCloudMachinesImpl(CMachineHandlerArg *a, int iFirst); 77 static RTEXITCODE handleCloudMachineInfo(CMachineHandlerArg *a, int iFirst); 90 78 91 79 static HRESULT printMachineInfo(const ComPtr<ICloudMachine> &pMachine); … … 119 107 const char *pcszProfileName) 120 108 { 121 C omPtr<ICloudClient> pClient;122 int rc = getCloudClient( pClient, a, pcszProviderName, pcszProfileName);109 CMachineHandlerArg handlerArg(*a); 110 int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName); 123 111 if (RT_FAILURE(rc)) 124 112 return RTEXITCODE_FAILURE; 125 113 126 return handleCloudMachineImpl( a, iFirst, pClient);114 return handleCloudMachineImpl(&handlerArg, iFirst); 127 115 } 128 116 … … 257 245 258 246 static int 259 getCloudClient(ComPtr<ICloudClient> &aCloudClient, 260 HandlerArg *a, 247 getCloudClient(CMachineHandlerArg &a, 261 248 const char *pcszProviderName, 262 249 const char *pcszProfileName) … … 266 253 267 254 ComPtr<ICloudProvider> pProvider; 268 rc = selectCloudProvider(pProvider, a ->virtualBox, pcszProviderName);255 rc = selectCloudProvider(pProvider, a.virtualBox, pcszProviderName); 269 256 if (RT_FAILURE(rc)) 270 257 return rc; … … 280 267 VERR_GENERAL_FAILURE); 281 268 282 a CloudClient = pCloudClient;269 a.pClient = pCloudClient; 283 270 return VINF_SUCCESS; 284 271 } … … 309 296 310 297 static HRESULT 311 getMachineById(ComPtr<ICloudMachine> &pMachineOut, 312 const ComPtr<ICloudClient> &pClient, 313 const char *pcszId) 298 getMachineById(CMachineHandlerArg *a) 314 299 { 315 300 HRESULT hrc; 316 301 317 302 ComPtr<ICloudMachine> pMachine; 318 CHECK_ERROR2_RET(hrc, pClient,319 GetCloudMachine(com::Bstr( pcszId).raw(),303 CHECK_ERROR2_RET(hrc, a->pClient, 304 GetCloudMachine(com::Bstr(a->pcszSpec).raw(), 320 305 pMachine.asOutParam()), hrc); 321 306 … … 328 313 return hrc; 329 314 330 pMachineOut= pMachine;315 a->pMachine = pMachine; 331 316 return S_OK; 332 317 } … … 334 319 335 320 static HRESULT 336 getMachineByName(ComPtr<ICloudMachine> &pMachineOut, 337 const ComPtr<ICloudClient> &pClient, 338 const char *pcszName) 321 getMachineByName(CMachineHandlerArg *a) 339 322 { 340 323 HRESULT hrc; 341 324 342 325 com::SafeIfaceArray<ICloudMachine> aMachines; 343 hrc = getMachineList(aMachines, pClient);326 hrc = getMachineList(aMachines, a->pClient); 344 327 if (FAILED(hrc)) 345 328 return hrc; … … 359 342 hrc); 360 343 361 if (!bstrName.equals( pcszName))344 if (!bstrName.equals(a->pcszSpec)) 362 345 continue; 363 346 … … 384 367 return VBOX_E_OBJECT_NOT_FOUND; 385 368 386 pMachineOut= pMachineFound;369 a->pMachine = pMachineFound; 387 370 return S_OK; 388 371 } … … 398 381 */ 399 382 static HRESULT 400 getMachineByGuess(ComPtr<ICloudMachine> &pMachineOut, 401 const ComPtr<ICloudClient> &pClient, 402 const char *pcszWhatever) 403 { 404 ComPtr<ICloudMachine> pMachine; 405 383 getMachineByGuess(CMachineHandlerArg *a) 384 { 406 385 HRESULT hrc; 407 386 408 387 RTUUID Uuid; 409 int rc = RTUuidFromStr(&Uuid, pcszWhatever);388 int rc = RTUuidFromStr(&Uuid, a->pcszSpec); 410 389 if (RT_SUCCESS(rc)) 411 hrc = getMachineById( pMachine, pClient, pcszWhatever);390 hrc = getMachineById(a); 412 391 else 413 hrc = getMachineByName( pMachine, pClient, pcszWhatever);392 hrc = getMachineByName(a); 414 393 415 394 if (FAILED(hrc)) 416 395 return hrc; 417 396 418 pMachineOut = pMachine;419 397 return S_OK; 420 398 } … … 456 434 */ 457 435 static int 458 checkMachineSpecArgument( MachineSpec &aMachineSpec,436 checkMachineSpecArgument(CMachineHandlerArg *a, 459 437 int ch, const RTGETOPTUNION &Val) 460 438 { … … 475 453 const char *pcszId = Val.psz; 476 454 477 if (a MachineSpec.pcszSpec != NULL)455 if (a->pcszSpec != NULL) 478 456 { 479 457 errThereCanBeOnlyOne(); … … 489 467 } 490 468 491 a MachineSpec.pcszSpec = pcszId;492 a MachineSpec.enmKind = MachineSpec::ID;469 a->pcszSpec = pcszId; 470 a->enmSpecKind = CMachineHandlerArg::ID; 493 471 return VINF_SUCCESS; 494 472 } … … 498 476 const char *pcszName = Val.psz; 499 477 500 if (a MachineSpec.pcszSpec != NULL)478 if (a->pcszSpec != NULL) 501 479 { 502 480 errThereCanBeOnlyOne(); … … 504 482 } 505 483 506 a MachineSpec.pcszSpec = pcszName;507 a MachineSpec.enmKind = MachineSpec::NAME;484 a->pcszSpec = pcszName; 485 a->enmSpecKind = CMachineHandlerArg::NAME; 508 486 return VINF_SUCCESS; 509 487 } … … 517 495 const char *pcszNameOrId = Val.psz; 518 496 519 if (a MachineSpec.pcszSpec != NULL)497 if (a->pcszSpec != NULL) 520 498 { 521 499 errThereCanBeOnlyOne(); … … 523 501 } 524 502 525 a MachineSpec.pcszSpec = pcszNameOrId;526 a MachineSpec.enmKind = MachineSpec::GUESS;503 a->pcszSpec = pcszNameOrId; 504 a->enmSpecKind = CMachineHandlerArg::GUESS; 527 505 return VINF_SUCCESS; 528 506 } … … 542 520 543 521 static HRESULT 544 getMachineBySpec(ComPtr<ICloudMachine> &pMachineOut, 545 const ComPtr<ICloudClient> &pClient, 546 const MachineSpec &aMachineSpec) 522 getMachineBySpec(CMachineHandlerArg *a) 547 523 { 548 524 HRESULT hrc = E_FAIL; 549 525 550 if (a MachineSpec.pcszSpec == NULL)526 if (a->pcszSpec == NULL) 551 527 { 552 528 RTMsgErrorExit(RTEXITCODE_SYNTAX, "machine not specified"); … … 554 530 } 555 531 556 if (a MachineSpec.pcszSpec[0] == '\0')532 if (a->pcszSpec[0] == '\0') 557 533 { 558 534 RTMsgError("machine name is empty"); … … 560 536 } 561 537 562 switch (a MachineSpec.enmKind)563 { 564 case MachineSpec::ID:565 hrc = getMachineById( pMachineOut, pClient, aMachineSpec.pcszSpec);538 switch (a->enmSpecKind) 539 { 540 case CMachineHandlerArg::ID: 541 hrc = getMachineById(a); 566 542 if (FAILED(hrc)) 567 543 { 568 544 if (hrc == VBOX_E_OBJECT_NOT_FOUND) 569 RTMsgError("unable to find machine with id %s", a MachineSpec.pcszSpec);545 RTMsgError("unable to find machine with id %s", a->pcszSpec); 570 546 return hrc; 571 547 } 572 548 break; 573 549 574 case MachineSpec::NAME:575 hrc = getMachineByName( pMachineOut, pClient, aMachineSpec.pcszSpec);550 case CMachineHandlerArg::NAME: 551 hrc = getMachineByName(a); 576 552 if (FAILED(hrc)) 577 553 { 578 554 if (hrc == VBOX_E_OBJECT_NOT_FOUND) 579 RTMsgError("unable to find machine with name %s", a MachineSpec.pcszSpec);555 RTMsgError("unable to find machine with name %s", a->pcszSpec); 580 556 return hrc; 581 557 } 582 558 break; 583 559 584 case MachineSpec::GUESS:585 hrc = getMachineByGuess( pMachineOut, pClient, aMachineSpec.pcszSpec);560 case CMachineHandlerArg::GUESS: 561 hrc = getMachineByGuess(a); 586 562 if (FAILED(hrc)) 587 563 { 588 564 if (hrc == VBOX_E_OBJECT_NOT_FOUND) 589 RTMsgError("unable to find machine %s", a MachineSpec.pcszSpec);565 RTMsgError("unable to find machine %s", a->pcszSpec); 590 566 return hrc; 591 567 } … … 602 578 603 579 /* 604 * cloud machine ...580 * cloud machine [--id id | --name name] command ... 605 581 * 606 * The "cloud" prefix handling is in VBoxManageCloud.cpp, so this 607 * function is not static. 582 * We allow machine to be specified after "machine" but only with an 583 * explicit option for the obvious reason. We will also check for 584 * these options and machine spec as a plain words argument after the 585 * command word, so user can use either of: 586 * 587 * cloud machine --name foo start 588 * cloud machine start --name foo 589 * cloud machine start foo 590 * 591 * This will accept e.g. cloud machine --name foo list ... b/c we 592 * don't yet know that it's "list" that is coming, so commands that 593 * don't take machine argument check that separately when called. One 594 * side effect of this is that specifying several machines or using a 595 * syntactically invalid id will be reported as such, not as an 596 * unknown option, but that's a relatively minor nit. 608 597 */ 609 598 static RTEXITCODE 610 handleCloudMachineImpl(HandlerArg *a, int iFirst, 611 const ComPtr<ICloudClient> &pClient) 599 handleCloudMachineImpl(CMachineHandlerArg *a, int iFirst) 612 600 { 613 601 int rc; … … 638 626 { "start", kMachine_Start, RTGETOPT_REQ_NOTHING }, 639 627 { "terminate", kMachine_Terminate, RTGETOPT_REQ_NOTHING }, 628 CLOUD_MACHINE_RTGETOPTDEF_MACHINE, 640 629 CLOUD_MACHINE_RTGETOPTDEF_HELP 641 630 }; … … 652 641 while ((ch = RTGetOpt(&OptState, &Val)) != 0) 653 642 { 643 if (RT_FAILURE(ch)) 644 return RTGetOptPrintError(ch, &Val); 645 646 /* 647 * Check for an unknown word first: checkMachineSpecArgument() 648 * would try to interpret that as a machine id/name. 649 */ 650 if (ch == VINF_GETOPT_NOT_OPTION) 651 return RTMsgErrorExit(RTEXITCODE_SYNTAX, 652 "Invalid sub-command: %s", Val.psz); 653 654 /* 655 * Allow --id/--name after "machine", before the command. 656 * Also handles --help. 657 */ 658 rc = checkMachineSpecArgument(a, ch, Val); 659 if (rc == VINF_SUCCESS) 660 continue; 661 else if (rc == VINF_CALLBACK_RETURN) 662 return RTEXITCODE_SUCCESS; 663 else if (rc == VERR_PARSE_ERROR) 664 return RTEXITCODE_SYNTAX; 665 666 /* 667 * Dispatch to command implementation ([ab]use getopt to do 668 * string comparisons for us). 669 */ 654 670 switch (ch) 655 671 { 656 672 case kMachine_ConsoleHistory: 657 return handleCloudMachineConsoleHistory(a, OptState.iNext , pClient);673 return handleCloudMachineConsoleHistory(a, OptState.iNext); 658 674 659 675 case kMachine_Info: 660 return handleCloudMachineInfo(a, OptState.iNext , pClient);676 return handleCloudMachineInfo(a, OptState.iNext); 661 677 662 678 case kMachine_List: 663 return listCloudMachinesImpl(a, OptState.iNext , pClient);679 return listCloudMachinesImpl(a, OptState.iNext); 664 680 665 681 case kMachine_Powerdown: 666 return handleCloudMachinePowerdown(a, OptState.iNext , pClient);682 return handleCloudMachinePowerdown(a, OptState.iNext); 667 683 668 684 case kMachine_Reboot: 669 return handleCloudMachineReboot(a, OptState.iNext , pClient);685 return handleCloudMachineReboot(a, OptState.iNext); 670 686 671 687 case kMachine_Shutdown: 672 return handleCloudMachineShutdown(a, OptState.iNext , pClient);688 return handleCloudMachineShutdown(a, OptState.iNext); 673 689 674 690 case kMachine_Start: 675 return handleCloudMachineStart(a, OptState.iNext , pClient);691 return handleCloudMachineStart(a, OptState.iNext); 676 692 677 693 case kMachine_Terminate: 678 return handleCloudMachineTerminate(a, OptState.iNext, pClient); 679 680 681 case 'h': /* --help */ 682 printHelp(g_pStdOut); 683 return RTEXITCODE_SUCCESS; 684 685 686 case VINF_GETOPT_NOT_OPTION: 687 return RTMsgErrorExit(RTEXITCODE_SYNTAX, 688 "Invalid sub-command: %s", Val.psz); 689 690 default: 691 return RTGetOptPrintError(ch, &Val); 694 return handleCloudMachineTerminate(a, OptState.iNext); 695 696 default: /* should never happen */ 697 return RTMsgErrorExit(RTEXITCODE_INIT, 698 "cloud machine: internal error: %d", ch); 692 699 } 693 700 } … … 711 718 const char *pcszProfileName) 712 719 { 713 int rc; 714 715 ComPtr<ICloudClient> pClient; 716 rc = getCloudClient(pClient, a, pcszProviderName, pcszProfileName); 720 CMachineHandlerArg handlerArg(*a); 721 int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName); 717 722 if (RT_FAILURE(rc)) 718 723 return RTEXITCODE_FAILURE; 719 724 720 return listCloudMachinesImpl( a, iFirst, pClient);725 return listCloudMachinesImpl(&handlerArg, iFirst); 721 726 } 722 727 … … 727 732 */ 728 733 static RTEXITCODE 729 listCloudMachinesImpl(HandlerArg *a, int iFirst, 730 const ComPtr<ICloudClient> &pClient) 734 listCloudMachinesImpl(CMachineHandlerArg *a, int iFirst) 731 735 { 732 736 HRESULT hrc; … … 746 750 enum kSortOrderEnum { kSortOrder_None, kSortOrder_Name, kSortOrder_Id }; 747 751 kSortOrderEnum enmSortOrder = kSortOrder_None; 752 753 if (a->pcszSpec != NULL) 754 return RTMsgErrorExit(RTEXITCODE_SYNTAX, 755 "cloud machine list: unexpected machine argument"); 756 748 757 749 758 RTGETOPTSTATE OptState; … … 784 793 785 794 com::SafeIfaceArray<ICloudMachine> aMachines; 786 hrc = getMachineList(aMachines, pClient);795 hrc = getMachineList(aMachines, a->pClient); 787 796 if (FAILED(hrc)) 788 797 return RTEXITCODE_FAILURE; … … 875 884 const char *pcszProfileName) 876 885 { 877 int rc; 878 879 ComPtr<ICloudClient> pClient; 880 rc = getCloudClient(pClient, a, pcszProviderName, pcszProfileName); 886 CMachineHandlerArg handlerArg(*a); 887 int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName); 881 888 if (RT_FAILURE(rc)) 882 889 return RTEXITCODE_FAILURE; 883 890 884 return handleCloudMachineInfo( a, iFirst, pClient);891 return handleCloudMachineInfo(&handlerArg, iFirst); 885 892 } 886 893 … … 890 897 */ 891 898 static RTEXITCODE 892 handleCloudMachineInfo(HandlerArg *a, int iFirst, 893 const ComPtr<ICloudClient> &pClient) 894 { 895 MachineSpec machineSpec; 896 ComPtr<ICloudMachine> pMachine; 899 handleCloudMachineInfo(CMachineHandlerArg *a, int iFirst) 900 { 897 901 HRESULT hrc; 898 902 int rc; … … 923 927 while ((ch = RTGetOpt(&OptState, &Val)) != 0) 924 928 { 925 rc = checkMachineSpecArgument( machineSpec, ch, Val);929 rc = checkMachineSpecArgument(a, ch, Val); 926 930 if (rc == VINF_SUCCESS) 927 931 continue; … … 942 946 } 943 947 944 hrc = getMachineBySpec( pMachine, pClient, machineSpec);948 hrc = getMachineBySpec(a); 945 949 if (FAILED(hrc)) 946 950 return RTEXITCODE_FAILURE; … … 949 953 950 954 951 hrc = printMachineInfo( pMachine);955 hrc = printMachineInfo(a->pMachine); 952 956 if (FAILED(hrc)) 953 957 return RTEXITCODE_FAILURE; … … 1193 1197 */ 1194 1198 static RTEXITCODE 1195 getMachineFromArgs(ComPtr<ICloudMachine> &pMachine, 1196 uint64_t fCurSubcommandScope, 1197 HandlerArg *a, int iFirst, 1198 const ComPtr<ICloudClient> &pClient) 1199 { 1200 MachineSpec machineSpec; 1199 getMachineFromArgs(CMachineHandlerArg *a, int iFirst) 1200 { 1201 1201 HRESULT hrc; 1202 1202 int rc; 1203 1203 1204 RT_NOREF(fCurSubcommandScope); /// @todo scopes not in the manual yet1205 // setCurrentSubcommand(fCurSubcommandScope);1206 1204 static const RTGETOPTDEF s_aOptions[] = 1207 1205 { … … 1222 1220 while ((ch = RTGetOpt(&OptState, &Val)) != 0) 1223 1221 { 1224 rc = checkMachineSpecArgument( machineSpec, ch, Val);1222 rc = checkMachineSpecArgument(a, ch, Val); 1225 1223 if (rc == VINF_SUCCESS) 1226 1224 continue; … … 1238 1236 } 1239 1237 1240 hrc = getMachineBySpec( pMachine, pClient, machineSpec);1238 hrc = getMachineBySpec(a); 1241 1239 if (FAILED(hrc)) 1242 1240 return RTEXITCODE_FAILURE; … … 1250 1248 */ 1251 1249 static RTEXITCODE 1252 handleCloudMachineStart(HandlerArg *a, int iFirst, 1253 const ComPtr<ICloudClient> &pClient) 1254 { 1255 ComPtr<ICloudMachine> pMachine; 1256 HRESULT hrc; 1257 1258 RTEXITCODE status 1259 = getMachineFromArgs(pMachine, 1260 /* HELP_SCOPE_CLOUD_MACHINE_START */ 0, 1261 a, iFirst, pClient); 1250 handleCloudMachineStart(CMachineHandlerArg *a, int iFirst) 1251 { 1252 HRESULT hrc; 1253 1254 // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_START); 1255 RTEXITCODE status = getMachineFromArgs(a, iFirst); 1262 1256 if (status != RTEXITCODE_SUCCESS) 1263 1257 return status; … … 1265 1259 1266 1260 ComPtr<IProgress> pProgress; 1267 CHECK_ERROR2_RET(hrc, pMachine,1261 CHECK_ERROR2_RET(hrc, a->pMachine, 1268 1262 PowerUp(pProgress.asOutParam()), 1269 1263 RTEXITCODE_FAILURE); … … 1279 1273 */ 1280 1274 static RTEXITCODE 1281 handleCloudMachineReboot(HandlerArg *a, int iFirst, 1282 const ComPtr<ICloudClient> &pClient) 1283 { 1284 ComPtr<ICloudMachine> pMachine; 1285 HRESULT hrc; 1286 1287 RTEXITCODE status 1288 = getMachineFromArgs(pMachine, 1289 /* HELP_SCOPE_CLOUD_MACHINE_REBOOT */ 0, 1290 a, iFirst, pClient); 1275 handleCloudMachineReboot(CMachineHandlerArg *a, int iFirst) 1276 { 1277 HRESULT hrc; 1278 1279 // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_REBOOT); 1280 RTEXITCODE status = getMachineFromArgs(a, iFirst); 1291 1281 if (status != RTEXITCODE_SUCCESS) 1292 1282 return status; … … 1294 1284 1295 1285 ComPtr<IProgress> pProgress; 1296 CHECK_ERROR2_RET(hrc, pMachine,1286 CHECK_ERROR2_RET(hrc, a->pMachine, 1297 1287 Reboot(pProgress.asOutParam()), 1298 1288 RTEXITCODE_FAILURE); … … 1308 1298 */ 1309 1299 static RTEXITCODE 1310 handleCloudMachineShutdown(HandlerArg *a, int iFirst, 1311 const ComPtr<ICloudClient> &pClient) 1312 { 1313 ComPtr<ICloudMachine> pMachine; 1314 HRESULT hrc; 1315 1316 RTEXITCODE status 1317 = getMachineFromArgs(pMachine, 1318 /* HELP_SCOPE_CLOUD_MACHINE_SHUTDOWN */ 0, 1319 a, iFirst, pClient); 1300 handleCloudMachineShutdown(CMachineHandlerArg *a, int iFirst) 1301 { 1302 HRESULT hrc; 1303 1304 // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_SHUTDOWN); 1305 RTEXITCODE status = getMachineFromArgs(a, iFirst); 1320 1306 if (status != RTEXITCODE_SUCCESS) 1321 1307 return status; … … 1323 1309 1324 1310 ComPtr<IProgress> pProgress; 1325 CHECK_ERROR2_RET(hrc, pMachine,1311 CHECK_ERROR2_RET(hrc, a->pMachine, 1326 1312 Shutdown(pProgress.asOutParam()), 1327 1313 RTEXITCODE_FAILURE); … … 1337 1323 */ 1338 1324 static RTEXITCODE 1339 handleCloudMachinePowerdown(HandlerArg *a, int iFirst, 1340 const ComPtr<ICloudClient> &pClient) 1341 { 1342 ComPtr<ICloudMachine> pMachine; 1343 HRESULT hrc; 1344 1345 RTEXITCODE status 1346 = getMachineFromArgs(pMachine, 1347 /* HELP_SCOPE_CLOUD_MACHINE_POWERDOWN */ 0, 1348 a, iFirst, pClient); 1325 handleCloudMachinePowerdown(CMachineHandlerArg *a, int iFirst) 1326 { 1327 HRESULT hrc; 1328 1329 // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_POWERDOWN); 1330 RTEXITCODE status = getMachineFromArgs(a, iFirst); 1349 1331 if (status != RTEXITCODE_SUCCESS) 1350 1332 return status; … … 1352 1334 1353 1335 ComPtr<IProgress> pProgress; 1354 CHECK_ERROR2_RET(hrc, pMachine,1336 CHECK_ERROR2_RET(hrc, a->pMachine, 1355 1337 PowerDown(pProgress.asOutParam()), 1356 1338 RTEXITCODE_FAILURE); … … 1366 1348 */ 1367 1349 static RTEXITCODE 1368 handleCloudMachineTerminate(HandlerArg *a, int iFirst, 1369 const ComPtr<ICloudClient> &pClient) 1370 { 1371 ComPtr<ICloudMachine> pMachine; 1372 HRESULT hrc; 1373 1374 RTEXITCODE status 1375 = getMachineFromArgs(pMachine, 1376 /* HELP_SCOPE_CLOUD_MACHINE_TERMINATE */ 0, 1377 a, iFirst, pClient); 1350 handleCloudMachineTerminate(CMachineHandlerArg *a, int iFirst) 1351 { 1352 HRESULT hrc; 1353 1354 // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_TERMINATE); 1355 RTEXITCODE status = getMachineFromArgs(a, iFirst); 1378 1356 if (status != RTEXITCODE_SUCCESS) 1379 1357 return status; … … 1381 1359 1382 1360 ComPtr<IProgress> pProgress; 1383 CHECK_ERROR2_RET(hrc, pMachine,1361 CHECK_ERROR2_RET(hrc, a->pMachine, 1384 1362 Terminate(pProgress.asOutParam()), 1385 1363 RTEXITCODE_FAILURE); … … 1394 1372 */ 1395 1373 static RTEXITCODE 1396 handleCloudMachineConsoleHistory(HandlerArg *a, int iFirst, 1397 const ComPtr<ICloudClient> &pClient) 1398 { 1399 ComPtr<ICloudMachine> pMachine; 1400 HRESULT hrc; 1401 1402 RTEXITCODE status 1403 = getMachineFromArgs(pMachine, 1404 /* HELP_SCOPE_CLOUD_MACHINE_CONSOLEHISTORY */ 0, 1405 a, iFirst, pClient); 1374 handleCloudMachineConsoleHistory(CMachineHandlerArg *a, int iFirst) 1375 { 1376 HRESULT hrc; 1377 1378 // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_CONSOLEHISTORY); 1379 RTEXITCODE status = getMachineFromArgs(a, iFirst); 1406 1380 if (status != RTEXITCODE_SUCCESS) 1407 1381 return status; … … 1410 1384 ComPtr<IDataStream> pHistoryStream; 1411 1385 ComPtr<IProgress> pHistoryProgress; 1412 CHECK_ERROR2_RET(hrc, pMachine,1386 CHECK_ERROR2_RET(hrc, a->pMachine, 1413 1387 GetConsoleHistory(pHistoryStream.asOutParam(), 1414 1388 pHistoryProgress.asOutParam()),
Note:
See TracChangeset
for help on using the changeset viewer.