- Timestamp:
- Aug 5, 2023 7:37:55 AM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageCloud.cpp
r99931 r100808 888 888 } 889 889 890 891 static RTEXITCODE cloneCloudInstance(HandlerArg *a, int iFirst, PCLOUDCOMMONOPT pCommonOpts) 892 { 893 HRESULT hrc = S_OK; 894 895 enum 896 { 897 kInstanceIota = 1000, 898 kInstance_ShapeCpu, 899 kInstance_ShapeMemory, 900 }; 901 902 static const RTGETOPTDEF s_aOptions[] = 903 { 904 { "--id", 'i', RTGETOPT_REQ_STRING }, 905 { "--clone-name", 'n', RTGETOPT_REQ_STRING }, 906 907 { "help", 'h', RTGETOPT_REQ_NOTHING }, 908 { "--help", 'h', RTGETOPT_REQ_NOTHING } 909 }; 910 RTGETOPTSTATE GetState; 911 RTGETOPTUNION ValueUnion; 912 int vrc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), iFirst, 0); 913 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 914 if (a->argc == iFirst) 915 { 916 RTPrintf(Cloud::tr("Empty command parameter list, show help.\n")); 917 printHelp(g_pStdOut); 918 return RTEXITCODE_SUCCESS; 919 } 920 921 Utf8Str strCloneName, strInstanceId; 922 int c; 923 while ((c = RTGetOpt(&GetState, &ValueUnion)) != 0) 924 { 925 switch (c) 926 { 927 case 'i': 928 strInstanceId = ValueUnion.psz; 929 930 break; 931 case 'n': 932 strCloneName = ValueUnion.psz; 933 break; 934 case 'h': 935 printHelp(g_pStdOut); 936 return RTEXITCODE_SUCCESS; 937 case VINF_GETOPT_NOT_OPTION: 938 return errorUnknownSubcommand(ValueUnion.psz); 939 default: 940 return errorGetOpt(c, &ValueUnion); 941 } 942 } 943 944 /* Delayed check. It allows us to print help information.*/ 945 hrc = checkAndSetCommonOptions(a, pCommonOpts); 946 if (FAILED(hrc)) 947 return RTEXITCODE_FAILURE; 948 949 if (strInstanceId.isEmpty()) 950 return errorArgument(Cloud::tr("Missing parameter --id.")); 951 952 // if (strCloneName.isEmpty()) 953 // return errorArgument(Cloud::tr("Missing parameter --clone-name.")); 954 955 ComPtr<ICloudProfile> pCloudProfile = pCommonOpts->profile.pCloudProfile; 956 957 ComObjPtr<ICloudClient> oCloudClient; 958 CHECK_ERROR2_RET(hrc, pCloudProfile, 959 CreateCloudClient(oCloudClient.asOutParam()), 960 RTEXITCODE_FAILURE); 961 962 ComPtr<IProgress> pProgress; 963 ComPtr<ICloudMachine> pClonedMachine; 964 965 RTPrintf(Cloud::tr("Cloning cloud instance with Id \'%s\'...\n"), strInstanceId.c_str()); 966 967 CHECK_ERROR2_RET(hrc, oCloudClient, CloneInstance(Bstr(strInstanceId).raw(), 968 Bstr(strCloneName).raw(), 969 pClonedMachine.asOutParam(), 970 pProgress.asOutParam()), RTEXITCODE_FAILURE); 971 972 hrc = showProgress(pProgress); 973 CHECK_PROGRESS_ERROR_RET(pProgress, (Cloud::tr("Cloning cloud instance failed")), RTEXITCODE_FAILURE); 974 975 Bstr strAttr; 976 pClonedMachine->COMGETTER(Id)(strAttr.asOutParam()); 977 RTPrintf(Cloud::tr("Cloned instance UUID in VirtualBox: %ls\n"), strAttr.raw()); 978 strAttr.setNull(); 979 pClonedMachine->COMGETTER(Name)(strAttr.asOutParam()); 980 RTPrintf(Cloud::tr("Cloned instance name: %ls\n"), strAttr.raw()); 981 982 if (SUCCEEDED(hrc)) 983 RTPrintf(Cloud::tr("Cloud instance was cloned successfully\n")); 984 985 return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 986 } 987 890 988 static RTEXITCODE updateCloudInstance(HandlerArg *a, int iFirst, PCLOUDCOMMONOPT pCommonOpts) 891 989 { … … 1390 1488 kCloudInstance_Update, 1391 1489 kCloudInstance_Reset, 1490 kCloudInstance_Clone, 1392 1491 }; 1393 1492 … … 1401 1500 { "update", kCloudInstance_Update, RTGETOPT_REQ_NOTHING }, 1402 1501 { "reset", kCloudInstance_Reset, RTGETOPT_REQ_NOTHING }, 1502 { "clone", kCloudInstance_Clone, RTGETOPT_REQ_NOTHING }, 1403 1503 1404 1504 { "help", 'h', RTGETOPT_REQ_NOTHING }, … … 1453 1553 setCurrentSubcommand(HELP_SCOPE_CLOUD_INSTANCE_RESET); 1454 1554 return resetCloudInstance(a, GetState.iNext, pCommonOpts); 1555 1556 case kCloudInstance_Clone: 1557 // setCurrentSubcommand(HELP_SCOPE_CLOUD_INSTANCE_CLONE); 1558 return cloneCloudInstance(a, GetState.iNext, pCommonOpts); 1455 1559 1456 1560 case 'h':
Note:
See TracChangeset
for help on using the changeset viewer.