Changeset 67652 in vbox for trunk/src/VBox
- Timestamp:
- Jun 27, 2017 5:59:55 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 116427
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r67619 r67652 1272 1272 * Options. 1273 1273 */ 1274 Bstr vboxAdditionsIsoPath; 1275 Bstr isoPath; 1276 Bstr user; 1277 Bstr password; 1278 Bstr productKey; 1279 Bstr auxiliaryCDPath; 1280 Bstr auxiliaryFloppyPath; 1274 Bstr bstrAdditionsIsoPath; 1275 Bstr bstrIsoPath; 1276 Bstr bstrUser; 1277 Bstr bstrPassword; 1278 Bstr bstrProductKey; 1279 Bstr bstrAuxiliaryBasePath; 1281 1280 Bstr group("group"); 1282 Bstr machineName;1283 Bstr fileWithSettings;1281 Bstr bstrMachineName; 1282 Bstr bstrSettingsFile; 1284 1283 unsigned short imageIndex = 1; // applied only to Windows installation 1285 int cSpecificOptions = 0; 1286 Bstr sessionType = "headless"; 1284 Bstr bstrSessionType = "headless"; 1287 1285 1288 1286 /* … … 1299 1297 { "--iso-path", 'i', RTGETOPT_REQ_STRING }, 1300 1298 { "--additions-iso-path", 'a', RTGETOPT_REQ_STRING }, 1301 { "--auxiliary-cd-path", 'c', RTGETOPT_REQ_STRING }, 1302 { "--auxiliary-floppy-path",'f', RTGETOPT_REQ_STRING }, 1299 { "--auxiliary-base-path", 'x', RTGETOPT_REQ_STRING }, 1303 1300 { "--image-index", 'm', RTGETOPT_REQ_UINT16 }, 1304 1301 { "--settings-file", 's', RTGETOPT_REQ_STRING }, … … 1317 1314 { 1318 1315 case VINF_GETOPT_NOT_OPTION: 1319 if ( machineName.isNotEmpty())1316 if (bstrMachineName.isNotEmpty()) 1320 1317 return errorSyntax(USAGE_UNATTENDEDINSTALL, "VM name/UUID given more than once!"); 1321 machineName = ValueUnion.psz;1322 if ( machineName.isEmpty())1318 bstrMachineName = ValueUnion.psz; 1319 if (bstrMachineName.isEmpty()) 1323 1320 return errorSyntax(USAGE_UNATTENDEDINSTALL, "VM name/UUID is empty!"); 1324 1321 break; 1325 1322 1326 case 's': // --settings-file <a file with data prepared by user> 1327 if (cSpecificOptions > 0) 1328 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--settings-file cannot be mixed with the other options"); 1329 fileWithSettings = ValueUnion.psz; 1330 cSpecificOptions = -1; 1323 case 's': // --settings-file <key value file> 1324 bstrSettingsFile = ValueUnion.psz; 1331 1325 break; 1332 1326 1333 1327 case 'u': // --user 1334 if (cSpecificOptions < 0) 1335 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--user cannot be mixed with --settings-file"); 1336 user = ValueUnion.psz; 1337 cSpecificOptions++; 1328 bstrUser = ValueUnion.psz; 1338 1329 break; 1339 1330 1340 1331 case 'p': // --password 1341 if (cSpecificOptions < 0) 1342 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--password cannot be mixed with --settings-file"); 1343 password = ValueUnion.psz; 1344 cSpecificOptions++; 1332 bstrPassword = ValueUnion.psz; 1345 1333 break; 1346 1334 1347 1335 case 'k': // --key 1348 if (cSpecificOptions < 0) 1349 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--key cannot be mixed with --settings-file"); 1350 productKey = ValueUnion.psz; 1351 cSpecificOptions++; 1336 bstrProductKey = ValueUnion.psz; 1352 1337 break; 1353 1338 1354 1339 case 'a': // --additions-iso-path 1355 if (cSpecificOptions < 0) 1356 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--additions-iso-path cannot be mixed with --settings-file"); 1357 vboxAdditionsIsoPath = ValueUnion.psz; 1358 cSpecificOptions++; 1340 bstrAdditionsIsoPath = ValueUnion.psz; 1359 1341 break; 1360 1342 1361 1343 case 'i': // --iso-path 1362 if (cSpecificOptions < 0) 1363 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--iso-path cannot be mixed with --settings-file"); 1364 isoPath = ValueUnion.psz; 1365 cSpecificOptions++; 1366 break; 1367 1368 case 'f': // --auxiliary-floppy-path 1369 if (cSpecificOptions < 0) 1370 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--auxiliary-floppy-path cannot be mixed with --settings-file"); 1371 auxiliaryFloppyPath = ValueUnion.psz; 1372 cSpecificOptions++; 1373 break; 1374 1375 case 'c': // --auxiliary-cd-path 1376 if (cSpecificOptions < 0) 1377 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--auxiliary-cd-path cannot be mixed with --settings-file"); 1378 auxiliaryCDPath = ValueUnion.psz; 1379 cSpecificOptions++; 1344 bstrIsoPath = ValueUnion.psz; 1345 break; 1346 1347 case 'x': // --auxiliary-base-path 1348 bstrAuxiliaryBasePath = ValueUnion.psz; 1380 1349 break; 1381 1350 1382 1351 case 'm': // --image-index 1383 if (cSpecificOptions < 0)1384 return errorSyntax(USAGE_UNATTENDEDINSTALL, "--image-index cannot be mixed with --settings-file");1385 1352 imageIndex = ValueUnion.u16; 1386 cSpecificOptions++;1387 1353 break; 1388 1354 1389 1355 case 'S': // --session-type 1390 sessionType = ValueUnion.psz;1356 bstrSessionType = ValueUnion.psz; 1391 1357 break; 1392 1358 … … 1399 1365 * Check for required stuff. 1400 1366 */ 1401 if ( machineName.isEmpty())1367 if (bstrMachineName.isEmpty()) 1402 1368 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing VM name/UUID"); 1403 1369 1404 if (cSpecificOptions > 0) 1405 { 1406 if (user.isEmpty()) 1407 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --user option"); 1408 if (password.isEmpty()) 1409 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --password option"); 1410 if (isoPath.isEmpty()) 1411 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --iso-path option"); 1412 } 1413 else if (fileWithSettings.isEmpty()) 1414 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Requires either --file or --user & --password & --iso-path"); 1370 if (bstrSettingsFile.isEmpty()) 1371 { 1372 if (bstrUser.isEmpty()) 1373 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --user (or --settings-file) option"); 1374 if (bstrPassword.isEmpty()) 1375 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --password (or --settings-file) option"); 1376 if (bstrIsoPath.isEmpty()) 1377 return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --iso-path (or --settings-file) option"); 1378 } 1415 1379 1416 1380 /* … … 1421 1385 HRESULT rc; 1422 1386 ComPtr<IMachine> machine; 1423 CHECK_ERROR(a->virtualBox, FindMachine( machineName.raw(), machine.asOutParam()));1387 CHECK_ERROR(a->virtualBox, FindMachine(bstrMachineName.raw(), machine.asOutParam())); 1424 1388 if (FAILED(rc)) 1425 1389 return RTEXITCODE_FAILURE; 1426 1390 1427 CHECK_ERROR_RET(machine, COMGETTER(Name)( machineName.asOutParam()), RTEXITCODE_FAILURE);1391 CHECK_ERROR_RET(machine, COMGETTER(Name)(bstrMachineName.asOutParam()), RTEXITCODE_FAILURE); 1428 1392 Bstr bstrUuid; 1429 1393 CHECK_ERROR_RET(machine, COMGETTER(Id)(bstrUuid.asOutParam()), RTEXITCODE_FAILURE); … … 1435 1399 CHECK_ERROR(a->session, COMGETTER(Console)(console.asOutParam())); 1436 1400 if (console) 1437 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Machine '%ls' is currently running", machineName.raw());1401 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Machine '%ls' is currently running", bstrMachineName.raw()); 1438 1402 1439 1403 /* ... and session machine */ … … 1451 1415 "UUID: %s\n", 1452 1416 strInstalledOS.c_str(), 1453 machineName.raw(),1417 bstrMachineName.raw(), 1454 1418 Utf8Str(bstrUuid).c_str()); 1455 1419 … … 1460 1424 CHECK_ERROR_BREAK(machine, COMGETTER(Unattended)(unAttended.asOutParam())); 1461 1425 1462 if (fileWithSettings.isEmpty())//may use also this condition (!strcmp(a->argv[1], "usedata")) 1463 { 1464 CHECK_ERROR_BREAK(unAttended, COMSETTER(Group)(group.raw())); 1465 1466 if (strInstalledOS.contains("Windows") && productKey.isEmpty()) 1467 return errorSyntax(USAGE_UNATTENDEDINSTALL, "A product key is required (--key)."); 1468 1469 CHECK_ERROR_BREAK(unAttended, COMSETTER(IsoPath)(isoPath.raw())); 1470 CHECK_ERROR_BREAK(unAttended, COMSETTER(User)(user.raw())); 1471 CHECK_ERROR_BREAK(unAttended, COMSETTER(Password)(password.raw())); 1472 CHECK_ERROR_BREAK(unAttended, COMSETTER(ProductKey)(productKey.raw())); 1473 CHECK_ERROR_BREAK(unAttended, COMSETTER(AuxiliaryCDPath)(auxiliaryCDPath.raw())); 1474 CHECK_ERROR_BREAK(unAttended, COMSETTER(AuxiliaryFloppyPath)(auxiliaryFloppyPath.raw())); 1475 CHECK_ERROR_BREAK(unAttended, COMSETTER(AdditionsIsoPath)(vboxAdditionsIsoPath.raw())); 1476 CHECK_ERROR_BREAK(unAttended, COMSETTER(InstallGuestAdditions)(vboxAdditionsIsoPath.isNotEmpty())); 1477 CHECK_ERROR_BREAK(unAttended, COMSETTER(ImageIndex)(imageIndex)); 1478 CHECK_ERROR_BREAK(unAttended,Preparation()); 1479 CHECK_ERROR_BREAK(unAttended,ConstructScript()); 1480 CHECK_ERROR_BREAK(unAttended,ConstructMedia()); 1481 } 1482 else 1483 { 1484 CHECK_ERROR_BREAK(unAttended, COMSETTER(FileWithPreparedData)(fileWithSettings.raw())); 1485 CHECK_ERROR_BREAK(unAttended,Preparation()); 1486 } 1487 CHECK_ERROR_BREAK(unAttended,ReconstructVM()); 1488 CHECK_ERROR_BREAK(unAttended,RunInstallation()); 1426 if (bstrSettingsFile.isNotEmpty()) 1427 CHECK_ERROR_BREAK(unAttended, LoadSettings(bstrSettingsFile.raw())); 1428 1429 CHECK_ERROR_BREAK(unAttended, COMSETTER(Group)(group.raw())); 1430 CHECK_ERROR_BREAK(unAttended, COMSETTER(IsoPath)(bstrIsoPath.raw())); 1431 CHECK_ERROR_BREAK(unAttended, COMSETTER(User)(bstrUser.raw())); 1432 CHECK_ERROR_BREAK(unAttended, COMSETTER(Password)(bstrPassword.raw())); 1433 CHECK_ERROR_BREAK(unAttended, COMSETTER(ProductKey)(bstrProductKey.raw())); 1434 CHECK_ERROR_BREAK(unAttended, COMSETTER(AdditionsIsoPath)(bstrAdditionsIsoPath.raw())); 1435 CHECK_ERROR_BREAK(unAttended, COMSETTER(InstallGuestAdditions)(bstrAdditionsIsoPath.isNotEmpty())); 1436 CHECK_ERROR_BREAK(unAttended, COMSETTER(ImageIndex)(imageIndex)); 1437 CHECK_ERROR_BREAK(unAttended, COMSETTER(AuxiliaryBasePath)(bstrAuxiliaryBasePath.raw())); 1438 1439 CHECK_ERROR_BREAK(unAttended,Prepare()); 1440 CHECK_ERROR_BREAK(unAttended,ConstructScript()); 1441 CHECK_ERROR_BREAK(unAttended,ConstructMedia()); 1442 CHECK_ERROR_BREAK(unAttended,ReconfigureVM()); 1443 CHECK_ERROR_BREAK(unAttended,Done()); 1489 1444 1490 1445 … … 1509 1464 #endif 1510 1465 ComPtr<IProgress> progress; 1511 CHECK_ERROR(machine, LaunchVMProcess(a->session, sessionType.raw(), env.raw(), progress.asOutParam()));1466 CHECK_ERROR(machine, LaunchVMProcess(a->session, bstrSessionType.raw(), env.raw(), progress.asOutParam())); 1512 1467 if (SUCCEEDED(rc) && !progress.isNull()) 1513 1468 { … … 1543 1498 * Retrieve and display the parameters actually used. 1544 1499 */ 1545 CHECK_ERROR_BREAK(unAttended, COMGETTER(FileWithPreparedData)(fileWithSettings.asOutParam()));1546 1500 CHECK_ERROR_BREAK(unAttended, COMGETTER(Group)(group.asOutParam())); 1547 CHECK_ERROR_BREAK(unAttended, COMGETTER(AdditionsIsoPath)( vboxAdditionsIsoPath.asOutParam()));1501 CHECK_ERROR_BREAK(unAttended, COMGETTER(AdditionsIsoPath)(bstrAdditionsIsoPath.asOutParam())); 1548 1502 BOOL fInstallGuestAdditions = FALSE; 1549 1503 CHECK_ERROR_BREAK(unAttended, COMGETTER(InstallGuestAdditions)(&fInstallGuestAdditions)); 1550 CHECK_ERROR_BREAK(unAttended, COMGETTER(IsoPath)(isoPath.asOutParam())); 1551 CHECK_ERROR_BREAK(unAttended, COMGETTER(User)(user.asOutParam())); 1552 CHECK_ERROR_BREAK(unAttended, COMGETTER(Password)(password.asOutParam())); 1553 CHECK_ERROR_BREAK(unAttended, COMGETTER(ProductKey)(productKey.asOutParam())); 1554 CHECK_ERROR_BREAK(unAttended, COMGETTER(AuxiliaryCDPath)(auxiliaryCDPath.asOutParam())); 1555 CHECK_ERROR_BREAK(unAttended, COMGETTER(AuxiliaryFloppyPath)(auxiliaryFloppyPath.asOutParam())); 1504 CHECK_ERROR_BREAK(unAttended, COMGETTER(IsoPath)(bstrIsoPath.asOutParam())); 1505 CHECK_ERROR_BREAK(unAttended, COMGETTER(User)(bstrUser.asOutParam())); 1506 CHECK_ERROR_BREAK(unAttended, COMGETTER(Password)(bstrPassword.asOutParam())); 1507 CHECK_ERROR_BREAK(unAttended, COMGETTER(ProductKey)(bstrProductKey.asOutParam())); 1508 CHECK_ERROR_BREAK(unAttended, COMGETTER(AuxiliaryBasePath)(bstrAuxiliaryBasePath.asOutParam())); 1556 1509 imageIndex = 0; 1557 1510 CHECK_ERROR_BREAK(unAttended, COMGETTER(ImageIndex)(&imageIndex)); 1558 1511 RTPrintf("Got values:\n" 1559 " fileWithSettings: %s\n " 1560 " user: %s\n" 1561 " password: %s\n" 1562 " productKey: %s\n" 1512 " user: %ls\n" 1513 " password: %ls\n" 1514 " productKey: %ls\n" 1563 1515 " image index: %u\n" 1564 " isoPath: % s\n"1565 " vboxAdditionsIsoPath: %s\n"1516 " isoPath: %ls\n" 1517 " additionsIsoPath: %ls\n" 1566 1518 " installGuestAdditions: %RTbool", 1567 Utf8Str(fileWithSettings).c_str(),1568 Utf8Str(user).c_str(),1569 Utf8Str(password).c_str(),1570 Utf8Str(productKey).c_str(),1519 " auxiliaryBasePath: %ls", 1520 bstrUser.raw(), 1521 bstrPassword.raw(), 1522 bstrProductKey.raw(), 1571 1523 imageIndex, 1572 Utf8Str(isoPath).c_str(), 1573 Utf8Str(vboxAdditionsIsoPath).c_str(), 1574 fInstallGuestAdditions); 1524 bstrIsoPath.raw(), 1525 bstrAdditionsIsoPath.raw(), 1526 fInstallGuestAdditions, 1527 bstrAuxiliaryBasePath.raw()); 1575 1528 } while (0); 1576 1529 … … 1578 1531 "UUID: %ls\n", 1579 1532 strInstalledOS.c_str(), 1580 machineName.raw(),1533 bstrMachineName.raw(), 1581 1534 bstrUuid.raw()); 1582 1535 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r67620 r67652 3767 3767 <interface 3768 3768 name="IUnattended" extends="$unknown" 3769 uuid=" 47f28e07-4cb5-4d24-1e1f-42f827f70fb0"3769 uuid="cc3e4bc1-2cb1-4ac7-f26b-dedf01dd24a9" 3770 3770 wsmap="managed" 3771 3771 reservedMethods="4" reservedAttributes="4" … … 3826 3826 </attribute> 3827 3827 3828 <attribute name="auxiliaryCDPath" type="wstring"> 3829 <desc> 3830 The path of any auxiliary CD image we might be creating. Related 3831 temporary files will appear in the same directory. 3832 </desc> 3833 </attribute> 3834 3835 <attribute name="auxiliaryFloppyPath" type="wstring"> 3836 <desc> 3837 Where to store the auxiliary floppy we might be creating. 3828 <attribute name="auxiliaryBasePath" type="wstring"> 3829 <desc> 3830 The path + basename for auxiliary files generated by the unattended 3831 installation. This defaults to the VM folder + Unattended + VM UUID. 3832 3833 The files which gets generated depends on the OS being installed. When 3834 installing Windows there is currently only a auxiliaryBasePath + "floppy.img" 3835 being created. But for linux, a "cdrom.viso" and one or more configuration 3836 files are generate generated. 3838 3837 </desc> 3839 3838 </attribute> … … 3846 3845 </attribute> 3847 3846 3848 <attribute name="fileWithPreparedData" type="wstring"> 3849 <!-- bird: Would make more sense to make this a method for loading settings from a given file, i.e. 3850 immediate feedback and ability to tweak it afterwards. --> 3851 <desc> 3852 A path to the file with data prepared by user. 3853 The internal rule is "name = value" like "isoPath = /correct/path/to/the/iso" 3854 One line - one parameter 3855 </desc> 3856 </attribute> 3857 3858 <method name="preparation"> 3859 <desc> 3860 Preparation for running the unattended process of installation 3847 <method name="loadSettings"> 3848 <desc> 3849 Loads attributes from a file. 3850 3851 The internal rule is "attribute = value" like for instance 3852 "isoPath = /correct/path/to/the/iso". One line - one parameter. 3853 </desc> 3854 3855 <param name="filename" type="wstring" dir="in"> 3856 <desc>File path.</desc> 3857 </param> 3858 </method> 3859 3860 <method name="prepare"> 3861 <desc> 3862 Prepare for running the unattended process of installation. 3861 3863 </desc> 3862 3864 </method> … … 3876 3878 </method> 3877 3879 3878 <method name="recon structVM">3880 <method name="reconfigureVM"> 3879 3881 <desc> 3880 3882 Prepare a newly created VM to start unattended installation … … 3883 3885 </method> 3884 3886 3885 <method name="runInstallation"> 3886 <desc> 3887 Run unattended installation 3887 <method name="done"> 3888 <desc> 3889 This flushes the settings and whatever else might be open before the 3890 caller launches the VM. 3888 3891 </desc> 3889 3892 </method>
Note:
See TracChangeset
for help on using the changeset viewer.