VirtualBox

Changeset 80599 in vbox


Ignore:
Timestamp:
Sep 5, 2019 8:23:58 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133120
Message:

bugref:9549. Fixed CLI command 'VBoxManage export' for the Cloud export case. Added the creation of instance after export to the Cloud.

File:
1 edited

Legend:

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

    r80426 r80599  
    369369        ComPtr<IAppliance> pAppliance;
    370370        CHECK_ERROR_BREAK(arg->virtualBox, CreateAppliance(pAppliance.asOutParam()));
    371 
    372371        //in the case of Cloud, append the instance id here because later it's harder to do
    373372        if (actionType == CLOUD)
     
    14741473            pszAbsFilePath = RTPathAbsDup(strOutputFile.c_str());
    14751474
     1475        /*
     1476         * The first stage - export machine/s to the Cloud or into the
     1477         * OVA/OVF format on the local host.
     1478         */
     1479
     1480        /* VSDList is needed for the second stage where we launch the cloud instances if it was requested by user */
     1481        std::list< ComPtr<IVirtualSystemDescription> > VSDList;
    14761482        std::list< ComPtr<IMachine> >::iterator itM;
    14771483        uint32_t i=0;
     
    15961602                }
    15971603            }
     1604
     1605            VSDList.push_back(pVSD);//store vsd for the possible second stage
    15981606        }
    15991607
     
    16501658            RTPrintf("Successfully exported %d machine(s).\n", llMachines.size());
    16511659
     1660        /*
     1661         *  The second stage for the cloud case
     1662         */
     1663        if (actionType == CLOUD)
     1664        {
     1665            /* Launch the exported VM if the appropriate flag had been set on the first stage */
     1666            for (std::list< ComPtr<IVirtualSystemDescription> >::iterator itVSD = VSDList.begin();
     1667                 itVSD != VSDList.end();
     1668                 ++itVSD)
     1669            {
     1670                ComPtr<IVirtualSystemDescription> pVSD = *itVSD;
     1671
     1672                com::SafeArray<VirtualSystemDescriptionType_T> retTypes;
     1673                com::SafeArray<BSTR> aRefs;
     1674                com::SafeArray<BSTR> aOvfValues;
     1675                com::SafeArray<BSTR> aVBoxValues;
     1676                com::SafeArray<BSTR> aExtraConfigValues;
     1677
     1678                CHECK_ERROR_BREAK(pVSD, GetDescriptionByType(VirtualSystemDescriptionType_CloudLaunchInstance,
     1679                                         ComSafeArrayAsOutParam(retTypes),
     1680                                         ComSafeArrayAsOutParam(aRefs),
     1681                                         ComSafeArrayAsOutParam(aOvfValues),
     1682                                         ComSafeArrayAsOutParam(aVBoxValues),
     1683                                         ComSafeArrayAsOutParam(aExtraConfigValues)));
     1684
     1685                Utf8Str flagCloudLaunchInstance(Bstr(aVBoxValues[0]).raw());
     1686                retTypes.setNull(); aRefs.setNull(); aOvfValues.setNull(); aVBoxValues.setNull(); aExtraConfigValues.setNull();
     1687
     1688                if (flagCloudLaunchInstance.equals("true"))
     1689                {
     1690                    /* Getting the short provider name */
     1691                    Bstr bstrCloudProviderShortName(strOutputFile.c_str(), strOutputFile.find("://"));
     1692
     1693                    ComPtr<IVirtualBox> pVirtualBox = a->virtualBox;
     1694                    ComPtr<ICloudProviderManager> pCloudProviderManager;
     1695                    CHECK_ERROR_BREAK(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
     1696
     1697                    ComPtr<ICloudProvider> pCloudProvider;
     1698                    CHECK_ERROR_BREAK(pCloudProviderManager,
     1699                                     GetProviderByShortName(bstrCloudProviderShortName.raw(), pCloudProvider.asOutParam()));
     1700
     1701                    CHECK_ERROR_BREAK(pVSD, GetDescriptionByType(VirtualSystemDescriptionType_CloudProfileName,
     1702                                             ComSafeArrayAsOutParam(retTypes),
     1703                                             ComSafeArrayAsOutParam(aRefs),
     1704                                             ComSafeArrayAsOutParam(aOvfValues),
     1705                                             ComSafeArrayAsOutParam(aVBoxValues),
     1706                                             ComSafeArrayAsOutParam(aExtraConfigValues)));
     1707
     1708                    ComPtr<ICloudProfile> pCloudProfile;
     1709                    CHECK_ERROR_BREAK(pCloudProvider, GetProfileByName(Bstr(aVBoxValues[0]).raw(), pCloudProfile.asOutParam()));
     1710                    retTypes.setNull(); aRefs.setNull(); aOvfValues.setNull(); aVBoxValues.setNull(); aExtraConfigValues.setNull();
     1711
     1712                    ComObjPtr<ICloudClient> oCloudClient;
     1713                    CHECK_ERROR_BREAK(pCloudProfile, CreateCloudClient(oCloudClient.asOutParam()));
     1714                    RTPrintf("Creating a cloud instance...\n");
     1715
     1716                    ComPtr<IProgress> progress1;
     1717                    CHECK_ERROR_BREAK(oCloudClient, LaunchVM(pVSD, progress1.asOutParam()));
     1718                    rc = showProgress(progress1);
     1719                    CHECK_PROGRESS_ERROR_RET(progress1, ("Creating the cloud instance failed"), RTEXITCODE_FAILURE);
     1720
     1721                    if (SUCCEEDED(rc))
     1722                    {
     1723                        CHECK_ERROR_BREAK(pVSD, GetDescriptionByType(VirtualSystemDescriptionType_CloudInstanceId,
     1724                                                 ComSafeArrayAsOutParam(retTypes),
     1725                                                 ComSafeArrayAsOutParam(aRefs),
     1726                                                 ComSafeArrayAsOutParam(aOvfValues),
     1727                                                 ComSafeArrayAsOutParam(aVBoxValues),
     1728                                                 ComSafeArrayAsOutParam(aExtraConfigValues)));
     1729
     1730                        RTPrintf("A cloud instance with id '%s' (provider '%s') was created\n",
     1731                                 Utf8Str(Bstr(aVBoxValues[0]).raw()).c_str(),
     1732                                 Utf8Str(bstrCloudProviderShortName.raw()).c_str());
     1733                        retTypes.setNull(); aRefs.setNull(); aOvfValues.setNull(); aVBoxValues.setNull(); aExtraConfigValues.setNull();
     1734                    }
     1735                }
     1736            }
     1737        }
    16521738    } while (0);
    16531739
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