VirtualBox

Changeset 79797 in vbox


Ignore:
Timestamp:
Jul 15, 2019 3:39:19 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132164
Message:

bugref:9481 - listCloudImages: 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

    r79727 r79797  
    255255    AssertRCReturn(vrc, RTEXITCODE_FAILURE);
    256256
     257    com::SafeArray<CloudImageState_T> imageStates;
     258
    257259    Utf8Str strCompartmentId;
    258     Utf8Str strState;
    259260    int c;
    260261    while ((c = RTGetOpt(&GetState, &ValueUnion)) != 0)
     
    265266                strCompartmentId = ValueUnion.psz;
    266267                break;
     268
    267269            case 's':
    268                 strState = ValueUnion.psz;
    269                 break;
    270             case VINF_GETOPT_NOT_OPTION:
    271                 return errorUnknownSubcommand(ValueUnion.psz);
    272             default:
    273                 return errorGetOpt(c, &ValueUnion);
    274         }
    275     }
    276 
    277     com::SafeArray<CloudImageState_T> imageStates;
    278     if (strState.isNotEmpty())
    279     {
    280         if (strState.equals("available"))
    281             imageStates.push_back(CloudImageState_Available);
    282         else if (strState.equals("disabled"))
    283             imageStates.push_back(CloudImageState_Disabled);
    284         else if (strState.equals("deleted"))
    285             imageStates.push_back(CloudImageState_Deleted);
    286         else if (strState.equals("exporting"))
    287             imageStates.push_back(CloudImageState_Exporting);
    288         else if (strState.equals("importing"))
    289             imageStates.push_back(CloudImageState_Importing);
    290     }
     270            {
     271                const char * const pszState = ValueUnion.psz;
     272
     273                if (RTStrICmp(pszState, "available") == 0)
     274                    imageStates.push_back(CloudImageState_Available);
     275                else if (RTStrICmp(pszState, "deleted") == 0)
     276                    imageStates.push_back(CloudImageState_Deleted);
     277                else if (RTStrICmp(pszState, "disabled") == 0)
     278                    imageStates.push_back(CloudImageState_Disabled);
     279                else if (RTStrICmp(pszState, "exporting") == 0)
     280                    imageStates.push_back(CloudImageState_Exporting);
     281                else if (RTStrICmp(pszState, "importing") == 0)
     282                    imageStates.push_back(CloudImageState_Importing);
     283                else if (RTStrICmp(pszState, "provisioning") == 0)
     284                    imageStates.push_back(CloudImageState_Provisioning);
     285                else
     286                    return errorArgument("Unknown cloud image state \"%s\"", pszState);
     287                break;
     288            }
     289
     290            case VINF_GETOPT_NOT_OPTION:
     291                return errorUnknownSubcommand(ValueUnion.psz);
     292
     293            default:
     294                return errorGetOpt(c, &ValueUnion);
     295        }
     296    }
     297
    291298
    292299    HRESULT hrc = S_OK;
    293300    ComPtr<IVirtualBox> pVirtualBox = a->virtualBox;
     301
    294302    ComPtr<ICloudProviderManager> pCloudProviderManager;
    295303    CHECK_ERROR2_RET(hrc, pVirtualBox,
    296304                     COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()),
    297305                     RTEXITCODE_FAILURE);
     306
    298307    ComPtr<ICloudProvider> pCloudProvider;
    299 
    300308    CHECK_ERROR2_RET(hrc, pCloudProviderManager,
    301309                     GetProviderByShortName(Bstr(pCommonOpts->provider.pszProviderName).raw(), pCloudProvider.asOutParam()),
    302310                     RTEXITCODE_FAILURE);
     311
    303312    ComPtr<ICloudProfile> pCloudProfile;
    304 
    305313    CHECK_ERROR2_RET(hrc, pCloudProvider,
    306314                     GetProfileByName(Bstr(pCommonOpts->profile.pszProfileName).raw(), pCloudProfile.asOutParam()),
    307315                     RTEXITCODE_FAILURE);
     316
    308317    if (strCompartmentId.isNotEmpty())
    309318    {
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