Changeset 73971 in vbox for trunk/src/VBox
- Timestamp:
- Aug 30, 2018 9:35:39 AM (6 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r73929 r73971 24996 24996 </desc> 24997 24997 </param> 24998 <param name="condition" type="wstring" dir="in"> 24999 <desc> 25000 The successful condition for finishing the command. 25001 The command will be repeated if condition isn't in the needed state 25002 </desc> 25003 </param> 24998 25004 <param name="Id" type="uuid" mod="string" dir="return"> 24999 25005 <desc> -
trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
r73932 r73971 891 891 // returns pBootableMedium if there are no diff images 892 892 rc = ptrSourceDisk->COMGETTER(Base)(pBootableBaseMedium.asOutParam()); 893 if (FAILED(rc)) 893 if (FAILED(rc)) 894 894 throw rc; 895 895 … … 907 907 // Locate the Medium object for this entry (by location/path). 908 908 Log(("Finding disk \"%s\"\n", path.c_str())); 909 ComObjPtr<Medium> ptrSourceDisk; 909 910 rc = mVirtualBox->i_findHardDiskByLocation(path, true , &ptrSourceDisk); 910 if (FAILED(rc)) 911 if (FAILED(rc)) 911 912 throw rc; 912 913 … … 920 921 if (vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage).empty()) 921 922 { 922 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 923 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 923 924 tr("Strange, but nothing to export to OCI after preparation steps")); 924 925 } … … 938 939 939 940 if (aLocInfo.strPath.isEmpty()) 940 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 941 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 941 942 tr("OCI: Cloud user profile wasn't found")); 942 943 … … 948 949 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIInstanceShape); 949 950 if (shapeId.empty()) 950 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 951 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 951 952 tr("OCI: Shape of instance wasn't found")); 952 953 … … 957 958 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIDomain); 958 959 if (domainName.empty()) 959 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 960 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 960 961 tr("OCI: Available domain wasn't found")); 961 962 … … 966 967 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIBootDiskSize); 967 968 if (bootDiskSize.empty()) 968 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 969 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 969 970 tr("OCI: Boot disk size wasn't found")); 970 971 … … 975 976 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIBucket); 976 977 if (bucketId.empty()) 977 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 978 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 978 979 tr("OCI: Bucket wasn't found")); 979 980 … … 984 985 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIVCN); 985 986 if (vcn.empty()) 986 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 987 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 987 988 tr("OCI: VCN wasn't found")); 988 989 … … 993 994 vsdescThis->i_findByType(VirtualSystemDescriptionType_CloudOCIPublicIP); 994 995 if (publicIP.empty()) 995 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 996 throw rc = setError(VBOX_E_OBJECT_NOT_FOUND, 996 997 tr("OCI: Public IP setting wasn't found")); 997 998 … … 2373 2374 LogFlowFuncEnter(); 2374 2375 HRESULT hrc = S_OK; 2375 //int vrc = VINF_SUCCESS;2376 int vrc = VINF_SUCCESS; 2376 2377 ComPtr<ICloudProviderManager> cpm; 2377 2378 hrc = mVirtualBox->COMGETTER(CloudProviderManager)(cpm.asOutParam()); 2378 2379 2379 2380 Utf8Str strProviderName("OCI"); 2380 ComPtr<ICloudProvider> ociProfile; 2381 hrc = cpm->GetProviderByShortName(Bstr(strProviderName.c_str()).raw(), ociProfile.asOutParam()); 2382 // initNew(VirtualBox *aVirtualBox, 2383 // OCIProvider *aParent, 2384 // const com::Utf8Str &aProfileName, 2385 // const std::vector<com::Utf8Str> &aNames, 2386 // const std::vector<com::Utf8Str> &aValues) 2387 2388 // hrc = cpm.i_getProfilesByProvider("OCI", ociProfiles); 2389 // if (FAILED(hrc) || ociProfiles.isNull()) 2390 // return hrc; 2381 ComPtr<ICloudProvider> ociProvider; 2382 hrc = cpm->GetProviderByShortName(Bstr(strProviderName.c_str()).raw(), ociProvider.asOutParam()); 2383 ComPtr<ICloudProfile> ociProfile; 2384 hrc = ociProvider->GetProfileByName(Bstr(m->m_OciExportData.strProfileName.c_str()).raw(), ociProfile.asOutParam()); 2385 ComObjPtr<ICloudClient> cloudClient; 2386 hrc = ociProfile->CreateCloudClient(cloudClient.asOutParam()); 2391 2387 2392 2388 //fills by values from m->m_OciExportData 2393 2389 //mostly all names(keys) come from official OCI API documentation (see LaunchInstance description) 2394 std::map<Utf8Str, Utf8Str> paramNameValueMap; 2395 paramNameValueMap.insert(make_pair("displayName", m->m_OciExportData.strDisplayMachineName)); 2396 paramNameValueMap.insert(make_pair("objectName", m->m_OciExportData.strBootImageName)); 2397 paramNameValueMap.insert(make_pair("vcnId", m->m_OciExportData.strVCN)); 2398 paramNameValueMap.insert(make_pair("bucketName", m->m_OciExportData.strBucketId)); 2399 paramNameValueMap.insert(make_pair("bootVolumeSizeInGBs", m->m_OciExportData.strBootDiskSize)); 2400 paramNameValueMap.insert(make_pair("availabilityDomain", m->m_OciExportData.strDomainName)); 2401 paramNameValueMap.insert(make_pair("shape", m->m_OciExportData.strInstanceShapeId)); 2402 paramNameValueMap.insert(make_pair("profileName", m->m_OciExportData.strProfileName)); 2403 paramNameValueMap.insert(make_pair("assignPublicIp", (m->m_OciExportData.fPublicIP == true) ? "true" : "false")); 2390 SafeArray <BSTR> paramNames; 2391 SafeArray <BSTR> paramValues; 2392 2393 Bstr("displayName").detachTo(paramNames.appendedRaw()); 2394 Bstr(m->m_OciExportData.strDisplayMachineName).detachTo(paramValues.appendedRaw()); 2395 Bstr("objectName").detachTo(paramNames.appendedRaw()); 2396 Bstr(m->m_OciExportData.strBootImageName).detachTo(paramValues.appendedRaw()); 2397 Bstr("vcnId").detachTo(paramNames.appendedRaw()); 2398 Bstr(m->m_OciExportData.strVCN).detachTo(paramValues.appendedRaw()); 2399 Bstr("bucketName").detachTo(paramNames.appendedRaw()); 2400 Bstr(m->m_OciExportData.strBucketId).detachTo(paramValues.appendedRaw()); 2401 Bstr("bootVolumeSizeInGBs").detachTo(paramNames.appendedRaw()); 2402 Bstr(m->m_OciExportData.strBootDiskSize).detachTo(paramValues.appendedRaw()); 2403 Bstr("availabilityDomain").detachTo(paramNames.appendedRaw()); 2404 Bstr(m->m_OciExportData.strDomainName).detachTo(paramValues.appendedRaw()); 2405 Bstr("shape").detachTo(paramNames.appendedRaw()); 2406 Bstr(m->m_OciExportData.strInstanceShapeId).detachTo(paramValues.appendedRaw()); 2407 Bstr("profileName").detachTo(paramNames.appendedRaw()); 2408 Bstr(m->m_OciExportData.strProfileName).detachTo(paramValues.appendedRaw()); 2409 Bstr("assignPublicIp").detachTo(paramNames.appendedRaw()); 2410 Utf8Str fIP = (m->m_OciExportData.fPublicIP == true) ? "true" : "false"; 2411 Bstr(fIP.c_str()).detachTo(paramValues.appendedRaw()); 2404 2412 2405 2413 com::SafeArray<CloudCommand_T> commandList; 2406 /*2407 ComObjPtr<ICloudClient> aCloudClient;2408 hrc = ociProfiles->CreateCloudClient(Bstr(m->m_OciExportData.strProfileName).raw(), aCloudClient.asOutParam());2409 2414 2410 2415 if (SUCCEEDED(hrc)) … … 2412 2417 try 2413 2418 { 2414 CloudClient *client = static_cast<CloudClient*>(aCloudClient.operator->()); 2415 2416 hrc = aCloudClient->GetCommandsForOperation(CloudOperation_exportVM, false, 2419 hrc = cloudClient->GetCommandsForOperation(CloudOperation_exportVM, false, 2417 2420 ComSafeArrayAsOutParam(commandList)); 2418 2421 if (SUCCEEDED(hrc)) 2419 2422 { 2420 std::vector<com::Guid> commandIdList;2423 SafeArray <BSTR> commandIdList; 2421 2424 2422 2425 for (ULONG i = 0; i < commandList.size(); i++) 2423 2426 { 2424 2427 CloudCommand_T cmd = commandList[i]; 2428 Utf8Str cond; 2429 switch(cmd) 2430 { 2431 case CloudCommand_getImage: 2432 case CloudCommand_getSubnet: 2433 cond.assign("AVAILABLE"); 2434 break; 2435 case CloudCommand_getInstance: 2436 cond.assign("RUNNING"); 2437 break; 2438 default: 2439 break; 2440 } 2441 2425 2442 Bstr bStrId; 2426 hrc = aCloudClient->CreateCommand(cmd, bStrId.asOutParam());2443 hrc = cloudClient->CreateCommand(cmd, (cond.isEmpty()) ? NULL : Bstr(cond.c_str()).raw(), bStrId.asOutParam()); 2427 2444 2428 2445 if (SUCCEEDED(hrc)) 2429 2446 { 2430 com::Guid cId(bStrId); 2431 //set conditions 2432 { 2433 CloudCommandCl *cc = NULL; 2434 vrc = client->i_getCommandById(cId, &cc); 2435 if (RT_SUCCESS(vrc)) 2436 { 2437 switch(cmd) 2438 { 2439 case CloudCommand_getImage: 2440 case CloudCommand_getSubnet: 2441 vrc = cc->setCondition(new oci::LifecycleStateCondition(Utf8Str("AVAILABLE"))); 2442 break; 2443 case CloudCommand_getInstance: 2444 vrc = cc->setCondition(new oci::LifecycleStateCondition(Utf8Str("RUNNING"))); 2445 break; 2446 default: 2447 break; 2448 } 2449 if (RT_FAILURE(vrc)) 2450 { 2451 hrc = E_FAIL; 2452 break; 2453 } 2454 2455 } 2456 else 2457 { 2458 hrc = E_FAIL; 2459 break; 2460 } 2461 } 2462 2463 commandIdList.push_back(cId);//fills the Id list 2447 bStrId.detachTo(commandIdList.appendedRaw()); 2464 2448 } 2465 2449 } 2466 2450 2467 2451 if (SUCCEEDED(hrc)) 2468 vrc = client->i_runSeveralCommands(commandIdList, paramNameValueMap); 2452 vrc = cloudClient->RunSeveralCommands(ComSafeArrayAsInParam(commandIdList), 2453 ComSafeArrayAsInParam(paramNames), 2454 ComSafeArrayAsInParam(paramValues)); 2469 2455 } 2470 2456 } … … 2478 2464 } 2479 2465 2480 aCloudClient.setNull();2481 } 2482 */ 2466 cloudClient.setNull(); 2467 } 2468 2483 2469 LogFlowFuncLeave(); 2484 2470 return hrc;
Note:
See TracChangeset
for help on using the changeset viewer.