VirtualBox

Changeset 18623 in vbox


Ignore:
Timestamp:
Apr 2, 2009 10:00:48 AM (15 years ago)
Author:
vboxsync
Message:

OVF: add support for writing OVF 0.9 instead of 1.0 and make it the default in front-ends for now

Location:
trunk/src/VBox
Files:
5 edited

Legend:

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

    r18490 r18623  
    656656
    657657        ComPtr<IProgress> progress;
    658         CHECK_ERROR_BREAK(pAppliance, Write(Bstr(strOutputFile), progress.asOutParam()));
     658        CHECK_ERROR_BREAK(pAppliance, Write(Bstr("ovf-0.9"), Bstr(strOutputFile), progress.asOutParam()));
    659659
    660660        showProgress(progress);
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxExportApplianceWzd.cpp

    r18402 r18623  
    302302{
    303303    /* Write the appliance */
    304     CProgress progress = aAppliance.Write (mFileSelector->path());
     304    CProgress progress = aAppliance.Write ("ovf-0.9", mFileSelector->path());
    305305    bool fResult = aAppliance.isOk();
    306306    if (fResult)
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r18591 r18623  
    24592459{
    24602460    TaskWriteOVF(Appliance *aThat, Progress *aProgress)
    2461         : pAppliance(aThat)
    2462         , progress(aProgress)
    2463         , rc(S_OK)
     2461        : pAppliance(aThat),
     2462          enFormat(unspecified),
     2463          progress(aProgress),
     2464          rc(S_OK)
    24642465    {}
    24652466    ~TaskWriteOVF() {}
     
    24682469
    24692470    Appliance *pAppliance;
     2471    enum { unspecified, OVF_0_9, OVF_1_0 }
     2472        enFormat;
     2473
    24702474    ComObjPtr<Progress> progress;
    24712475    HRESULT rc;
     
    24832487}
    24842488
    2485 STDMETHODIMP Appliance::Write(IN_BSTR path, IProgress **aProgress)
     2489STDMETHODIMP Appliance::Write(IN_BSTR format, IN_BSTR path, IProgress **aProgress)
    24862490{
    24872491    HRESULT rc = S_OK;
     
    25122516        //AssertComRCThrowRC (task->autoCaller.rc());
    25132517
     2518        Utf8Str strFormat(format);
     2519        if (strFormat == "ovf-0.9")
     2520            task->enFormat = TaskWriteOVF::OVF_0_9;
     2521        else if (strFormat == "ovf-1.0")
     2522            task->enFormat = TaskWriteOVF::OVF_1_0;
     2523        else
     2524            return setError(VBOX_E_FILE_ERROR,
     2525                            tr("Invalid format \"%s\" specified"), strFormat.c_str());
     2526
    25142527        rc = task->startThread();
    25152528        CheckComRCThrowRC(rc);
     
    25592572        xml::ElementNode *pelmRoot = doc.createRootElement("Envelope");
    25602573
    2561         pelmRoot->setAttribute("ovf:version", "1.0");
     2574        pelmRoot->setAttribute("ovf:version", (task->enFormat == TaskWriteOVF::OVF_1_0) ? "1.0" : "0.9");
    25622575        pelmRoot->setAttribute("xml:lang", "en-US");
    25632576        pelmRoot->setAttribute("xmlns", "http://schemas.dmtf.org/ovf/envelope/1");
    25642577        pelmRoot->setAttribute("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1");
    2565         pelmRoot->setAttribute("xmlns:ovfstr", "http://schema.dmtf.org/ovf/strings/1");
     2578//         pelmRoot->setAttribute("xmlns:ovfstr", "http://schema.dmtf.org/ovf/strings/1");
    25662579        pelmRoot->setAttribute("xmlns:rasd", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData");
    25672580        pelmRoot->setAttribute("xmlns:vssd", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData");
    25682581        pelmRoot->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    2569         pelmRoot->setAttribute("xsi:schemaLocation", "http://schemas.dmtf.org/ovf/envelope/1 ../ovf-envelope.xsd");
     2582//         pelmRoot->setAttribute("xsi:schemaLocation", "http://schemas.dmtf.org/ovf/envelope/1 ../ovf-envelope.xsd");
    25702583
    25712584        // <Envelope>/<References>
    2572         xml::ElementNode *pelmReferences = pelmRoot->createChild("References");
     2585        xml::ElementNode *pelmReferences = pelmRoot->createChild("References");     // 0.9 and 1.0
    25732586
    25742587        /* <Envelope>/<DiskSection>:
     
    25772590                <Disk ovf:capacity="4294967296" ovf:diskId="lamp" ovf:format="http://www.vmware.com/specifications/vmdk.html#compressed" ovf:populatedSize="1924967692"/>
    25782591            </DiskSection> */
    2579         xml::ElementNode *pelmDiskSection = pelmRoot->createChild("DiskSection");
     2592        xml::ElementNode *pelmDiskSection;
     2593        if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2594        {
     2595            // <Section xsi:type="ovf:DiskSection_Type">
     2596            pelmDiskSection = pelmRoot->createChild("Section");
     2597            pelmDiskSection->setAttribute("xsi:type", "ovf:DiskSection_Type");
     2598        }
     2599        else
     2600            pelmDiskSection = pelmRoot->createChild("DiskSection");
     2601
    25802602        xml::ElementNode *pelmDiskSectionInfo = pelmDiskSection->createChild("Info");
    25812603        pelmDiskSectionInfo->addContent("List of the virtual disks used in the package");
     
    25912613                </Network>
    25922614            </NetworkSection> */
    2593         xml::ElementNode *pelmNetworkSection = pelmRoot->createChild("NetworkSection");
     2615        xml::ElementNode *pelmNetworkSection;
     2616        if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2617        {
     2618            // <Section xsi:type="ovf:NetworkSection_Type">
     2619            pelmNetworkSection = pelmRoot->createChild("Section");
     2620            pelmNetworkSection->setAttribute("xsi:type", "ovf:NetworkSection_Type");
     2621        }
     2622        else
     2623            pelmNetworkSection = pelmRoot->createChild("NetworkSection");
     2624
    25942625        xml::ElementNode *pelmNetworkSectionInfo = pelmNetworkSection->createChild("Info");
    25952626        pelmNetworkSectionInfo->addContent("Logical networks used in the package");
     
    26002631
    26012632        // and here come the virtual systems:
    2602         xml::ElementNode *pelmVirtualSystemCollection = pelmRoot->createChild("VirtualSystemCollection");
     2633        xml::ElementNode *pelmVirtualSystemCollection;
     2634        if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2635        {
     2636            // <Section xsi:type="ovf:NetworkSection_Type">
     2637            pelmVirtualSystemCollection = pelmRoot->createChild("Content");
     2638            pelmVirtualSystemCollection->setAttribute("xsi:type", "ovf:VirtualSystemCollection_Type");
     2639        }
     2640        else
     2641            pelmVirtualSystemCollection = pelmRoot->createChild("VirtualSystemCollection");
    26032642        /* xml::AttributeNode *pattrVirtualSystemCollectionId = */ pelmVirtualSystemCollection->setAttribute("ovf:id", "ExportedVirtualBoxMachines");      // whatever
    26042643
     
    26112650            ComObjPtr<VirtualSystemDescription> vsdescThis = (*it);
    26122651
    2613             xml::ElementNode *pelmVirtualSystem = pelmVirtualSystemCollection->createChild("VirtualSystem");
     2652            xml::ElementNode *pelmVirtualSystem;
     2653            if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2654            {
     2655                // <Section xsi:type="ovf:NetworkSection_Type">
     2656                pelmVirtualSystem = pelmVirtualSystemCollection->createChild("Content");
     2657                pelmVirtualSystem->setAttribute("xsi:type", "ovf:VirtualSystem_Type");
     2658            }
     2659            else
     2660                pelmVirtualSystem = pelmVirtualSystemCollection->createChild("VirtualSystem");
    26142661
    26152662            /*xml::ElementNode *pelmVirtualSystemInfo =*/ pelmVirtualSystem->createChild("Info")->addContent("A virtual machine");
     
    26192666                throw setError(VBOX_E_NOT_SUPPORTED,
    26202667                               tr("Missing VM name"));
    2621             pelmVirtualSystem->setAttribute("ovf:id", llName.front()->strVbox);
     2668            Utf8Str &strVMName = llName.front()->strVbox;
     2669            pelmVirtualSystem->setAttribute("ovf:id", strVMName);
    26222670
    26232671            // product info
     
    26452693                    <ProductUrl>http://blogs.sun.com/VirtualGuru</ProductUrl>
    26462694                    <VendorUrl>http://www.sun.com</VendorUrl>
    2647                    </Section> */
    2648                 xml::ElementNode *pelmAnnotationSection = pelmVirtualSystem->createChild("ProductSection");
     2695                </Section> */
     2696                xml::ElementNode *pelmAnnotationSection;
     2697                if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2698                {
     2699                    // <Section ovf:required="false" xsi:type="ovf:ProductSection_Type">
     2700                    pelmAnnotationSection = pelmVirtualSystem->createChild("Section");
     2701                    pelmAnnotationSection->setAttribute("xsi:type", "ovf:ProductSection_Type");
     2702                }
     2703                else
     2704                    pelmAnnotationSection = pelmVirtualSystem->createChild("ProductSection");
     2705
    26492706                pelmAnnotationSection->createChild("Info")->addContent("Meta-information about the installed software");
    26502707                if (fProduct)
     
    26692726                        <Annotation>Plan 9</Annotation>
    26702727                    </Section> */
    2671                 xml::ElementNode *pelmAnnotationSection = pelmVirtualSystem->createChild("AnnotationSection");
     2728                xml::ElementNode *pelmAnnotationSection;
     2729                if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2730                {
     2731                    // <Section ovf:required="false" xsi:type="ovf:AnnotationSection_Type">
     2732                    pelmAnnotationSection = pelmVirtualSystem->createChild("Section");
     2733                    pelmAnnotationSection->setAttribute("xsi:type", "ovf:AnnotationSection_Type");
     2734                }
     2735                else
     2736                    pelmAnnotationSection = pelmVirtualSystem->createChild("AnnotationSection");
     2737
    26722738                pelmAnnotationSection->createChild("Info")->addContent("A human-readable annotation");
    26732739                pelmAnnotationSection->createChild("Annotation")->addContent(llDescription.front()->strVbox);
     
    26832749                   <License ovf:msgid="1">License terms can go in here.</License>
    26842750                   </EulaSection> */
    2685                 xml::ElementNode *pelmAnnotationSection = pelmVirtualSystem->createChild("EulaSection");
    2686                 pelmAnnotationSection->createChild("Info")->addContent("License agreement for the Virtual System.");
    2687                 pelmAnnotationSection->createChild("License")->addContent(llLicense.front()->strVbox);
     2751                xml::ElementNode *pelmEulaSection;
     2752                if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2753                {
     2754                    pelmEulaSection = pelmVirtualSystem->createChild("Section");
     2755                    pelmEulaSection->setAttribute("xsi:type", "ovf:EulaSection_Type");
     2756                }
     2757                else
     2758                    pelmEulaSection = pelmVirtualSystem->createChild("EulaSection");
     2759
     2760                pelmEulaSection->createChild("Info")->addContent("License agreement for the virtual system");
     2761                pelmEulaSection->createChild("License")->addContent(llLicense.front()->strVbox);
    26882762            }
    26892763
     
    26972771                    <Description>Linux 2.6.x</Description>
    26982772                </OperatingSystemSection> */
    2699             xml::ElementNode *pelmOperatingSystemSection = pelmVirtualSystem->createChild("OperatingSystemSection");
     2773            xml::ElementNode *pelmOperatingSystemSection;
     2774            if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2775            {
     2776                pelmOperatingSystemSection = pelmVirtualSystem->createChild("Section");
     2777                pelmOperatingSystemSection->setAttribute("xsi:type", "ovf:OperatingSystemSection_Type");
     2778            }
     2779            else
     2780                pelmOperatingSystemSection = pelmVirtualSystem->createChild("OperatingSystemSection");
     2781
    27002782            pelmOperatingSystemSection->setAttribute("ovf:id", llOS.front()->strOvf);
    2701 //             pelmOperatingSystemSection->createChild("Info")->addContent("blah");        // @todo
    2702 //             pelmOperatingSystemSection->createChild("Description")->addContent("blah");        // @todo
     2783            pelmOperatingSystemSection->createChild("Info")->addContent("The kind of installed guest operating system");
     2784//             pelmOperatingSystemSection->createChild("Description")->addContent("blah"); // @todo
    27032785
    27042786            // <VirtualHardwareSection ovf:id="hw1" ovf:transport="iso">
    2705             xml::ElementNode *pelmVirtualHardwareSection = pelmVirtualSystem->createChild("VirtualHardwareSection");
     2787            xml::ElementNode *pelmVirtualHardwareSection;
     2788            if (task->enFormat == TaskWriteOVF::OVF_0_9)
     2789            {
     2790                // <Section xsi:type="ovf:VirtualHardwareSection_Type">
     2791                pelmVirtualHardwareSection = pelmVirtualSystem->createChild("Section");
     2792                pelmVirtualHardwareSection->setAttribute("xsi:type", "ovf:VirtualHardwareSection_Type");
     2793            }
     2794            else
     2795                pelmVirtualHardwareSection = pelmVirtualSystem->createChild("VirtualHardwareSection");
     2796
     2797            pelmVirtualHardwareSection->createChild("Info")->addContent("Virtual hardware requirements for a virtual machine");
    27062798
    27072799            /*  <System>
     
    27142806            xml::ElementNode *pelmSystem = pelmVirtualHardwareSection->createChild("System");
    27152807
     2808            // <vssd:InstanceId>0</vssd:InstanceId>
     2809            pelmSystem->createChild("vssd:InstanceId")->addContent("0");
     2810            // <vssd:VirtualSystemIdentifier>VAtest</vssd:VirtualSystemIdentifier>
     2811            pelmSystem->createChild("vssd:VirtualSystemIdentifier")->addContent(strVMName);
    27162812            // <vssd:VirtualSystemType>vmx-4</vssd:VirtualSystemType>
    2717             xml::ElementNode *pelmVirtualSystemType = pelmSystem->createChild("VirtualSystemType");
    2718             pelmVirtualSystemType->addContent("virtualbox-2.2");            // instead of vmx-7?
     2813            pelmSystem->createChild("vssd:VirtualSystemType")->addContent("virtualbox-2.2");            // instead of vmx-7?
    27192814
    27202815            // loop thru all description entries twice; once to write out all
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r18592 r18623  
    32343234          returns an IProgress object to allow the caller to monitor the progress.
    32353235      </desc>
     3236      <param name="format" type="wstring" dir="in">
     3237        <desc>
     3238            Output format, as a string. Currently supported formats are "ovf-0.9" and "ovf-1.0";
     3239            future versions of VirtualBox may support additional formats.
     3240        </desc>
     3241      </param>
    32363242      <param name="path" type="wstring" dir="in">
    3237         <desc>
    3238           Name of appliance file to open (either with an <tt>.ovf</tt> or <tt>.ova</tt> extension, depending
    3239           on whether the appliance is distributed as a set of files or as a single file, respectively).
    3240         </desc>
     3243          <desc>
     3244              Name of appliance file to open (either with an <tt>.ovf</tt> or <tt>.ova</tt> extension, depending
     3245              on whether the appliance is distributed as a set of files or as a single file, respectively).
     3246          </desc>
    32413247      </param>
    32423248      <param name="aProgress" type="IProgress" dir="return">
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r18304 r18623  
    7777    STDMETHOD(Interpret)(void);
    7878    STDMETHOD(ImportMachines)(IProgress **aProgress);
    79     STDMETHOD(Write)(IN_BSTR path, IProgress **aProgress);
     79    STDMETHOD(Write)(IN_BSTR format, IN_BSTR path, IProgress **aProgress);
    8080    STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
    8181
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