VirtualBox

Changeset 79583 in vbox


Ignore:
Timestamp:
Jul 8, 2019 7:26:43 AM (5 years ago)
Author:
vboxsync
Message:

bugref:9481. API function ICloudClient::exportImage makes the export of VBox image into the Cloud. OCICloudClient::i_launchInstance returns oci::compute::Instance.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

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

    r79319 r79583  
    813813    AssertRCReturn(vrc, RTEXITCODE_FAILURE);
    814814
    815     Utf8Str strCompartmentId("compartment-id");
    816     Utf8Str strInstanceId("instance-id");
    817     Utf8Str strDisplayName("display-name");
     815    Utf8Str strCompartmentId;
     816    Utf8Str strInstanceId;
     817    Utf8Str strDisplayName;
    818818    com::SafeArray<BSTR>  parameters;
    819819
     
    824824        {
    825825            case 'c':
    826                 strCompartmentId.append("=").append(ValueUnion.psz);
    827                 Bstr(strCompartmentId).detachTo(parameters.appendedRaw());
     826                strCompartmentId=ValueUnion.psz;
     827                Bstr(Utf8Str("compartment-id=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    828828                break;
    829829            case 'i':
    830                 strInstanceId.append("=").append(ValueUnion.psz);
    831                 Bstr(strInstanceId).detachTo(parameters.appendedRaw());
     830                strInstanceId=ValueUnion.psz;
     831                Bstr(Utf8Str("instance-id=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    832832                break;
    833833            case 'd':
    834                 strDisplayName.append("=").append(ValueUnion.psz);
    835                 Bstr(strDisplayName).detachTo(parameters.appendedRaw());
     834                strDisplayName=ValueUnion.psz;
     835                Bstr(Utf8Str("display-name=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    836836                break;
    837837            case VINF_GETOPT_NOT_OPTION:
     
    885885    AssertRCReturn(vrc, RTEXITCODE_FAILURE);
    886886
    887     Utf8Str strBucketName("bucket-name");
    888     Utf8Str strObjectName("object-name");
     887    Utf8Str strBucketName;
     888    Utf8Str strObjectName;
    889889    Utf8Str strImageId;
    890890    com::SafeArray<BSTR>  parameters;
     
    896896        {
    897897            case 'b':
    898                 strBucketName.append("=").append(ValueUnion.psz);
    899                 Bstr(strBucketName).detachTo(parameters.appendedRaw());
     898                strBucketName=ValueUnion.psz;
     899                Bstr(Utf8Str("bucket-name=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    900900                break;
    901901            case 'o':
    902                 strObjectName.append("=").append(ValueUnion.psz);
    903                 Bstr(strObjectName).detachTo(parameters.appendedRaw());
     902                strObjectName=ValueUnion.psz;
     903                Bstr(Utf8Str("object-name=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    904904                break;
    905905            case 'i':
    906                 strImageId = ValueUnion.psz;
    907                 Bstr(strImageId).detachTo(parameters.appendedRaw());
     906                strImageId=ValueUnion.psz;
     907                Bstr(Utf8Str("image-id=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    908908                break;
    909909            case VINF_GETOPT_NOT_OPTION:
     
    922922                     CreateCloudClient(oCloudClient.asOutParam()),
    923923                     RTEXITCODE_FAILURE);
    924     RTPrintf("Exporting cloud image \'%s\' to the object \'%s\'...\n", strImageId.c_str(), strObjectName.c_str());
     924    RTPrintf("Exporting image \'%s\' to the Cloud with name \'%s\'...\n", strImageId.c_str(), strObjectName.c_str());
     925
     926    ComPtr<IVirtualBox> pVirtualBox = a->virtualBox;
     927    SafeIfaceArray<IMedium> aImageList;
     928    CHECK_ERROR2_RET(hrc, pVirtualBox,
     929                     COMGETTER(HardDisks)(ComSafeArrayAsOutParam(aImageList)),
     930                     RTEXITCODE_FAILURE);
     931
     932    ComPtr<IMedium> pImage;
     933    size_t cImages = aImageList.size();
     934    bool fFound = false;
     935    for (size_t i = 0; i < cImages; ++i)
     936    {
     937        pImage = aImageList[i];
     938        Bstr bstrImageId;
     939        hrc = pImage->COMGETTER(Id)(bstrImageId.asOutParam());
     940        if (FAILED(hrc))
     941            continue;
     942
     943        com::Guid imageId(bstrImageId);
     944
     945        if (!imageId.isValid() || imageId.isZero())
     946            continue;
     947
     948        if (!strImageId.compare(imageId.toString()))
     949        {
     950            fFound = true;
     951            RTPrintf("Image %s was found\n", strImageId.c_str());
     952            break;
     953        }
     954    }
     955
     956    if (!fFound)
     957    {
     958        RTPrintf("Process of exporting the image to the Cloud was interrupted. The image wasn't found.\n");
     959        return RTEXITCODE_FAILURE;
     960    }
    925961
    926962    ComPtr<IProgress> progress;
    927963    CHECK_ERROR2_RET(hrc, oCloudClient,
    928                      ExportImage(Bstr(strImageId).raw(), ComSafeArrayAsInParam(parameters), progress.asOutParam()),
     964                     ExportImage(pImage, pVirtualBox, ComSafeArrayAsInParam(parameters), progress.asOutParam()),
    929965                     RTEXITCODE_FAILURE);
    930966    hrc = showProgress(progress);
    931     CHECK_PROGRESS_ERROR_RET(progress, ("Cloud image export failed"), RTEXITCODE_FAILURE);
     967    CHECK_PROGRESS_ERROR_RET(progress, ("Export the image to the Cloud failed"), RTEXITCODE_FAILURE);
    932968
    933969    if (SUCCEEDED(hrc))
    934         RTPrintf("Cloud image was exported successfully\n");
     970        RTPrintf("Export the image to the Cloud was successfull\n");
    935971
    936972    return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
     
    956992    AssertRCReturn(vrc, RTEXITCODE_FAILURE);
    957993
    958     Utf8Str strCompartmentId("compartment-id");
    959     Utf8Str strBucketName("bucket-name");
    960     Utf8Str strObjectName("object-name");
    961     Utf8Str strDisplayName("display-name");
     994    Utf8Str strCompartmentId;
     995    Utf8Str strBucketName;
     996    Utf8Str strObjectName;
     997    Utf8Str strDisplayName;
    962998    com::SafeArray<BSTR>  parameters;
    963999
     
    9681004        {
    9691005            case 'c':
    970                 strCompartmentId.append("=").append(ValueUnion.psz);
    971                 Bstr(strCompartmentId).detachTo(parameters.appendedRaw());
     1006                strCompartmentId=ValueUnion.psz;
     1007                Bstr(Utf8Str("compartment-id=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    9721008                break;
    9731009            case 'b':
    974                 strBucketName.append("=").append(ValueUnion.psz);
    975                 Bstr(strBucketName).detachTo(parameters.appendedRaw());
     1010                strBucketName=ValueUnion.psz;
     1011                Bstr(Utf8Str("bucket-name=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    9761012                break;
    9771013            case 'o':
    978                 strObjectName.append("=").append(ValueUnion.psz);
    979                 Bstr(strObjectName).detachTo(parameters.appendedRaw());
     1014                strObjectName=ValueUnion.psz;
     1015                Bstr(Utf8Str("object-name=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    9801016                break;
    9811017            case 'd':
    982                 strDisplayName.append("=").append(ValueUnion.psz);
    983                 Bstr(strDisplayName).detachTo(parameters.appendedRaw());
     1018                strDisplayName=ValueUnion.psz;
     1019                Bstr(Utf8Str("display-name=").append(ValueUnion.psz)).detachTo(parameters.appendedRaw());
    9841020                break;
    9851021            case VINF_GETOPT_NOT_OPTION:
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r79466 r79583  
    2601126011  <interface
    2601226012    name="ICloudClient" extends="$unknown"
    26013     uuid="1c757554-9768-11e9-9319-ab248c01ad59"
     26013    uuid="361276ab-3be4-4a1a-abf2-2993048766c4"
    2601426014    wsmap="managed" reservedMethods="16" reservedAttributes="8"
    2601526015    >
     
    2615526155    </method>
    2615626156
     26157    <method name="importInstance">
     26158      <desc>
     26159        Import an existing instance with passed id to the local host.
     26160      </desc>
     26161      <param name="description" type="IVirtualSystemDescription" dir="in">
     26162        <desc>VirtualSystemDescription object which is describing a machine and all required parameters.</desc>
     26163      </param>
     26164      <param name="uid" type="wstring" dir="in">
     26165        <desc>the UUID of instance imported from the Cloud.</desc>
     26166      </param>
     26167      <param name="virtualBox" type="IVirtualBox" dir="in">
     26168        <desc>Reference to the server-side API root object.</desc>
     26169      </param>
     26170      <param name="progress" type="IProgress" dir="in">
     26171        <desc>Progress object to track the operation completion.</desc>
     26172      </param>
     26173    </method>
     26174
    2615726175    <method name="listInstances" const="yes">
    2615826176      <desc>
     
    2620826226    </method>
    2620926227
    26210     <method name="importInstance">
    26211       <desc>
    26212         Import an existing instance with passed id to the local host.
    26213       </desc>
    26214       <param name="description" type="IVirtualSystemDescription" dir="in">
    26215         <desc>VirtualSystemDescription object which is describing a machine and all required parameters.</desc>
    26216       </param>
     26228    <method name="startInstance">
     26229      <desc>
     26230        Start an existing instance with passed id.
     26231      </desc>
    2621726232      <param name="uid" type="wstring" dir="in">
    26218         <desc>the UUID of instance imported from the Cloud.</desc>
     26233        <desc>the UUID of instance in the Cloud.</desc>
     26234      </param>
     26235      <param name="progress" type="IProgress" dir="return">
     26236        <desc>Progress object to track the operation completion.</desc>
     26237      </param>
     26238    </method>
     26239
     26240    <method name="pauseInstance">
     26241      <desc>
     26242        Pause an existing instance with passed id.
     26243      </desc>
     26244      <param name="uid" type="wstring" dir="in">
     26245        <desc>the UUID of instance in the Cloud.</desc>
     26246      </param>
     26247      <param name="progress" type="IProgress" dir="return">
     26248        <desc>Progress object to track the operation completion.</desc>
     26249      </param>
     26250    </method>
     26251
     26252    <method name="terminateInstance">
     26253      <desc>
     26254        Terminate an existing instance with passed id.
     26255      </desc>
     26256      <param name="uid" type="wstring" dir="in">
     26257        <desc>the UUID of instance in the Cloud.</desc>
     26258      </param>
     26259      <param name="progress" type="IProgress" dir="return">
     26260        <desc>Progress object to track the operation completion.</desc>
     26261      </param>
     26262    </method>
     26263
     26264    <method name="createImage">
     26265      <desc>
     26266        Create an image in the Cloud.
     26267      </desc>
     26268      <param name="parameters" type="wstring" dir="in" safearray="yes">
     26269        <desc>Each parameter in the array must be in the form "name=value".</desc>
     26270      </param>
     26271      <param name="progress" type="IProgress" dir="return">
     26272        <desc>Progress object to track the operation completion.</desc>
     26273      </param>
     26274    </method>
     26275
     26276    <method name="exportImage">
     26277      <desc>
     26278        Export an existing image with passed id somewhere in the Cloud.
     26279      </desc>
     26280      <param name="image" type="IMedium" dir="in">
     26281        <desc>Reference to the existing VBox image.</desc>
    2621926282      </param>
    2622026283      <param name="virtualBox" type="IVirtualBox" dir="in">
    2622126284        <desc>Reference to the server-side API root object.</desc>
    26222       </param>
    26223       <param name="progress" type="IProgress" dir="in">
    26224         <desc>Progress object to track the operation completion.</desc>
    26225       </param>
    26226     </method>
    26227 
    26228     <method name="startInstance">
    26229       <desc>
    26230         Start an existing instance with passed id.
    26231       </desc>
    26232       <param name="uid" type="wstring" dir="in">
    26233         <desc>the UUID of instance in the Cloud.</desc>
    26234       </param>
    26235       <param name="progress" type="IProgress" dir="return">
    26236         <desc>Progress object to track the operation completion.</desc>
    26237       </param>
    26238     </method>
    26239 
    26240     <method name="pauseInstance">
    26241       <desc>
    26242         Pause an existing instance with passed id.
    26243       </desc>
    26244       <param name="uid" type="wstring" dir="in">
    26245         <desc>the UUID of instance in the Cloud.</desc>
    26246       </param>
    26247       <param name="progress" type="IProgress" dir="return">
    26248         <desc>Progress object to track the operation completion.</desc>
    26249       </param>
    26250     </method>
    26251 
    26252     <method name="terminateInstance">
    26253       <desc>
    26254         Terminate an existing instance with passed id.
    26255       </desc>
    26256       <param name="uid" type="wstring" dir="in">
    26257         <desc>the UUID of instance in the Cloud.</desc>
    26258       </param>
    26259       <param name="progress" type="IProgress" dir="return">
    26260         <desc>Progress object to track the operation completion.</desc>
    26261       </param>
    26262     </method>
    26263 
    26264     <method name="createImage">
    26265       <desc>
    26266         Create an image in the Cloud.
    26267       </desc>
    26268       <param name="parameters" type="wstring" dir="in" safearray="yes">
    26269         <desc>Each parameter in the array must be in the form "name=value".</desc>
    26270       </param>
    26271       <param name="progress" type="IProgress" dir="return">
    26272         <desc>Progress object to track the operation completion.</desc>
    26273       </param>
    26274     </method>
    26275 
    26276     <method name="exportImage">
    26277       <desc>
    26278         Export an existing image with passed id somewhere in the Cloud.
    26279       </desc>
    26280       <param name="uid" type="wstring" dir="in">
    26281         <desc>the UUID of image in the Cloud.</desc>
    2628226285      </param>
    2628326286      <param name="parameters" type="wstring" dir="in" safearray="yes">
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