[pve-devel] [RFC PATCH qemu-server 4/4] Add a new command line option 'ovfcreate', to create VMs from an OVF manifest

Alexandre DERUMIER aderumier at odiso.com
Fri Feb 24 08:23:27 CET 2017


Hi Emmanuel,

I think "ovfcreate" is a little bit confusing. (sound like we want to create an ovf).

maybe "ovfimport" could be better ?  (If later we want to add something like ovfexport, to generate ovf"


----- Mail original -----
De: "Emmanuel Kasper" <e.kasper at proxmox.com>
À: "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Mardi 21 Février 2017 10:18:56
Objet: [pve-devel] [RFC PATCH qemu-server 4/4] Add a new command line	option 'ovfcreate', to create VMs from an OVF manifest

Currently the following extracted paramaters are used to create a VM: 
* VM name 
* Memory 
* Number of cores 
--- 
PVE/CLI/qm.pm | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 
1 file changed, 47 insertions(+) 

diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm 
index 44439dd..f431023 100755 
--- a/PVE/CLI/qm.pm 
+++ b/PVE/CLI/qm.pm 
@@ -17,10 +17,12 @@ use PVE::SafeSyslog; 
use PVE::INotify; 
use PVE::RPCEnvironment; 
use PVE::QemuServer; 
+use PVE::QemuServer::OVF; 
use PVE::API2::Qemu; 
use JSON; 
use PVE::JSONSchema qw(get_standard_option); 
use Term::ReadLine; 
+use Data::Dumper; 

use PVE::CLIHandler; 

@@ -432,6 +434,48 @@ __PACKAGE__->register_method ({ 
return undef; 
}}); 

+__PACKAGE__->register_method ({ 
+ name => 'ovfcreate', 
+ path => 'ovfcreate', 
+ description => "Create a new VM using parameters read from an OVF manifest", 
+ parameters => { 
+ additionalProperties => 0, 
+ properties => { 
+ vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }), 
+ dryrun => { 
+ type => 'boolean', 
+ description => 'Print a text representation of the extracted OVF parameters, but do not create a VM', 
+ optional => 1, 
+ }, 
+ manifest => { 
+ type => 'string' 
+ } 
+ }, 
+ }, 
+ returns => { 
+ type => 'string', 
+ }, 
+ code => sub { 
+ my ($param) = @_; 
+ my $vmid = $param->{vmid}; 
+ my $ovf_file = PVE::Tools::extract_param($param, 'manifest'); 
+ my $dryrun = PVE::Tools::extract_param($param, 'dryrun'); 
+ 
+ my $parsed = PVE::QemuServer::OVF::parse_ovf($ovf_file); 
+ 
+ if ($dryrun) { 
+ print Dumper($parsed); 
+ exit(0); 
+ } 
+ 
+ $param->{name} = $parsed->{qm}->{name} || "OVF-imported-VM"; 
+ $param->{memory} = $parsed->{qm}->{memory} || 512; 
+ $param->{cores} = $parsed->{qm}->{cores} || 1; 
+ $param->{node} = $nodename; 
+ 
+ PVE::API2::Qemu->create_vm($param); 
+ } 
+}); 

my $print_agent_result = sub { 
my ($data) = @_; 
@@ -587,6 +631,9 @@ our $cmddef = { 
nbdstop => [ __PACKAGE__, 'nbdstop', ['vmid']], 

terminal => [ __PACKAGE__, 'terminal', ['vmid']], 
+ 
+ ovfcreate => [ __PACKAGE__, 'ovfcreate', ['vmid']], 
+ 
}; 

1; 
-- 
2.1.4 


_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 




More information about the pve-devel mailing list