VirtualBox

Changeset 17033 in vbox for trunk/src/VBox/Frontends


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/Frontends/VBoxManage
Files:
3 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 */
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