VirtualBox

Changeset 17033 in vbox for trunk


Ignore:
Timestamp:
Feb 23, 2009 8:12:10 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
43246
Message:

OVF: prototypes for export.

Location:
trunk/src/VBox
Files:
7 edited

Legend:

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

    r16960 r17033  
    315315    {
    316316        RTPrintf("VBoxManage import           <ovf>\n"
     317                 "\n"); // @todo
     318    }
     319
     320    if (u64Cmd & USAGE_EXPORTAPPLIANCE)
     321    {
     322        RTPrintf("VBoxManage export           <machines> -o <ovf>\n"
    317323                 "\n");
    318324    }
     
    30073013        { "metrics",          handleMetrics },
    30083014        { "import",           handleImportAppliance },
     3015        { "export",           handleExportAppliance },
    30093016        { NULL,               NULL }
    30103017    };
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r16485 r17033  
    8787#define USAGE_CONVERTHD             RT_BIT_64(43)
    8888#define USAGE_IMPORTAPPLIANCE       RT_BIT_64(44)
     89#define USAGE_EXPORTAPPLIANCE       RT_BIT_64(45)
    8990#define USAGE_ALL                   (~(uint64_t)0)
    9091/** @} */
     
    170171// VBoxManageImport.cpp
    171172int handleImportAppliance(HandlerArg *a);
     173int handleExportAppliance(HandlerArg *a);
    172174
    173175/* VBoxManageUSB.cpp */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp

    r16834 r17033  
    9898        Utf8Str strThisArg(a->argv[i]);
    9999        if (    (strThisArg == "--dry-run")
     100             || (strThisArg == "-dry-run")
    100101             || (strThisArg == "-n")
    101102           )
     
    156157    {
    157158        Bstr bstrOvfFilename(strOvfFilename);
    158         ComPtr<IAppliance> appliance;
    159         CHECK_ERROR_BREAK(a->virtualBox, CreateAppliance(appliance.asOutParam()));
    160 
    161         CHECK_ERROR_BREAK(appliance, Read(bstrOvfFilename));
     159        ComPtr<IAppliance> pAppliance;
     160        CHECK_ERROR_BREAK(a->virtualBox, CreateAppliance(pAppliance.asOutParam()));
     161
     162        CHECK_ERROR_BREAK(pAppliance, Read(bstrOvfFilename));
    162163
    163164        RTPrintf("Interpreting %s... ", strOvfFilename.c_str());
    164         CHECK_ERROR_BREAK(appliance, Interpret());
     165        CHECK_ERROR_BREAK(pAppliance, Interpret());
    165166        RTPrintf("OK.\n");
    166167
    167168        // fetch all disks
    168169        com::SafeArray<BSTR> retDisks;
    169         CHECK_ERROR_BREAK(appliance,
     170        CHECK_ERROR_BREAK(pAppliance,
    170171                          COMGETTER(Disks)(ComSafeArrayAsOutParam(retDisks)));
    171172        if (retDisks.size() > 0)
     
    179180        // fetch virtual system descriptions
    180181        com::SafeIfaceArray<IVirtualSystemDescription> aVirtualSystemDescriptions;
    181         CHECK_ERROR_BREAK(appliance,
     182        CHECK_ERROR_BREAK(pAppliance,
    182183                          COMGETTER(VirtualSystemDescriptions)(ComSafeArrayAsOutParam(aVirtualSystemDescriptions)));
    183184
     
    469470            {
    470471                ComPtr<IProgress> progress;
    471                 CHECK_ERROR_BREAK(appliance,
     472                CHECK_ERROR_BREAK(pAppliance,
    472473                                  ImportMachines(progress.asOutParam()));
    473474
     
    492493}
    493494
     495int handleExportAppliance(HandlerArg *a)
     496{
     497    HRESULT rc = S_OK;
     498
     499    Utf8Str strOutputFile;
     500    std::list< ComPtr<IMachine> > llMachines;
     501
     502    do
     503    {
     504        for (int i = 0;
     505            i < a->argc;
     506            ++i)
     507        {
     508            Utf8Str strThisArg(a->argv[i]);
     509
     510            if (    strThisArg == "--output"
     511                || strThisArg == "-output"
     512                || strThisArg == "-o"
     513            )
     514            {
     515                if (++i < a->argc)
     516                {
     517                    if (strOutputFile.length())
     518                        return errorSyntax(USAGE_EXPORTAPPLIANCE, "You can only specify --output once.");
     519                    else
     520                        strOutputFile = strThisArg;
     521                }
     522                else
     523                    return errorSyntax(USAGE_EXPORTAPPLIANCE, "Missing argument to --output option.");
     524            }
     525            else
     526            {
     527                // must be machine: try UUID or name
     528                ComPtr<IMachine> machine;
     529                /* assume it's a UUID */
     530                rc = a->virtualBox->GetMachine(Guid(strThisArg), machine.asOutParam());
     531                if (FAILED(rc) || !machine)
     532                {
     533                    /* must be a name */
     534                    CHECK_ERROR_BREAK(a->virtualBox, FindMachine(Bstr(strThisArg), machine.asOutParam()));
     535                }
     536
     537                if (machine)
     538                    llMachines.push_back(machine);
     539            }
     540        }
     541
     542        if (llMachines.size() == 0)
     543            return errorSyntax(USAGE_EXPORTAPPLIANCE, "Missing arguments to export command.");
     544
     545        ComPtr<IAppliance> pAppliance;
     546        CHECK_ERROR_BREAK(a->virtualBox, CreateAppliance(pAppliance.asOutParam()));
     547
     548        std::list< ComPtr<IMachine> >::iterator itM;
     549        for (itM = llMachines.begin();
     550             itM != llMachines.end();
     551             ++itM)
     552        {
     553            ComPtr<IMachine> pMachine = *itM;
     554            CHECK_ERROR_BREAK(pMachine, Export(pAppliance));
     555        }
     556
     557        if (FAILED(rc))
     558            break;
     559
     560        CHECK_ERROR_BREAK(pAppliance, Write(Bstr(strOutputFile)));
     561
     562    } while (0);
     563
     564    return SUCCEEDED(rc) ? 0 : 1;
     565}
     566
    494567#endif /* !VBOX_ONLY_DOCS */
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r16949 r17033  
    22/** @file
    33 *
    4  * IAppliance and IVirtualSystem COM class implementations
     4 * IAppliance and IVirtualSystem COM class implementations.
    55 */
    66
     
    3030#include "GuestOSTypeImpl.h"
    3131#include "ProgressImpl.h"
     32#include "MachineImpl.h"
    3233
    3334#include "Logging.h"
     
    16091610}
    16101611
     1612STDMETHODIMP Appliance::Write(IN_BSTR path)
     1613{
     1614    HRESULT rc = S_OK;
     1615    return rc;
     1616}
     1617
    16111618HRESULT Appliance::searchUniqueVMName(Utf8Str& aName) const
    16121619{
     
    24982505}
    24992506
     2507STDMETHODIMP Machine::Export(IAppliance *appliance)
     2508{
     2509    HRESULT rc = S_OK;
     2510    return rc;
     2511}
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r16971 r17033  
    17311731      <desc>
    17321732        Creates a new appliance object, which represents an appliance in the Open Virtual Machine
    1733         Format (OVF). This can then be used to import an OVF appliance into VirtualBox; see the
    1734         documentation for <link to="IAppliance" /> for details.
     1733        Format (OVF). This can then be used to import an OVF appliance into VirtualBox or to export
     1734        machines as an OVF appliance; see the documentation for <link to="IAppliance" /> for details.
    17351735      </desc>
    17361736      <param name="appliance" type="IAppliance" dir="return">
     
    28542854     >
    28552855    <desc>
    2856         Represents an appliance in OVF format. An instance of this is returned by
    2857         <link to="IVirtualBox::createAppliance" />.
    2858 
    2859         Importing an OVF appliance into VirtualBox involves the following sequence
    2860         of API calls:
     2856        Represents a platform-independent appliance in OVF format. An instance of this is returned
     2857        by <link to="IVirtualBox::createAppliance" />, which can then be used to import and export
     2858        appliances with VirtualBox.
     2859
     2860        The OVF standard suggests two different physical file formats:
    28612861
    28622862        <ol>
    2863           <li>
    2864           Call <link to="IVirtualBox::createAppliance" />. This will create an empty IAppliance object.
     2863            <li>If the OVF is distributed as a set of files, then @a file must be a fully qualified
     2864                path name to an existing OVF descriptor file with an <tt>.ovf</tt> file extension. If
     2865                this descriptor file references other files, as OVF appliances distributed as a set of
     2866                files most likely do, those files must be in the same directory as the descriptor file.</li>
     2867
     2868            <li>If the OVF is distributed as a single file, it must be in TAR format and have the
     2869                <tt>.ova</tt> file extension. This TAR file must then contain at least the OVF descriptor
     2870                files and optionally other files.
     2871
     2872                At this time, VirtualBox does not not yet support the packed (TAR) variant; support will
     2873                be added with a later version.</li>
     2874        </ol>
     2875
     2876        <b>Importing</b> an OVF appliance into VirtualBox as instances of
     2877        <link to="IMachine" /> involves the following sequence of API calls:
     2878
     2879        <ol>
     2880          <li>Call <link to="IVirtualBox::createAppliance" />. This will create an empty IAppliance object.
    28652881          </li>
    28662882
    2867           <li>
    2868           On the new object, call <link to="#read" /> with the full path of the OVF file you
    2869           would like to import. So long as this file is syntactically valid, this will succeed
    2870           and return an instance of IAppliance that contains the parsed data from the OVF file.
     2883          <li>On the new object, call <link to="#read" /> with the full path of the OVF file you
     2884              would like to import. So long as this file is syntactically valid, this will succeed
     2885              and return an instance of IAppliance that contains the parsed data from the OVF file.
    28712886          </li>
    28722887
    28732888          <li>Next, call <link to="#interpret" />, which analyzes the OVF data and sets up the
    2874           contents of the IAppliance attributes accordingly. These can be inspected by a
    2875           VirtualBox front-end such as the GUI, and the suggestions can be displayed to the
    2876           user. In particular, the <link to="#virtualSystemDescriptions" /> array contains
    2877           instances of <link to="IVirtualSystemDescription" /> which represent the virtual
    2878           systems in the OVF, which in turn describe the virtual hardware prescribed
    2879           by the OVF (network and hardware adapters, virtual disk images, memory size and so on).
    2880           The GUI can then give the user the option to confirm and/or change these suggestions.
     2889              contents of the IAppliance attributes accordingly. These can be inspected by a
     2890              VirtualBox front-end such as the GUI, and the suggestions can be displayed to the
     2891              user. In particular, the <link to="#virtualSystemDescriptions" /> array contains
     2892              instances of <link to="IVirtualSystemDescription" /> which represent the virtual
     2893              systems in the OVF, which in turn describe the virtual hardware prescribed by the
     2894              OVF (network and hardware adapters, virtual disk images, memory size and so on).
     2895              The GUI can then give the user the option to confirm and/or change these suggestions.
    28812896          </li>
    28822897
    2883           <li>If desired, call <link to="IVirtualSystemDescription::setFinalValues" /> for
    2884           each virtual system to override the suggestions made by VirtualBox.
     2898          <li>If desired, call <link to="IVirtualSystemDescription::setFinalValues" /> for each
     2899              virtual system to override the suggestions made by VirtualBox.
    28852900          </li>
    28862901
    28872902          <li>Finally, call <link to="#importMachines" /> to  create virtual machines in
    2888           VirtualBox as instances of <link to="IMachine" /> that match the information in the
    2889           virtual system descriptions.
     2903              VirtualBox as instances of <link to="IMachine" /> that match the information in the
     2904              virtual system descriptions.
    28902905          </li>
    28912906        </ol>
    28922907
     2908        <b>Exporting</b> VirtualBox machines into an OVF appliance involves the following steps:
     2909
     2910        <ol>
     2911            <li>As with importing, first call <link to="IVirtualBox::createAppliance" /> to create
     2912                an empty IAppliance object.
     2913            </li>
     2914
     2915            <li>For each machine you would like to export, call <link to="IMachine::export" />
     2916                with the IAppliance object you just created. This creates an instance of
     2917                <link to="IVirtualSystemDescription" /> inside the appliance.
     2918            </li>
     2919
     2920            <li>Finally, call <link to="#write" /> with a path specification to have the OVF
     2921                file written.</li>
     2922        </ol>
     2923
    28932924    </desc>
    28942925
    28952926    <attribute name="path" type="wstring" readonly="yes">
    28962927      <desc>Path to the main file of the OVF appliance, which is either the <tt>.ovf</tt> or
    2897       the <tt>.ova</tt> file passed to <link to="IAppliance::read" />.</desc>
     2928          the <tt>.ova</tt> file passed to <link to="IAppliance::read" />.</desc>
    28982929    </attribute>
    28992930
     
    29132944        <ol>
    29142945            <li>Disk ID (unique string identifier given to disk)</li>
     2946
    29152947            <li>Capacity (unsigned integer indicating the maximum capacity of the disk)</li>
     2948
    29162949            <li>Populated size (optional unsigned integer indicating the current size of the
    29172950            disk; can be approximate; -1 if unspecified)</li>
     2951
    29182952            <li>Format (string identifying the disk format, typically
    29192953            "http://www.vmware.com/specifications/vmdk.html#sparse")</li>
     2954
    29202955            <li>Reference (where to find the disk image, typically a file name; if empty,
    29212956            then the disk should be created on import)</li>
     2957
    29222958            <li>Image size (optional unsigned integer indicating the size of the image,
    29232959            which need not necessarily be the same as the values specified above, since
    29242960            the image may be compressed or sparse; -1 if not specified)</li>
     2961
    29252962            <li>Chunk size (optional unsigned integer if the image is split into chunks;
    29262963            presently unsupported and always -1)</li>
     2964
    29272965            <li>Compression (optional string equalling "gzip" if the image is gzip-compressed)</li>
    29282966        </ol>
     
    29312969
    29322970    <attribute name="virtualSystemDescriptions" type="IVirtualSystemDescription" readonly="yes" safearray="yes">
    2933       <desc>
    2934       Array of virtual system descriptions. One such description is created
     2971      <desc> Array of virtual system descriptions. One such description is created
    29352972      for each virtual system found in the OVF. The array is empty until after <link to="#interpret" />
    29362973      has been called.
     
    29422979        Reads an OVF file into the appliance object.
    29432980
    2944         The OVF standard suggests two different file formats:
    2945 
    2946         <ol>
    2947           <li>If the OVF is distributed as a set of files, then @a file must be a fully qualified
    2948           path name to an existing OVF descriptor file with an <tt>.ovf</tt> file extension. If
    2949           this descriptor file references other files, as OVF appliances distributed as a set of
    2950           files most likely do, those files must be in the same directory as the descriptor file.</li>
    2951 
    2952           <li>If the OVF is distributed as a single file, it must be in TAR format and have the
    2953           <tt>.ova</tt> file extension. This TAR file must then contain at least the OVF descriptor
    2954           files and optionally other files. This variant is not yet supported by VirtualBox;
    2955           support will be added in a later version.</li>
    2956         </ol>
    2957 
    29582981        This method succeeds if the OVF is syntactically valid and, by itself, without errors. The
    29592982        mere fact that this method returns successfully does not mean that VirtualBox supports all
    2960         features requested by the appliance; this can be examined after a call to <link to="#interpret" />.
     2983        features requested by the appliance; this can only be examined after a call to <link to="#interpret" />.
    29612984      </desc>
    29622985      <param name="file" type="wstring" dir="in">
     
    29983021      <param name="aProgress" type="IProgress" dir="return">
    29993022        <desc></desc>
     3023      </param>
     3024    </method>
     3025
     3026    <method name="write">
     3027      <desc>
     3028          Writes the contents of the appliance exports into a new OVF file.
     3029
     3030          Calling this method is the final step of exporting an appliance from VirtualBox;
     3031          see <link to="IAppliance" /> for an overview.
     3032      </desc>
     3033      <param name="path" type="wstring" dir="in">
     3034        <desc>
     3035          Name of appliance file to open (either with an <tt>.ovf</tt> or <tt>.ova</tt> extension, depending
     3036          on whether the appliance is distributed as a set of files or as a single file, respectively).
     3037        </desc>
    30003038      </param>
    30013039    </method>
     
    46854723    </method>
    46864724
     4725    <method name="export">
     4726        <desc>Exports the machine to an OVF appliance. See <link to="IAppliance" /> for the
     4727              steps required to export VirtualBox machines to OVF.
     4728        </desc>
     4729
     4730        <param name="appliance" type="IAppliance" dir="in">
     4731            <desc>Appliance to export this machine to.</desc>
     4732        </param>
     4733    </method >
     4734
    46874735    <method name="getSnapshot">
    46884736      <desc>
     
    64856533      <desc>Status of the interface.</desc>
    64866534    </attribute>
    6487    
     6535
    64886536    <attribute name="real" type="boolean" readonly="yes">
    6489       <desc>True if this is a real interface false 
     6537      <desc>True if this is a real interface false
    64906538      if this is a Virtualbox Host Adapter interface.</desc>
    64916539    </attribute>
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r16932 r17033  
    7777    STDMETHOD(Interpret)(void);
    7878    STDMETHOD(ImportMachines)(IProgress **aProgress);
    79 
     79    STDMETHOD(Write)(IN_BSTR path);
    8080    /* public methods only for internal purposes */
    8181
  • trunk/src/VBox/Main/include/MachineImpl.h

    r16966 r17033  
    6060////////////////////////////////////////////////////////////////////////////////
    6161
     62class IAppliance;
    6263class VirtualBox;
    6364class Progress;
     
    547548    STDMETHOD(DiscardSettings)();
    548549    STDMETHOD(DeleteSettings)();
     550    STDMETHOD(Export)(IAppliance *appliance);
    549551    STDMETHOD(GetSnapshot) (IN_GUID aId, ISnapshot **aSnapshot);
    550552    STDMETHOD(FindSnapshot) (IN_BSTR aName, ISnapshot **aSnapshot);
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