VirtualBox

Changeset 79869 in vbox


Ignore:
Timestamp:
Jul 18, 2019 11:29:25 PM (6 years ago)
Author:
vboxsync
Message:

bugref:9404 - listCloudInstances: handle all known values for --state;
report an error if an unknown one is specified; allow multiple --state
options (API call takes an array of states).

File:
1 edited

Legend:

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

    r79797 r79869  
    9595}
    9696
     97
    9798/**
    9899 * List all available cloud instances for the specified cloud provider.
     
    118119
    119120    Utf8Str strCompartmentId;
    120     Utf8Str strState;
     121    com::SafeArray<CloudMachineState_T> machineStates;
    121122
    122123    int c;
     
    128129                strCompartmentId = ValueUnion.psz;
    129130                break;
     131
    130132            case 's':
    131                 strState = ValueUnion.psz;
    132                 break;
    133             case VINF_GETOPT_NOT_OPTION:
    134                 return errorUnknownSubcommand(ValueUnion.psz);
    135             default:
    136                 return errorGetOpt(c, &ValueUnion);
    137         }
    138     }
    139 
    140     com::SafeArray<CloudMachineState_T> machineStates;
    141     if (strState.isNotEmpty())
    142     {
    143         if (strState.equals("running"))
    144             machineStates.push_back(CloudMachineState_Running);
    145         else if (strState.equals("paused"))
    146             machineStates.push_back(CloudMachineState_Stopped);
    147         else if (strState.equals("terminated"))
    148             machineStates.push_back(CloudMachineState_Terminated);
     133            {
     134                const char * const pszState = ValueUnion.psz;
     135
     136                if (RTStrICmp(pszState, "creatingimage") == 0)
     137                    machineStates.push_back(CloudMachineState_CreatingImage);
     138                else if (RTStrICmp(pszState, "paused") == 0) /* XXX */
     139                    machineStates.push_back(CloudMachineState_Stopped);
     140                else if (RTStrICmp(pszState, "provisioning") == 0)
     141                    machineStates.push_back(CloudMachineState_Provisioning);
     142                else if (RTStrICmp(pszState, "running") == 0)
     143                    machineStates.push_back(CloudMachineState_Running);
     144                else if (RTStrICmp(pszState, "starting") == 0)
     145                    machineStates.push_back(CloudMachineState_Starting);
     146                else if (RTStrICmp(pszState, "stopped") == 0)
     147                    machineStates.push_back(CloudMachineState_Stopped);
     148                else if (RTStrICmp(pszState, "stopping") == 0)
     149                    machineStates.push_back(CloudMachineState_Stopping);
     150                else if (RTStrICmp(pszState, "terminated") == 0)
     151                    machineStates.push_back(CloudMachineState_Terminated);
     152                else if (RTStrICmp(pszState, "terminating") == 0)
     153                    machineStates.push_back(CloudMachineState_Terminating);
     154                else
     155                    return errorArgument("Unknown cloud instance state \"%s\"", pszState);
     156                break;
     157            }
     158
     159            case VINF_GETOPT_NOT_OPTION:
     160                return errorUnknownSubcommand(ValueUnion.psz);
     161
     162            default:
     163                return errorGetOpt(c, &ValueUnion);
     164        }
    149165    }
    150166
    151167    HRESULT hrc = S_OK;
    152168    ComPtr<IVirtualBox> pVirtualBox = a->virtualBox;
     169
    153170    ComPtr<ICloudProviderManager> pCloudProviderManager;
    154171    CHECK_ERROR2_RET(hrc, pVirtualBox,
    155172                     COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()),
    156173                     RTEXITCODE_FAILURE);
     174
    157175    ComPtr<ICloudProvider> pCloudProvider;
    158 
    159176    CHECK_ERROR2_RET(hrc, pCloudProviderManager,
    160177                     GetProviderByShortName(Bstr(pCommonOpts->provider.pszProviderName).raw(), pCloudProvider.asOutParam()),
    161178                     RTEXITCODE_FAILURE);
     179
    162180    ComPtr<ICloudProfile> pCloudProfile;
    163 
    164181    CHECK_ERROR2_RET(hrc, pCloudProvider,
    165182                     GetProfileByName(Bstr(pCommonOpts->profile.pszProfileName).raw(), pCloudProfile.asOutParam()),
     
    234251}
    235252
     253
    236254/**
    237255 * List all available cloud images for the specified cloud provider.
     
    255273    AssertRCReturn(vrc, RTEXITCODE_FAILURE);
    256274
     275    Utf8Str strCompartmentId;
    257276    com::SafeArray<CloudImageState_T> imageStates;
    258277
    259     Utf8Str strCompartmentId;
    260278    int c;
    261279    while ((c = RTGetOpt(&GetState, &ValueUnion)) != 0)
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