[pve-devel] r6014 - pve-manager/pve2/lib/PVE/API2

svn-commits at proxmox.com svn-commits at proxmox.com
Tue May 24 09:39:58 CEST 2011


Author: dietmar
Date: 2011-05-24 09:39:58 +0200 (Tue, 24 May 2011)
New Revision: 6014

Modified:
   pve-manager/pve2/lib/PVE/API2/Network.pm
Log:
cleanups


Modified: pve-manager/pve2/lib/PVE/API2/Network.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Network.pm	2011-05-24 07:31:25 UTC (rev 6013)
+++ pve-manager/pve2/lib/PVE/API2/Network.pm	2011-05-24 07:39:58 UTC (rev 6014)
@@ -27,6 +27,55 @@
     'balance-alb'
     ];
 
+my $confdesc = {
+    autostart => {
+	description => "Automatically start interface on boot.",
+	type => 'boolean',
+	optional => 1,
+    },
+    bridge_ports => {
+	description => "Specify the iterfaces you want to add to your bridge.",
+	optional => 1,
+	type => 'string', format => 'pve-iface-list',
+    },
+    slaves => {
+	description => "Specify the interfaces used by the bonding device.",
+	optional => 1,
+	type => 'string', format => 'pve-iface-list',
+    },
+    bond_mode => {
+	description => "Bonding mode.",
+	optional => 1,
+	type => 'string', enum => $bond_mode_enum,
+    },
+    gateway => {
+	description => 'Default gateway address.',
+	type => 'string', format => 'ipv4',
+	optional => 1,
+    },
+    netmask => {
+	description => 'Network mask.',
+	type => 'string', format => 'ipv4mask',
+	optional => 1,
+    },
+    address => {
+	description => 'IP address.',
+	type => 'string', format => 'ipv4',
+	optional => 1,
+	requires => 'netmask',
+    }
+};
+
+sub json_config_properties {
+    my $prop = shift;
+
+    foreach my $opt (keys %$confdesc) {
+	$prop->{$opt} = $confdesc->{$opt};
+    }
+
+    return $prop;
+}
+
 __PACKAGE__->register_method({
     name => 'index', 
     path => '', 
@@ -82,47 +131,9 @@
     proxyto => 'node',
     parameters => {
     	additionalProperties => 0,
-	properties => {
+	properties => json_config_properties({
 	    node => get_standard_option('pve-node'),
-	    iface => get_standard_option('pve-iface'),
-	    autostart => {
-		description => "Automatically start interface on boot.",
-		type => 'boolean',
-		optional => 1,
-	    },
-	    bridge_ports => {
-		description => "Specify the iterfaces you want to add to your bridge.",
-		optional => 1,
-		type => 'string', format => 'pve-iface-list',
-	    },
-	    slaves => {
-		description => "Specify the interfaces used by the bonding device.",
-		optional => 1,
-		type => 'string', format => 'pve-iface-list',
-	    },
-	    bond_mode => {
-		description => "Bonding mode.",
-		optional => 1,
-		type => 'string', enum => $bond_mode_enum,
-	    },
-	    gateway => {
-		description => 'Default gateway address.',
-		type => 'string', format => 'ipv4',
-		optional => 1,
-	    },
-	    netmask => {
-		description => 'Network mask.',
-		type => 'string', format => 'ipv4mask',
-		optional => 1,
-	    },
-	    address => {
-		description => 'IP address.',
-		type => 'string', format => 'ipv4',
-		optional => 1,
-		requires => 'netmask',
-	    },
-
-	},
+	    iface => get_standard_option('pve-iface')}),
     },
     returns => { type => 'null' },
     code => sub {
@@ -166,51 +177,14 @@
     proxyto => 'node',
     parameters => {
     	additionalProperties => 0,
-	properties => {
+	properties => json_config_properties({
 	    node => get_standard_option('pve-node'),
 	    iface => get_standard_option('pve-iface'),
-	    autostart => {
-		description => "Automatically start interface on boot.",
-		type => 'boolean',
-		optional => 1,
-	    },
-	    bridge_ports => {
-		description => "Specify the iterfaces you want to add to your bridge.",
-		optional => 1,
-		type => 'string', format => 'pve-iface-list',
-	    },
-	    slaves => {
-		description => "Specify the interfaces used by the bonding device.",
-		optional => 1,
-		type => 'string', format => 'pve-iface-list',
-	    },
-	    bond_mode => {
-		description => "Bonding mode.",
-		optional => 1,
-		type => 'string', enum => $bond_mode_enum,
-	    },
-	    gateway => {
-		description => 'Default gateway address.',
-		type => 'string', format => 'ipv4',
-		optional => 1,
-	    },
-	    netmask => {
-		description => 'Network mask.',
-		type => 'string', format => 'ipv4mask',
-		optional => 1,
-	    },
-	    address => {
-		description => 'IP address.',
-		type => 'string', format => 'ipv4',
-		optional => 1,
-		requires => 'netmask',
-	    },
 	    delete => {
 		type => 'string', format => 'pve-configid-list',
 		description => "A list of settings you want to delete.",
 		optional => 1,
-	    },
-	},
+	    }}),
     },
     returns => { type => 'null' },
     code => sub {




More information about the pve-devel mailing list