[pve-devel] [PATCH pve-network 5/6] add vnet
Alexandre Derumier
aderumier at odiso.com
Wed Mar 27 18:24:09 CET 2019
This allow to define bridges with a tag (can be vxlan or vlan tag),
and use configuration from transportzone
/etc/pve/network/vnet.cfg
vnet1:
tag 2
transportzone vlanzone1
name network1
ipv4 10.0.0.1
ipv6 2a03:2880:f003:c07:face:b00c::2
mtu 1500
vnet2:
transportzone vlanzone1
tag 3
name network2
ipv6 2a03:2880:f003:c07:face:b00c::2
vnet3:
transportzone vxlanmulticastzone1
tag 100000
name network3
mtu 1400
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Network/Vnet.pm | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
create mode 100644 PVE/Network/Vnet.pm
diff --git a/PVE/Network/Vnet.pm b/PVE/Network/Vnet.pm
new file mode 100644
index 0000000..c20a35d
--- /dev/null
+++ b/PVE/Network/Vnet.pm
@@ -0,0 +1,94 @@
+package PVE::Network::Vnet;
+
+use strict;
+use warnings;
+
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::SectionConfig;
+
+use base qw(PVE::SectionConfig);
+
+PVE::Cluster::cfs_register_file('network/vnet.cfg',
+ sub { __PACKAGE__->parse_config(@_); },
+ sub { __PACKAGE__->write_config(@_); });
+
+
+sub options {
+ return {
+ transportzone => { fixed => 1 },
+ tag => { fixed => 1 },
+ name => { optional => 1 },
+ ipv4 => { optional => 1 },
+ ipv6 => { optional => 1 },
+ name => { optional => 1 },
+ mtu => { optional => 1 },
+ };
+}
+
+my $defaultData = {
+ propertyList => {
+ transportzone => {
+ type => 'string',
+ description => "transportzone id",
+ optional => 1,
+ },
+ tag => {
+ type => 'integer',
+ description => "vlan or vxlan id",
+ optional => 1,
+ },
+ name => {
+ type => 'string',
+ description => "name of the network",
+ optional => 1,
+ },
+ mtu => {
+ type => 'integer',
+ description => "mtu",
+ optional => 1,
+ },
+ ipv4 => {
+ description => "Anycast router ipv4 address.",
+ type => 'string', format => 'ipv4',
+ optional => 1,
+ },
+ ipv6 => {
+ description => "Anycast router ipv6 address.",
+ type => 'string', format => 'ipv6',
+ optional => 1,
+ },
+ mac => {
+ type => 'boolean',
+ description => "Anycast router mac address",
+ optional => 1,
+ }
+ },
+};
+
+sub type {
+ return 'vnet';
+}
+
+sub private {
+ return $defaultData;
+}
+
+
+sub parse_section_header {
+ my ($class, $line) = @_;
+
+ if ($line =~ m/^(vnet(\d+)):$/) {
+ my $type = 'vnet';
+ my $errmsg = undef; # set if you want to skip whole section
+ eval { PVE::JSONSchema::pve_verify_configid($type); };
+ $errmsg = $@ if $@;
+ my $config = {}; # to return additional attributes
+ return ($type, $1, $errmsg, $config);
+ }
+ return undef;
+}
+
+__PACKAGE__->register();
+__PACKAGE__->init();
+
+1;
--
2.11.0
More information about the pve-devel
mailing list