VirtualBox

Changeset 18052 in vbox


Ignore:
Timestamp:
Mar 18, 2009 9:56:49 AM (16 years ago)
Author:
vboxsync
Message:

OVF: use AnnotationSection for VM description, don't fail on export if XML file exists

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/xml.h

    r17573 r18052  
    298298     * Possible file access modes.
    299299     */
    300     enum Mode { Mode_Read, Mode_Write, Mode_ReadWrite };
     300    enum Mode { Mode_Read, Mode_WriteCreate, Mode_Overwrite, Mode_ReadWrite };
    301301
    302302    /**
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r18024 r18052  
    508508                return rc;
    509509        }
    510        else if (    (!strcmp(pcszElemName, "NetworkSection"))            // we ignore NetworkSections for now
     510       else if (    (!strcmp(pcszElemName, "NetworkSection"))
    511511                  || (    (!strcmp(pcszElemName, "Section"))
    512512                       && (!strcmp(pcszTypeAttr, "ovf:NetworkSection_Type"))
     
    517517                return rc;
    518518        }
    519         else if (    (!strcmp(pcszElemName, "DeploymentOptionSection>")))
     519        else if (    (!strcmp(pcszElemName, "DeploymentOptionSection")))
    520520        {
    521521            // TODO
     
    694694        const char *pcszTypeAttr = (pTypeAttr) ? pTypeAttr->getValue() : "";
    695695
    696         if (!strcmp(pcszElemName, "Info"))
    697         {
    698             // the "Info" section directly under VirtualSystem is where our export routine
    699             // chooses to save the VM description (comments), so re-import it from there too
    700             vsys.strDescription = pelmThis->getValue();
    701         }
    702         else if (!strcmp(pcszElemName, "EulaSection"))
     696        if (!strcmp(pcszElemName, "EulaSection"))
    703697        {
    704698         /* <EulaSection>
     
    10631057            vsys.cimos = (CIMOSType_T)cimos64;
    10641058        }
     1059        else if (    (!strcmp(pcszElemName, "AnnotationSection"))
     1060                  || (!strcmp(pcszTypeAttr, "ovf:AnnotationSection_Type"))
     1061                )
     1062        {
     1063            const xml::ElementNode *pelmAnnotation;
     1064            if ((pelmAnnotation = pelmThis->findChildElement("Annotation")))
     1065                vsys.strDescription = pelmAnnotation->getValue();
     1066        }
    10651067    }
    10661068
     
    25612563        pelmRoot->setAttribute("xsi:schemaLocation", "http://schemas.dmtf.org/ovf/envelope/1 ../ovf-envelope.xsd");
    25622564
    2563 
    25642565        // <Envelope>/<References>
    25652566        xml::ElementNode *pelmReferences = pelmRoot->createChild("References");
    2566                 // @ŧodo
    25672567
    25682568        /* <Envelope>/<DiskSection>:
     
    26072607            xml::ElementNode *pelmVirtualSystem = pelmVirtualSystemCollection->createChild("VirtualSystem");
    26082608
    2609             xml::ElementNode *pelmVirtualSystemInfo = pelmVirtualSystem->createChild("Info");
    2610             std::list<VirtualSystemDescriptionEntry*> llDescription = vsdescThis->findByType(VirtualSystemDescriptionType_Description);
    2611             if (llDescription.size())
    2612                 pelmVirtualSystemInfo->addContent(llDescription.front()->strVbox);
     2609            /*xml::ElementNode *pelmVirtualSystemInfo =*/ pelmVirtualSystem->createChild("Info")->addContent("A virtual machine");
    26132610
    26142611            std::list<VirtualSystemDescriptionEntry*> llName = vsdescThis->findByType(VirtualSystemDescriptionType_Name);
     
    26182615            pelmVirtualSystem->setAttribute("ovf:id", llName.front()->strVbox);
    26192616
     2617            // description
     2618            std::list<VirtualSystemDescriptionEntry*> llDescription = vsdescThis->findByType(VirtualSystemDescriptionType_Description);
     2619            if (llDescription.size())
     2620            {
     2621                /*  <Section ovf:required="false" xsi:type="ovf:AnnotationSection_Type">
     2622                        <Info>A human-readable annotation</Info>
     2623                        <Annotation>Plan 9</Annotation>
     2624                    </Section> */
     2625                xml::ElementNode *pelmAnnotationSection = pelmVirtualSystem->createChild("AnnotationSection");
     2626                pelmAnnotationSection->createChild("Info")->addContent("A human-readable annotation");
     2627                pelmAnnotationSection->createChild("Annotation")->addContent(llDescription.front()->strVbox);
     2628            }
     2629
     2630            // operating system
    26202631            std::list<VirtualSystemDescriptionEntry*> llOS = vsdescThis->findByType(VirtualSystemDescriptionType_OS);
    26212632            if (llOS.size() != 1)
  • trunk/src/VBox/Main/xml/xml.cpp

    r17664 r18052  
    184184            flags = RTFILE_O_READ;
    185185            break;
    186         case Mode_Write:
     186        case Mode_WriteCreate:      // fail if file exists
    187187            flags = RTFILE_O_WRITE | RTFILE_O_CREATE;
     188            break;
     189        case Mode_Overwrite:        // overwrite if file exists
     190            flags = RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE;
    188191            break;
    189192        case Mode_ReadWrite:
     
    11331136{
    11341137    WriteContext(const char *pcszFilename)
    1135         : IOContext(pcszFilename, File::Mode_Write)
     1138        : IOContext(pcszFilename, File::Mode_Overwrite)
    11361139    {
    11371140    }
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