VirtualBox

Changeset 91320 in vbox


Ignore:
Timestamp:
Sep 20, 2021 10:08:15 PM (3 years ago)
Author:
vboxsync
Message:

VBoxManageCloudMachine: reboot, powerdown, terminate. bugref:10065.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageCloudMachine.cpp

    r91319 r91320  
    7272static RTEXITCODE handleCloudMachineStart(HandlerArg *a, int iFirst,
    7373                                          const ComPtr<ICloudClient> &pClient);
     74static RTEXITCODE handleCloudMachineReboot(HandlerArg *a, int iFirst,
     75                                           const ComPtr<ICloudClient> &pClient);
    7476static RTEXITCODE handleCloudMachineShutdown(HandlerArg *a, int iFirst,
    7577                                             const ComPtr<ICloudClient> &pClient);
     78static RTEXITCODE handleCloudMachinePowerdown(HandlerArg *a, int iFirst,
     79                                              const ComPtr<ICloudClient> &pClient);
     80static RTEXITCODE handleCloudMachineTerminate(HandlerArg *a, int iFirst,
     81                                              const ComPtr<ICloudClient> &pClient);
    7682
    7783static RTEXITCODE handleCloudMachineConsoleHistory(HandlerArg *a, int iFirst,
     
    613619        kMachine_Info,
    614620        kMachine_List,
     621        kMachine_Powerdown,
     622        kMachine_Reboot,
    615623        kMachine_Shutdown,
    616624        kMachine_Start,
     625        kMachine_Terminate,
    617626    };
    618627
    619628    // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE);
    620629    static const RTGETOPTDEF s_aOptions[] =
    621         {
     630    {
    622631        { "console-history",    kMachine_ConsoleHistory,    RTGETOPT_REQ_NOTHING },
    623632        { "consolehistory",     kMachine_ConsoleHistory,    RTGETOPT_REQ_NOTHING },
    624633        { "info",               kMachine_Info,              RTGETOPT_REQ_NOTHING },
    625634        { "list",               kMachine_List,              RTGETOPT_REQ_NOTHING },
     635        { "powerdown",          kMachine_Powerdown,         RTGETOPT_REQ_NOTHING },
     636        { "reboot",             kMachine_Reboot,            RTGETOPT_REQ_NOTHING },
    626637        { "shutdown",           kMachine_Shutdown,          RTGETOPT_REQ_NOTHING },
    627638        { "start",              kMachine_Start,             RTGETOPT_REQ_NOTHING },
     639        { "terminate",          kMachine_Terminate,         RTGETOPT_REQ_NOTHING },
    628640        CLOUD_MACHINE_RTGETOPTDEF_HELP
    629641    };
     
    651663                return listCloudMachinesImpl(a, OptState.iNext, pClient);
    652664
     665            case kMachine_Powerdown:
     666                return handleCloudMachinePowerdown(a, OptState.iNext, pClient);
     667
     668            case kMachine_Reboot:
     669                return handleCloudMachineReboot(a, OptState.iNext, pClient);
     670
    653671            case kMachine_Shutdown:
    654672                return handleCloudMachineShutdown(a, OptState.iNext, pClient);
     
    656674            case kMachine_Start:
    657675                return handleCloudMachineStart(a, OptState.iNext, pClient);
     676
     677            case kMachine_Terminate:
     678                return handleCloudMachineTerminate(a, OptState.iNext, pClient);
    658679
    659680
     
    12541275
    12551276/*
     1277 * cloud machine reboot "id"
     1278 *     "Press" ACPI power button, then power the instance back up.
     1279 */
     1280static RTEXITCODE
     1281handleCloudMachineReboot(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);
     1291    if (status != RTEXITCODE_SUCCESS)
     1292        return status;
     1293
     1294
     1295    ComPtr<IProgress> pProgress;
     1296    CHECK_ERROR2_RET(hrc, pMachine,
     1297        Reboot(pProgress.asOutParam()),
     1298            RTEXITCODE_FAILURE);
     1299
     1300    hrc = showProgress(pProgress, SHOW_PROGRESS_NONE);
     1301    return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
     1302}
     1303
     1304
     1305/*
    12561306 * cloud machine shutdown "id"
     1307 *     "Press" ACPI power button.
    12571308 */
    12581309static RTEXITCODE
     
    12821333
    12831334/*
     1335 * cloud machine powerdown "id"
     1336 *     Yank the power cord.
     1337 */
     1338static RTEXITCODE
     1339handleCloudMachinePowerdown(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);
     1349    if (status != RTEXITCODE_SUCCESS)
     1350        return status;
     1351
     1352
     1353    ComPtr<IProgress> pProgress;
     1354    CHECK_ERROR2_RET(hrc, pMachine,
     1355        PowerDown(pProgress.asOutParam()),
     1356            RTEXITCODE_FAILURE);
     1357
     1358    hrc = showProgress(pProgress, SHOW_PROGRESS_NONE);
     1359    return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
     1360}
     1361
     1362
     1363/*
     1364 * cloud machine terminate "id"
     1365 *     Discard the instance running this machine.
     1366 */
     1367static RTEXITCODE
     1368handleCloudMachineTerminate(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);
     1378    if (status != RTEXITCODE_SUCCESS)
     1379        return status;
     1380
     1381
     1382    ComPtr<IProgress> pProgress;
     1383    CHECK_ERROR2_RET(hrc, pMachine,
     1384        Terminate(pProgress.asOutParam()),
     1385            RTEXITCODE_FAILURE);
     1386
     1387    hrc = showProgress(pProgress, SHOW_PROGRESS_NONE);
     1388    return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
     1389}
     1390
     1391
     1392/*
    12841393 * cloud machine console-history "id"
    12851394 */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette