VirtualBox

Changeset 78755 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
May 26, 2019 2:49:29 AM (6 years ago)
Author:
vboxsync
Message:

Main/Appliance: Introduced the concept of status code checking to the 2nd half of Appliance::i_writeCloudImpl. POC from r124918 is partly at blame, but r127127 expanded upon it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r78754 r78755  
    830830HRESULT Appliance::i_writeCloudImpl(const LocationInfo &aLocInfo, ComObjPtr<Progress> &aProgress)
    831831{
    832     HRESULT rc;
    833 
    834832    for (list<ComObjPtr<VirtualSystemDescription> >::const_iterator
    835833         it = m->virtualSystemDescriptions.begin();
     
    862860        //just in case
    863861        if (vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage).empty())
    864         {
    865             return setError(VBOX_E_OBJECT_NOT_FOUND,
    866                                 tr("There are no images to export to Cloud after preparation steps"));
    867         }
     862            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("There are no images to export to Cloud after preparation steps"));
    868863
    869864        /*
    870865         * Fills out the OCI settings
    871         */
    872         std::list<VirtualSystemDescriptionEntry*> profileName =
    873             vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudProfileName);
     866         */
     867        std::list<VirtualSystemDescriptionEntry*> profileName
     868            = vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudProfileName);
    874869        if (profileName.size() > 1)
    875             return setError(VBOX_E_OBJECT_NOT_FOUND,
    876                                 tr("Cloud: More than one profile name was found."));
    877         else if (profileName.empty())
    878             return setError(VBOX_E_OBJECT_NOT_FOUND,
    879                                 tr("Cloud: Profile name wasn't specified."));
     870            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("Cloud: More than one profile name was found."));
     871        if (profileName.empty())
     872            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("Cloud: Profile name wasn't specified."));
    880873
    881874        if (profileName.front()->strVBoxCurrent.isEmpty())
    882             return setError(VBOX_E_OBJECT_NOT_FOUND,
    883                                 tr("Cloud: Cloud user profile name is empty"));
     875            return setError(VBOX_E_OBJECT_NOT_FOUND, tr("Cloud: Cloud user profile name is empty"));
    884876
    885877        LogRel(("profile name: %s\n", profileName.front()->strVBoxCurrent.c_str()));
    886 
    887878    }
    888879
    889880    // we need to do that as otherwise Task won't be created successfully
    890     aProgress.createObject();
    891     if (aLocInfo.strProvider.equals("OCI"))
    892     {
    893         aProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
    894                      Bstr("Exporting VM to Cloud...").raw(),
    895                      TRUE /* aCancelable */,
    896                      5, // ULONG cOperations,
    897                      1000, // ULONG ulTotalOperationsWeight,
    898                      Bstr("Exporting VM to Cloud...").raw(), // aFirstOperationDescription
    899                      10); // ULONG ulFirstOperationWeight
    900     }
    901     else
    902         return setErrorVrc(VBOX_E_NOT_SUPPORTED,
    903                            tr("Only \"OCI\" cloud provider is supported for now. \"%s\" isn't supported."),
    904                            aLocInfo.strProvider.c_str());
    905     // Initialize our worker task
    906     TaskCloud* task = NULL;
    907     try
    908     {
    909         task = new Appliance::TaskCloud(this, TaskCloud::Export, aLocInfo, aProgress);
    910 
    911     }
    912     catch(...)
    913     {
    914         return setError(VBOX_E_OBJECT_NOT_FOUND,
    915                         tr("Could not create TaskCloud object for exporting to Cloud"));
    916     }
    917 
    918     rc = task->createThread();
    919 
    920     return rc;
     881    /// @todo r=bird: What's 'that' here exactly?
     882    HRESULT hrc = aProgress.createObject();
     883    if (SUCCEEDED(hrc))
     884    {
     885        if (aLocInfo.strProvider.equals("OCI"))
     886        {
     887            hrc = aProgress->init(mVirtualBox, static_cast<IAppliance *>(this),
     888                                  Utf8Str(tr("Exporting VM to Cloud...")),
     889                                  TRUE /* aCancelable */,
     890                                  5, // ULONG cOperations,
     891                                  1000, // ULONG ulTotalOperationsWeight,
     892                                  Utf8Str(tr("Exporting VM to Cloud...")), // aFirstOperationDescription
     893                                  10); // ULONG ulFirstOperationWeight
     894        }
     895        else
     896            hrc = setErrorVrc(VBOX_E_NOT_SUPPORTED,
     897                              tr("Only \"OCI\" cloud provider is supported for now. \"%s\" isn't supported."),
     898                              aLocInfo.strProvider.c_str());
     899        if (SUCCEEDED(hrc))
     900        {
     901            /* Initialize the worker task: */
     902            TaskCloud *pTask = NULL;
     903            try
     904            {
     905                pTask = new Appliance::TaskCloud(this, TaskCloud::Export, aLocInfo, aProgress);
     906            }
     907            catch (std::bad_alloc &)
     908            {
     909                pTask = NULL;
     910                hrc = E_OUTOFMEMORY;
     911            }
     912            if (SUCCEEDED(hrc))
     913            {
     914                /* Kick off the worker task: */
     915                hrc = pTask->createThread();
     916                pTask = NULL;
     917            }
     918        }
     919    }
     920    return hrc;
    921921}
    922922
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