- Timestamp:
- Feb 23, 2009 8:12:10 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 43246
- Location:
- trunk/src/VBox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r16960 r17033 315 315 { 316 316 RTPrintf("VBoxManage import <ovf>\n" 317 "\n"); // @todo 318 } 319 320 if (u64Cmd & USAGE_EXPORTAPPLIANCE) 321 { 322 RTPrintf("VBoxManage export <machines> -o <ovf>\n" 317 323 "\n"); 318 324 } … … 3007 3013 { "metrics", handleMetrics }, 3008 3014 { "import", handleImportAppliance }, 3015 { "export", handleExportAppliance }, 3009 3016 { NULL, NULL } 3010 3017 }; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r16485 r17033 87 87 #define USAGE_CONVERTHD RT_BIT_64(43) 88 88 #define USAGE_IMPORTAPPLIANCE RT_BIT_64(44) 89 #define USAGE_EXPORTAPPLIANCE RT_BIT_64(45) 89 90 #define USAGE_ALL (~(uint64_t)0) 90 91 /** @} */ … … 170 171 // VBoxManageImport.cpp 171 172 int handleImportAppliance(HandlerArg *a); 173 int handleExportAppliance(HandlerArg *a); 172 174 173 175 /* VBoxManageUSB.cpp */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp
r16834 r17033 98 98 Utf8Str strThisArg(a->argv[i]); 99 99 if ( (strThisArg == "--dry-run") 100 || (strThisArg == "-dry-run") 100 101 || (strThisArg == "-n") 101 102 ) … … 156 157 { 157 158 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)); 162 163 163 164 RTPrintf("Interpreting %s... ", strOvfFilename.c_str()); 164 CHECK_ERROR_BREAK( appliance, Interpret());165 CHECK_ERROR_BREAK(pAppliance, Interpret()); 165 166 RTPrintf("OK.\n"); 166 167 167 168 // fetch all disks 168 169 com::SafeArray<BSTR> retDisks; 169 CHECK_ERROR_BREAK( appliance,170 CHECK_ERROR_BREAK(pAppliance, 170 171 COMGETTER(Disks)(ComSafeArrayAsOutParam(retDisks))); 171 172 if (retDisks.size() > 0) … … 179 180 // fetch virtual system descriptions 180 181 com::SafeIfaceArray<IVirtualSystemDescription> aVirtualSystemDescriptions; 181 CHECK_ERROR_BREAK( appliance,182 CHECK_ERROR_BREAK(pAppliance, 182 183 COMGETTER(VirtualSystemDescriptions)(ComSafeArrayAsOutParam(aVirtualSystemDescriptions))); 183 184 … … 469 470 { 470 471 ComPtr<IProgress> progress; 471 CHECK_ERROR_BREAK( appliance,472 CHECK_ERROR_BREAK(pAppliance, 472 473 ImportMachines(progress.asOutParam())); 473 474 … … 492 493 } 493 494 495 int 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 494 567 #endif /* !VBOX_ONLY_DOCS */ -
trunk/src/VBox/Main/ApplianceImpl.cpp
r16949 r17033 2 2 /** @file 3 3 * 4 * IAppliance and IVirtualSystem COM class implementations 4 * IAppliance and IVirtualSystem COM class implementations. 5 5 */ 6 6 … … 30 30 #include "GuestOSTypeImpl.h" 31 31 #include "ProgressImpl.h" 32 #include "MachineImpl.h" 32 33 33 34 #include "Logging.h" … … 1609 1610 } 1610 1611 1612 STDMETHODIMP Appliance::Write(IN_BSTR path) 1613 { 1614 HRESULT rc = S_OK; 1615 return rc; 1616 } 1617 1611 1618 HRESULT Appliance::searchUniqueVMName(Utf8Str& aName) const 1612 1619 { … … 2498 2505 } 2499 2506 2507 STDMETHODIMP Machine::Export(IAppliance *appliance) 2508 { 2509 HRESULT rc = S_OK; 2510 return rc; 2511 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r16971 r17033 1731 1731 <desc> 1732 1732 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 the1734 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. 1735 1735 </desc> 1736 1736 <param name="appliance" type="IAppliance" dir="return"> … … 2854 2854 > 2855 2855 <desc> 2856 Represents a n appliance in OVF format. An instance of this is returned by2857 <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: 2861 2861 2862 2862 <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. 2865 2881 </li> 2866 2882 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. 2871 2886 </li> 2872 2887 2873 2888 <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 a2875 VirtualBox front-end such as the GUI, and the suggestions can be displayed to the2876 user. In particular, the <link to="#virtualSystemDescriptions" /> array contains2877 instances of <link to="IVirtualSystemDescription" /> which represent the virtual2878 systems in the OVF, which in turn describe the virtual hardware prescribed2879 by theOVF (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. 2881 2896 </li> 2882 2897 2883 <li>If desired, call <link to="IVirtualSystemDescription::setFinalValues" /> for 2884 eachvirtual 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. 2885 2900 </li> 2886 2901 2887 2902 <li>Finally, call <link to="#importMachines" /> to create virtual machines in 2888 VirtualBox as instances of <link to="IMachine" /> that match the information in the2889 virtual system descriptions.2903 VirtualBox as instances of <link to="IMachine" /> that match the information in the 2904 virtual system descriptions. 2890 2905 </li> 2891 2906 </ol> 2892 2907 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 2893 2924 </desc> 2894 2925 2895 2926 <attribute name="path" type="wstring" readonly="yes"> 2896 2927 <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> 2898 2929 </attribute> 2899 2930 … … 2913 2944 <ol> 2914 2945 <li>Disk ID (unique string identifier given to disk)</li> 2946 2915 2947 <li>Capacity (unsigned integer indicating the maximum capacity of the disk)</li> 2948 2916 2949 <li>Populated size (optional unsigned integer indicating the current size of the 2917 2950 disk; can be approximate; -1 if unspecified)</li> 2951 2918 2952 <li>Format (string identifying the disk format, typically 2919 2953 "http://www.vmware.com/specifications/vmdk.html#sparse")</li> 2954 2920 2955 <li>Reference (where to find the disk image, typically a file name; if empty, 2921 2956 then the disk should be created on import)</li> 2957 2922 2958 <li>Image size (optional unsigned integer indicating the size of the image, 2923 2959 which need not necessarily be the same as the values specified above, since 2924 2960 the image may be compressed or sparse; -1 if not specified)</li> 2961 2925 2962 <li>Chunk size (optional unsigned integer if the image is split into chunks; 2926 2963 presently unsupported and always -1)</li> 2964 2927 2965 <li>Compression (optional string equalling "gzip" if the image is gzip-compressed)</li> 2928 2966 </ol> … … 2931 2969 2932 2970 <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 2935 2972 for each virtual system found in the OVF. The array is empty until after <link to="#interpret" /> 2936 2973 has been called. … … 2942 2979 Reads an OVF file into the appliance object. 2943 2980 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 qualified2948 path name to an existing OVF descriptor file with an <tt>.ovf</tt> file extension. If2949 this descriptor file references other files, as OVF appliances distributed as a set of2950 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 the2953 <tt>.ova</tt> file extension. This TAR file must then contain at least the OVF descriptor2954 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 2958 2981 This method succeeds if the OVF is syntactically valid and, by itself, without errors. The 2959 2982 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" />. 2961 2984 </desc> 2962 2985 <param name="file" type="wstring" dir="in"> … … 2998 3021 <param name="aProgress" type="IProgress" dir="return"> 2999 3022 <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> 3000 3038 </param> 3001 3039 </method> … … 4685 4723 </method> 4686 4724 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 4687 4735 <method name="getSnapshot"> 4688 4736 <desc> … … 6485 6533 <desc>Status of the interface.</desc> 6486 6534 </attribute> 6487 6535 6488 6536 <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 6490 6538 if this is a Virtualbox Host Adapter interface.</desc> 6491 6539 </attribute> -
trunk/src/VBox/Main/include/ApplianceImpl.h
r16932 r17033 77 77 STDMETHOD(Interpret)(void); 78 78 STDMETHOD(ImportMachines)(IProgress **aProgress); 79 79 STDMETHOD(Write)(IN_BSTR path); 80 80 /* public methods only for internal purposes */ 81 81 -
trunk/src/VBox/Main/include/MachineImpl.h
r16966 r17033 60 60 //////////////////////////////////////////////////////////////////////////////// 61 61 62 class IAppliance; 62 63 class VirtualBox; 63 64 class Progress; … … 547 548 STDMETHOD(DiscardSettings)(); 548 549 STDMETHOD(DeleteSettings)(); 550 STDMETHOD(Export)(IAppliance *appliance); 549 551 STDMETHOD(GetSnapshot) (IN_GUID aId, ISnapshot **aSnapshot); 550 552 STDMETHOD(FindSnapshot) (IN_BSTR aName, ISnapshot **aSnapshot);
Note:
See TracChangeset
for help on using the changeset viewer.