- Timestamp:
- Sep 23, 2019 8:53:36 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageCloud.cpp
r80743 r80939 462 462 static RTEXITCODE createCloudInstance(HandlerArg *a, int iFirst, PCLOUDCOMMONOPT pCommonOpts) 463 463 { 464 RT_NOREF(a); 465 RT_NOREF(iFirst); 466 RT_NOREF(pCommonOpts); 467 return RTEXITCODE_SUCCESS; 464 HRESULT hrc = S_OK; 465 hrc = checkAndSetCommonOptions(a, pCommonOpts); 466 if (FAILED(hrc)) 467 return RTEXITCODE_FAILURE; 468 469 static const RTGETOPTDEF s_aOptions[] = 470 { 471 { "--image-id", 'i', RTGETOPT_REQ_STRING }, 472 { "--display-name", 'n', RTGETOPT_REQ_STRING }, 473 { "--launch-mode", 'm', RTGETOPT_REQ_STRING }, 474 { "--shape", 's', RTGETOPT_REQ_STRING }, 475 { "--domain-name", 'd', RTGETOPT_REQ_STRING }, 476 { "--boot-disk-size", 'b', RTGETOPT_REQ_STRING }, 477 { "--publicip", 'p', RTGETOPT_REQ_STRING }, 478 { "--subnet", 't', RTGETOPT_REQ_STRING }, 479 { "--privateip", 'P', RTGETOPT_REQ_STRING }, 480 }; 481 RTGETOPTSTATE GetState; 482 RTGETOPTUNION ValueUnion; 483 int vrc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), iFirst, 0); 484 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 485 486 ComPtr<IAppliance> pAppliance; 487 CHECK_ERROR2_RET(hrc, a->virtualBox, CreateAppliance(pAppliance.asOutParam()), RTEXITCODE_FAILURE); 488 ULONG vsdNum = 1; 489 CHECK_ERROR2_RET(hrc, pAppliance, CreateVirtualSystemDescriptions(1, &vsdNum), RTEXITCODE_FAILURE); 490 com::SafeIfaceArray<IVirtualSystemDescription> virtualSystemDescriptions; 491 CHECK_ERROR2_RET(hrc, pAppliance, 492 COMGETTER(VirtualSystemDescriptions)(ComSafeArrayAsOutParam(virtualSystemDescriptions)), 493 RTEXITCODE_FAILURE); 494 ComPtr<IVirtualSystemDescription> pVSD = virtualSystemDescriptions[0]; 495 496 Utf8Str strDisplayName, strImageId; 497 498 int c; 499 while ((c = RTGetOpt(&GetState, &ValueUnion)) != 0) 500 { 501 switch (c) 502 { 503 case 'i': 504 strImageId = ValueUnion.psz; 505 pVSD->AddDescription(VirtualSystemDescriptionType_CloudImageId, 506 Bstr(ValueUnion.psz).raw(), 507 Bstr(ValueUnion.psz).raw()); 508 break; 509 case 'n': 510 strDisplayName = ValueUnion.psz; 511 pVSD->AddDescription(VirtualSystemDescriptionType_Name, 512 Bstr(ValueUnion.psz).raw(), 513 Bstr(ValueUnion.psz).raw()); 514 break; 515 case 'm': 516 pVSD->AddDescription(VirtualSystemDescriptionType_CloudOCILaunchMode, 517 Bstr(ValueUnion.psz).raw(), 518 Bstr(ValueUnion.psz).raw()); 519 break; 520 case 's': 521 pVSD->AddDescription(VirtualSystemDescriptionType_CloudInstanceShape, 522 Bstr(ValueUnion.psz).raw(), 523 Bstr(ValueUnion.psz).raw()); 524 break; 525 case 'd': 526 pVSD->AddDescription(VirtualSystemDescriptionType_CloudDomain, 527 Bstr(ValueUnion.psz).raw(), 528 Bstr(ValueUnion.psz).raw()); 529 break; 530 531 case 'b': 532 pVSD->AddDescription(VirtualSystemDescriptionType_CloudBootDiskSize, 533 Bstr(ValueUnion.psz).raw(), 534 Bstr(ValueUnion.psz).raw()); 535 break; 536 case 'p': 537 pVSD->AddDescription(VirtualSystemDescriptionType_CloudPublicIP, 538 Bstr(ValueUnion.psz).raw(), 539 Bstr(ValueUnion.psz).raw()); 540 break; 541 case 'P': 542 pVSD->AddDescription(VirtualSystemDescriptionType_CloudPrivateIP, 543 Bstr(ValueUnion.psz).raw(), 544 Bstr(ValueUnion.psz).raw()); 545 break; 546 case 't': 547 pVSD->AddDescription(VirtualSystemDescriptionType_CloudOCISubnet, 548 Bstr(ValueUnion.psz).raw(), 549 Bstr(ValueUnion.psz).raw()); 550 break; 551 case VINF_GETOPT_NOT_OPTION: 552 return errorUnknownSubcommand(ValueUnion.psz); 553 default: 554 return errorGetOpt(c, &ValueUnion); 555 } 556 } 557 558 if (strImageId.isEmpty()) 559 return errorArgument("Missing parameter --image-id."); 560 561 ComPtr<ICloudProfile> pCloudProfile = pCommonOpts->profile.pCloudProfile; 562 563 pVSD->AddDescription(VirtualSystemDescriptionType_CloudProfileName, 564 Bstr(pCommonOpts->profile.pszProfileName).raw(), 565 Bstr(pCommonOpts->profile.pszProfileName).raw()); 566 567 ComObjPtr<ICloudClient> oCloudClient; 568 CHECK_ERROR2_RET(hrc, pCloudProfile, 569 CreateCloudClient(oCloudClient.asOutParam()), 570 RTEXITCODE_FAILURE); 571 572 ComPtr<IStringArray> infoArray; 573 com::SafeArray<BSTR> pStrInfoArray; 574 ComPtr<IProgress> pProgress; 575 576 #if 0 577 /* 578 * OCI API returns an error during an instance creation if the image isn't available 579 * or in the inappropriate state. So the check can be omitted. 580 */ 581 RTPrintf("Checking the cloud image with id \'%s\'...\n", strImageId.c_str()); 582 CHECK_ERROR2_RET(hrc, oCloudClient, 583 GetImageInfo(Bstr(strImageId).raw(), 584 infoArray.asOutParam(), 585 pProgress.asOutParam()), 586 RTEXITCODE_FAILURE); 587 588 hrc = showProgress(pProgress); 589 CHECK_PROGRESS_ERROR_RET(pProgress, ("Checking the cloud image failed"), RTEXITCODE_FAILURE); 590 591 pProgress.setNull(); 592 #endif 593 594 RTPrintf("Creating cloud instance with name \'%s\' from the image \'%s\'...\n", 595 strDisplayName.c_str(), strImageId.c_str()); 596 597 598 CHECK_ERROR2_RET(hrc, oCloudClient, LaunchVM(pVSD, pProgress.asOutParam()), RTEXITCODE_FAILURE); 599 600 hrc = showProgress(pProgress); 601 CHECK_PROGRESS_ERROR_RET(pProgress, ("Creating cloud instance failed"), RTEXITCODE_FAILURE); 602 603 if (SUCCEEDED(hrc)) 604 RTPrintf("Cloud instance was created successfully\n"); 605 606 return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 468 607 } 469 608
Note:
See TracChangeset
for help on using the changeset viewer.