Changeset 75921 in vbox
- Timestamp:
- Dec 3, 2018 6:25:11 PM (6 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.cpp
r74878 r75921 152 152 /* For Cloud formats: */ 153 153 if (field("isFormatCloudOne").toBool()) 154 return QString("%1://%2").arg(field("providerShortName").toString(), field("profileName").toString()); 154 // return QString("%1://%2").arg(field("providerShortName").toString(), field("profileName").toString()); 155 return QString("%1://%2").arg(field("providerShortName").toString(), field("path").toString()); 155 156 else 156 157 { -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp
r75434 r75921 408 408 parameter.kind = ParameterKind_Array; 409 409 } 410 else 411 if (strFieldName == "name") 412 { 413 AbstractVSDParameterString get; 414 get.value = parseJsonFieldString(strFieldName, field); 415 parameter.get = QVariant::fromValue(get); 416 parameter.kind = ParameterKind_String; 417 } 410 418 } 411 419 -
trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
r75766 r75921 652 652 i_parseURI(aPath, m->locInfo); 653 653 654 /** @todo r=klaus all of this code should be made fully generic, applicable655 * to any cloud provider. This implies changing the method names accordingly656 * and (more importantly) moving all the cloud specific checking code to the657 * actual ICloudClient implementation in the corresponding extpack. It will658 * move the check to the async task, but that's a bearable cost, not getting659 * the error straight from the API call but a tiny bit later through the660 * Progress object. */661 654 if (m->locInfo.storageType == VFSType_Cloud)//(isCloudDestination(aPath)) 662 655 { … … 799 792 { 800 793 HRESULT rc; 794 795 rc = i_setUpProgress(aProgress, 796 BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()), 797 (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3); 798 if (FAILED(rc)) 799 return rc; 800 801 /* Initialize our worker task */ 802 TaskOVF* task = NULL; 801 803 try 802 804 { 803 rc = i_setUpProgress(aProgress, 804 BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()), 805 (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3); 806 if (FAILED(rc)) 807 return rc; 808 809 /* Initialize our worker task */ 810 TaskOVF* task = NULL; 811 try 812 { 813 task = new TaskOVF(this, TaskOVF::Write, aLocInfo, aProgress); 814 } 815 catch(...) 816 { 817 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 818 tr("Could not create TaskOVF object for for writing out the OVF to disk")); 819 } 820 821 /* The OVF version to write */ 822 task->enFormat = aFormat; 823 824 rc = task->createThread(); 825 if (FAILED(rc)) throw rc; 826 827 } 828 catch (HRESULT aRC) 829 { 830 rc = aRC; 831 } 805 task = new TaskOVF(this, TaskOVF::Write, aLocInfo, aProgress); 806 } 807 catch(...) 808 { 809 return setError(VBOX_E_OBJECT_NOT_FOUND, 810 tr("Could not create TaskOVF object for for writing out the OVF to disk")); 811 } 812 813 /* The OVF version to write */ 814 task->enFormat = aFormat; 815 816 rc = task->createThread(); 832 817 833 818 return rc; … … 838 823 { 839 824 HRESULT rc; 825 826 for (list<ComObjPtr<VirtualSystemDescription> >::const_iterator 827 it = m->virtualSystemDescriptions.begin(); 828 it != m->virtualSystemDescriptions.end(); 829 ++it) 830 { 831 ComObjPtr<VirtualSystemDescription> vsdescThis = *it; 832 std::list<VirtualSystemDescriptionEntry*> skipped = vsdescThis->i_findByType(VirtualSystemDescriptionType_CDROM); 833 std::list<VirtualSystemDescriptionEntry*>::const_iterator itSkipped = skipped.begin(); 834 while (itSkipped != skipped.end()) 835 { 836 (*itSkipped)->skipIt = true; 837 ++itSkipped; 838 } 839 840 //remove all disks from the VirtualSystemDescription exept one 841 skipped = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 842 itSkipped = skipped.begin(); 843 844 Utf8Str strBootLocation; 845 while (itSkipped != skipped.end()) 846 { 847 if (strBootLocation.isEmpty()) 848 strBootLocation = (*itSkipped)->strVBoxCurrent; 849 else 850 (*itSkipped)->skipIt = true; 851 ++itSkipped; 852 } 853 854 //just in case 855 if (vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage).empty()) 856 { 857 return setError(VBOX_E_OBJECT_NOT_FOUND, 858 tr("There are no images to export to Cloud after preparation steps")); 859 } 860 861 /* 862 * Fills out the OCI settings 863 */ 864 std::list<VirtualSystemDescriptionEntry*> profileName = 865 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIProfileName); 866 if (profileName.size() > 1) 867 return setError(VBOX_E_OBJECT_NOT_FOUND, 868 tr("Cloud: More than one profile name was found.")); 869 else if (profileName.empty()) 870 return setError(VBOX_E_OBJECT_NOT_FOUND, 871 tr("Cloud: Profile name wasn't specified.")); 872 873 if (profileName.front()->strVBoxCurrent.isEmpty()) 874 return setError(VBOX_E_OBJECT_NOT_FOUND, 875 tr("Cloud: Cloud user profile name is empty")); 876 877 LogRel(("profile name: %s\n", profileName.front()->strVBoxCurrent.c_str())); 878 879 } 880 881 // we need to do that as otherwise Task won't be created successfully 882 aProgress.createObject(); 883 if (aLocInfo.strProvider.equals("OCI")) 884 { 885 aProgress->init(mVirtualBox, static_cast<IAppliance*>(this), 886 Bstr("Exporting VM to Cloud...").raw(), 887 TRUE /* aCancelable */, 888 5, // ULONG cOperations, 889 1000, // ULONG ulTotalOperationsWeight, 890 Bstr("Exporting VM to Cloud...").raw(), // aFirstOperationDescription 891 10); // ULONG ulFirstOperationWeight 892 } 893 else 894 return setErrorVrc(VBOX_E_NOT_SUPPORTED, 895 tr("Only \"OCI\" cloud provider is supported for now. \"%s\" isn't supported."), 896 aLocInfo.strProvider); 897 // Initialize our worker task 898 TaskCloud* task = NULL; 840 899 try 841 900 { 842 /** @todo r=klaus all of this code should be made fully generic, 843 * doing only what is common for all cloud providers, i.e. pretty 844 * much nothing. The logic and data types need to be moved to the 845 * extension pack, anything else will not work. */ 846 847 //remove all disks from the VirtualSystemDescription exept one 848 for (list<ComObjPtr<VirtualSystemDescription> >::const_iterator 849 it = m->virtualSystemDescriptions.begin(); 850 it != m->virtualSystemDescriptions.end(); 851 ++it) 852 { 853 ComObjPtr<VirtualSystemDescription> vsdescThis = *it; 854 std::list<VirtualSystemDescriptionEntry*> skipped = vsdescThis->i_findByType(VirtualSystemDescriptionType_CDROM); 855 std::list<VirtualSystemDescriptionEntry*>::const_iterator itSkipped = skipped.begin(); 856 while (itSkipped != skipped.end()) 857 { 858 (*itSkipped)->skipIt = true; 859 ++itSkipped; 860 } 861 862 skipped = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 863 itSkipped = skipped.begin(); 864 865 Utf8Str strBootLocation; 866 while (itSkipped != skipped.end()) 867 { 868 if (strBootLocation.isEmpty()) 869 strBootLocation = (*itSkipped)->strVBoxCurrent; 870 else 871 (*itSkipped)->skipIt = true; 872 ++itSkipped; 873 } 874 875 //just in case 876 if (vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage).empty()) 877 { 878 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 879 tr("There are no images to export to Cloud after preparation steps")); 880 } 881 882 /* 883 * Fills out the OCI settings 884 */ 885 std::list<VirtualSystemDescriptionEntry*> machineName = 886 vsdescThis->i_findByType(VirtualSystemDescriptionType_Name); 887 if (machineName.empty()) 888 throw setError(VBOX_E_FILE_ERROR, tr("Cloud: VM name wasn't found")); 889 m->m_CloudExportData.strDisplayMachineName = machineName.front()->strVBoxCurrent; 890 LogRel(("Exported machine name: %s\n", m->m_CloudExportData.strDisplayMachineName.c_str())); 891 892 m->m_CloudExportData.strBootImageName = strBootLocation; 893 LogRel(("Exported image: %s\n", m->m_CloudExportData.strBootImageName.c_str())); 894 895 if (aLocInfo.strPath.isEmpty()) 896 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 897 tr("Cloud: Cloud user profile wasn't found")); 898 899 m->m_CloudExportData.strProfileName = aLocInfo.strPath; 900 LogRel(("profile name: %s\n", m->m_CloudExportData.strProfileName.c_str())); 901 902 Utf8Str strInstanceShapeId; 903 std::list<VirtualSystemDescriptionEntry*> shapeId = 904 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIInstanceShape); 905 if (shapeId.empty()) 906 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 907 tr("Cloud: Shape of instance wasn't found")); 908 909 m->m_CloudExportData.strInstanceShapeId = shapeId.front()->strVBoxCurrent; 910 LogRel(("Shape: %s\n", m->m_CloudExportData.strInstanceShapeId.c_str())); 911 912 std::list<VirtualSystemDescriptionEntry*> domainName = 913 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIDomain); 914 if (domainName.empty()) 915 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 916 tr("Cloud: Available domain wasn't found")); 917 918 m->m_CloudExportData.strDomainName = domainName.front()->strVBoxCurrent; 919 LogRel(("Available domain name: %s\n", m->m_CloudExportData.strDomainName.c_str())); 920 921 std::list<VirtualSystemDescriptionEntry*> bootDiskSize = 922 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIBootDiskSize); 923 if (bootDiskSize.empty()) 924 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 925 tr("Cloud: Boot disk size wasn't found")); 926 927 m->m_CloudExportData.strBootDiskSize = bootDiskSize.front()->strVBoxCurrent; 928 LogRel(("Boot disk size: %s\n", m->m_CloudExportData.strBootDiskSize.c_str())); 929 930 std::list<VirtualSystemDescriptionEntry*> bucketId = 931 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIBucket); 932 if (bucketId.empty()) 933 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 934 tr("Cloud: Bucket wasn't found")); 935 936 m->m_CloudExportData.strBucketId = bucketId.front()->strVBoxCurrent; 937 LogRel(("bucket name: %s\n", m->m_CloudExportData.strBucketId.c_str())); 938 939 std::list<VirtualSystemDescriptionEntry*> subnet = 940 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCISubnet); 941 if (subnet.empty()) 942 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 943 tr("Cloud: Subnet wasn't found")); 944 945 m->m_CloudExportData.strSubnet = subnet.front()->strVBoxCurrent; 946 LogRel(("Subnet name: %s\n", m->m_CloudExportData.strSubnet.c_str())); 947 948 std::list<VirtualSystemDescriptionEntry*> publicIP = 949 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIPublicIP); 950 if (publicIP.empty()) 951 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 952 tr("Cloud: Public IP setting wasn't found")); 953 954 m->m_CloudExportData.fPublicIP = (publicIP.front()->strVBoxCurrent == "true") ? true : false; 955 LogRel(("public IP: %s\n", m->m_CloudExportData.fPublicIP ? "yes" : "no")); 956 } 957 958 // we need to do that as otherwise Task won't be created successfully 959 aProgress.createObject(); 960 961 // Initialize our worker task 962 TaskCloud* task = NULL; 963 try 964 { 965 task = new Appliance::TaskCloud(this, TaskCloud::Export, aLocInfo, aProgress); 966 } 967 catch(...) 968 { 969 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 970 tr("Could not create TaskCloud object for exporting to Cloud")); 971 } 972 973 rc = task->createThread(); 974 if (FAILED(rc)) throw rc; 975 976 } 977 catch (HRESULT aRC) 978 { 979 rc = aRC; 980 } 901 task = new Appliance::TaskCloud(this, TaskCloud::Export, aLocInfo, aProgress); 902 903 } 904 catch(...) 905 { 906 return setError(VBOX_E_OBJECT_NOT_FOUND, 907 tr("Could not create TaskCloud object for exporting to Cloud")); 908 } 909 910 rc = task->createThread(); 981 911 982 912 return rc; … … 987 917 HRESULT rc; 988 918 RT_NOREF(aFormat); 919 920 rc = i_setUpProgress(aProgress, 921 BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()), 922 (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3); 923 if (FAILED(rc)) 924 return rc; 925 926 /* Initialize our worker task */ 927 TaskOPC* task = NULL; 989 928 try 990 929 { 991 rc = i_setUpProgress(aProgress, 992 BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()), 993 (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3); 994 if (FAILED(rc)) 995 return rc; 996 997 /* Initialize our worker task */ 998 TaskOPC* task = NULL; 999 try 1000 { 1001 task = new Appliance::TaskOPC(this, TaskOPC::Export, aLocInfo, aProgress); 1002 } 1003 catch(...) 1004 { 1005 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 1006 tr("Could not create TaskOPC object for for writing out the OPC to disk")); 1007 } 1008 1009 rc = task->createThread(); 1010 if (FAILED(rc)) throw rc; 1011 1012 } 1013 catch (HRESULT aRC) 1014 { 1015 rc = aRC; 1016 } 930 task = new Appliance::TaskOPC(this, TaskOPC::Export, aLocInfo, aProgress); 931 } 932 catch(...) 933 { 934 return setError(VBOX_E_OBJECT_NOT_FOUND, 935 tr("Could not create TaskOPC object for for writing out the OPC to disk")); 936 } 937 938 rc = task->createThread(); 1017 939 1018 940 return rc; … … 2326 2248 ComPtr<ICloudProviderManager> cpm; 2327 2249 hrc = mVirtualBox->COMGETTER(CloudProviderManager)(cpm.asOutParam()); 2328 Utf8Str strProviderName("OCI"); 2250 if (FAILED(hrc)) 2251 return setErrorVrc(VERR_COM_OBJECT_NOT_FOUND, tr("Cloud: Cloud provider manager object wasn't found")); 2252 2253 Utf8Str strProviderName = pTask->locInfo.strProvider; 2329 2254 ComPtr<ICloudProvider> cloudProvider; 2255 ComPtr<ICloudProfile> cloudProfile; 2330 2256 hrc = cpm->GetProviderByShortName(Bstr(strProviderName.c_str()).raw(), cloudProvider.asOutParam()); 2331 ComPtr<ICloudProfile> cloudProfile; 2332 hrc = cloudProvider->GetProfileByName(Bstr(m->m_CloudExportData.strProfileName.c_str()).raw(), cloudProfile.asOutParam()); 2257 2258 if (FAILED(hrc)) 2259 return setErrorVrc(VERR_COM_OBJECT_NOT_FOUND, tr("Cloud: Cloud provider object wasn't found")); 2260 2261 ComPtr<IVirtualSystemDescription> vsd = m->virtualSystemDescriptions.front(); 2262 2263 com::SafeArray<VirtualSystemDescriptionType_T> retTypes; 2264 com::SafeArray<BSTR> aRefs; 2265 com::SafeArray<BSTR> aOvfValues; 2266 com::SafeArray<BSTR> aVBoxValues; 2267 com::SafeArray<BSTR> aExtraConfigValues; 2268 2269 hrc = vsd->GetDescriptionByType(VirtualSystemDescriptionType_CloudOCIProfileName, 2270 ComSafeArrayAsOutParam(retTypes), 2271 ComSafeArrayAsOutParam(aRefs), 2272 ComSafeArrayAsOutParam(aOvfValues), 2273 ComSafeArrayAsOutParam(aVBoxValues), 2274 ComSafeArrayAsOutParam(aExtraConfigValues)); 2275 if (FAILED(hrc)) 2276 return hrc; 2277 2278 Utf8Str profileName(aVBoxValues[0]); 2279 if (profileName.isEmpty()) 2280 return setErrorVrc(VBOX_E_OBJECT_NOT_FOUND, tr("Cloud: Cloud user profile name wasn't found")); 2281 2282 hrc = cloudProvider->GetProfileByName(aVBoxValues[0], cloudProfile.asOutParam()); 2283 if (FAILED(hrc)) 2284 return setErrorVrc(VERR_COM_OBJECT_NOT_FOUND, tr("Cloud: Cloud profile object wasn't found")); 2285 2333 2286 ComObjPtr<ICloudClient> cloudClient; 2334 2287 hrc = cloudProfile->CreateCloudClient(cloudClient.asOutParam()); 2335 2336 if (SUCCEEDED(hrc)) 2337 { 2338 LogRel(("Appliance::i_writeFSCloud(): calling CloudClient::ExportLaunchVM\n")); 2339 2340 if (m->virtualSystemDescriptions.size() == 1) { 2341 ComPtr<IVirtualBox> VBox(mVirtualBox); 2342 2343 pTask->pProgress->init(mVirtualBox, static_cast<IAppliance*>(this), 2344 Bstr("Exporting VM to Cloud...").raw(), 2345 TRUE /* aCancelable */, 2346 5, // ULONG cOperations, 2347 1000, // ULONG ulTotalOperationsWeight, 2348 Bstr("Exporting VM to Cloud...").raw(), // aFirstOperationDescription 2349 10); // ULONG ulFirstOperationWeight, 2350 2351 hrc = cloudClient->ExportLaunchVM(m->virtualSystemDescriptions.front(), pTask->pProgress, VBox); 2352 } else { 2353 /// @todo Fail here with user notification. We do export 1 VM only 2354 } 2355 } 2288 if (FAILED(hrc)) 2289 return setErrorVrc(VERR_COM_OBJECT_NOT_FOUND, tr("Cloud: Cloud client object wasn't found")); 2290 2291 LogRel(("Appliance::i_writeFSCloud(): calling CloudClient::ExportLaunchVM\n")); 2292 2293 if (m->virtualSystemDescriptions.size() == 1) 2294 { 2295 ComPtr<IVirtualBox> VBox(mVirtualBox); 2296 hrc = cloudClient->ExportLaunchVM(m->virtualSystemDescriptions.front(), pTask->pProgress, VBox); 2297 } 2298 else 2299 hrc = setErrorVrc(VERR_MISMATCH, tr("Export to Cloud isn't supported for more than one VM instance.")); 2356 2300 2357 2301 LogFlowFuncLeave();
Note:
See TracChangeset
for help on using the changeset viewer.