Skip to content

Commit

Permalink
lxd-to-incus: Delete old OVN bridges
Browse files Browse the repository at this point in the history
Closes #288

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
  • Loading branch information
stgraber committed Dec 8, 2023
1 parent 9d57c66 commit 9089a80
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/lxd-to-incus/ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ func ovsConvert() ([][]string, error) {
}

oldValue := strings.TrimSpace(strings.Replace(output, "\"", "", -1))
oldBridges := []string{}

values := strings.Split(oldValue, ",")
for i, value := range values {
fields := strings.Split(value, ":")
oldBridges = append(oldBridges, fields[1])
fields[1] = strings.Replace(fields[1], "lxdovn", "incusovn", -1)
values[i] = strings.Join(fields, ":")
}
Expand All @@ -34,6 +36,10 @@ func ovsConvert() ([][]string, error) {
commands = append(commands, []string{"ovs-vsctl", "set", "open_vswitch", ".", fmt.Sprintf("external-ids:ovn-bridge-mappings=%s", newValue)})
}

for _, bridge := range oldBridges {
commands = append(commands, []string{"ovs-vsctl", "del-br", bridge})
}

return commands, nil
}

Expand Down

0 comments on commit 9089a80

Please sign in to comment.