Changeset 68140 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jul 27, 2017 3:16:23 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r64997 r68140 120 120 { "startvm", USAGE_STARTVM, VBMG_CMD_TODO, handleStartVM, 0 }, 121 121 { "controlvm", USAGE_CONTROLVM, VBMG_CMD_TODO, handleControlVM, 0 }, 122 { "unattended", USAGE_UNATTENDEDINSTALL, VBMG_CMD_TODO, handleUnattendedInstall, 0 },122 { "unattended", USAGE_UNATTENDEDINSTALL, HELP_CMD_UNATTENDED, handleUnattended, 0 }, 123 123 { "discardstate", USAGE_DISCARDSTATE, VBMG_CMD_TODO, handleDiscardState, 0 }, 124 124 { "adoptstate", USAGE_ADOPTSTATE, VBMG_CMD_TODO, handleAdoptState, 0 }, -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r65049 r68140 216 216 /* VBoxManageControlVM.cpp */ 217 217 RTEXITCODE handleControlVM(HandlerArg *a); 218 RTEXITCODE handleUnattendedInstall(HandlerArg *a);219 218 #ifndef VBOX_ONLY_DOCS 220 219 unsigned int getMaxNics(IVirtualBox* vbox, IMachine* mach); … … 277 276 RTEXITCODE handleSharedFolder(HandlerArg *a); 278 277 RTEXITCODE handleExtPack(HandlerArg *a); 278 RTEXITCODE handleUnattended(HandlerArg *a); 279 279 280 280 /* VBoxManageDisk.cpp */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r68055 r68140 1021 1021 } 1022 1022 1023 if (fCategory & USAGE_UNATTENDEDINSTALL)1024 RTStrmPrintf(pStrm, /* This will be replaced by a docbook man page. */1025 "%s unattended %s <uuid|vmname>\n"1026 " <OUTDATED-TODO> --settings-file <file>\n"1027 " <OUTDATED-TODO> [--session-type <type>]\n"1028 "%s unattended %s <uuid|vmname>\n"1029 " <OUTDATED-TODO> --user <user>\n"1030 " <OUTDATED-TODO> --password <password>\n"1031 " <OUTDATED-TODO> --iso-path <path>\n"1032 " <OUTDATED-TODO> [--key <CD-key>]\n"1033 " <OUTDATED-TODO> [--additions-iso-path <path>]\n"1034 " <OUTDATED-TODO> [--install-additions]\n"1035 " <OUTDATED-TODO> [--image-index <index>]\n"1036 " <OUTDATED-TODO> [--session-type <type>]\n"1037 "\n", SEP, SEP);1038 1039 1023 if (fCategory & USAGE_DISCARDSTATE) 1040 1024 RTStrmPrintf(pStrm, -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r68135 r68140 5 5 6 6 /* 7 * Copyright (C) 2006-201 6Oracle Corporation7 * Copyright (C) 2006-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1268 1268 } 1269 1269 1270 RTEXITCODE handleUnattendedDetect(HandlerArg *a) 1271 { 1272 HRESULT hrc; 1273 1274 /* 1275 * Options. We work directly on an IUnattended instace while parsing 1276 * the options. This saves a lot of extra clutter. 1277 */ 1278 bool fMachineReadable = false; 1279 char szIsoPath[RTPATH_MAX]; 1280 szIsoPath[0] = '\0'; 1281 1282 /* 1283 * Parse options. 1284 */ 1285 static const RTGETOPTDEF s_aOptions[] = 1286 { 1287 { "--iso", 'i', RTGETOPT_REQ_STRING }, 1288 { "--machine-readable", 'M', RTGETOPT_REQ_NOTHING }, 1289 }; 1290 1291 RTGETOPTSTATE GetState; 1292 int vrc = RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, RTGETOPTINIT_FLAGS_OPTS_FIRST); 1293 AssertRCReturn(vrc, RTEXITCODE_FAILURE); 1294 1295 int c; 1296 RTGETOPTUNION ValueUnion; 1297 while ((c = RTGetOpt(&GetState, &ValueUnion)) != 0) 1298 { 1299 switch (c) 1300 { 1301 case 'i': // --iso 1302 vrc = RTPathAbs(ValueUnion.psz, szIsoPath, sizeof(szIsoPath)); 1303 if (RT_FAILURE(vrc)) 1304 return errorSyntax("RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc); 1305 break; 1306 1307 case 'M': // --machine-readable. 1308 fMachineReadable = true; 1309 break; 1310 1311 default: 1312 return errorGetOpt(c, &ValueUnion); 1313 } 1314 } 1315 1316 /* 1317 * Check for required stuff. 1318 */ 1319 if (szIsoPath[0] == '\0') 1320 return errorSyntax("No ISO specified"); 1321 1322 /* 1323 * Do the job. 1324 */ 1325 ComPtr<IUnattended> ptrUnattended; 1326 CHECK_ERROR2_RET(hrc, a->virtualBox, CreateUnattendedInstaller(ptrUnattended.asOutParam()), RTEXITCODE_FAILURE); 1327 CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(IsoPath)(Bstr(szIsoPath).raw()), RTEXITCODE_FAILURE); 1328 CHECK_ERROR2_RET(hrc, ptrUnattended, DetectIsoOS(), RTEXITCODE_FAILURE); 1329 1330 /* 1331 * Retrieve the results. 1332 */ 1333 Bstr bstrDetectedOSTypeId; 1334 CHECK_ERROR2_RET(hrc, ptrUnattended, COMGETTER(DetectedOSTypeId)(bstrDetectedOSTypeId.asOutParam()), RTEXITCODE_FAILURE); 1335 Bstr bstrDetectedVersion; 1336 CHECK_ERROR2_RET(hrc, ptrUnattended, COMGETTER(DetectedOSVersion)(bstrDetectedVersion.asOutParam()), RTEXITCODE_FAILURE); 1337 Bstr bstrDetectedFlavor; 1338 CHECK_ERROR2_RET(hrc, ptrUnattended, COMGETTER(DetectedOSFlavor)(bstrDetectedFlavor.asOutParam()), RTEXITCODE_FAILURE); 1339 Bstr bstrDetectedHints; 1340 CHECK_ERROR2_RET(hrc, ptrUnattended, COMGETTER(DetectedOSHints)(bstrDetectedHints.asOutParam()), RTEXITCODE_FAILURE); 1341 if (fMachineReadable) 1342 RTPrintf("OSTypeId=\"%ls\"\n" 1343 "OSVersion=\"%ls\"\n" 1344 "OSFlavor=\"%ls\"\n" 1345 "OSHints=\"%ls\"\n", 1346 bstrDetectedOSTypeId.raw(), 1347 bstrDetectedVersion.raw(), 1348 bstrDetectedFlavor.raw(), 1349 bstrDetectedHints.raw()); 1350 else 1351 { 1352 RTMsgInfo("Detected '%s' to be:\n", szIsoPath); 1353 RTPrintf(" OS TypeId = %ls\n" 1354 " OS Version = %ls\n" 1355 " OS Flavor = %ls\n" 1356 " OS Hints = %ls\n", 1357 bstrDetectedOSTypeId.raw(), 1358 bstrDetectedVersion.raw(), 1359 bstrDetectedFlavor.raw(), 1360 bstrDetectedHints.raw()); 1361 } 1362 1363 return RTEXITCODE_SUCCESS; 1364 } 1365 1270 1366 RTEXITCODE handleUnattendedInstall(HandlerArg *a) 1271 1367 { … … 1281 1377 RTCList<RTCString> arrPackageSelectionAdjustments; 1282 1378 ComPtr<IMachine> ptrMachine; 1379 bool fDryRun = false; 1283 1380 const char *pszSessionType = "headless"; 1284 1381 … … 1286 1383 * Parse options. 1287 1384 */ 1288 if (a->argc <= 1)1289 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing VM name/UUID.");1290 1291 1385 static const RTGETOPTDEF s_aOptions[] = 1292 1386 { … … 1308 1402 { "--hostname", 'H', RTGETOPT_REQ_STRING }, 1309 1403 { "--package-selection-adjustment", 's', RTGETOPT_REQ_STRING }, 1404 { "--dry-run", 'D', RTGETOPT_REQ_NOTHING }, 1310 1405 // advance options: 1311 1406 { "--auxiliary-base-path", 'x', RTGETOPT_REQ_STRING }, … … 1331 1426 case VINF_GETOPT_NOT_OPTION: 1332 1427 if (ptrMachine.isNotNull()) 1333 return errorSyntax( USAGE_UNATTENDEDINSTALL,"VM name/UUID given more than once!");1428 return errorSyntax("VM name/UUID given more than once!"); 1334 1429 CHECK_ERROR2_RET(hrc, a->virtualBox, FindMachine(Bstr(ValueUnion.psz).raw(), ptrMachine.asOutParam()), RTEXITCODE_FAILURE); 1335 1430 CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(Machine)(ptrMachine), RTEXITCODE_FAILURE); … … 1339 1434 vrc = RTPathAbs(ValueUnion.psz, szAbsPath, sizeof(szAbsPath)); 1340 1435 if (RT_FAILURE(vrc)) 1341 return errorSyntax( USAGE_UNATTENDEDINSTALL,"RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc);1436 return errorSyntax("RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc); 1342 1437 CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(IsoPath)(Bstr(szAbsPath).raw()), RTEXITCODE_FAILURE); 1343 1438 break; … … 1368 1463 vrc = RTPathAbs(ValueUnion.psz, szAbsPath, sizeof(szAbsPath)); 1369 1464 if (RT_FAILURE(vrc)) 1370 return errorSyntax( USAGE_UNATTENDEDINSTALL,"RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc);1465 return errorSyntax("RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc); 1371 1466 CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(AdditionsIsoPath)(Bstr(szAbsPath).raw()), RTEXITCODE_FAILURE); 1372 1467 break; … … 1381 1476 vrc = RTPathAbs(ValueUnion.psz, szAbsPath, sizeof(szAbsPath)); 1382 1477 if (RT_FAILURE(vrc)) 1383 return errorSyntax( USAGE_UNATTENDEDINSTALL,"RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc);1478 return errorSyntax("RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc); 1384 1479 CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(ValidationKitIsoPath)(Bstr(szAbsPath).raw()), RTEXITCODE_FAILURE); 1385 1480 break; … … 1407 1502 case 's': // --package-selection-adjustment 1408 1503 arrPackageSelectionAdjustments.append(ValueUnion.psz); 1504 break; 1505 1506 case 'D': 1507 fDryRun = true; 1409 1508 break; 1410 1509 … … 1412 1511 vrc = RTPathAbs(ValueUnion.psz, szAbsPath, sizeof(szAbsPath)); 1413 1512 if (RT_FAILURE(vrc)) 1414 return errorSyntax( USAGE_UNATTENDEDINSTALL,"RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc);1513 return errorSyntax("RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc); 1415 1514 CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(AuxiliaryBasePath)(Bstr(szAbsPath).raw()), RTEXITCODE_FAILURE); 1416 1515 break; … … 1423 1522 vrc = RTPathAbs(ValueUnion.psz, szAbsPath, sizeof(szAbsPath)); 1424 1523 if (RT_FAILURE(vrc)) 1425 return errorSyntax( USAGE_UNATTENDEDINSTALL,"RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc);1524 return errorSyntax("RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc); 1426 1525 CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(ScriptTemplatePath)(Bstr(szAbsPath).raw()), RTEXITCODE_FAILURE); 1427 1526 break; … … 1430 1529 vrc = RTPathAbs(ValueUnion.psz, szAbsPath, sizeof(szAbsPath)); 1431 1530 if (RT_FAILURE(vrc)) 1432 return errorSyntax( USAGE_UNATTENDEDINSTALL,"RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc);1531 return errorSyntax("RTPathAbs failed on '%s': %Rrc", ValueUnion.psz, vrc); 1433 1532 CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(PostInstallScriptTemplatePath)(Bstr(szAbsPath).raw()), RTEXITCODE_FAILURE); 1434 1533 break; … … 1447 1546 1448 1547 default: 1449 return errorGetOpt( USAGE_UNATTENDEDINSTALL,c, &ValueUnion);1548 return errorGetOpt(c, &ValueUnion); 1450 1549 } 1451 1550 } … … 1455 1554 */ 1456 1555 if (ptrMachine.isNull()) 1457 return errorSyntax( USAGE_UNATTENDEDINSTALL,"Missing VM name/UUID");1556 return errorSyntax("Missing VM name/UUID"); 1458 1557 1459 1558 /* … … 1504 1603 1505 1604 CHECK_ERROR2_RET(hrc, ptrUnattended,Prepare(), RTEXITCODE_FAILURE); 1506 CHECK_ERROR2_RET(hrc, ptrUnattended,ConstructMedia(), RTEXITCODE_FAILURE); 1507 CHECK_ERROR2_RET(hrc, ptrUnattended,ReconfigureVM(), RTEXITCODE_FAILURE); 1605 if (!fDryRun) 1606 { 1607 CHECK_ERROR2_RET(hrc, ptrUnattended, ConstructMedia(), RTEXITCODE_FAILURE); 1608 CHECK_ERROR2_RET(hrc, ptrUnattended,ReconfigureVM(), RTEXITCODE_FAILURE); 1609 } 1508 1610 1509 1611 /* … … 1563 1665 * Start the VM if requested. 1564 1666 */ 1565 if (RTStrICmp(pszSessionType, "none") == 0) 1667 if ( fDryRun 1668 || RTStrICmp(pszSessionType, "none") == 0) 1566 1669 hrc = S_OK; 1567 1670 else … … 1617 1720 return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 1618 1721 } 1722 1723 1724 RTEXITCODE handleUnattended(HandlerArg *a) 1725 { 1726 /* 1727 * Sub-command switch. 1728 */ 1729 if (a->argc < 1) 1730 return errorNoSubcommand(); 1731 1732 if (!strcmp(a->argv[0], "detect")) 1733 { 1734 setCurrentSubcommand(HELP_SCOPE_UNATTENDED_DETECT); 1735 return handleUnattendedDetect(a); 1736 } 1737 1738 if (!strcmp(a->argv[0], "install")) 1739 { 1740 setCurrentSubcommand(HELP_SCOPE_UNATTENDED_INSTALL); 1741 return handleUnattendedInstall(a); 1742 } 1743 1744 /* Consider some kind of create-vm-and-install-guest-os command. */ 1745 return errorUnknownSubcommand(a->argv[0]); 1746 }
Note:
See TracChangeset
for help on using the changeset viewer.