Skip to content

Commit

Permalink
replace nb_global function call with ovnClient
Browse files Browse the repository at this point in the history
  • Loading branch information
liguo authored and gugulee committed Mar 9, 2023
1 parent b399cca commit 8c1ecf0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 40 deletions.
7 changes: 4 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,12 @@ func (c *Controller) Run(ctx context.Context) {
util.LogFatalAndExit(nil, "failed to wait for caches to sync")
}

if err := c.ovnLegacyClient.SetLsDnatModDlDst(c.config.LsDnatModDlDst); err != nil {
if err := c.ovnClient.SetLsDnatModDlDst(c.config.LsDnatModDlDst); err != nil {
util.LogFatalAndExit(err, "failed to set NB_Global option ls_dnat_mod_dl_dst")
}
if err := c.ovnLegacyClient.SetUseCtInvMatch(); err != nil {
util.LogFatalAndExit(err, "failed to set NB_Global option use_ct_inv_match")

if err := c.ovnClient.SetUseCtInvMatch(); err != nil {
klog.Fatalf("failed to set NB_Global option use_ct_inv_match to false: %v", err)
}

if err := c.InitDefaultVpc(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Controller) InitOVN() error {
}
v4Svc, _ := util.SplitStringIP(c.config.ServiceClusterIPRange)
if v4Svc != "" {
if err := c.ovnLegacyClient.SetLBCIDR(v4Svc); err != nil {
if err := c.ovnClient.SetLBCIDR(v4Svc); err != nil {
klog.Errorf("init load balancer svc cidr failed: %v", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/ovn-ic.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (c *Controller) resyncInterConnection() {
blackList = append(blackList, ipv6)
}
}
if err := c.ovnLegacyClient.SetICAutoRoute(autoRoute, blackList); err != nil {
if err := c.ovnClient.SetICAutoRoute(autoRoute, blackList); err != nil {
klog.Errorf("failed to config auto route, %v", err)
return
}
Expand Down
35 changes: 0 additions & 35 deletions pkg/ovs/ovn-nbctl-legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,41 +74,6 @@ func (c LegacyClient) GetVersion() (string, error) {
return c.Version, nil
}

func (c LegacyClient) SetAzName(azName string) error {
if _, err := c.ovnNbCommand("set", "NB_Global", ".", fmt.Sprintf("name=%s", azName)); err != nil {
return fmt.Errorf("failed to set az name, %v", err)
}
return nil
}

func (c LegacyClient) SetLsDnatModDlDst(enabled bool) error {
if _, err := c.ovnNbCommand("set", "NB_Global", ".", fmt.Sprintf("options:ls_dnat_mod_dl_dst=%v", enabled)); err != nil {
return fmt.Errorf("failed to set NB_Global option ls_dnat_mod_dl_dst to %v: %v", enabled, err)
}
return nil
}

func (c LegacyClient) SetUseCtInvMatch() error {
if _, err := c.ovnNbCommand("set", "NB_Global", ".", "options:use_ct_inv_match=false"); err != nil {
return fmt.Errorf("failed to set NB_Global option use_ct_inv_match to false: %v", err)
}
return nil
}

func (c LegacyClient) SetICAutoRoute(enable bool, blackList []string) error {
if enable {
if _, err := c.ovnNbCommand("set", "NB_Global", ".", "options:ic-route-adv=true", "options:ic-route-learn=true", fmt.Sprintf("options:ic-route-blacklist=%s", strings.Join(blackList, ","))); err != nil {
return fmt.Errorf("failed to enable ovn-ic auto route, %v", err)
}
return nil
} else {
if _, err := c.ovnNbCommand("set", "NB_Global", ".", "options:ic-route-adv=false", "options:ic-route-learn=false"); err != nil {
return fmt.Errorf("failed to disable ovn-ic auto route, %v", err)
}
return nil
}
}

// DeleteLogicalSwitchPort delete logical switch port in ovn
func (c LegacyClient) DeleteLogicalSwitchPort(port string) error {
klog.Infof("delete lsp %s", port)
Expand Down

0 comments on commit 8c1ecf0

Please sign in to comment.