VirtualBox

Changeset 91338 in vbox for trunk/src


Ignore:
Timestamp:
Sep 23, 2021 12:21:53 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147005
Message:

VBoxManageCloudMachine: bugref:10065. Refactor the code some more.
Extend HandlerArg to carry the stuff we need instead of passing around
a bunch of arguments.

While here accept machie spec after "machine" too. In that position
an explicit --id/--name option is required for the obvious reason.
We will also check for these options and machine spec as a plain words
argument after the command word, so user can use either of:

VBoxManage cloud ... machine --name foo start
VBoxManage cloud ... machine start --name foo
VBoxManage cloud ... machine start foo

where the first form is easier to wrap into a convenience shell
function.

File:
1 edited

Legend:

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

    r91320 r91338  
    2828
    2929
     30struct CMachineHandlerArg
     31  : public HandlerArg
     32{
     33    ComPtr<ICloudClient> pClient;
     34
     35    const char *pcszSpec;   /* RTGETOPTUNION::psz, points inside argv */
     36    enum { GUESS, ID, NAME } enmSpecKind;
     37    ComPtr<ICloudMachine> pMachine;
     38
     39    explicit CMachineHandlerArg(const HandlerArg &a)
     40      : HandlerArg(a), pcszSpec(NULL), enmSpecKind(GUESS) {}
     41};
     42
     43
    3044static int selectCloudProvider(ComPtr<ICloudProvider> &pProvider,
    3145                               const ComPtr<IVirtualBox> &pVirtualBox,
     
    3448                              const ComPtr<ICloudProvider> &pProvider,
    3549                              const char *pszProviderName);
    36 static int getCloudClient(ComPtr<ICloudClient> &aClient,
    37                           HandlerArg *a,
     50static int getCloudClient(CMachineHandlerArg &a,
    3851                          const char *pcszProviderName,
    3952                          const char *pcszProfileName);
     
    4255                              const ComPtr<ICloudClient> &pClient);
    4356
    44 static HRESULT getMachineById(ComPtr<ICloudMachine> &pMachineOut,
    45                               const ComPtr<ICloudClient> &pClient,
    46                               const char *pcszId);
    47 static HRESULT getMachineByName(ComPtr<ICloudMachine> &pMachineOut,
    48                                 const ComPtr<ICloudClient> &pClient,
    49                                 const char *pcszName);
    50 static HRESULT getMachineByGuess(ComPtr<ICloudMachine> &pMachineOut,
    51                                  const ComPtr<ICloudClient> &pClient,
    52                                  const char *pcszWhatever);
    53 
    54 struct MachineSpec {
    55     const char *pcszSpec;
    56     enum { GUESS, ID, NAME } enmKind;
    57 
    58     MachineSpec()
    59       : pcszSpec(NULL), enmKind(GUESS) {}
    60 };
    61 
    62 static int checkMachineSpecArgument(MachineSpec &aMachineSpec,
     57static HRESULT getMachineBySpec(CMachineHandlerArg *a);
     58static HRESULT getMachineById(CMachineHandlerArg *a);
     59static HRESULT getMachineByName(CMachineHandlerArg *a);
     60static HRESULT getMachineByGuess(CMachineHandlerArg *a);
     61
     62static int checkMachineSpecArgument(CMachineHandlerArg *a,
    6363                                    int ch, const RTGETOPTUNION &Val);
    64 static HRESULT getMachineBySpec(ComPtr<ICloudMachine> &pMachineOut,
    65                                 const ComPtr<ICloudClient> &pClient,
    66                                 const MachineSpec &aMachineSpec);
    67 
    68 
    69 static RTEXITCODE handleCloudMachineImpl(HandlerArg *a, int iFirst,
    70                                          const ComPtr<ICloudClient> &pClient);
    71 
    72 static RTEXITCODE handleCloudMachineStart(HandlerArg *a, int iFirst,
    73                                           const ComPtr<ICloudClient> &pClient);
    74 static RTEXITCODE handleCloudMachineReboot(HandlerArg *a, int iFirst,
    75                                            const ComPtr<ICloudClient> &pClient);
    76 static RTEXITCODE handleCloudMachineShutdown(HandlerArg *a, int iFirst,
    77                                              const ComPtr<ICloudClient> &pClient);
    78 static RTEXITCODE handleCloudMachinePowerdown(HandlerArg *a, int iFirst,
    79                                               const ComPtr<ICloudClient> &pClient);
    80 static RTEXITCODE handleCloudMachineTerminate(HandlerArg *a, int iFirst,
    81                                               const ComPtr<ICloudClient> &pClient);
    82 
    83 static RTEXITCODE handleCloudMachineConsoleHistory(HandlerArg *a, int iFirst,
    84                                                    const ComPtr<ICloudClient> &pClient);
    85 
    86 static RTEXITCODE listCloudMachinesImpl(HandlerArg *a, int iFirst,
    87                                         const ComPtr<ICloudClient> &pClient);
    88 static RTEXITCODE handleCloudMachineInfo(HandlerArg *a, int iFirst,
    89                                           const ComPtr<ICloudClient> &pClient);
     64
     65
     66static RTEXITCODE handleCloudMachineImpl(CMachineHandlerArg *a, int iFirst);
     67
     68static RTEXITCODE handleCloudMachineStart(CMachineHandlerArg *a, int iFirst);
     69static RTEXITCODE handleCloudMachineReboot(CMachineHandlerArg *a, int iFirst);
     70static RTEXITCODE handleCloudMachineShutdown(CMachineHandlerArg *a, int iFirst);
     71static RTEXITCODE handleCloudMachinePowerdown(CMachineHandlerArg *a, int iFirst);
     72static RTEXITCODE handleCloudMachineTerminate(CMachineHandlerArg *a, int iFirst);
     73
     74static RTEXITCODE handleCloudMachineConsoleHistory(CMachineHandlerArg *a, int iFirst);
     75
     76static RTEXITCODE listCloudMachinesImpl(CMachineHandlerArg *a, int iFirst);
     77static RTEXITCODE handleCloudMachineInfo(CMachineHandlerArg *a, int iFirst);
    9078
    9179static HRESULT printMachineInfo(const ComPtr<ICloudMachine> &pMachine);
     
    119107                   const char *pcszProfileName)
    120108{
    121     ComPtr<ICloudClient> pClient;
    122     int rc = getCloudClient(pClient, a, pcszProviderName, pcszProfileName);
     109    CMachineHandlerArg handlerArg(*a);
     110    int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName);
    123111    if (RT_FAILURE(rc))
    124112        return RTEXITCODE_FAILURE;
    125113
    126     return handleCloudMachineImpl(a, iFirst, pClient);
     114    return handleCloudMachineImpl(&handlerArg, iFirst);
    127115}
    128116
     
    257245
    258246static int
    259 getCloudClient(ComPtr<ICloudClient> &aCloudClient,
    260                 HandlerArg *a,
     247getCloudClient(CMachineHandlerArg &a,
    261248                const char *pcszProviderName,
    262249                const char *pcszProfileName)
     
    266253
    267254    ComPtr<ICloudProvider> pProvider;
    268     rc = selectCloudProvider(pProvider, a->virtualBox, pcszProviderName);
     255    rc = selectCloudProvider(pProvider, a.virtualBox, pcszProviderName);
    269256    if (RT_FAILURE(rc))
    270257        return rc;
     
    280267            VERR_GENERAL_FAILURE);
    281268
    282     aCloudClient = pCloudClient;
     269    a.pClient = pCloudClient;
    283270    return VINF_SUCCESS;
    284271}
     
    309296
    310297static HRESULT
    311 getMachineById(ComPtr<ICloudMachine> &pMachineOut,
    312                const ComPtr<ICloudClient> &pClient,
    313                const char *pcszId)
     298getMachineById(CMachineHandlerArg *a)
    314299{
    315300    HRESULT hrc;
    316301
    317302    ComPtr<ICloudMachine> pMachine;
    318     CHECK_ERROR2_RET(hrc, pClient,
    319         GetCloudMachine(com::Bstr(pcszId).raw(),
     303    CHECK_ERROR2_RET(hrc, a->pClient,
     304        GetCloudMachine(com::Bstr(a->pcszSpec).raw(),
    320305                        pMachine.asOutParam()), hrc);
    321306
     
    328313        return hrc;
    329314
    330     pMachineOut = pMachine;
     315    a->pMachine = pMachine;
    331316    return S_OK;
    332317}
     
    334319
    335320static HRESULT
    336 getMachineByName(ComPtr<ICloudMachine> &pMachineOut,
    337                  const ComPtr<ICloudClient> &pClient,
    338                  const char *pcszName)
     321getMachineByName(CMachineHandlerArg *a)
    339322{
    340323    HRESULT hrc;
    341324
    342325    com::SafeIfaceArray<ICloudMachine> aMachines;
    343     hrc = getMachineList(aMachines, pClient);
     326    hrc = getMachineList(aMachines, a->pClient);
    344327    if (FAILED(hrc))
    345328        return hrc;
     
    359342                hrc);
    360343
    361         if (!bstrName.equals(pcszName))
     344        if (!bstrName.equals(a->pcszSpec))
    362345            continue;
    363346
     
    384367        return VBOX_E_OBJECT_NOT_FOUND;
    385368
    386     pMachineOut = pMachineFound;
     369    a->pMachine = pMachineFound;
    387370    return S_OK;
    388371}
     
    398381 */
    399382static HRESULT
    400 getMachineByGuess(ComPtr<ICloudMachine> &pMachineOut,
    401                   const ComPtr<ICloudClient> &pClient,
    402                   const char *pcszWhatever)
    403 {
    404     ComPtr<ICloudMachine> pMachine;
    405 
     383getMachineByGuess(CMachineHandlerArg *a)
     384{
    406385    HRESULT hrc;
    407386
    408387    RTUUID Uuid;
    409     int rc = RTUuidFromStr(&Uuid, pcszWhatever);
     388    int rc = RTUuidFromStr(&Uuid, a->pcszSpec);
    410389    if (RT_SUCCESS(rc))
    411         hrc = getMachineById(pMachine, pClient, pcszWhatever);
     390        hrc = getMachineById(a);
    412391    else
    413         hrc = getMachineByName(pMachine, pClient, pcszWhatever);
     392        hrc = getMachineByName(a);
    414393
    415394    if (FAILED(hrc))
    416395        return hrc;
    417396
    418     pMachineOut = pMachine;
    419397    return S_OK;
    420398}
     
    456434 */
    457435static int
    458 checkMachineSpecArgument(MachineSpec &aMachineSpec,
     436checkMachineSpecArgument(CMachineHandlerArg *a,
    459437                         int ch, const RTGETOPTUNION &Val)
    460438{
     
    475453            const char *pcszId = Val.psz;
    476454
    477             if (aMachineSpec.pcszSpec != NULL)
     455            if (a->pcszSpec != NULL)
    478456            {
    479457                errThereCanBeOnlyOne();
     
    489467            }
    490468
    491             aMachineSpec.pcszSpec = pcszId;
    492             aMachineSpec.enmKind = MachineSpec::ID;
     469            a->pcszSpec = pcszId;
     470            a->enmSpecKind = CMachineHandlerArg::ID;
    493471            return VINF_SUCCESS;
    494472        }
     
    498476            const char *pcszName = Val.psz;
    499477
    500             if (aMachineSpec.pcszSpec != NULL)
     478            if (a->pcszSpec != NULL)
    501479            {
    502480                errThereCanBeOnlyOne();
     
    504482            }
    505483
    506             aMachineSpec.pcszSpec = pcszName;
    507             aMachineSpec.enmKind = MachineSpec::NAME;
     484            a->pcszSpec = pcszName;
     485            a->enmSpecKind = CMachineHandlerArg::NAME;
    508486            return VINF_SUCCESS;
    509487        }
     
    517495            const char *pcszNameOrId = Val.psz;
    518496
    519             if (aMachineSpec.pcszSpec != NULL)
     497            if (a->pcszSpec != NULL)
    520498            {
    521499                errThereCanBeOnlyOne();
     
    523501            }
    524502
    525             aMachineSpec.pcszSpec = pcszNameOrId;
    526             aMachineSpec.enmKind = MachineSpec::GUESS;
     503            a->pcszSpec = pcszNameOrId;
     504            a->enmSpecKind = CMachineHandlerArg::GUESS;
    527505            return VINF_SUCCESS;
    528506        }
     
    542520
    543521static HRESULT
    544 getMachineBySpec(ComPtr<ICloudMachine> &pMachineOut,
    545                  const ComPtr<ICloudClient> &pClient,
    546                  const MachineSpec &aMachineSpec)
     522getMachineBySpec(CMachineHandlerArg *a)
    547523{
    548524    HRESULT hrc = E_FAIL;
    549525
    550     if (aMachineSpec.pcszSpec == NULL)
     526    if (a->pcszSpec == NULL)
    551527    {
    552528        RTMsgErrorExit(RTEXITCODE_SYNTAX, "machine not specified");
     
    554530    }
    555531
    556     if (aMachineSpec.pcszSpec[0] == '\0')
     532    if (a->pcszSpec[0] == '\0')
    557533    {
    558534        RTMsgError("machine name is empty");
     
    560536    }
    561537
    562     switch (aMachineSpec.enmKind)
    563     {
    564         case MachineSpec::ID:
    565             hrc = getMachineById(pMachineOut, pClient, aMachineSpec.pcszSpec);
     538    switch (a->enmSpecKind)
     539    {
     540        case CMachineHandlerArg::ID:
     541            hrc = getMachineById(a);
    566542            if (FAILED(hrc))
    567543            {
    568544                if (hrc == VBOX_E_OBJECT_NOT_FOUND)
    569                     RTMsgError("unable to find machine with id %s", aMachineSpec.pcszSpec);
     545                    RTMsgError("unable to find machine with id %s", a->pcszSpec);
    570546                return hrc;
    571547            }
    572548            break;
    573549
    574         case MachineSpec::NAME:
    575             hrc = getMachineByName(pMachineOut, pClient, aMachineSpec.pcszSpec);
     550        case CMachineHandlerArg::NAME:
     551            hrc = getMachineByName(a);
    576552            if (FAILED(hrc))
    577553            {
    578554                if (hrc == VBOX_E_OBJECT_NOT_FOUND)
    579                     RTMsgError("unable to find machine with name %s", aMachineSpec.pcszSpec);
     555                    RTMsgError("unable to find machine with name %s", a->pcszSpec);
    580556                return hrc;
    581557            }
    582558            break;
    583559
    584         case MachineSpec::GUESS:
    585             hrc = getMachineByGuess(pMachineOut, pClient, aMachineSpec.pcszSpec);
     560        case CMachineHandlerArg::GUESS:
     561            hrc = getMachineByGuess(a);
    586562            if (FAILED(hrc))
    587563            {
    588564                if (hrc == VBOX_E_OBJECT_NOT_FOUND)
    589                     RTMsgError("unable to find machine %s", aMachineSpec.pcszSpec);
     565                    RTMsgError("unable to find machine %s", a->pcszSpec);
    590566                return hrc;
    591567            }
     
    602578
    603579/*
    604  * cloud machine ...
     580 * cloud machine [--id id | --name name] command ...
    605581 *
    606  * The "cloud" prefix handling is in VBoxManageCloud.cpp, so this
    607  * function is not static.
     582 * We allow machine to be specified after "machine" but only with an
     583 * explicit option for the obvious reason.  We will also check for
     584 * these options and machine spec as a plain words argument after the
     585 * command word, so user can use either of:
     586 *
     587 *   cloud machine --name foo start
     588 *   cloud machine start --name foo
     589 *   cloud machine start foo
     590 *
     591 * This will accept e.g.  cloud machine --name foo list ... b/c we
     592 * don't yet know that it's "list" that is coming, so commands that
     593 * don't take machine argument check that separately when called.  One
     594 * side effect of this is that specifying several machines or using a
     595 * syntactically invalid id will be reported as such, not as an
     596 * unknown option, but that's a relatively minor nit.
    608597 */
    609598static RTEXITCODE
    610 handleCloudMachineImpl(HandlerArg *a, int iFirst,
    611                        const ComPtr<ICloudClient> &pClient)
     599handleCloudMachineImpl(CMachineHandlerArg *a, int iFirst)
    612600{
    613601    int rc;
     
    638626        { "start",              kMachine_Start,             RTGETOPT_REQ_NOTHING },
    639627        { "terminate",          kMachine_Terminate,         RTGETOPT_REQ_NOTHING },
     628        CLOUD_MACHINE_RTGETOPTDEF_MACHINE,
    640629        CLOUD_MACHINE_RTGETOPTDEF_HELP
    641630    };
     
    652641    while ((ch = RTGetOpt(&OptState, &Val)) != 0)
    653642    {
     643        if (RT_FAILURE(ch))
     644            return RTGetOptPrintError(ch, &Val);
     645
     646        /*
     647         * Check for an unknown word first: checkMachineSpecArgument()
     648         * would try to interpret that as a machine id/name.
     649         */
     650        if (ch == VINF_GETOPT_NOT_OPTION)
     651            return RTMsgErrorExit(RTEXITCODE_SYNTAX,
     652                       "Invalid sub-command: %s", Val.psz);
     653
     654        /*
     655         * Allow --id/--name after "machine", before the command.
     656         * Also handles --help.
     657         */
     658        rc = checkMachineSpecArgument(a, ch, Val);
     659        if (rc == VINF_SUCCESS)
     660            continue;
     661        else if (rc == VINF_CALLBACK_RETURN)
     662            return RTEXITCODE_SUCCESS;
     663        else if (rc == VERR_PARSE_ERROR)
     664            return RTEXITCODE_SYNTAX;
     665
     666        /*
     667         * Dispatch to command implementation ([ab]use getopt to do
     668         * string comparisons for us).
     669         */
    654670        switch (ch)
    655671        {
    656672            case kMachine_ConsoleHistory:
    657                 return handleCloudMachineConsoleHistory(a, OptState.iNext, pClient);
     673                return handleCloudMachineConsoleHistory(a, OptState.iNext);
    658674
    659675            case kMachine_Info:
    660                 return handleCloudMachineInfo(a, OptState.iNext, pClient);
     676                return handleCloudMachineInfo(a, OptState.iNext);
    661677
    662678            case kMachine_List:
    663                 return listCloudMachinesImpl(a, OptState.iNext, pClient);
     679                return listCloudMachinesImpl(a, OptState.iNext);
    664680
    665681            case kMachine_Powerdown:
    666                 return handleCloudMachinePowerdown(a, OptState.iNext, pClient);
     682                return handleCloudMachinePowerdown(a, OptState.iNext);
    667683
    668684            case kMachine_Reboot:
    669                 return handleCloudMachineReboot(a, OptState.iNext, pClient);
     685                return handleCloudMachineReboot(a, OptState.iNext);
    670686
    671687            case kMachine_Shutdown:
    672                 return handleCloudMachineShutdown(a, OptState.iNext, pClient);
     688                return handleCloudMachineShutdown(a, OptState.iNext);
    673689
    674690            case kMachine_Start:
    675                 return handleCloudMachineStart(a, OptState.iNext, pClient);
     691                return handleCloudMachineStart(a, OptState.iNext);
    676692
    677693            case kMachine_Terminate:
    678                 return handleCloudMachineTerminate(a, OptState.iNext, pClient);
    679 
    680 
    681             case 'h':           /* --help */
    682                 printHelp(g_pStdOut);
    683                 return RTEXITCODE_SUCCESS;
    684 
    685 
    686             case VINF_GETOPT_NOT_OPTION:
    687                 return RTMsgErrorExit(RTEXITCODE_SYNTAX,
    688                            "Invalid sub-command: %s", Val.psz);
    689 
    690             default:
    691                 return RTGetOptPrintError(ch, &Val);
     694                return handleCloudMachineTerminate(a, OptState.iNext);
     695
     696            default:            /* should never happen */
     697                return RTMsgErrorExit(RTEXITCODE_INIT,
     698                           "cloud machine: internal error: %d", ch);
    692699        }
    693700    }
     
    711718                  const char *pcszProfileName)
    712719{
    713     int rc;
    714 
    715     ComPtr<ICloudClient> pClient;
    716     rc = getCloudClient(pClient, a, pcszProviderName, pcszProfileName);
     720    CMachineHandlerArg handlerArg(*a);
     721    int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName);
    717722    if (RT_FAILURE(rc))
    718723        return RTEXITCODE_FAILURE;
    719724
    720     return listCloudMachinesImpl(a, iFirst, pClient);
     725    return listCloudMachinesImpl(&handlerArg, iFirst);
    721726}
    722727
     
    727732 */
    728733static RTEXITCODE
    729 listCloudMachinesImpl(HandlerArg *a, int iFirst,
    730                       const ComPtr<ICloudClient> &pClient)
     734listCloudMachinesImpl(CMachineHandlerArg *a, int iFirst)
    731735{
    732736    HRESULT hrc;
     
    746750    enum kSortOrderEnum { kSortOrder_None, kSortOrder_Name, kSortOrder_Id };
    747751    kSortOrderEnum enmSortOrder = kSortOrder_None;
     752
     753    if (a->pcszSpec != NULL)
     754        return RTMsgErrorExit(RTEXITCODE_SYNTAX,
     755                   "cloud machine list: unexpected machine argument");
     756
    748757
    749758    RTGETOPTSTATE OptState;
     
    784793
    785794    com::SafeIfaceArray<ICloudMachine> aMachines;
    786     hrc = getMachineList(aMachines, pClient);
     795    hrc = getMachineList(aMachines, a->pClient);
    787796    if (FAILED(hrc))
    788797        return RTEXITCODE_FAILURE;
     
    875884                      const char *pcszProfileName)
    876885{
    877     int rc;
    878 
    879     ComPtr<ICloudClient> pClient;
    880     rc = getCloudClient(pClient, a, pcszProviderName, pcszProfileName);
     886    CMachineHandlerArg handlerArg(*a);
     887    int rc = getCloudClient(handlerArg, pcszProviderName, pcszProfileName);
    881888    if (RT_FAILURE(rc))
    882889        return RTEXITCODE_FAILURE;
    883890
    884     return handleCloudMachineInfo(a, iFirst, pClient);
     891    return handleCloudMachineInfo(&handlerArg, iFirst);
    885892}
    886893
     
    890897 */
    891898static RTEXITCODE
    892 handleCloudMachineInfo(HandlerArg *a, int iFirst,
    893                        const ComPtr<ICloudClient> &pClient)
    894 {
    895     MachineSpec machineSpec;
    896     ComPtr<ICloudMachine> pMachine;
     899handleCloudMachineInfo(CMachineHandlerArg *a, int iFirst)
     900{
    897901    HRESULT hrc;
    898902    int rc;
     
    923927    while ((ch = RTGetOpt(&OptState, &Val)) != 0)
    924928    {
    925         rc = checkMachineSpecArgument(machineSpec, ch, Val);
     929        rc = checkMachineSpecArgument(a, ch, Val);
    926930        if (rc == VINF_SUCCESS)
    927931            continue;
     
    942946    }
    943947
    944     hrc = getMachineBySpec(pMachine, pClient, machineSpec);
     948    hrc = getMachineBySpec(a);
    945949    if (FAILED(hrc))
    946950        return RTEXITCODE_FAILURE;
     
    949953
    950954
    951     hrc = printMachineInfo(pMachine);
     955    hrc = printMachineInfo(a->pMachine);
    952956    if (FAILED(hrc))
    953957        return RTEXITCODE_FAILURE;
     
    11931197 */
    11941198static RTEXITCODE
    1195 getMachineFromArgs(ComPtr<ICloudMachine> &pMachine,
    1196                    uint64_t fCurSubcommandScope,
    1197                    HandlerArg *a, int iFirst,
    1198                    const ComPtr<ICloudClient> &pClient)
    1199 {
    1200     MachineSpec machineSpec;
     1199getMachineFromArgs(CMachineHandlerArg *a, int iFirst)
     1200{
    12011201    HRESULT hrc;
    12021202    int rc;
    12031203
    1204     RT_NOREF(fCurSubcommandScope); /// @todo scopes not in the manual yet
    1205     // setCurrentSubcommand(fCurSubcommandScope);
    12061204    static const RTGETOPTDEF s_aOptions[] =
    12071205    {
     
    12221220    while ((ch = RTGetOpt(&OptState, &Val)) != 0)
    12231221    {
    1224         rc = checkMachineSpecArgument(machineSpec, ch, Val);
     1222        rc = checkMachineSpecArgument(a, ch, Val);
    12251223        if (rc == VINF_SUCCESS)
    12261224            continue;
     
    12381236    }
    12391237
    1240     hrc = getMachineBySpec(pMachine, pClient, machineSpec);
     1238    hrc = getMachineBySpec(a);
    12411239    if (FAILED(hrc))
    12421240        return RTEXITCODE_FAILURE;
     
    12501248 */
    12511249static RTEXITCODE
    1252 handleCloudMachineStart(HandlerArg *a, int iFirst,
    1253                         const ComPtr<ICloudClient> &pClient)
    1254 {
    1255     ComPtr<ICloudMachine> pMachine;
    1256     HRESULT hrc;
    1257 
    1258     RTEXITCODE status
    1259         = getMachineFromArgs(pMachine,
    1260               /* HELP_SCOPE_CLOUD_MACHINE_START */ 0,
    1261               a, iFirst, pClient);
     1250handleCloudMachineStart(CMachineHandlerArg *a, int iFirst)
     1251{
     1252    HRESULT hrc;
     1253
     1254    // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_START);
     1255    RTEXITCODE status = getMachineFromArgs(a, iFirst);
    12621256    if (status != RTEXITCODE_SUCCESS)
    12631257        return status;
     
    12651259
    12661260    ComPtr<IProgress> pProgress;
    1267     CHECK_ERROR2_RET(hrc, pMachine,
     1261    CHECK_ERROR2_RET(hrc, a->pMachine,
    12681262        PowerUp(pProgress.asOutParam()),
    12691263            RTEXITCODE_FAILURE);
     
    12791273 */
    12801274static RTEXITCODE
    1281 handleCloudMachineReboot(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);
     1275handleCloudMachineReboot(CMachineHandlerArg *a, int iFirst)
     1276{
     1277    HRESULT hrc;
     1278
     1279    // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_REBOOT);
     1280    RTEXITCODE status = getMachineFromArgs(a, iFirst);
    12911281    if (status != RTEXITCODE_SUCCESS)
    12921282        return status;
     
    12941284
    12951285    ComPtr<IProgress> pProgress;
    1296     CHECK_ERROR2_RET(hrc, pMachine,
     1286    CHECK_ERROR2_RET(hrc, a->pMachine,
    12971287        Reboot(pProgress.asOutParam()),
    12981288            RTEXITCODE_FAILURE);
     
    13081298 */
    13091299static RTEXITCODE
    1310 handleCloudMachineShutdown(HandlerArg *a, int iFirst,
    1311                            const ComPtr<ICloudClient> &pClient)
    1312 {
    1313     ComPtr<ICloudMachine> pMachine;
    1314     HRESULT hrc;
    1315 
    1316     RTEXITCODE status
    1317         = getMachineFromArgs(pMachine,
    1318               /* HELP_SCOPE_CLOUD_MACHINE_SHUTDOWN */ 0,
    1319               a, iFirst, pClient);
     1300handleCloudMachineShutdown(CMachineHandlerArg *a, int iFirst)
     1301{
     1302    HRESULT hrc;
     1303
     1304    // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_SHUTDOWN);
     1305    RTEXITCODE status = getMachineFromArgs(a, iFirst);
    13201306    if (status != RTEXITCODE_SUCCESS)
    13211307        return status;
     
    13231309
    13241310    ComPtr<IProgress> pProgress;
    1325     CHECK_ERROR2_RET(hrc, pMachine,
     1311    CHECK_ERROR2_RET(hrc, a->pMachine,
    13261312        Shutdown(pProgress.asOutParam()),
    13271313            RTEXITCODE_FAILURE);
     
    13371323 */
    13381324static RTEXITCODE
    1339 handleCloudMachinePowerdown(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);
     1325handleCloudMachinePowerdown(CMachineHandlerArg *a, int iFirst)
     1326{
     1327    HRESULT hrc;
     1328
     1329    // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_POWERDOWN);
     1330    RTEXITCODE status = getMachineFromArgs(a, iFirst);
    13491331    if (status != RTEXITCODE_SUCCESS)
    13501332        return status;
     
    13521334
    13531335    ComPtr<IProgress> pProgress;
    1354     CHECK_ERROR2_RET(hrc, pMachine,
     1336    CHECK_ERROR2_RET(hrc, a->pMachine,
    13551337        PowerDown(pProgress.asOutParam()),
    13561338            RTEXITCODE_FAILURE);
     
    13661348 */
    13671349static RTEXITCODE
    1368 handleCloudMachineTerminate(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);
     1350handleCloudMachineTerminate(CMachineHandlerArg *a, int iFirst)
     1351{
     1352    HRESULT hrc;
     1353
     1354    // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_TERMINATE);
     1355    RTEXITCODE status = getMachineFromArgs(a, iFirst);
    13781356    if (status != RTEXITCODE_SUCCESS)
    13791357        return status;
     
    13811359
    13821360    ComPtr<IProgress> pProgress;
    1383     CHECK_ERROR2_RET(hrc, pMachine,
     1361    CHECK_ERROR2_RET(hrc, a->pMachine,
    13841362        Terminate(pProgress.asOutParam()),
    13851363            RTEXITCODE_FAILURE);
     
    13941372 */
    13951373static RTEXITCODE
    1396 handleCloudMachineConsoleHistory(HandlerArg *a, int iFirst,
    1397                                  const ComPtr<ICloudClient> &pClient)
    1398 {
    1399     ComPtr<ICloudMachine> pMachine;
    1400     HRESULT hrc;
    1401 
    1402     RTEXITCODE status
    1403         = getMachineFromArgs(pMachine,
    1404               /* HELP_SCOPE_CLOUD_MACHINE_CONSOLEHISTORY */ 0,
    1405               a, iFirst, pClient);
     1374handleCloudMachineConsoleHistory(CMachineHandlerArg *a, int iFirst)
     1375{
     1376    HRESULT hrc;
     1377
     1378    // setCurrentSubcommand(HELP_SCOPE_CLOUD_MACHINE_CONSOLEHISTORY);
     1379    RTEXITCODE status = getMachineFromArgs(a, iFirst);
    14061380    if (status != RTEXITCODE_SUCCESS)
    14071381        return status;
     
    14101384    ComPtr<IDataStream> pHistoryStream;
    14111385    ComPtr<IProgress> pHistoryProgress;
    1412     CHECK_ERROR2_RET(hrc, pMachine,
     1386    CHECK_ERROR2_RET(hrc, a->pMachine,
    14131387        GetConsoleHistory(pHistoryStream.asOutParam(),
    14141388                          pHistoryProgress.asOutParam()),
Note: See TracChangeset for help on using the changeset viewer.

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