[pve-devel] r6242 - qemu-server/pve2/PVE/API2

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jul 6 07:54:32 CEST 2011


Author: dietmar
Date: 2011-07-06 07:54:32 +0200 (Wed, 06 Jul 2011)
New Revision: 6242

Modified:
   qemu-server/pve2/PVE/API2/Qemu.pm
Log:
fix coding style


Modified: qemu-server/pve2/PVE/API2/Qemu.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu.pm	2011-07-06 05:49:21 UTC (rev 6241)
+++ qemu-server/pve2/PVE/API2/Qemu.pm	2011-07-06 05:54:32 UTC (rev 6242)
@@ -31,7 +31,7 @@
     }
 };
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'vmlist', 
     path => '', 
     method => 'GET',
@@ -61,7 +61,7 @@
 
     }});
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'create_vm', 
     path => '', 
     method => 'POST',
@@ -86,7 +86,7 @@
 
 	my $vmid = extract_param($param, 'vmid');
 
-	my $filename = PVE::QemuServer::config_file ($vmid);
+	my $filename = PVE::QemuServer::config_file($vmid);
 	# first test (befor locking)
 	die "unable to create vm $vmid: config file already exists\n" 
 	    if -f $filename;
@@ -97,15 +97,15 @@
 
 	foreach my $opt (keys %$param) {
 	    if (PVE::QemuServer::valid_drivename($opt)) {
-		my $drive = PVE::QemuServer::parse_drive ($opt, $param->{$opt});
+		my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt});
 		raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive;
 
 		PVE::QemuServer::cleanup_drive_path($opt, $storecfg, $drive);
-		$param->{$opt} = PVE::QemuServer::print_drive ($vmid, $drive);
+		$param->{$opt} = PVE::QemuServer::print_drive($vmid, $drive);
 	    }
 	}
 
-	PVE::QemuServer::add_random_macs ($param);
+	PVE::QemuServer::add_random_macs($param);
 
 	#fixme: ? syslog ('info', "VM $vmid creating new virtual machine");
 	
@@ -117,15 +117,15 @@
 	    die "unable to create vm $vmid: config file already exists\n" 
 		if -f $filename;
 
-	    $vollist = PVE::QemuServer::create_disks ($storecfg, $vmid, $param);
+	    $vollist = PVE::QemuServer::create_disks($storecfg, $vmid, $param);
 
 	    # try to be smart about bootdisk
 	    my @disks = PVE::QemuServer::disknames();
 	    my $firstdisk;
 	    foreach my $ds (reverse @disks) {
 		next if !$param->{$ds};
-		my $disk = PVE::QemuServer::parse_drive ($ds, $param->{$ds});
-		next if PVE::QemuServer::drive_is_cdrom ($disk);
+		my $disk = PVE::QemuServer::parse_drive($ds, $param->{$ds});
+		next if PVE::QemuServer::drive_is_cdrom($disk);
 		$firstdisk = $ds;
 	    }
 
@@ -136,12 +136,12 @@
 	    PVE::QemuServer::create_conf_nolock($vmid, $param);
 	};
 
-	eval { PVE::QemuServer::lock_config ($vmid, $createfn); };
+	eval { PVE::QemuServer::lock_config($vmid, $createfn); };
 	my $err = $@;
 
 	if ($err) {
 	    foreach my $volid (@$vollist) {
-		eval { PVE::Storage::vdisk_free ($storecfg, $volid); };
+		eval { PVE::Storage::vdisk_free($storecfg, $volid); };
 		warn $@ if $@;
 	    }
 	    die "create failed - $err";
@@ -150,7 +150,7 @@
 	return undef;
     }});
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'vmdiridx',
     path => '{vmid}', 
     method => 'GET',
@@ -278,7 +278,7 @@
     }});
 
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'vm_config', 
     path => '{vmid}/config', 
     method => 'GET',
@@ -295,12 +295,12 @@
     code => sub {
 	my ($param) = @_;
 
-	my $conf = PVE::QemuServer::load_config ($param->{vmid});
+	my $conf = PVE::QemuServer::load_config($param->{vmid});
 
 	return $conf;
     }});
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'update_vm', 
     path => '{vmid}/config', 
     method => 'PUT',
@@ -362,7 +362,7 @@
 
 	foreach my $opt (keys %$param) {
 	    if (PVE::QemuServer::valid_drivename($opt)) {
-		my $drive = PVE::QemuServer::parse_drive ($opt, $param->{$opt});
+		my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt});
 		raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive;
 		if ($drive->{file} eq 'eject') {
 		    $eject->{$opt} = 1;
@@ -371,10 +371,10 @@
 		}
 
 		PVE::QemuServer::cleanup_drive_path($opt, $storecfg, $drive);
-		$param->{$opt} = PVE::QemuServer::print_drive ($vmid, $drive);
+		$param->{$opt} = PVE::QemuServer::print_drive($vmid, $drive);
 
-		if (PVE::QemuServer::drive_is_cdrom ($drive)) {
-		    $cdchange->{$opt} = PVE::QemuServer::get_iso_path ($storecfg, $vmid, $drive->{file});
+		if (PVE::QemuServer::drive_is_cdrom($drive)) {
+		    $cdchange->{$opt} = PVE::QemuServer::get_iso_path($storecfg, $vmid, $drive->{file});
 		}
 	    }
 	}
@@ -385,13 +385,13 @@
 		if defined($param->{$opt});
 	}
 
