mirror of
https://git.proxmox.com/git/pve-network
synced 2025-08-09 12:51:18 +00:00
add nodes option to zones
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
a069f0b4a4
commit
c2b9c1734f
@ -32,6 +32,10 @@ my $api_sdn_zones_config = sub {
|
|||||||
$scfg->{zone} = $id;
|
$scfg->{zone} = $id;
|
||||||
$scfg->{digest} = $cfg->{digest};
|
$scfg->{digest} = $cfg->{digest};
|
||||||
|
|
||||||
|
if ($scfg->{nodes}) {
|
||||||
|
$scfg->{nodes} = PVE::Storage::Plugin->encode_value($scfg->{type}, 'nodes', $scfg->{nodes});
|
||||||
|
}
|
||||||
|
|
||||||
return $scfg;
|
return $scfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,6 +97,8 @@ sub generate_etc_network_config {
|
|||||||
|
|
||||||
#generate configuration
|
#generate configuration
|
||||||
my $config = {};
|
my $config = {};
|
||||||
|
my $nodename = PVE::INotify::nodename();
|
||||||
|
|
||||||
foreach my $id (keys %{$vnet_cfg->{ids}}) {
|
foreach my $id (keys %{$vnet_cfg->{ids}}) {
|
||||||
my $vnet = $vnet_cfg->{ids}->{$id};
|
my $vnet = $vnet_cfg->{ids}->{$id};
|
||||||
my $zone = $vnet->{zone};
|
my $zone = $vnet->{zone};
|
||||||
@ -113,6 +115,8 @@ sub generate_etc_network_config {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next if defined($plugin_config->{nodes}) && !$plugin_config->{nodes}->{$nodename};
|
||||||
|
|
||||||
my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
|
my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
|
||||||
$plugin->generate_sdn_config($plugin_config, $zone, $id, $vnet, $uplinks, $config);
|
$plugin->generate_sdn_config($plugin_config, $zone, $id, $vnet, $uplinks, $config);
|
||||||
}
|
}
|
||||||
@ -196,12 +200,16 @@ sub status {
|
|||||||
my $status = ifquery_check();
|
my $status = ifquery_check();
|
||||||
|
|
||||||
my $vnet_cfg = PVE::Cluster::cfs_read_file('sdn/vnets.cfg');
|
my $vnet_cfg = PVE::Cluster::cfs_read_file('sdn/vnets.cfg');
|
||||||
|
my $zone_cfg = PVE::Cluster::cfs_read_file('sdn/zones.cfg');
|
||||||
|
my $nodename = PVE::INotify::nodename();
|
||||||
|
|
||||||
my $vnet_status = {};
|
my $vnet_status = {};
|
||||||
my $transport_status = {};
|
my $transport_status = {};
|
||||||
|
|
||||||
foreach my $id (keys %{$vnet_cfg->{ids}}) {
|
foreach my $id (keys %{$vnet_cfg->{ids}}) {
|
||||||
my $zone = $vnet_cfg->{ids}->{$id}->{zone};
|
my $zone = $vnet_cfg->{ids}->{$id}->{zone};
|
||||||
|
next if defined($zone_cfg->{ids}->{$zone}->{nodes}) && !$zone_cfg->{ids}->{$zone}->{nodes}->{$nodename};
|
||||||
|
|
||||||
$vnet_status->{$id}->{zone} = $zone;
|
$vnet_status->{$id}->{zone} = $zone;
|
||||||
$transport_status->{$zone}->{status} = 'available' if !defined($transport_status->{$zone}->{status});
|
$transport_status->{$zone}->{status} = 'available' if !defined($transport_status->{$zone}->{status});
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ sub properties {
|
|||||||
sub options {
|
sub options {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
nodes => { optional => 1},
|
||||||
'uplink-id' => { optional => 0 },
|
'uplink-id' => { optional => 0 },
|
||||||
'vrf' => { optional => 0 },
|
'vrf' => { optional => 0 },
|
||||||
'vrf-vxlan' => { optional => 0 },
|
'vrf-vxlan' => { optional => 0 },
|
||||||
|
@ -28,6 +28,7 @@ sub properties {
|
|||||||
sub options {
|
sub options {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
nodes => { optional => 1},
|
||||||
'dp-id' => { optional => 0 },
|
'dp-id' => { optional => 0 },
|
||||||
'uplink-id' => { optional => 0 },
|
'uplink-id' => { optional => 0 },
|
||||||
'controller' => { optional => 0 },
|
'controller' => { optional => 0 },
|
||||||
|
@ -42,6 +42,7 @@ my $defaultData = {
|
|||||||
type => 'string', format => 'pve-configid',
|
type => 'string', format => 'pve-configid',
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
|
nodes => get_standard_option('pve-node-list', { optional => 1 }),
|
||||||
zone => get_standard_option('pve-sdn-zone-id',
|
zone => get_standard_option('pve-sdn-zone-id',
|
||||||
{ completion => \&PVE::Network::SDN::Zones::complete_sdn_zone }),
|
{ completion => \&PVE::Network::SDN::Zones::complete_sdn_zone }),
|
||||||
},
|
},
|
||||||
@ -51,6 +52,34 @@ sub private {
|
|||||||
return $defaultData;
|
return $defaultData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub decode_value {
|
||||||
|
my ($class, $type, $key, $value) = @_;
|
||||||
|
|
||||||
|
if ($key eq 'nodes') {
|
||||||
|
my $res = {};
|
||||||
|
|
||||||
|
foreach my $node (PVE::Tools::split_list($value)) {
|
||||||
|
if (PVE::JSONSchema::pve_verify_node_name($node)) {
|
||||||
|
$res->{$node} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub encode_value {
|
||||||
|
my ($class, $type, $key, $value) = @_;
|
||||||
|
|
||||||
|
if ($key eq 'nodes') {
|
||||||
|
return join(',', keys(%$value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
sub parse_section_header {
|
sub parse_section_header {
|
||||||
my ($class, $line) = @_;
|
my ($class, $line) = @_;
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ sub properties {
|
|||||||
sub options {
|
sub options {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
nodes => { optional => 1},
|
||||||
'uplink-id' => { optional => 0 },
|
'uplink-id' => { optional => 0 },
|
||||||
'tag' => { optional => 0 },
|
'tag' => { optional => 0 },
|
||||||
'vlan-protocol' => { optional => 1 },
|
'vlan-protocol' => { optional => 1 },
|
||||||
|
@ -32,6 +32,7 @@ sub properties {
|
|||||||
sub options {
|
sub options {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
nodes => { optional => 1},
|
||||||
'uplink-id' => { optional => 0 },
|
'uplink-id' => { optional => 0 },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ sub properties {
|
|||||||
sub options {
|
sub options {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
nodes => { optional => 1},
|
||||||
'uplink-id' => { optional => 0 },
|
'uplink-id' => { optional => 0 },
|
||||||
'multicast-address' => { optional => 1 },
|
'multicast-address' => { optional => 1 },
|
||||||
'unicast-address' => { optional => 1 },
|
'unicast-address' => { optional => 1 },
|
||||||
|
Loading…
Reference in New Issue
Block a user