Skip to content

Commit

Permalink
network: nmstate add support for ovsintport and ovsbridge
Browse files Browse the repository at this point in the history
  • Loading branch information
stdweird committed Sep 19, 2024
1 parent 3482ac9 commit 68ac9cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ncm-network/src/main/perl/network.pm
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ sub process_network
$iface->{$attr} = [map {"$_=$opts->{$_}"} sort keys %$opts];
$self->debug(1, "Replaced $attr with ", join(' ', @{$iface->{$attr}}), " for interface $ifname");

# for bonding_opts, we need linkagregation settings for nmstate.
# for bonding_opts, we need link aggregation settings for nmstate.
# this should not impact existing configs as it adds interface/$name/link_aggregation
if ($attr eq "bonding_opts"){
foreach my $opt (sort keys %$opts){
Expand Down Expand Up @@ -906,6 +906,18 @@ sub process_network
}
}

# insert ovs bridge->ports data
if ($iface->{ovs_bridge}) {
my $bridge = $iface->{ovs_bridge};
my $bridgeiface = $nwtree->{interfaces}->{$bridge};
if ($bridgeiface) {
$bridgeiface->{ports} = [] if !exists($bridgeiface->{ports});
push(@{$bridgeiface->{ports}}, $ifname);
} else {
$self->warn("Interface $ifname has OVS bridge $bridge configured, but corresponding iface entry not found");
}
}

}

return $nwtree;
Expand Down
9 changes: 9 additions & 0 deletions ncm-network/src/main/perl/nmstate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ sub generate_nmstate_config
$ib->{pkey} = "0x" . sprintf("%04x", $pkey);
$ib->{mode} = 'datagram'; # TODO: add connected mode, but who still uses that
$ifaceconfig->{infiniband} = $ib;
} elsif (lc($iface->{type} || '') eq 'ovsbridge') {
$ifaceconfig->{type} = "ovs-bridge";
$ifaceconfig->{state} = "up";
$ifaceconfig->{bridge}->{options} = {
stp => $YTRUE,
port => delete $ifaceconfig->{ports},
};
} elsif (lc($iface->{type} || '') eq 'ovsintport') {
$ifaceconfig->{type} = "ovs-interface";
} elsif ($is_eth) {
$ifaceconfig->{type} = "ethernet";
if ($is_partof_bond) {
Expand Down

0 comments on commit 68ac9cc

Please sign in to comment.