-	PVE::QemuServer::add_random_macs ($param);
+	PVE::QemuServer::add_random_macs($param);
 
 	my $vollist = [];
 
 	my $updatefn =  sub {
 
-	    my $conf = PVE::QemuServer::load_config ($vmid);
+	    my $conf = PVE::QemuServer::load_config($vmid);
 
 	    PVE::QemuServer::check_lock($conf) if !$skiplock;
 
@@ -411,17 +411,17 @@
 		if (!PVE::QemuServer::option_exists($opt)) {
 		    raise_param_exc({ delete => "unknown option '$opt'" });
 		} 
-		next if !defined ($conf->{$opt});
+		next if !defined($conf->{$opt});
 		if (PVE::QemuServer::valid_drivename($opt)) {
 		    my $drive = PVE::QemuServer::parse_drive($opt, $conf->{$opt});
-		    if (PVE::QemuServer::drive_is_cdrom ($drive)) {
+		    if (PVE::QemuServer::drive_is_cdrom($drive)) {
 			$cdchange->{$opt} = undef;
 		    } else {
 			my $volid = $drive->{file};
 
 			if ($volid !~  m|^/|) {
 			    my ($path, $owner);
-			    eval { ($path, $owner) = PVE::Storage::path ($storecfg, $volid); };
+			    eval { ($path, $owner) = PVE::Storage::path($storecfg, $volid); };
 			    if ($owner && ($owner == $vmid)) {
 				if ($force) {
 				    push @$vollist, $volid;
@@ -438,24 +438,24 @@
 		$unset->{$opt} = 1;
 	    }
 
-	    PVE::QemuServer::create_disks ($storecfg, $vmid, $param);
+	    PVE::QemuServer::create_disks($storecfg, $vmid, $param);
 
-	    PVE::QemuServer::change_config_nolock  ($vmid, $param, $unset, 1);
+	    PVE::QemuServer::change_config_nolock($vmid, $param, $unset, 1);
 
-	    return if !PVE::QemuServer::check_running ($vmid);
+	    return if !PVE::QemuServer::check_running($vmid);
 
 	    foreach my $opt (keys %$cdchange) {
-		my $qdn = PVE::QemuServer::qemu_drive_name ($opt, 'cdrom');
+		my $qdn = PVE::QemuServer::qemu_drive_name($opt, 'cdrom');
 		my $path = $cdchange->{$opt};
-		PVE::QemuServer::vm_monitor_command ($vmid, "eject $qdn", 0);
-		PVE::QemuServer::vm_monitor_command ($vmid, "change $qdn \"$path\"", 0) if $path;
+		PVE::QemuServer::vm_monitor_command($vmid, "eject $qdn", 0);
+		PVE::QemuServer::vm_monitor_command($vmid, "change $qdn \"$path\"", 0) if $path;
 	    }
 	};
 
-	PVE::QemuServer::lock_config ($vmid, $updatefn);
+	PVE::QemuServer::lock_config($vmid, $updatefn);
 
 	foreach my $volid (@$vollist) {
-	    eval { PVE::Storage::vdisk_free ($storecfg, $volid); };
+	    eval { PVE::Storage::vdisk_free($storecfg, $volid); };
 	    # fixme: log ?
 	    warn $@ if $@;
 	}
@@ -464,7 +464,7 @@
     }});
 
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'destroy_vm', 
     path => '{vmid}', 
     method => 'DELETE',
@@ -494,12 +494,12 @@
 
 	my $storecfg = PVE::Storage::config(); 
 
-	PVE::QemuServer::vm_destroy ($storecfg, $vmid, $skiplock);
+	PVE::QemuServer::vm_destroy($storecfg, $vmid, $skiplock);
 
 	return undef;
     }});
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'unlink', 
     path => '{vmid}/unlink', 
     method => 'PUT',
@@ -535,7 +535,7 @@
 
 my $sslcert;
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'vncproxy', 
     path => '{vmid}/vncproxy', 
     method => 'POST',
@@ -594,21 +594,21 @@
 	my $realcmd = sub {
 	    my $upid = shift;
 
-	    syslog ('info', "starting vnc proxy $upid\n");
+	    syslog('info', "starting vnc proxy $upid\n");
 
 	    my $qmcmd = [@$remcmd, "/usr/sbin/qm", 'vncproxy', $vmid];
 
-	    my $qmstr = join (' ', @$qmcmd);
+	    my $qmstr = join(' ', @$qmcmd);
 
 	    # also redirect stderr (else we get RFB protocol errors)
 	    my @cmd = ('/bin/nc', '-l', '-p', $port, '-w', $timeout, '-c', "$qmstr 2>/dev/null");
 
-	    my $cmdstr = join (' ', @cmd);
-	    syslog ('info', "CMD3: $cmdstr");
+	    my $cmdstr = join(' ', @cmd);
+	    syslog('info', "CMD3: $cmdstr");
 
-	    if (system (@cmd) != 0) {
+	    if (system(@cmd) != 0) {
 		my $msg = "VM $vmid vnc proxy failed - $?";
-		syslog ('err', $msg);
+		syslog('err', $msg);
 		return;
 	    }
 
@@ -626,7 +626,7 @@
 	};
     }});
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'vm_status', 
     path => '{vmid}/status',
     method => 'GET',
@@ -645,14 +645,14 @@
 	my ($param) = @_;
 
 	# test if VM exists
-	my $conf = PVE::QemuServer::load_config ($param->{vmid});
+	my $conf = PVE::QemuServer::load_config($param->{vmid});
 
 	my $vmstatus =  PVE::QemuServer::vmstatus($param->{vmid});
 
 	return $vmstatus->{$param->{vmid}};
     }});
 
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
     name => 'vm_command', 
     path => '{vmid}/status',
     method => 'PUT',




More information about the pve-devel mailing list