From bcbae34ebaeecbadb91b020da8214a3d5b069ebc Mon Sep 17 00:00:00 2001 From: bobz965 Date: Thu, 17 Aug 2023 15:08:59 +0800 Subject: [PATCH] sbctl chassis operation replace with libovsdb (#3119) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add ovnsb mod * ovn 层名统一复用用底层 ovs client 命名 * kube-ovn-controller 需要使用 sb nb client, 所以调整命名 * replace sbctl operate chassis Signed-off-by: bobz965 Co-authored-by: 张祖建 --- cmd/daemon/cniserver.go | 16 +- mocks/pkg/ovs/interface.go | 1114 ++++++++---- pkg/controller/controller.go | 20 +- pkg/controller/controller_test.go | 6 +- pkg/controller/endpoint.go | 6 +- pkg/controller/external-gw.go | 24 +- pkg/controller/external_vpc.go | 8 +- pkg/controller/gc.go | 65 +- pkg/controller/init.go | 37 +- pkg/controller/inspection.go | 2 +- pkg/controller/network_policy.go | 78 +- pkg/controller/node.go | 106 +- pkg/controller/ovn-ic.go | 48 +- pkg/controller/ovn_dnat.go | 10 +- pkg/controller/ovn_eip.go | 6 +- pkg/controller/ovn_fip.go | 10 +- pkg/controller/ovn_snat.go | 22 +- pkg/controller/pod.go | 38 +- pkg/controller/security_group.go | 40 +- pkg/controller/service.go | 12 +- pkg/controller/subnet.go | 108 +- pkg/controller/vip.go | 8 +- pkg/controller/vlan.go | 4 +- pkg/controller/vpc.go | 36 +- pkg/ovs/interface.go | 29 +- pkg/ovs/ovn-nb-acl.go | 54 +- pkg/ovs/ovn-nb-acl_test.go | 9 +- pkg/ovs/ovn-nb-address_set.go | 20 +- pkg/ovs/ovn-nb-bfd.go | 8 +- pkg/ovs/ovn-nb-dhcp_options.go | 24 +- pkg/ovs/ovn-nb-gateway_chassis.go | 14 +- pkg/ovs/ovn-nb-load_balancer.go | 36 +- pkg/ovs/ovn-nb-logical_router.go | 36 +- pkg/ovs/ovn-nb-logical_router_policy.go | 32 +- pkg/ovs/ovn-nb-logical_router_port.go | 38 +- pkg/ovs/ovn-nb-logical_router_port_test.go | 2 +- pkg/ovs/ovn-nb-logical_router_route.go | 28 +- pkg/ovs/ovn-nb-logical_router_test.go | 4 +- pkg/ovs/ovn-nb-logical_switch.go | 40 +- pkg/ovs/ovn-nb-logical_switch_port.go | 44 +- pkg/ovs/ovn-nb-logical_switch_port_test.go | 2 +- pkg/ovs/ovn-nb-logical_switch_test.go | 2 +- pkg/ovs/ovn-nb-nat.go | 30 +- pkg/ovs/ovn-nb-port_group.go | 32 +- pkg/ovs/ovn-nb-suite_test.go | 13 +- pkg/ovs/ovn-nb.go | 34 +- pkg/ovs/ovn-nb_global.go | 22 +- pkg/ovs/ovn-sb-chassis.go | 193 +++ pkg/ovs/ovn-sbctl.go | 173 -- pkg/ovs/ovn.go | 139 +- pkg/ovsdb/client/client.go | 49 +- pkg/ovsdb/ovnsb/address_set.go | 13 + pkg/ovsdb/ovnsb/bfd.go | 32 + pkg/ovsdb/ovnsb/chassis.go | 19 + pkg/ovsdb/ovnsb/chassis_private.go | 16 + pkg/ovsdb/ovnsb/chassis_template_var.go | 13 + pkg/ovsdb/ovnsb/connection.go | 20 + pkg/ovsdb/ovnsb/controller_event.go | 23 + pkg/ovsdb/ovnsb/datapath_binding.go | 14 + pkg/ovsdb/ovnsb/dhcp_options.go | 30 + pkg/ovsdb/ovnsb/dhcpv6_options.go | 24 + pkg/ovsdb/ovnsb/dns.go | 14 + pkg/ovsdb/ovnsb/encap.go | 25 + pkg/ovsdb/ovnsb/fdb.go | 14 + pkg/ovsdb/ovnsb/gateway_chassis.go | 16 + pkg/ovsdb/ovnsb/ha_chassis.go | 14 + pkg/ovsdb/ovnsb/ha_chassis_group.go | 15 + pkg/ovsdb/ovnsb/igmp_group.go | 15 + pkg/ovsdb/ovnsb/ip_multicast.go | 22 + pkg/ovsdb/ovnsb/load_balancer.go | 28 + pkg/ovsdb/ovnsb/logical_dp_group.go | 12 + pkg/ovsdb/ovnsb/logical_flow.go | 30 + pkg/ovsdb/ovnsb/mac_binding.go | 16 + pkg/ovsdb/ovnsb/meter.go | 23 + pkg/ovsdb/ovnsb/meter_band.go | 22 + pkg/ovsdb/ovnsb/mirror.go | 29 + pkg/ovsdb/ovnsb/model.go | 1798 ++++++++++++++++++++ pkg/ovsdb/ovnsb/multicast_group.go | 15 + pkg/ovsdb/ovnsb/port_binding.go | 33 + pkg/ovsdb/ovnsb/port_group.go | 13 + pkg/ovsdb/ovnsb/rbac_permission.go | 15 + pkg/ovsdb/ovnsb/rbac_role.go | 13 + pkg/ovsdb/ovnsb/sb_global.go | 17 + pkg/ovsdb/ovnsb/service_monitor.go | 33 + pkg/ovsdb/ovnsb/ssl.go | 18 + pkg/ovsdb/ovnsb/static_mac_binding.go | 16 + 86 files changed, 4170 insertions(+), 1231 deletions(-) create mode 100644 pkg/ovs/ovn-sb-chassis.go delete mode 100644 pkg/ovs/ovn-sbctl.go create mode 100644 pkg/ovsdb/ovnsb/address_set.go create mode 100644 pkg/ovsdb/ovnsb/bfd.go create mode 100644 pkg/ovsdb/ovnsb/chassis.go create mode 100644 pkg/ovsdb/ovnsb/chassis_private.go create mode 100644 pkg/ovsdb/ovnsb/chassis_template_var.go create mode 100644 pkg/ovsdb/ovnsb/connection.go create mode 100644 pkg/ovsdb/ovnsb/controller_event.go create mode 100644 pkg/ovsdb/ovnsb/datapath_binding.go create mode 100644 pkg/ovsdb/ovnsb/dhcp_options.go create mode 100644 pkg/ovsdb/ovnsb/dhcpv6_options.go create mode 100644 pkg/ovsdb/ovnsb/dns.go create mode 100644 pkg/ovsdb/ovnsb/encap.go create mode 100644 pkg/ovsdb/ovnsb/fdb.go create mode 100644 pkg/ovsdb/ovnsb/gateway_chassis.go create mode 100644 pkg/ovsdb/ovnsb/ha_chassis.go create mode 100644 pkg/ovsdb/ovnsb/ha_chassis_group.go create mode 100644 pkg/ovsdb/ovnsb/igmp_group.go create mode 100644 pkg/ovsdb/ovnsb/ip_multicast.go create mode 100644 pkg/ovsdb/ovnsb/load_balancer.go create mode 100644 pkg/ovsdb/ovnsb/logical_dp_group.go create mode 100644 pkg/ovsdb/ovnsb/logical_flow.go create mode 100644 pkg/ovsdb/ovnsb/mac_binding.go create mode 100644 pkg/ovsdb/ovnsb/meter.go create mode 100644 pkg/ovsdb/ovnsb/meter_band.go create mode 100644 pkg/ovsdb/ovnsb/mirror.go create mode 100644 pkg/ovsdb/ovnsb/model.go create mode 100644 pkg/ovsdb/ovnsb/multicast_group.go create mode 100644 pkg/ovsdb/ovnsb/port_binding.go create mode 100644 pkg/ovsdb/ovnsb/port_group.go create mode 100644 pkg/ovsdb/ovnsb/rbac_permission.go create mode 100644 pkg/ovsdb/ovnsb/rbac_role.go create mode 100644 pkg/ovsdb/ovnsb/sb_global.go create mode 100644 pkg/ovsdb/ovnsb/service_monitor.go create mode 100644 pkg/ovsdb/ovnsb/ssl.go create mode 100644 pkg/ovsdb/ovnsb/static_mac_binding.go diff --git a/cmd/daemon/cniserver.go b/cmd/daemon/cniserver.go index 67b17a618b0..318916db456 100644 --- a/cmd/daemon/cniserver.go +++ b/cmd/daemon/cniserver.go @@ -164,7 +164,21 @@ func initChassisAnno(cfg *daemon.Configuration) error { } chassistr := string(chassisID) - node.Annotations[util.ChassisAnnotation] = strings.TrimSpace(chassistr) + chassesName := strings.TrimSpace(chassistr) + if chassesName == "" { + // not ready yet + err = fmt.Errorf("chassis id is empty") + klog.Error(err) + return err + } + if annoChassesName, ok := node.Annotations[util.ChassisAnnotation]; ok { + if annoChassesName == chassesName { + return nil + } else { + klog.Infof("chassis id changed, old: %s, new: %s", annoChassesName, chassesName) + } + } + node.Annotations[util.ChassisAnnotation] = chassesName patchPayloadTemplate := `[{ "op": "%s", diff --git a/mocks/pkg/ovs/interface.go b/mocks/pkg/ovs/interface.go index cd5d7081564..3b2a9eed704 100644 --- a/mocks/pkg/ovs/interface.go +++ b/mocks/pkg/ovs/interface.go @@ -11,6 +11,7 @@ import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" ovs "github.com/kubeovn/kube-ovn/pkg/ovs" ovnnb "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnnb" + ovnsb "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnsb" util "github.com/kubeovn/kube-ovn/pkg/util" ovsdb "github.com/ovn-org/libovsdb/ovsdb" v10 "k8s.io/api/networking/v1" @@ -1281,17 +1282,17 @@ func (mr *MockACLMockRecorder) SetAclLog(pgName, protocol, logEnable, isIngress } // SetLogicalSwitchPrivate mocks base method. -func (m *MockACL) SetLogicalSwitchPrivate(lsName, cidrBlock string, allowSubnets []string) error { +func (m *MockACL) SetLogicalSwitchPrivate(lsName, cidrBlock, nodeSwitchCIDR string, allowSubnets []string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetLogicalSwitchPrivate", lsName, cidrBlock, allowSubnets) + ret := m.ctrl.Call(m, "SetLogicalSwitchPrivate", lsName, cidrBlock, nodeSwitchCIDR, allowSubnets) ret0, _ := ret[0].(error) return ret0 } // SetLogicalSwitchPrivate indicates an expected call of SetLogicalSwitchPrivate. -func (mr *MockACLMockRecorder) SetLogicalSwitchPrivate(lsName, cidrBlock, allowSubnets interface{}) *gomock.Call { +func (mr *MockACLMockRecorder) SetLogicalSwitchPrivate(lsName, cidrBlock, nodeSwitchCIDR, allowSubnets interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPrivate", reflect.TypeOf((*MockACL)(nil).SetLogicalSwitchPrivate), lsName, cidrBlock, allowSubnets) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPrivate", reflect.TypeOf((*MockACL)(nil).SetLogicalSwitchPrivate), lsName, cidrBlock, nodeSwitchCIDR, allowSubnets) } // UpdateEgressAclOps mocks base method. @@ -1926,31 +1927,31 @@ func (mr *MockDHCPOptionsMockRecorder) UpdateDHCPOptions(subnet, mtu interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDHCPOptions", reflect.TypeOf((*MockDHCPOptions)(nil).UpdateDHCPOptions), subnet, mtu) } -// MockOvnClient is a mock of OvnClient interface. -type MockOvnClient struct { +// MockNbClient is a mock of NbClient interface. +type MockNbClient struct { ctrl *gomock.Controller - recorder *MockOvnClientMockRecorder + recorder *MockNbClientMockRecorder } -// MockOvnClientMockRecorder is the mock recorder for MockOvnClient. -type MockOvnClientMockRecorder struct { - mock *MockOvnClient +// MockNbClientMockRecorder is the mock recorder for MockNbClient. +type MockNbClientMockRecorder struct { + mock *MockNbClient } -// NewMockOvnClient creates a new mock instance. -func NewMockOvnClient(ctrl *gomock.Controller) *MockOvnClient { - mock := &MockOvnClient{ctrl: ctrl} - mock.recorder = &MockOvnClientMockRecorder{mock} +// NewMockNbClient creates a new mock instance. +func NewMockNbClient(ctrl *gomock.Controller) *MockNbClient { + mock := &MockNbClient{ctrl: ctrl} + mock.recorder = &MockNbClientMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockOvnClient) EXPECT() *MockOvnClientMockRecorder { +func (m *MockNbClient) EXPECT() *MockNbClientMockRecorder { return m.recorder } // AddLogicalRouterPolicy mocks base method. -func (m *MockOvnClient) AddLogicalRouterPolicy(lrName string, priority int, match, action string, nextHops []string, externalIDs map[string]string) error { +func (m *MockNbClient) AddLogicalRouterPolicy(lrName string, priority int, match, action string, nextHops []string, externalIDs map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AddLogicalRouterPolicy", lrName, priority, match, action, nextHops, externalIDs) ret0, _ := ret[0].(error) @@ -1958,13 +1959,13 @@ func (m *MockOvnClient) AddLogicalRouterPolicy(lrName string, priority int, matc } // AddLogicalRouterPolicy indicates an expected call of AddLogicalRouterPolicy. -func (mr *MockOvnClientMockRecorder) AddLogicalRouterPolicy(lrName, priority, match, action, nextHops, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) AddLogicalRouterPolicy(lrName, priority, match, action, nextHops, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddLogicalRouterPolicy", reflect.TypeOf((*MockOvnClient)(nil).AddLogicalRouterPolicy), lrName, priority, match, action, nextHops, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddLogicalRouterPolicy", reflect.TypeOf((*MockNbClient)(nil).AddLogicalRouterPolicy), lrName, priority, match, action, nextHops, externalIDs) } // AddLogicalRouterStaticRoute mocks base method. -func (m *MockOvnClient) AddLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix string, bfdId *string, nexthops ...string) error { +func (m *MockNbClient) AddLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix string, bfdId *string, nexthops ...string) error { m.ctrl.T.Helper() varargs := []interface{}{lrName, routeTable, policy, ipPrefix, bfdId} for _, a := range nexthops { @@ -1976,14 +1977,14 @@ func (m *MockOvnClient) AddLogicalRouterStaticRoute(lrName, routeTable, policy, } // AddLogicalRouterStaticRoute indicates an expected call of AddLogicalRouterStaticRoute. -func (mr *MockOvnClientMockRecorder) AddLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, bfdId interface{}, nexthops ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) AddLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, bfdId interface{}, nexthops ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{lrName, routeTable, policy, ipPrefix, bfdId}, nexthops...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddLogicalRouterStaticRoute", reflect.TypeOf((*MockOvnClient)(nil).AddLogicalRouterStaticRoute), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddLogicalRouterStaticRoute", reflect.TypeOf((*MockNbClient)(nil).AddLogicalRouterStaticRoute), varargs...) } // AddNat mocks base method. -func (m *MockOvnClient) AddNat(lrName, natType, externalIP, logicalIP, logicalMac, port string, options map[string]string) error { +func (m *MockNbClient) AddNat(lrName, natType, externalIP, logicalIP, logicalMac, port string, options map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AddNat", lrName, natType, externalIP, logicalIP, logicalMac, port, options) ret0, _ := ret[0].(error) @@ -1991,13 +1992,13 @@ func (m *MockOvnClient) AddNat(lrName, natType, externalIP, logicalIP, logicalMa } // AddNat indicates an expected call of AddNat. -func (mr *MockOvnClientMockRecorder) AddNat(lrName, natType, externalIP, logicalIP, logicalMac, port, options interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) AddNat(lrName, natType, externalIP, logicalIP, logicalMac, port, options interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddNat", reflect.TypeOf((*MockOvnClient)(nil).AddNat), lrName, natType, externalIP, logicalIP, logicalMac, port, options) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddNat", reflect.TypeOf((*MockNbClient)(nil).AddNat), lrName, natType, externalIP, logicalIP, logicalMac, port, options) } // AddressSetUpdateAddress mocks base method. -func (m *MockOvnClient) AddressSetUpdateAddress(asName string, addresses ...string) error { +func (m *MockNbClient) AddressSetUpdateAddress(asName string, addresses ...string) error { m.ctrl.T.Helper() varargs := []interface{}{asName} for _, a := range addresses { @@ -2009,14 +2010,14 @@ func (m *MockOvnClient) AddressSetUpdateAddress(asName string, addresses ...stri } // AddressSetUpdateAddress indicates an expected call of AddressSetUpdateAddress. -func (mr *MockOvnClientMockRecorder) AddressSetUpdateAddress(asName interface{}, addresses ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) AddressSetUpdateAddress(asName interface{}, addresses ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{asName}, addresses...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddressSetUpdateAddress", reflect.TypeOf((*MockOvnClient)(nil).AddressSetUpdateAddress), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddressSetUpdateAddress", reflect.TypeOf((*MockNbClient)(nil).AddressSetUpdateAddress), varargs...) } // ClearLogicalRouterPolicy mocks base method. -func (m *MockOvnClient) ClearLogicalRouterPolicy(lrName string) error { +func (m *MockNbClient) ClearLogicalRouterPolicy(lrName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ClearLogicalRouterPolicy", lrName) ret0, _ := ret[0].(error) @@ -2024,13 +2025,13 @@ func (m *MockOvnClient) ClearLogicalRouterPolicy(lrName string) error { } // ClearLogicalRouterPolicy indicates an expected call of ClearLogicalRouterPolicy. -func (mr *MockOvnClientMockRecorder) ClearLogicalRouterPolicy(lrName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ClearLogicalRouterPolicy(lrName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearLogicalRouterPolicy", reflect.TypeOf((*MockOvnClient)(nil).ClearLogicalRouterPolicy), lrName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearLogicalRouterPolicy", reflect.TypeOf((*MockNbClient)(nil).ClearLogicalRouterPolicy), lrName) } // ClearLogicalRouterStaticRoute mocks base method. -func (m *MockOvnClient) ClearLogicalRouterStaticRoute(lrName string) error { +func (m *MockNbClient) ClearLogicalRouterStaticRoute(lrName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ClearLogicalRouterStaticRoute", lrName) ret0, _ := ret[0].(error) @@ -2038,13 +2039,13 @@ func (m *MockOvnClient) ClearLogicalRouterStaticRoute(lrName string) error { } // ClearLogicalRouterStaticRoute indicates an expected call of ClearLogicalRouterStaticRoute. -func (mr *MockOvnClientMockRecorder) ClearLogicalRouterStaticRoute(lrName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ClearLogicalRouterStaticRoute(lrName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearLogicalRouterStaticRoute", reflect.TypeOf((*MockOvnClient)(nil).ClearLogicalRouterStaticRoute), lrName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearLogicalRouterStaticRoute", reflect.TypeOf((*MockNbClient)(nil).ClearLogicalRouterStaticRoute), lrName) } // CreateAddressSet mocks base method. -func (m *MockOvnClient) CreateAddressSet(asName string, externalIDs map[string]string) error { +func (m *MockNbClient) CreateAddressSet(asName string, externalIDs map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateAddressSet", asName, externalIDs) ret0, _ := ret[0].(error) @@ -2052,13 +2053,13 @@ func (m *MockOvnClient) CreateAddressSet(asName string, externalIDs map[string]s } // CreateAddressSet indicates an expected call of CreateAddressSet. -func (mr *MockOvnClientMockRecorder) CreateAddressSet(asName, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateAddressSet(asName, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAddressSet", reflect.TypeOf((*MockOvnClient)(nil).CreateAddressSet), asName, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAddressSet", reflect.TypeOf((*MockNbClient)(nil).CreateAddressSet), asName, externalIDs) } // CreateBFD mocks base method. -func (m *MockOvnClient) CreateBFD(lrpName, dstIP string, minRx, minTx, detectMult int) (*ovnnb.BFD, error) { +func (m *MockNbClient) CreateBFD(lrpName, dstIP string, minRx, minTx, detectMult int) (*ovnnb.BFD, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateBFD", lrpName, dstIP, minRx, minTx, detectMult) ret0, _ := ret[0].(*ovnnb.BFD) @@ -2067,13 +2068,13 @@ func (m *MockOvnClient) CreateBFD(lrpName, dstIP string, minRx, minTx, detectMul } // CreateBFD indicates an expected call of CreateBFD. -func (mr *MockOvnClientMockRecorder) CreateBFD(lrpName, dstIP, minRx, minTx, detectMult interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateBFD(lrpName, dstIP, minRx, minTx, detectMult interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBFD", reflect.TypeOf((*MockOvnClient)(nil).CreateBFD), lrpName, dstIP, minRx, minTx, detectMult) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBFD", reflect.TypeOf((*MockNbClient)(nil).CreateBFD), lrpName, dstIP, minRx, minTx, detectMult) } // CreateBareLogicalSwitch mocks base method. -func (m *MockOvnClient) CreateBareLogicalSwitch(lsName string) error { +func (m *MockNbClient) CreateBareLogicalSwitch(lsName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateBareLogicalSwitch", lsName) ret0, _ := ret[0].(error) @@ -2081,13 +2082,13 @@ func (m *MockOvnClient) CreateBareLogicalSwitch(lsName string) error { } // CreateBareLogicalSwitch indicates an expected call of CreateBareLogicalSwitch. -func (mr *MockOvnClientMockRecorder) CreateBareLogicalSwitch(lsName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateBareLogicalSwitch(lsName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBareLogicalSwitch", reflect.TypeOf((*MockOvnClient)(nil).CreateBareLogicalSwitch), lsName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBareLogicalSwitch", reflect.TypeOf((*MockNbClient)(nil).CreateBareLogicalSwitch), lsName) } // CreateBareLogicalSwitchPort mocks base method. -func (m *MockOvnClient) CreateBareLogicalSwitchPort(lsName, lspName, ip, mac string) error { +func (m *MockNbClient) CreateBareLogicalSwitchPort(lsName, lspName, ip, mac string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateBareLogicalSwitchPort", lsName, lspName, ip, mac) ret0, _ := ret[0].(error) @@ -2095,13 +2096,13 @@ func (m *MockOvnClient) CreateBareLogicalSwitchPort(lsName, lspName, ip, mac str } // CreateBareLogicalSwitchPort indicates an expected call of CreateBareLogicalSwitchPort. -func (mr *MockOvnClientMockRecorder) CreateBareLogicalSwitchPort(lsName, lspName, ip, mac interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateBareLogicalSwitchPort(lsName, lspName, ip, mac interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBareLogicalSwitchPort", reflect.TypeOf((*MockOvnClient)(nil).CreateBareLogicalSwitchPort), lsName, lspName, ip, mac) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBareLogicalSwitchPort", reflect.TypeOf((*MockNbClient)(nil).CreateBareLogicalSwitchPort), lsName, lspName, ip, mac) } // CreateGatewayAcl mocks base method. -func (m *MockOvnClient) CreateGatewayAcl(lsName, pgName, gateway string) error { +func (m *MockNbClient) CreateGatewayAcl(lsName, pgName, gateway string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateGatewayAcl", lsName, pgName, gateway) ret0, _ := ret[0].(error) @@ -2109,13 +2110,13 @@ func (m *MockOvnClient) CreateGatewayAcl(lsName, pgName, gateway string) error { } // CreateGatewayAcl indicates an expected call of CreateGatewayAcl. -func (mr *MockOvnClientMockRecorder) CreateGatewayAcl(lsName, pgName, gateway interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateGatewayAcl(lsName, pgName, gateway interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGatewayAcl", reflect.TypeOf((*MockOvnClient)(nil).CreateGatewayAcl), lsName, pgName, gateway) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGatewayAcl", reflect.TypeOf((*MockNbClient)(nil).CreateGatewayAcl), lsName, pgName, gateway) } // CreateGatewayLogicalSwitch mocks base method. -func (m *MockOvnClient) CreateGatewayLogicalSwitch(lsName, lrName, provider, ip, mac string, vlanID int, chassises ...string) error { +func (m *MockNbClient) CreateGatewayLogicalSwitch(lsName, lrName, provider, ip, mac string, vlanID int, chassises ...string) error { m.ctrl.T.Helper() varargs := []interface{}{lsName, lrName, provider, ip, mac, vlanID} for _, a := range chassises { @@ -2127,14 +2128,14 @@ func (m *MockOvnClient) CreateGatewayLogicalSwitch(lsName, lrName, provider, ip, } // CreateGatewayLogicalSwitch indicates an expected call of CreateGatewayLogicalSwitch. -func (mr *MockOvnClientMockRecorder) CreateGatewayLogicalSwitch(lsName, lrName, provider, ip, mac, vlanID interface{}, chassises ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateGatewayLogicalSwitch(lsName, lrName, provider, ip, mac, vlanID interface{}, chassises ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{lsName, lrName, provider, ip, mac, vlanID}, chassises...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGatewayLogicalSwitch", reflect.TypeOf((*MockOvnClient)(nil).CreateGatewayLogicalSwitch), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGatewayLogicalSwitch", reflect.TypeOf((*MockNbClient)(nil).CreateGatewayLogicalSwitch), varargs...) } // CreateLoadBalancer mocks base method. -func (m *MockOvnClient) CreateLoadBalancer(lbName, protocol, selectFields string) error { +func (m *MockNbClient) CreateLoadBalancer(lbName, protocol, selectFields string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateLoadBalancer", lbName, protocol, selectFields) ret0, _ := ret[0].(error) @@ -2142,13 +2143,13 @@ func (m *MockOvnClient) CreateLoadBalancer(lbName, protocol, selectFields string } // CreateLoadBalancer indicates an expected call of CreateLoadBalancer. -func (mr *MockOvnClientMockRecorder) CreateLoadBalancer(lbName, protocol, selectFields interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateLoadBalancer(lbName, protocol, selectFields interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLoadBalancer", reflect.TypeOf((*MockOvnClient)(nil).CreateLoadBalancer), lbName, protocol, selectFields) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLoadBalancer", reflect.TypeOf((*MockNbClient)(nil).CreateLoadBalancer), lbName, protocol, selectFields) } // CreateLocalnetLogicalSwitchPort mocks base method. -func (m *MockOvnClient) CreateLocalnetLogicalSwitchPort(lsName, lspName, provider string, vlanID int) error { +func (m *MockNbClient) CreateLocalnetLogicalSwitchPort(lsName, lspName, provider string, vlanID int) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateLocalnetLogicalSwitchPort", lsName, lspName, provider, vlanID) ret0, _ := ret[0].(error) @@ -2156,13 +2157,13 @@ func (m *MockOvnClient) CreateLocalnetLogicalSwitchPort(lsName, lspName, provide } // CreateLocalnetLogicalSwitchPort indicates an expected call of CreateLocalnetLogicalSwitchPort. -func (mr *MockOvnClientMockRecorder) CreateLocalnetLogicalSwitchPort(lsName, lspName, provider, vlanID interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateLocalnetLogicalSwitchPort(lsName, lspName, provider, vlanID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLocalnetLogicalSwitchPort", reflect.TypeOf((*MockOvnClient)(nil).CreateLocalnetLogicalSwitchPort), lsName, lspName, provider, vlanID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLocalnetLogicalSwitchPort", reflect.TypeOf((*MockNbClient)(nil).CreateLocalnetLogicalSwitchPort), lsName, lspName, provider, vlanID) } // CreateLogicalPatchPort mocks base method. -func (m *MockOvnClient) CreateLogicalPatchPort(lsName, lrName, lspName, lrpName, ip, mac string, chassises ...string) error { +func (m *MockNbClient) CreateLogicalPatchPort(lsName, lrName, lspName, lrpName, ip, mac string, chassises ...string) error { m.ctrl.T.Helper() varargs := []interface{}{lsName, lrName, lspName, lrpName, ip, mac} for _, a := range chassises { @@ -2174,14 +2175,14 @@ func (m *MockOvnClient) CreateLogicalPatchPort(lsName, lrName, lspName, lrpName, } // CreateLogicalPatchPort indicates an expected call of CreateLogicalPatchPort. -func (mr *MockOvnClientMockRecorder) CreateLogicalPatchPort(lsName, lrName, lspName, lrpName, ip, mac interface{}, chassises ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateLogicalPatchPort(lsName, lrName, lspName, lrpName, ip, mac interface{}, chassises ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{lsName, lrName, lspName, lrpName, ip, mac}, chassises...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalPatchPort", reflect.TypeOf((*MockOvnClient)(nil).CreateLogicalPatchPort), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalPatchPort", reflect.TypeOf((*MockNbClient)(nil).CreateLogicalPatchPort), varargs...) } // CreateLogicalRouter mocks base method. -func (m *MockOvnClient) CreateLogicalRouter(lrName string) error { +func (m *MockNbClient) CreateLogicalRouter(lrName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateLogicalRouter", lrName) ret0, _ := ret[0].(error) @@ -2189,13 +2190,13 @@ func (m *MockOvnClient) CreateLogicalRouter(lrName string) error { } // CreateLogicalRouter indicates an expected call of CreateLogicalRouter. -func (mr *MockOvnClientMockRecorder) CreateLogicalRouter(lrName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateLogicalRouter(lrName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalRouter", reflect.TypeOf((*MockOvnClient)(nil).CreateLogicalRouter), lrName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalRouter", reflect.TypeOf((*MockNbClient)(nil).CreateLogicalRouter), lrName) } // CreateLogicalRouterPort mocks base method. -func (m *MockOvnClient) CreateLogicalRouterPort(lrName, lrpName, mac string, networks []string) error { +func (m *MockNbClient) CreateLogicalRouterPort(lrName, lrpName, mac string, networks []string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateLogicalRouterPort", lrName, lrpName, mac, networks) ret0, _ := ret[0].(error) @@ -2203,13 +2204,13 @@ func (m *MockOvnClient) CreateLogicalRouterPort(lrName, lrpName, mac string, net } // CreateLogicalRouterPort indicates an expected call of CreateLogicalRouterPort. -func (mr *MockOvnClientMockRecorder) CreateLogicalRouterPort(lrName, lrpName, mac, networks interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateLogicalRouterPort(lrName, lrpName, mac, networks interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalRouterPort", reflect.TypeOf((*MockOvnClient)(nil).CreateLogicalRouterPort), lrName, lrpName, mac, networks) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalRouterPort", reflect.TypeOf((*MockNbClient)(nil).CreateLogicalRouterPort), lrName, lrpName, mac, networks) } // CreateLogicalSwitch mocks base method. -func (m *MockOvnClient) CreateLogicalSwitch(lsName, lrName, cidrBlock, gateway string, needRouter, randomAllocateGW bool) error { +func (m *MockNbClient) CreateLogicalSwitch(lsName, lrName, cidrBlock, gateway string, needRouter, randomAllocateGW bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateLogicalSwitch", lsName, lrName, cidrBlock, gateway, needRouter, randomAllocateGW) ret0, _ := ret[0].(error) @@ -2217,13 +2218,13 @@ func (m *MockOvnClient) CreateLogicalSwitch(lsName, lrName, cidrBlock, gateway s } // CreateLogicalSwitch indicates an expected call of CreateLogicalSwitch. -func (mr *MockOvnClientMockRecorder) CreateLogicalSwitch(lsName, lrName, cidrBlock, gateway, needRouter, randomAllocateGW interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateLogicalSwitch(lsName, lrName, cidrBlock, gateway, needRouter, randomAllocateGW interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalSwitch", reflect.TypeOf((*MockOvnClient)(nil).CreateLogicalSwitch), lsName, lrName, cidrBlock, gateway, needRouter, randomAllocateGW) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalSwitch", reflect.TypeOf((*MockNbClient)(nil).CreateLogicalSwitch), lsName, lrName, cidrBlock, gateway, needRouter, randomAllocateGW) } // CreateLogicalSwitchPort mocks base method. -func (m *MockOvnClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, namespace string, portSecurity bool, securityGroups, vips string, enableDHCP bool, dhcpOptions *ovs.DHCPOptionsUUIDs, vpc string) error { +func (m *MockNbClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, namespace string, portSecurity bool, securityGroups, vips string, enableDHCP bool, dhcpOptions *ovs.DHCPOptionsUUIDs, vpc string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateLogicalSwitchPort", lsName, lspName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc) ret0, _ := ret[0].(error) @@ -2231,13 +2232,13 @@ func (m *MockOvnClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podNam } // CreateLogicalSwitchPort indicates an expected call of CreateLogicalSwitchPort. -func (mr *MockOvnClientMockRecorder) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalSwitchPort", reflect.TypeOf((*MockOvnClient)(nil).CreateLogicalSwitchPort), lsName, lspName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLogicalSwitchPort", reflect.TypeOf((*MockNbClient)(nil).CreateLogicalSwitchPort), lsName, lspName, ip, mac, podName, namespace, portSecurity, securityGroups, vips, enableDHCP, dhcpOptions, vpc) } // CreateNodeAcl mocks base method. -func (m *MockOvnClient) CreateNodeAcl(pgName, nodeIpStr, joinIpStr string) error { +func (m *MockNbClient) CreateNodeAcl(pgName, nodeIpStr, joinIpStr string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateNodeAcl", pgName, nodeIpStr, joinIpStr) ret0, _ := ret[0].(error) @@ -2245,13 +2246,13 @@ func (m *MockOvnClient) CreateNodeAcl(pgName, nodeIpStr, joinIpStr string) error } // CreateNodeAcl indicates an expected call of CreateNodeAcl. -func (mr *MockOvnClientMockRecorder) CreateNodeAcl(pgName, nodeIpStr, joinIpStr interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateNodeAcl(pgName, nodeIpStr, joinIpStr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateNodeAcl", reflect.TypeOf((*MockOvnClient)(nil).CreateNodeAcl), pgName, nodeIpStr, joinIpStr) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateNodeAcl", reflect.TypeOf((*MockNbClient)(nil).CreateNodeAcl), pgName, nodeIpStr, joinIpStr) } // CreatePeerRouterPort mocks base method. -func (m *MockOvnClient) CreatePeerRouterPort(localRouter, remoteRouter, localRouterPortIP string) error { +func (m *MockNbClient) CreatePeerRouterPort(localRouter, remoteRouter, localRouterPortIP string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreatePeerRouterPort", localRouter, remoteRouter, localRouterPortIP) ret0, _ := ret[0].(error) @@ -2259,13 +2260,13 @@ func (m *MockOvnClient) CreatePeerRouterPort(localRouter, remoteRouter, localRou } // CreatePeerRouterPort indicates an expected call of CreatePeerRouterPort. -func (mr *MockOvnClientMockRecorder) CreatePeerRouterPort(localRouter, remoteRouter, localRouterPortIP interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreatePeerRouterPort(localRouter, remoteRouter, localRouterPortIP interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePeerRouterPort", reflect.TypeOf((*MockOvnClient)(nil).CreatePeerRouterPort), localRouter, remoteRouter, localRouterPortIP) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePeerRouterPort", reflect.TypeOf((*MockNbClient)(nil).CreatePeerRouterPort), localRouter, remoteRouter, localRouterPortIP) } // CreatePortGroup mocks base method. -func (m *MockOvnClient) CreatePortGroup(pgName string, externalIDs map[string]string) error { +func (m *MockNbClient) CreatePortGroup(pgName string, externalIDs map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreatePortGroup", pgName, externalIDs) ret0, _ := ret[0].(error) @@ -2273,13 +2274,13 @@ func (m *MockOvnClient) CreatePortGroup(pgName string, externalIDs map[string]st } // CreatePortGroup indicates an expected call of CreatePortGroup. -func (mr *MockOvnClientMockRecorder) CreatePortGroup(pgName, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreatePortGroup(pgName, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePortGroup", reflect.TypeOf((*MockOvnClient)(nil).CreatePortGroup), pgName, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreatePortGroup", reflect.TypeOf((*MockNbClient)(nil).CreatePortGroup), pgName, externalIDs) } // CreateSgBaseACL mocks base method. -func (m *MockOvnClient) CreateSgBaseACL(sgName, direction string) error { +func (m *MockNbClient) CreateSgBaseACL(sgName, direction string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateSgBaseACL", sgName, direction) ret0, _ := ret[0].(error) @@ -2287,13 +2288,13 @@ func (m *MockOvnClient) CreateSgBaseACL(sgName, direction string) error { } // CreateSgBaseACL indicates an expected call of CreateSgBaseACL. -func (mr *MockOvnClientMockRecorder) CreateSgBaseACL(sgName, direction interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateSgBaseACL(sgName, direction interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSgBaseACL", reflect.TypeOf((*MockOvnClient)(nil).CreateSgBaseACL), sgName, direction) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSgBaseACL", reflect.TypeOf((*MockNbClient)(nil).CreateSgBaseACL), sgName, direction) } // CreateSgDenyAllAcl mocks base method. -func (m *MockOvnClient) CreateSgDenyAllAcl(sgName string) error { +func (m *MockNbClient) CreateSgDenyAllAcl(sgName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateSgDenyAllAcl", sgName) ret0, _ := ret[0].(error) @@ -2301,13 +2302,13 @@ func (m *MockOvnClient) CreateSgDenyAllAcl(sgName string) error { } // CreateSgDenyAllAcl indicates an expected call of CreateSgDenyAllAcl. -func (mr *MockOvnClientMockRecorder) CreateSgDenyAllAcl(sgName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateSgDenyAllAcl(sgName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSgDenyAllAcl", reflect.TypeOf((*MockOvnClient)(nil).CreateSgDenyAllAcl), sgName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSgDenyAllAcl", reflect.TypeOf((*MockNbClient)(nil).CreateSgDenyAllAcl), sgName) } // CreateVirtualLogicalSwitchPorts mocks base method. -func (m *MockOvnClient) CreateVirtualLogicalSwitchPorts(lsName string, ips ...string) error { +func (m *MockNbClient) CreateVirtualLogicalSwitchPorts(lsName string, ips ...string) error { m.ctrl.T.Helper() varargs := []interface{}{lsName} for _, a := range ips { @@ -2319,14 +2320,14 @@ func (m *MockOvnClient) CreateVirtualLogicalSwitchPorts(lsName string, ips ...st } // CreateVirtualLogicalSwitchPorts indicates an expected call of CreateVirtualLogicalSwitchPorts. -func (mr *MockOvnClientMockRecorder) CreateVirtualLogicalSwitchPorts(lsName interface{}, ips ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) CreateVirtualLogicalSwitchPorts(lsName interface{}, ips ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{lsName}, ips...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVirtualLogicalSwitchPorts", reflect.TypeOf((*MockOvnClient)(nil).CreateVirtualLogicalSwitchPorts), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateVirtualLogicalSwitchPorts", reflect.TypeOf((*MockNbClient)(nil).CreateVirtualLogicalSwitchPorts), varargs...) } // DeleteAcls mocks base method. -func (m *MockOvnClient) DeleteAcls(parentName, parentType, direction string, externalIDs map[string]string) error { +func (m *MockNbClient) DeleteAcls(parentName, parentType, direction string, externalIDs map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteAcls", parentName, parentType, direction, externalIDs) ret0, _ := ret[0].(error) @@ -2334,13 +2335,13 @@ func (m *MockOvnClient) DeleteAcls(parentName, parentType, direction string, ext } // DeleteAcls indicates an expected call of DeleteAcls. -func (mr *MockOvnClientMockRecorder) DeleteAcls(parentName, parentType, direction, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteAcls(parentName, parentType, direction, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAcls", reflect.TypeOf((*MockOvnClient)(nil).DeleteAcls), parentName, parentType, direction, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAcls", reflect.TypeOf((*MockNbClient)(nil).DeleteAcls), parentName, parentType, direction, externalIDs) } // DeleteAclsOps mocks base method. -func (m *MockOvnClient) DeleteAclsOps(parentName, parentType, direction string, externalIDs map[string]string) ([]ovsdb.Operation, error) { +func (m *MockNbClient) DeleteAclsOps(parentName, parentType, direction string, externalIDs map[string]string) ([]ovsdb.Operation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteAclsOps", parentName, parentType, direction, externalIDs) ret0, _ := ret[0].([]ovsdb.Operation) @@ -2349,13 +2350,13 @@ func (m *MockOvnClient) DeleteAclsOps(parentName, parentType, direction string, } // DeleteAclsOps indicates an expected call of DeleteAclsOps. -func (mr *MockOvnClientMockRecorder) DeleteAclsOps(parentName, parentType, direction, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteAclsOps(parentName, parentType, direction, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAclsOps", reflect.TypeOf((*MockOvnClient)(nil).DeleteAclsOps), parentName, parentType, direction, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAclsOps", reflect.TypeOf((*MockNbClient)(nil).DeleteAclsOps), parentName, parentType, direction, externalIDs) } // DeleteAddressSet mocks base method. -func (m *MockOvnClient) DeleteAddressSet(asName string) error { +func (m *MockNbClient) DeleteAddressSet(asName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteAddressSet", asName) ret0, _ := ret[0].(error) @@ -2363,13 +2364,13 @@ func (m *MockOvnClient) DeleteAddressSet(asName string) error { } // DeleteAddressSet indicates an expected call of DeleteAddressSet. -func (mr *MockOvnClientMockRecorder) DeleteAddressSet(asName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteAddressSet(asName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAddressSet", reflect.TypeOf((*MockOvnClient)(nil).DeleteAddressSet), asName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAddressSet", reflect.TypeOf((*MockNbClient)(nil).DeleteAddressSet), asName) } // DeleteAddressSets mocks base method. -func (m *MockOvnClient) DeleteAddressSets(externalIDs map[string]string) error { +func (m *MockNbClient) DeleteAddressSets(externalIDs map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteAddressSets", externalIDs) ret0, _ := ret[0].(error) @@ -2377,13 +2378,13 @@ func (m *MockOvnClient) DeleteAddressSets(externalIDs map[string]string) error { } // DeleteAddressSets indicates an expected call of DeleteAddressSets. -func (mr *MockOvnClientMockRecorder) DeleteAddressSets(externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteAddressSets(externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAddressSets", reflect.TypeOf((*MockOvnClient)(nil).DeleteAddressSets), externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAddressSets", reflect.TypeOf((*MockNbClient)(nil).DeleteAddressSets), externalIDs) } // DeleteBFD mocks base method. -func (m *MockOvnClient) DeleteBFD(lrpName, dstIP string) error { +func (m *MockNbClient) DeleteBFD(lrpName, dstIP string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteBFD", lrpName, dstIP) ret0, _ := ret[0].(error) @@ -2391,13 +2392,13 @@ func (m *MockOvnClient) DeleteBFD(lrpName, dstIP string) error { } // DeleteBFD indicates an expected call of DeleteBFD. -func (mr *MockOvnClientMockRecorder) DeleteBFD(lrpName, dstIP interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteBFD(lrpName, dstIP interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBFD", reflect.TypeOf((*MockOvnClient)(nil).DeleteBFD), lrpName, dstIP) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBFD", reflect.TypeOf((*MockNbClient)(nil).DeleteBFD), lrpName, dstIP) } // DeleteDHCPOptions mocks base method. -func (m *MockOvnClient) DeleteDHCPOptions(lsName, protocol string) error { +func (m *MockNbClient) DeleteDHCPOptions(lsName, protocol string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteDHCPOptions", lsName, protocol) ret0, _ := ret[0].(error) @@ -2405,13 +2406,13 @@ func (m *MockOvnClient) DeleteDHCPOptions(lsName, protocol string) error { } // DeleteDHCPOptions indicates an expected call of DeleteDHCPOptions. -func (mr *MockOvnClientMockRecorder) DeleteDHCPOptions(lsName, protocol interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteDHCPOptions(lsName, protocol interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDHCPOptions", reflect.TypeOf((*MockOvnClient)(nil).DeleteDHCPOptions), lsName, protocol) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDHCPOptions", reflect.TypeOf((*MockNbClient)(nil).DeleteDHCPOptions), lsName, protocol) } // DeleteDHCPOptionsByUUIDs mocks base method. -func (m *MockOvnClient) DeleteDHCPOptionsByUUIDs(uuidList ...string) error { +func (m *MockNbClient) DeleteDHCPOptionsByUUIDs(uuidList ...string) error { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range uuidList { @@ -2423,13 +2424,13 @@ func (m *MockOvnClient) DeleteDHCPOptionsByUUIDs(uuidList ...string) error { } // DeleteDHCPOptionsByUUIDs indicates an expected call of DeleteDHCPOptionsByUUIDs. -func (mr *MockOvnClientMockRecorder) DeleteDHCPOptionsByUUIDs(uuidList ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteDHCPOptionsByUUIDs(uuidList ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDHCPOptionsByUUIDs", reflect.TypeOf((*MockOvnClient)(nil).DeleteDHCPOptionsByUUIDs), uuidList...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDHCPOptionsByUUIDs", reflect.TypeOf((*MockNbClient)(nil).DeleteDHCPOptionsByUUIDs), uuidList...) } // DeleteLoadBalancers mocks base method. -func (m *MockOvnClient) DeleteLoadBalancers(filter func(*ovnnb.LoadBalancer) bool) error { +func (m *MockNbClient) DeleteLoadBalancers(filter func(*ovnnb.LoadBalancer) bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLoadBalancers", filter) ret0, _ := ret[0].(error) @@ -2437,13 +2438,13 @@ func (m *MockOvnClient) DeleteLoadBalancers(filter func(*ovnnb.LoadBalancer) boo } // DeleteLoadBalancers indicates an expected call of DeleteLoadBalancers. -func (mr *MockOvnClientMockRecorder) DeleteLoadBalancers(filter interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLoadBalancers(filter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLoadBalancers", reflect.TypeOf((*MockOvnClient)(nil).DeleteLoadBalancers), filter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLoadBalancers", reflect.TypeOf((*MockNbClient)(nil).DeleteLoadBalancers), filter) } // DeleteLogicalGatewaySwitch mocks base method. -func (m *MockOvnClient) DeleteLogicalGatewaySwitch(lsName, lrName string) error { +func (m *MockNbClient) DeleteLogicalGatewaySwitch(lsName, lrName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalGatewaySwitch", lsName, lrName) ret0, _ := ret[0].(error) @@ -2451,13 +2452,13 @@ func (m *MockOvnClient) DeleteLogicalGatewaySwitch(lsName, lrName string) error } // DeleteLogicalGatewaySwitch indicates an expected call of DeleteLogicalGatewaySwitch. -func (mr *MockOvnClientMockRecorder) DeleteLogicalGatewaySwitch(lsName, lrName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalGatewaySwitch(lsName, lrName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalGatewaySwitch", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalGatewaySwitch), lsName, lrName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalGatewaySwitch", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalGatewaySwitch), lsName, lrName) } // DeleteLogicalRouter mocks base method. -func (m *MockOvnClient) DeleteLogicalRouter(lrName string) error { +func (m *MockNbClient) DeleteLogicalRouter(lrName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalRouter", lrName) ret0, _ := ret[0].(error) @@ -2465,13 +2466,13 @@ func (m *MockOvnClient) DeleteLogicalRouter(lrName string) error { } // DeleteLogicalRouter indicates an expected call of DeleteLogicalRouter. -func (mr *MockOvnClientMockRecorder) DeleteLogicalRouter(lrName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalRouter(lrName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouter", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalRouter), lrName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouter", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalRouter), lrName) } // DeleteLogicalRouterPolicies mocks base method. -func (m *MockOvnClient) DeleteLogicalRouterPolicies(lrName string, priority int, externalIDs map[string]string) error { +func (m *MockNbClient) DeleteLogicalRouterPolicies(lrName string, priority int, externalIDs map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalRouterPolicies", lrName, priority, externalIDs) ret0, _ := ret[0].(error) @@ -2479,13 +2480,13 @@ func (m *MockOvnClient) DeleteLogicalRouterPolicies(lrName string, priority int, } // DeleteLogicalRouterPolicies indicates an expected call of DeleteLogicalRouterPolicies. -func (mr *MockOvnClientMockRecorder) DeleteLogicalRouterPolicies(lrName, priority, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalRouterPolicies(lrName, priority, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPolicies", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalRouterPolicies), lrName, priority, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPolicies", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalRouterPolicies), lrName, priority, externalIDs) } // DeleteLogicalRouterPolicy mocks base method. -func (m *MockOvnClient) DeleteLogicalRouterPolicy(lrName string, priority int, match string) error { +func (m *MockNbClient) DeleteLogicalRouterPolicy(lrName string, priority int, match string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalRouterPolicy", lrName, priority, match) ret0, _ := ret[0].(error) @@ -2493,13 +2494,13 @@ func (m *MockOvnClient) DeleteLogicalRouterPolicy(lrName string, priority int, m } // DeleteLogicalRouterPolicy indicates an expected call of DeleteLogicalRouterPolicy. -func (mr *MockOvnClientMockRecorder) DeleteLogicalRouterPolicy(lrName, priority, match interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalRouterPolicy(lrName, priority, match interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPolicy", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalRouterPolicy), lrName, priority, match) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPolicy", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalRouterPolicy), lrName, priority, match) } // DeleteLogicalRouterPolicyByNexthop mocks base method. -func (m *MockOvnClient) DeleteLogicalRouterPolicyByNexthop(lrName string, priority int, nexthop string) error { +func (m *MockNbClient) DeleteLogicalRouterPolicyByNexthop(lrName string, priority int, nexthop string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalRouterPolicyByNexthop", lrName, priority, nexthop) ret0, _ := ret[0].(error) @@ -2507,13 +2508,13 @@ func (m *MockOvnClient) DeleteLogicalRouterPolicyByNexthop(lrName string, priori } // DeleteLogicalRouterPolicyByNexthop indicates an expected call of DeleteLogicalRouterPolicyByNexthop. -func (mr *MockOvnClientMockRecorder) DeleteLogicalRouterPolicyByNexthop(lrName, priority, nexthop interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalRouterPolicyByNexthop(lrName, priority, nexthop interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPolicyByNexthop", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalRouterPolicyByNexthop), lrName, priority, nexthop) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPolicyByNexthop", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalRouterPolicyByNexthop), lrName, priority, nexthop) } // DeleteLogicalRouterPolicyByUUID mocks base method. -func (m *MockOvnClient) DeleteLogicalRouterPolicyByUUID(lrName, uuid string) error { +func (m *MockNbClient) DeleteLogicalRouterPolicyByUUID(lrName, uuid string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalRouterPolicyByUUID", lrName, uuid) ret0, _ := ret[0].(error) @@ -2521,13 +2522,13 @@ func (m *MockOvnClient) DeleteLogicalRouterPolicyByUUID(lrName, uuid string) err } // DeleteLogicalRouterPolicyByUUID indicates an expected call of DeleteLogicalRouterPolicyByUUID. -func (mr *MockOvnClientMockRecorder) DeleteLogicalRouterPolicyByUUID(lrName, uuid interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalRouterPolicyByUUID(lrName, uuid interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPolicyByUUID", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalRouterPolicyByUUID), lrName, uuid) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPolicyByUUID", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalRouterPolicyByUUID), lrName, uuid) } // DeleteLogicalRouterPort mocks base method. -func (m *MockOvnClient) DeleteLogicalRouterPort(lrpName string) error { +func (m *MockNbClient) DeleteLogicalRouterPort(lrpName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalRouterPort", lrpName) ret0, _ := ret[0].(error) @@ -2535,13 +2536,13 @@ func (m *MockOvnClient) DeleteLogicalRouterPort(lrpName string) error { } // DeleteLogicalRouterPort indicates an expected call of DeleteLogicalRouterPort. -func (mr *MockOvnClientMockRecorder) DeleteLogicalRouterPort(lrpName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalRouterPort(lrpName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPort", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalRouterPort), lrpName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPort", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalRouterPort), lrpName) } // DeleteLogicalRouterPorts mocks base method. -func (m *MockOvnClient) DeleteLogicalRouterPorts(externalIDs map[string]string, filter func(*ovnnb.LogicalRouterPort) bool) error { +func (m *MockNbClient) DeleteLogicalRouterPorts(externalIDs map[string]string, filter func(*ovnnb.LogicalRouterPort) bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalRouterPorts", externalIDs, filter) ret0, _ := ret[0].(error) @@ -2549,13 +2550,13 @@ func (m *MockOvnClient) DeleteLogicalRouterPorts(externalIDs map[string]string, } // DeleteLogicalRouterPorts indicates an expected call of DeleteLogicalRouterPorts. -func (mr *MockOvnClientMockRecorder) DeleteLogicalRouterPorts(externalIDs, filter interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalRouterPorts(externalIDs, filter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPorts", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalRouterPorts), externalIDs, filter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterPorts", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalRouterPorts), externalIDs, filter) } // DeleteLogicalRouterStaticRoute mocks base method. -func (m *MockOvnClient) DeleteLogicalRouterStaticRoute(lrName string, routeTable, policy *string, ipPrefix, nextHop string) error { +func (m *MockNbClient) DeleteLogicalRouterStaticRoute(lrName string, routeTable, policy *string, ipPrefix, nextHop string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalRouterStaticRoute", lrName, routeTable, policy, ipPrefix, nextHop) ret0, _ := ret[0].(error) @@ -2563,13 +2564,13 @@ func (m *MockOvnClient) DeleteLogicalRouterStaticRoute(lrName string, routeTable } // DeleteLogicalRouterStaticRoute indicates an expected call of DeleteLogicalRouterStaticRoute. -func (mr *MockOvnClientMockRecorder) DeleteLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, nextHop interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, nextHop interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterStaticRoute", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalRouterStaticRoute), lrName, routeTable, policy, ipPrefix, nextHop) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalRouterStaticRoute", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalRouterStaticRoute), lrName, routeTable, policy, ipPrefix, nextHop) } // DeleteLogicalSwitch mocks base method. -func (m *MockOvnClient) DeleteLogicalSwitch(lsName string) error { +func (m *MockNbClient) DeleteLogicalSwitch(lsName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalSwitch", lsName) ret0, _ := ret[0].(error) @@ -2577,13 +2578,13 @@ func (m *MockOvnClient) DeleteLogicalSwitch(lsName string) error { } // DeleteLogicalSwitch indicates an expected call of DeleteLogicalSwitch. -func (mr *MockOvnClientMockRecorder) DeleteLogicalSwitch(lsName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalSwitch(lsName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalSwitch", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalSwitch), lsName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalSwitch", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalSwitch), lsName) } // DeleteLogicalSwitchPort mocks base method. -func (m *MockOvnClient) DeleteLogicalSwitchPort(lspName string) error { +func (m *MockNbClient) DeleteLogicalSwitchPort(lspName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteLogicalSwitchPort", lspName) ret0, _ := ret[0].(error) @@ -2591,13 +2592,13 @@ func (m *MockOvnClient) DeleteLogicalSwitchPort(lspName string) error { } // DeleteLogicalSwitchPort indicates an expected call of DeleteLogicalSwitchPort. -func (mr *MockOvnClientMockRecorder) DeleteLogicalSwitchPort(lspName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteLogicalSwitchPort(lspName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalSwitchPort", reflect.TypeOf((*MockOvnClient)(nil).DeleteLogicalSwitchPort), lspName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLogicalSwitchPort", reflect.TypeOf((*MockNbClient)(nil).DeleteLogicalSwitchPort), lspName) } // DeleteNat mocks base method. -func (m *MockOvnClient) DeleteNat(lrName, natType, externalIP, logicalIP string) error { +func (m *MockNbClient) DeleteNat(lrName, natType, externalIP, logicalIP string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteNat", lrName, natType, externalIP, logicalIP) ret0, _ := ret[0].(error) @@ -2605,13 +2606,13 @@ func (m *MockOvnClient) DeleteNat(lrName, natType, externalIP, logicalIP string) } // DeleteNat indicates an expected call of DeleteNat. -func (mr *MockOvnClientMockRecorder) DeleteNat(lrName, natType, externalIP, logicalIP interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteNat(lrName, natType, externalIP, logicalIP interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNat", reflect.TypeOf((*MockOvnClient)(nil).DeleteNat), lrName, natType, externalIP, logicalIP) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNat", reflect.TypeOf((*MockNbClient)(nil).DeleteNat), lrName, natType, externalIP, logicalIP) } // DeleteNats mocks base method. -func (m *MockOvnClient) DeleteNats(lrName, natType, logicalIP string) error { +func (m *MockNbClient) DeleteNats(lrName, natType, logicalIP string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteNats", lrName, natType, logicalIP) ret0, _ := ret[0].(error) @@ -2619,13 +2620,13 @@ func (m *MockOvnClient) DeleteNats(lrName, natType, logicalIP string) error { } // DeleteNats indicates an expected call of DeleteNats. -func (mr *MockOvnClientMockRecorder) DeleteNats(lrName, natType, logicalIP interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteNats(lrName, natType, logicalIP interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNats", reflect.TypeOf((*MockOvnClient)(nil).DeleteNats), lrName, natType, logicalIP) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteNats", reflect.TypeOf((*MockNbClient)(nil).DeleteNats), lrName, natType, logicalIP) } // DeletePortGroup mocks base method. -func (m *MockOvnClient) DeletePortGroup(pgName string) error { +func (m *MockNbClient) DeletePortGroup(pgName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeletePortGroup", pgName) ret0, _ := ret[0].(error) @@ -2633,13 +2634,13 @@ func (m *MockOvnClient) DeletePortGroup(pgName string) error { } // DeletePortGroup indicates an expected call of DeletePortGroup. -func (mr *MockOvnClientMockRecorder) DeletePortGroup(pgName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeletePortGroup(pgName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePortGroup", reflect.TypeOf((*MockOvnClient)(nil).DeletePortGroup), pgName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePortGroup", reflect.TypeOf((*MockNbClient)(nil).DeletePortGroup), pgName) } // DeleteSecurityGroup mocks base method. -func (m *MockOvnClient) DeleteSecurityGroup(sgName string) error { +func (m *MockNbClient) DeleteSecurityGroup(sgName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteSecurityGroup", sgName) ret0, _ := ret[0].(error) @@ -2647,13 +2648,13 @@ func (m *MockOvnClient) DeleteSecurityGroup(sgName string) error { } // DeleteSecurityGroup indicates an expected call of DeleteSecurityGroup. -func (mr *MockOvnClientMockRecorder) DeleteSecurityGroup(sgName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) DeleteSecurityGroup(sgName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSecurityGroup", reflect.TypeOf((*MockOvnClient)(nil).DeleteSecurityGroup), sgName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSecurityGroup", reflect.TypeOf((*MockNbClient)(nil).DeleteSecurityGroup), sgName) } // EnablePortLayer2forward mocks base method. -func (m *MockOvnClient) EnablePortLayer2forward(lspName string) error { +func (m *MockNbClient) EnablePortLayer2forward(lspName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EnablePortLayer2forward", lspName) ret0, _ := ret[0].(error) @@ -2661,13 +2662,13 @@ func (m *MockOvnClient) EnablePortLayer2forward(lspName string) error { } // EnablePortLayer2forward indicates an expected call of EnablePortLayer2forward. -func (mr *MockOvnClientMockRecorder) EnablePortLayer2forward(lspName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) EnablePortLayer2forward(lspName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnablePortLayer2forward", reflect.TypeOf((*MockOvnClient)(nil).EnablePortLayer2forward), lspName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnablePortLayer2forward", reflect.TypeOf((*MockNbClient)(nil).EnablePortLayer2forward), lspName) } // GetEntityInfo mocks base method. -func (m *MockOvnClient) GetEntityInfo(entity interface{}) error { +func (m *MockNbClient) GetEntityInfo(entity interface{}) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetEntityInfo", entity) ret0, _ := ret[0].(error) @@ -2675,13 +2676,13 @@ func (m *MockOvnClient) GetEntityInfo(entity interface{}) error { } // GetEntityInfo indicates an expected call of GetEntityInfo. -func (mr *MockOvnClientMockRecorder) GetEntityInfo(entity interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetEntityInfo(entity interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEntityInfo", reflect.TypeOf((*MockOvnClient)(nil).GetEntityInfo), entity) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEntityInfo", reflect.TypeOf((*MockNbClient)(nil).GetEntityInfo), entity) } // GetLoadBalancer mocks base method. -func (m *MockOvnClient) GetLoadBalancer(lbName string, ignoreNotFound bool) (*ovnnb.LoadBalancer, error) { +func (m *MockNbClient) GetLoadBalancer(lbName string, ignoreNotFound bool) (*ovnnb.LoadBalancer, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLoadBalancer", lbName, ignoreNotFound) ret0, _ := ret[0].(*ovnnb.LoadBalancer) @@ -2690,13 +2691,13 @@ func (m *MockOvnClient) GetLoadBalancer(lbName string, ignoreNotFound bool) (*ov } // GetLoadBalancer indicates an expected call of GetLoadBalancer. -func (mr *MockOvnClientMockRecorder) GetLoadBalancer(lbName, ignoreNotFound interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetLoadBalancer(lbName, ignoreNotFound interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLoadBalancer", reflect.TypeOf((*MockOvnClient)(nil).GetLoadBalancer), lbName, ignoreNotFound) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLoadBalancer", reflect.TypeOf((*MockNbClient)(nil).GetLoadBalancer), lbName, ignoreNotFound) } // GetLogicalRouter mocks base method. -func (m *MockOvnClient) GetLogicalRouter(lrName string, ignoreNotFound bool) (*ovnnb.LogicalRouter, error) { +func (m *MockNbClient) GetLogicalRouter(lrName string, ignoreNotFound bool) (*ovnnb.LogicalRouter, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLogicalRouter", lrName, ignoreNotFound) ret0, _ := ret[0].(*ovnnb.LogicalRouter) @@ -2705,13 +2706,13 @@ func (m *MockOvnClient) GetLogicalRouter(lrName string, ignoreNotFound bool) (*o } // GetLogicalRouter indicates an expected call of GetLogicalRouter. -func (mr *MockOvnClientMockRecorder) GetLogicalRouter(lrName, ignoreNotFound interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetLogicalRouter(lrName, ignoreNotFound interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalRouter", reflect.TypeOf((*MockOvnClient)(nil).GetLogicalRouter), lrName, ignoreNotFound) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalRouter", reflect.TypeOf((*MockNbClient)(nil).GetLogicalRouter), lrName, ignoreNotFound) } // GetLogicalRouterPolicy mocks base method. -func (m *MockOvnClient) GetLogicalRouterPolicy(lrName string, priority int, match string, ignoreNotFound bool) ([]*ovnnb.LogicalRouterPolicy, error) { +func (m *MockNbClient) GetLogicalRouterPolicy(lrName string, priority int, match string, ignoreNotFound bool) ([]*ovnnb.LogicalRouterPolicy, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLogicalRouterPolicy", lrName, priority, match, ignoreNotFound) ret0, _ := ret[0].([]*ovnnb.LogicalRouterPolicy) @@ -2720,13 +2721,13 @@ func (m *MockOvnClient) GetLogicalRouterPolicy(lrName string, priority int, matc } // GetLogicalRouterPolicy indicates an expected call of GetLogicalRouterPolicy. -func (mr *MockOvnClientMockRecorder) GetLogicalRouterPolicy(lrName, priority, match, ignoreNotFound interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetLogicalRouterPolicy(lrName, priority, match, ignoreNotFound interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalRouterPolicy", reflect.TypeOf((*MockOvnClient)(nil).GetLogicalRouterPolicy), lrName, priority, match, ignoreNotFound) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalRouterPolicy", reflect.TypeOf((*MockNbClient)(nil).GetLogicalRouterPolicy), lrName, priority, match, ignoreNotFound) } // GetLogicalRouterPort mocks base method. -func (m *MockOvnClient) GetLogicalRouterPort(lrpName string, ignoreNotFound bool) (*ovnnb.LogicalRouterPort, error) { +func (m *MockNbClient) GetLogicalRouterPort(lrpName string, ignoreNotFound bool) (*ovnnb.LogicalRouterPort, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLogicalRouterPort", lrpName, ignoreNotFound) ret0, _ := ret[0].(*ovnnb.LogicalRouterPort) @@ -2735,13 +2736,13 @@ func (m *MockOvnClient) GetLogicalRouterPort(lrpName string, ignoreNotFound bool } // GetLogicalRouterPort indicates an expected call of GetLogicalRouterPort. -func (mr *MockOvnClientMockRecorder) GetLogicalRouterPort(lrpName, ignoreNotFound interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetLogicalRouterPort(lrpName, ignoreNotFound interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalRouterPort", reflect.TypeOf((*MockOvnClient)(nil).GetLogicalRouterPort), lrpName, ignoreNotFound) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalRouterPort", reflect.TypeOf((*MockNbClient)(nil).GetLogicalRouterPort), lrpName, ignoreNotFound) } // GetLogicalRouterPortByUUID mocks base method. -func (m *MockOvnClient) GetLogicalRouterPortByUUID(uuid string) (*ovnnb.LogicalRouterPort, error) { +func (m *MockNbClient) GetLogicalRouterPortByUUID(uuid string) (*ovnnb.LogicalRouterPort, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLogicalRouterPortByUUID", uuid) ret0, _ := ret[0].(*ovnnb.LogicalRouterPort) @@ -2750,13 +2751,13 @@ func (m *MockOvnClient) GetLogicalRouterPortByUUID(uuid string) (*ovnnb.LogicalR } // GetLogicalRouterPortByUUID indicates an expected call of GetLogicalRouterPortByUUID. -func (mr *MockOvnClientMockRecorder) GetLogicalRouterPortByUUID(uuid interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetLogicalRouterPortByUUID(uuid interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalRouterPortByUUID", reflect.TypeOf((*MockOvnClient)(nil).GetLogicalRouterPortByUUID), uuid) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalRouterPortByUUID", reflect.TypeOf((*MockNbClient)(nil).GetLogicalRouterPortByUUID), uuid) } // GetLogicalSwitchPort mocks base method. -func (m *MockOvnClient) GetLogicalSwitchPort(lspName string, ignoreNotFound bool) (*ovnnb.LogicalSwitchPort, error) { +func (m *MockNbClient) GetLogicalSwitchPort(lspName string, ignoreNotFound bool) (*ovnnb.LogicalSwitchPort, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLogicalSwitchPort", lspName, ignoreNotFound) ret0, _ := ret[0].(*ovnnb.LogicalSwitchPort) @@ -2765,13 +2766,13 @@ func (m *MockOvnClient) GetLogicalSwitchPort(lspName string, ignoreNotFound bool } // GetLogicalSwitchPort indicates an expected call of GetLogicalSwitchPort. -func (mr *MockOvnClientMockRecorder) GetLogicalSwitchPort(lspName, ignoreNotFound interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetLogicalSwitchPort(lspName, ignoreNotFound interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalSwitchPort", reflect.TypeOf((*MockOvnClient)(nil).GetLogicalSwitchPort), lspName, ignoreNotFound) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogicalSwitchPort", reflect.TypeOf((*MockNbClient)(nil).GetLogicalSwitchPort), lspName, ignoreNotFound) } // GetNATByUUID mocks base method. -func (m *MockOvnClient) GetNATByUUID(uuid string) (*ovnnb.NAT, error) { +func (m *MockNbClient) GetNATByUUID(uuid string) (*ovnnb.NAT, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetNATByUUID", uuid) ret0, _ := ret[0].(*ovnnb.NAT) @@ -2780,13 +2781,13 @@ func (m *MockOvnClient) GetNATByUUID(uuid string) (*ovnnb.NAT, error) { } // GetNATByUUID indicates an expected call of GetNATByUUID. -func (mr *MockOvnClientMockRecorder) GetNATByUUID(uuid interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetNATByUUID(uuid interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNATByUUID", reflect.TypeOf((*MockOvnClient)(nil).GetNATByUUID), uuid) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNATByUUID", reflect.TypeOf((*MockNbClient)(nil).GetNATByUUID), uuid) } // GetNbGlobal mocks base method. -func (m *MockOvnClient) GetNbGlobal() (*ovnnb.NBGlobal, error) { +func (m *MockNbClient) GetNbGlobal() (*ovnnb.NBGlobal, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetNbGlobal") ret0, _ := ret[0].(*ovnnb.NBGlobal) @@ -2795,13 +2796,13 @@ func (m *MockOvnClient) GetNbGlobal() (*ovnnb.NBGlobal, error) { } // GetNbGlobal indicates an expected call of GetNbGlobal. -func (mr *MockOvnClientMockRecorder) GetNbGlobal() *gomock.Call { +func (mr *MockNbClientMockRecorder) GetNbGlobal() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNbGlobal", reflect.TypeOf((*MockOvnClient)(nil).GetNbGlobal)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNbGlobal", reflect.TypeOf((*MockNbClient)(nil).GetNbGlobal)) } // GetPortGroup mocks base method. -func (m *MockOvnClient) GetPortGroup(pgName string, ignoreNotFound bool) (*ovnnb.PortGroup, error) { +func (m *MockNbClient) GetPortGroup(pgName string, ignoreNotFound bool) (*ovnnb.PortGroup, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetPortGroup", pgName, ignoreNotFound) ret0, _ := ret[0].(*ovnnb.PortGroup) @@ -2810,13 +2811,13 @@ func (m *MockOvnClient) GetPortGroup(pgName string, ignoreNotFound bool) (*ovnnb } // GetPortGroup indicates an expected call of GetPortGroup. -func (mr *MockOvnClientMockRecorder) GetPortGroup(pgName, ignoreNotFound interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) GetPortGroup(pgName, ignoreNotFound interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPortGroup", reflect.TypeOf((*MockOvnClient)(nil).GetPortGroup), pgName, ignoreNotFound) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPortGroup", reflect.TypeOf((*MockNbClient)(nil).GetPortGroup), pgName, ignoreNotFound) } // ListAddressSets mocks base method. -func (m *MockOvnClient) ListAddressSets(externalIDs map[string]string) ([]ovnnb.AddressSet, error) { +func (m *MockNbClient) ListAddressSets(externalIDs map[string]string) ([]ovnnb.AddressSet, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListAddressSets", externalIDs) ret0, _ := ret[0].([]ovnnb.AddressSet) @@ -2825,13 +2826,13 @@ func (m *MockOvnClient) ListAddressSets(externalIDs map[string]string) ([]ovnnb. } // ListAddressSets indicates an expected call of ListAddressSets. -func (mr *MockOvnClientMockRecorder) ListAddressSets(externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListAddressSets(externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAddressSets", reflect.TypeOf((*MockOvnClient)(nil).ListAddressSets), externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAddressSets", reflect.TypeOf((*MockNbClient)(nil).ListAddressSets), externalIDs) } // ListDHCPOptions mocks base method. -func (m *MockOvnClient) ListDHCPOptions(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.DHCPOptions, error) { +func (m *MockNbClient) ListDHCPOptions(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.DHCPOptions, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListDHCPOptions", needVendorFilter, externalIDs) ret0, _ := ret[0].([]ovnnb.DHCPOptions) @@ -2840,13 +2841,13 @@ func (m *MockOvnClient) ListDHCPOptions(needVendorFilter bool, externalIDs map[s } // ListDHCPOptions indicates an expected call of ListDHCPOptions. -func (mr *MockOvnClientMockRecorder) ListDHCPOptions(needVendorFilter, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListDHCPOptions(needVendorFilter, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListDHCPOptions", reflect.TypeOf((*MockOvnClient)(nil).ListDHCPOptions), needVendorFilter, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListDHCPOptions", reflect.TypeOf((*MockNbClient)(nil).ListDHCPOptions), needVendorFilter, externalIDs) } // ListLoadBalancers mocks base method. -func (m *MockOvnClient) ListLoadBalancers(filter func(*ovnnb.LoadBalancer) bool) ([]ovnnb.LoadBalancer, error) { +func (m *MockNbClient) ListLoadBalancers(filter func(*ovnnb.LoadBalancer) bool) ([]ovnnb.LoadBalancer, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLoadBalancers", filter) ret0, _ := ret[0].([]ovnnb.LoadBalancer) @@ -2855,13 +2856,13 @@ func (m *MockOvnClient) ListLoadBalancers(filter func(*ovnnb.LoadBalancer) bool) } // ListLoadBalancers indicates an expected call of ListLoadBalancers. -func (mr *MockOvnClientMockRecorder) ListLoadBalancers(filter interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLoadBalancers(filter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLoadBalancers", reflect.TypeOf((*MockOvnClient)(nil).ListLoadBalancers), filter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLoadBalancers", reflect.TypeOf((*MockNbClient)(nil).ListLoadBalancers), filter) } // ListLogicalRouter mocks base method. -func (m *MockOvnClient) ListLogicalRouter(needVendorFilter bool, filter func(*ovnnb.LogicalRouter) bool) ([]ovnnb.LogicalRouter, error) { +func (m *MockNbClient) ListLogicalRouter(needVendorFilter bool, filter func(*ovnnb.LogicalRouter) bool) ([]ovnnb.LogicalRouter, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLogicalRouter", needVendorFilter, filter) ret0, _ := ret[0].([]ovnnb.LogicalRouter) @@ -2870,13 +2871,13 @@ func (m *MockOvnClient) ListLogicalRouter(needVendorFilter bool, filter func(*ov } // ListLogicalRouter indicates an expected call of ListLogicalRouter. -func (mr *MockOvnClientMockRecorder) ListLogicalRouter(needVendorFilter, filter interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLogicalRouter(needVendorFilter, filter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouter", reflect.TypeOf((*MockOvnClient)(nil).ListLogicalRouter), needVendorFilter, filter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouter", reflect.TypeOf((*MockNbClient)(nil).ListLogicalRouter), needVendorFilter, filter) } // ListLogicalRouterPolicies mocks base method. -func (m *MockOvnClient) ListLogicalRouterPolicies(lrName string, priority int, externalIDs map[string]string) ([]*ovnnb.LogicalRouterPolicy, error) { +func (m *MockNbClient) ListLogicalRouterPolicies(lrName string, priority int, externalIDs map[string]string) ([]*ovnnb.LogicalRouterPolicy, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLogicalRouterPolicies", lrName, priority, externalIDs) ret0, _ := ret[0].([]*ovnnb.LogicalRouterPolicy) @@ -2885,13 +2886,13 @@ func (m *MockOvnClient) ListLogicalRouterPolicies(lrName string, priority int, e } // ListLogicalRouterPolicies indicates an expected call of ListLogicalRouterPolicies. -func (mr *MockOvnClientMockRecorder) ListLogicalRouterPolicies(lrName, priority, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLogicalRouterPolicies(lrName, priority, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouterPolicies", reflect.TypeOf((*MockOvnClient)(nil).ListLogicalRouterPolicies), lrName, priority, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouterPolicies", reflect.TypeOf((*MockNbClient)(nil).ListLogicalRouterPolicies), lrName, priority, externalIDs) } // ListLogicalRouterPorts mocks base method. -func (m *MockOvnClient) ListLogicalRouterPorts(externalIDs map[string]string, filter func(*ovnnb.LogicalRouterPort) bool) ([]ovnnb.LogicalRouterPort, error) { +func (m *MockNbClient) ListLogicalRouterPorts(externalIDs map[string]string, filter func(*ovnnb.LogicalRouterPort) bool) ([]ovnnb.LogicalRouterPort, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLogicalRouterPorts", externalIDs, filter) ret0, _ := ret[0].([]ovnnb.LogicalRouterPort) @@ -2900,13 +2901,13 @@ func (m *MockOvnClient) ListLogicalRouterPorts(externalIDs map[string]string, fi } // ListLogicalRouterPorts indicates an expected call of ListLogicalRouterPorts. -func (mr *MockOvnClientMockRecorder) ListLogicalRouterPorts(externalIDs, filter interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLogicalRouterPorts(externalIDs, filter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouterPorts", reflect.TypeOf((*MockOvnClient)(nil).ListLogicalRouterPorts), externalIDs, filter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouterPorts", reflect.TypeOf((*MockNbClient)(nil).ListLogicalRouterPorts), externalIDs, filter) } // ListLogicalRouterStaticRoutes mocks base method. -func (m *MockOvnClient) ListLogicalRouterStaticRoutes(lrName string, routeTable, policy *string, ipPrefix string, externalIDs map[string]string) ([]*ovnnb.LogicalRouterStaticRoute, error) { +func (m *MockNbClient) ListLogicalRouterStaticRoutes(lrName string, routeTable, policy *string, ipPrefix string, externalIDs map[string]string) ([]*ovnnb.LogicalRouterStaticRoute, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLogicalRouterStaticRoutes", lrName, routeTable, policy, ipPrefix, externalIDs) ret0, _ := ret[0].([]*ovnnb.LogicalRouterStaticRoute) @@ -2915,13 +2916,13 @@ func (m *MockOvnClient) ListLogicalRouterStaticRoutes(lrName string, routeTable, } // ListLogicalRouterStaticRoutes indicates an expected call of ListLogicalRouterStaticRoutes. -func (mr *MockOvnClientMockRecorder) ListLogicalRouterStaticRoutes(lrName, routeTable, policy, ipPrefix, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLogicalRouterStaticRoutes(lrName, routeTable, policy, ipPrefix, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouterStaticRoutes", reflect.TypeOf((*MockOvnClient)(nil).ListLogicalRouterStaticRoutes), lrName, routeTable, policy, ipPrefix, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouterStaticRoutes", reflect.TypeOf((*MockNbClient)(nil).ListLogicalRouterStaticRoutes), lrName, routeTable, policy, ipPrefix, externalIDs) } // ListLogicalRouterStaticRoutesByOption mocks base method. -func (m *MockOvnClient) ListLogicalRouterStaticRoutesByOption(lrName, routeTable, key, value string) ([]*ovnnb.LogicalRouterStaticRoute, error) { +func (m *MockNbClient) ListLogicalRouterStaticRoutesByOption(lrName, routeTable, key, value string) ([]*ovnnb.LogicalRouterStaticRoute, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLogicalRouterStaticRoutesByOption", lrName, routeTable, key, value) ret0, _ := ret[0].([]*ovnnb.LogicalRouterStaticRoute) @@ -2930,13 +2931,13 @@ func (m *MockOvnClient) ListLogicalRouterStaticRoutesByOption(lrName, routeTable } // ListLogicalRouterStaticRoutesByOption indicates an expected call of ListLogicalRouterStaticRoutesByOption. -func (mr *MockOvnClientMockRecorder) ListLogicalRouterStaticRoutesByOption(lrName, routeTable, key, value interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLogicalRouterStaticRoutesByOption(lrName, routeTable, key, value interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouterStaticRoutesByOption", reflect.TypeOf((*MockOvnClient)(nil).ListLogicalRouterStaticRoutesByOption), lrName, routeTable, key, value) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalRouterStaticRoutesByOption", reflect.TypeOf((*MockNbClient)(nil).ListLogicalRouterStaticRoutesByOption), lrName, routeTable, key, value) } // ListLogicalSwitch mocks base method. -func (m *MockOvnClient) ListLogicalSwitch(needVendorFilter bool, filter func(*ovnnb.LogicalSwitch) bool) ([]ovnnb.LogicalSwitch, error) { +func (m *MockNbClient) ListLogicalSwitch(needVendorFilter bool, filter func(*ovnnb.LogicalSwitch) bool) ([]ovnnb.LogicalSwitch, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLogicalSwitch", needVendorFilter, filter) ret0, _ := ret[0].([]ovnnb.LogicalSwitch) @@ -2945,13 +2946,13 @@ func (m *MockOvnClient) ListLogicalSwitch(needVendorFilter bool, filter func(*ov } // ListLogicalSwitch indicates an expected call of ListLogicalSwitch. -func (mr *MockOvnClientMockRecorder) ListLogicalSwitch(needVendorFilter, filter interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLogicalSwitch(needVendorFilter, filter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalSwitch", reflect.TypeOf((*MockOvnClient)(nil).ListLogicalSwitch), needVendorFilter, filter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalSwitch", reflect.TypeOf((*MockNbClient)(nil).ListLogicalSwitch), needVendorFilter, filter) } // ListLogicalSwitchPorts mocks base method. -func (m *MockOvnClient) ListLogicalSwitchPorts(needVendorFilter bool, externalIDs map[string]string, filter func(*ovnnb.LogicalSwitchPort) bool) ([]ovnnb.LogicalSwitchPort, error) { +func (m *MockNbClient) ListLogicalSwitchPorts(needVendorFilter bool, externalIDs map[string]string, filter func(*ovnnb.LogicalSwitchPort) bool) ([]ovnnb.LogicalSwitchPort, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLogicalSwitchPorts", needVendorFilter, externalIDs, filter) ret0, _ := ret[0].([]ovnnb.LogicalSwitchPort) @@ -2960,13 +2961,13 @@ func (m *MockOvnClient) ListLogicalSwitchPorts(needVendorFilter bool, externalID } // ListLogicalSwitchPorts indicates an expected call of ListLogicalSwitchPorts. -func (mr *MockOvnClientMockRecorder) ListLogicalSwitchPorts(needVendorFilter, externalIDs, filter interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLogicalSwitchPorts(needVendorFilter, externalIDs, filter interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalSwitchPorts", reflect.TypeOf((*MockOvnClient)(nil).ListLogicalSwitchPorts), needVendorFilter, externalIDs, filter) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalSwitchPorts", reflect.TypeOf((*MockNbClient)(nil).ListLogicalSwitchPorts), needVendorFilter, externalIDs, filter) } // ListLogicalSwitchPortsWithLegacyExternalIDs mocks base method. -func (m *MockOvnClient) ListLogicalSwitchPortsWithLegacyExternalIDs() ([]ovnnb.LogicalSwitchPort, error) { +func (m *MockNbClient) ListLogicalSwitchPortsWithLegacyExternalIDs() ([]ovnnb.LogicalSwitchPort, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListLogicalSwitchPortsWithLegacyExternalIDs") ret0, _ := ret[0].([]ovnnb.LogicalSwitchPort) @@ -2975,13 +2976,13 @@ func (m *MockOvnClient) ListLogicalSwitchPortsWithLegacyExternalIDs() ([]ovnnb.L } // ListLogicalSwitchPortsWithLegacyExternalIDs indicates an expected call of ListLogicalSwitchPortsWithLegacyExternalIDs. -func (mr *MockOvnClientMockRecorder) ListLogicalSwitchPortsWithLegacyExternalIDs() *gomock.Call { +func (mr *MockNbClientMockRecorder) ListLogicalSwitchPortsWithLegacyExternalIDs() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalSwitchPortsWithLegacyExternalIDs", reflect.TypeOf((*MockOvnClient)(nil).ListLogicalSwitchPortsWithLegacyExternalIDs)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogicalSwitchPortsWithLegacyExternalIDs", reflect.TypeOf((*MockNbClient)(nil).ListLogicalSwitchPortsWithLegacyExternalIDs)) } // ListNats mocks base method. -func (m *MockOvnClient) ListNats(lrName, natType, logicalIP string, externalIDs map[string]string) ([]*ovnnb.NAT, error) { +func (m *MockNbClient) ListNats(lrName, natType, logicalIP string, externalIDs map[string]string) ([]*ovnnb.NAT, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListNats", lrName, natType, logicalIP, externalIDs) ret0, _ := ret[0].([]*ovnnb.NAT) @@ -2990,13 +2991,13 @@ func (m *MockOvnClient) ListNats(lrName, natType, logicalIP string, externalIDs } // ListNats indicates an expected call of ListNats. -func (mr *MockOvnClientMockRecorder) ListNats(lrName, natType, logicalIP, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListNats(lrName, natType, logicalIP, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListNats", reflect.TypeOf((*MockOvnClient)(nil).ListNats), lrName, natType, logicalIP, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListNats", reflect.TypeOf((*MockNbClient)(nil).ListNats), lrName, natType, logicalIP, externalIDs) } // ListNormalLogicalSwitchPorts mocks base method. -func (m *MockOvnClient) ListNormalLogicalSwitchPorts(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.LogicalSwitchPort, error) { +func (m *MockNbClient) ListNormalLogicalSwitchPorts(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.LogicalSwitchPort, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListNormalLogicalSwitchPorts", needVendorFilter, externalIDs) ret0, _ := ret[0].([]ovnnb.LogicalSwitchPort) @@ -3005,13 +3006,13 @@ func (m *MockOvnClient) ListNormalLogicalSwitchPorts(needVendorFilter bool, exte } // ListNormalLogicalSwitchPorts indicates an expected call of ListNormalLogicalSwitchPorts. -func (mr *MockOvnClientMockRecorder) ListNormalLogicalSwitchPorts(needVendorFilter, externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListNormalLogicalSwitchPorts(needVendorFilter, externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListNormalLogicalSwitchPorts", reflect.TypeOf((*MockOvnClient)(nil).ListNormalLogicalSwitchPorts), needVendorFilter, externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListNormalLogicalSwitchPorts", reflect.TypeOf((*MockNbClient)(nil).ListNormalLogicalSwitchPorts), needVendorFilter, externalIDs) } // ListPortGroups mocks base method. -func (m *MockOvnClient) ListPortGroups(externalIDs map[string]string) ([]ovnnb.PortGroup, error) { +func (m *MockNbClient) ListPortGroups(externalIDs map[string]string) ([]ovnnb.PortGroup, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListPortGroups", externalIDs) ret0, _ := ret[0].([]ovnnb.PortGroup) @@ -3020,13 +3021,13 @@ func (m *MockOvnClient) ListPortGroups(externalIDs map[string]string) ([]ovnnb.P } // ListPortGroups indicates an expected call of ListPortGroups. -func (mr *MockOvnClientMockRecorder) ListPortGroups(externalIDs interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) ListPortGroups(externalIDs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPortGroups", reflect.TypeOf((*MockOvnClient)(nil).ListPortGroups), externalIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPortGroups", reflect.TypeOf((*MockNbClient)(nil).ListPortGroups), externalIDs) } // LoadBalancerAddVip mocks base method. -func (m *MockOvnClient) LoadBalancerAddVip(lbName, vip string, backends ...string) error { +func (m *MockNbClient) LoadBalancerAddVip(lbName, vip string, backends ...string) error { m.ctrl.T.Helper() varargs := []interface{}{lbName, vip} for _, a := range backends { @@ -3038,14 +3039,14 @@ func (m *MockOvnClient) LoadBalancerAddVip(lbName, vip string, backends ...strin } // LoadBalancerAddVip indicates an expected call of LoadBalancerAddVip. -func (mr *MockOvnClientMockRecorder) LoadBalancerAddVip(lbName, vip interface{}, backends ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LoadBalancerAddVip(lbName, vip interface{}, backends ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{lbName, vip}, backends...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBalancerAddVip", reflect.TypeOf((*MockOvnClient)(nil).LoadBalancerAddVip), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBalancerAddVip", reflect.TypeOf((*MockNbClient)(nil).LoadBalancerAddVip), varargs...) } // LoadBalancerDeleteVip mocks base method. -func (m *MockOvnClient) LoadBalancerDeleteVip(lbName, vip string) error { +func (m *MockNbClient) LoadBalancerDeleteVip(lbName, vip string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LoadBalancerDeleteVip", lbName, vip) ret0, _ := ret[0].(error) @@ -3053,13 +3054,13 @@ func (m *MockOvnClient) LoadBalancerDeleteVip(lbName, vip string) error { } // LoadBalancerDeleteVip indicates an expected call of LoadBalancerDeleteVip. -func (mr *MockOvnClientMockRecorder) LoadBalancerDeleteVip(lbName, vip interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LoadBalancerDeleteVip(lbName, vip interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBalancerDeleteVip", reflect.TypeOf((*MockOvnClient)(nil).LoadBalancerDeleteVip), lbName, vip) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBalancerDeleteVip", reflect.TypeOf((*MockNbClient)(nil).LoadBalancerDeleteVip), lbName, vip) } // LoadBalancerExists mocks base method. -func (m *MockOvnClient) LoadBalancerExists(lbName string) (bool, error) { +func (m *MockNbClient) LoadBalancerExists(lbName string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LoadBalancerExists", lbName) ret0, _ := ret[0].(bool) @@ -3068,13 +3069,13 @@ func (m *MockOvnClient) LoadBalancerExists(lbName string) (bool, error) { } // LoadBalancerExists indicates an expected call of LoadBalancerExists. -func (mr *MockOvnClientMockRecorder) LoadBalancerExists(lbName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LoadBalancerExists(lbName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBalancerExists", reflect.TypeOf((*MockOvnClient)(nil).LoadBalancerExists), lbName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadBalancerExists", reflect.TypeOf((*MockNbClient)(nil).LoadBalancerExists), lbName) } // LogicalRouterExists mocks base method. -func (m *MockOvnClient) LogicalRouterExists(name string) (bool, error) { +func (m *MockNbClient) LogicalRouterExists(name string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LogicalRouterExists", name) ret0, _ := ret[0].(bool) @@ -3083,13 +3084,13 @@ func (m *MockOvnClient) LogicalRouterExists(name string) (bool, error) { } // LogicalRouterExists indicates an expected call of LogicalRouterExists. -func (mr *MockOvnClientMockRecorder) LogicalRouterExists(name interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LogicalRouterExists(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalRouterExists", reflect.TypeOf((*MockOvnClient)(nil).LogicalRouterExists), name) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalRouterExists", reflect.TypeOf((*MockNbClient)(nil).LogicalRouterExists), name) } // LogicalRouterPortExists mocks base method. -func (m *MockOvnClient) LogicalRouterPortExists(lrpName string) (bool, error) { +func (m *MockNbClient) LogicalRouterPortExists(lrpName string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LogicalRouterPortExists", lrpName) ret0, _ := ret[0].(bool) @@ -3098,13 +3099,13 @@ func (m *MockOvnClient) LogicalRouterPortExists(lrpName string) (bool, error) { } // LogicalRouterPortExists indicates an expected call of LogicalRouterPortExists. -func (mr *MockOvnClientMockRecorder) LogicalRouterPortExists(lrpName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LogicalRouterPortExists(lrpName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalRouterPortExists", reflect.TypeOf((*MockOvnClient)(nil).LogicalRouterPortExists), lrpName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalRouterPortExists", reflect.TypeOf((*MockNbClient)(nil).LogicalRouterPortExists), lrpName) } // LogicalRouterStaticRouteExists mocks base method. -func (m *MockOvnClient) LogicalRouterStaticRouteExists(lrName, routeTable, policy, ipPrefix, nexthop string) (bool, error) { +func (m *MockNbClient) LogicalRouterStaticRouteExists(lrName, routeTable, policy, ipPrefix, nexthop string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LogicalRouterStaticRouteExists", lrName, routeTable, policy, ipPrefix, nexthop) ret0, _ := ret[0].(bool) @@ -3113,13 +3114,13 @@ func (m *MockOvnClient) LogicalRouterStaticRouteExists(lrName, routeTable, polic } // LogicalRouterStaticRouteExists indicates an expected call of LogicalRouterStaticRouteExists. -func (mr *MockOvnClientMockRecorder) LogicalRouterStaticRouteExists(lrName, routeTable, policy, ipPrefix, nexthop interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LogicalRouterStaticRouteExists(lrName, routeTable, policy, ipPrefix, nexthop interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalRouterStaticRouteExists", reflect.TypeOf((*MockOvnClient)(nil).LogicalRouterStaticRouteExists), lrName, routeTable, policy, ipPrefix, nexthop) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalRouterStaticRouteExists", reflect.TypeOf((*MockNbClient)(nil).LogicalRouterStaticRouteExists), lrName, routeTable, policy, ipPrefix, nexthop) } // LogicalRouterUpdateLoadBalancers mocks base method. -func (m *MockOvnClient) LogicalRouterUpdateLoadBalancers(lrName string, op ovsdb.Mutator, lbNames ...string) error { +func (m *MockNbClient) LogicalRouterUpdateLoadBalancers(lrName string, op ovsdb.Mutator, lbNames ...string) error { m.ctrl.T.Helper() varargs := []interface{}{lrName, op} for _, a := range lbNames { @@ -3131,14 +3132,14 @@ func (m *MockOvnClient) LogicalRouterUpdateLoadBalancers(lrName string, op ovsdb } // LogicalRouterUpdateLoadBalancers indicates an expected call of LogicalRouterUpdateLoadBalancers. -func (mr *MockOvnClientMockRecorder) LogicalRouterUpdateLoadBalancers(lrName, op interface{}, lbNames ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LogicalRouterUpdateLoadBalancers(lrName, op interface{}, lbNames ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{lrName, op}, lbNames...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalRouterUpdateLoadBalancers", reflect.TypeOf((*MockOvnClient)(nil).LogicalRouterUpdateLoadBalancers), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalRouterUpdateLoadBalancers", reflect.TypeOf((*MockNbClient)(nil).LogicalRouterUpdateLoadBalancers), varargs...) } // LogicalSwitchExists mocks base method. -func (m *MockOvnClient) LogicalSwitchExists(lsName string) (bool, error) { +func (m *MockNbClient) LogicalSwitchExists(lsName string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LogicalSwitchExists", lsName) ret0, _ := ret[0].(bool) @@ -3147,13 +3148,13 @@ func (m *MockOvnClient) LogicalSwitchExists(lsName string) (bool, error) { } // LogicalSwitchExists indicates an expected call of LogicalSwitchExists. -func (mr *MockOvnClientMockRecorder) LogicalSwitchExists(lsName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LogicalSwitchExists(lsName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalSwitchExists", reflect.TypeOf((*MockOvnClient)(nil).LogicalSwitchExists), lsName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalSwitchExists", reflect.TypeOf((*MockNbClient)(nil).LogicalSwitchExists), lsName) } // LogicalSwitchPortExists mocks base method. -func (m *MockOvnClient) LogicalSwitchPortExists(name string) (bool, error) { +func (m *MockNbClient) LogicalSwitchPortExists(name string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LogicalSwitchPortExists", name) ret0, _ := ret[0].(bool) @@ -3162,13 +3163,13 @@ func (m *MockOvnClient) LogicalSwitchPortExists(name string) (bool, error) { } // LogicalSwitchPortExists indicates an expected call of LogicalSwitchPortExists. -func (mr *MockOvnClientMockRecorder) LogicalSwitchPortExists(name interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LogicalSwitchPortExists(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalSwitchPortExists", reflect.TypeOf((*MockOvnClient)(nil).LogicalSwitchPortExists), name) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalSwitchPortExists", reflect.TypeOf((*MockNbClient)(nil).LogicalSwitchPortExists), name) } // LogicalSwitchUpdateLoadBalancers mocks base method. -func (m *MockOvnClient) LogicalSwitchUpdateLoadBalancers(lsName string, op ovsdb.Mutator, lbNames ...string) error { +func (m *MockNbClient) LogicalSwitchUpdateLoadBalancers(lsName string, op ovsdb.Mutator, lbNames ...string) error { m.ctrl.T.Helper() varargs := []interface{}{lsName, op} for _, a := range lbNames { @@ -3180,14 +3181,14 @@ func (m *MockOvnClient) LogicalSwitchUpdateLoadBalancers(lsName string, op ovsdb } // LogicalSwitchUpdateLoadBalancers indicates an expected call of LogicalSwitchUpdateLoadBalancers. -func (mr *MockOvnClientMockRecorder) LogicalSwitchUpdateLoadBalancers(lsName, op interface{}, lbNames ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LogicalSwitchUpdateLoadBalancers(lsName, op interface{}, lbNames ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{lsName, op}, lbNames...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalSwitchUpdateLoadBalancers", reflect.TypeOf((*MockOvnClient)(nil).LogicalSwitchUpdateLoadBalancers), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalSwitchUpdateLoadBalancers", reflect.TypeOf((*MockNbClient)(nil).LogicalSwitchUpdateLoadBalancers), varargs...) } // LogicalSwitchUpdateOtherConfig mocks base method. -func (m *MockOvnClient) LogicalSwitchUpdateOtherConfig(lsName string, op ovsdb.Mutator, otherConfig map[string]string) error { +func (m *MockNbClient) LogicalSwitchUpdateOtherConfig(lsName string, op ovsdb.Mutator, otherConfig map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LogicalSwitchUpdateOtherConfig", lsName, op, otherConfig) ret0, _ := ret[0].(error) @@ -3195,13 +3196,13 @@ func (m *MockOvnClient) LogicalSwitchUpdateOtherConfig(lsName string, op ovsdb.M } // LogicalSwitchUpdateOtherConfig indicates an expected call of LogicalSwitchUpdateOtherConfig. -func (mr *MockOvnClientMockRecorder) LogicalSwitchUpdateOtherConfig(lsName, op, otherConfig interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) LogicalSwitchUpdateOtherConfig(lsName, op, otherConfig interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalSwitchUpdateOtherConfig", reflect.TypeOf((*MockOvnClient)(nil).LogicalSwitchUpdateOtherConfig), lsName, op, otherConfig) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogicalSwitchUpdateOtherConfig", reflect.TypeOf((*MockNbClient)(nil).LogicalSwitchUpdateOtherConfig), lsName, op, otherConfig) } // NatExists mocks base method. -func (m *MockOvnClient) NatExists(lrName, natType, externalIP, logicalIP string) (bool, error) { +func (m *MockNbClient) NatExists(lrName, natType, externalIP, logicalIP string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NatExists", lrName, natType, externalIP, logicalIP) ret0, _ := ret[0].(bool) @@ -3210,13 +3211,13 @@ func (m *MockOvnClient) NatExists(lrName, natType, externalIP, logicalIP string) } // NatExists indicates an expected call of NatExists. -func (mr *MockOvnClientMockRecorder) NatExists(lrName, natType, externalIP, logicalIP interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) NatExists(lrName, natType, externalIP, logicalIP interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NatExists", reflect.TypeOf((*MockOvnClient)(nil).NatExists), lrName, natType, externalIP, logicalIP) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NatExists", reflect.TypeOf((*MockNbClient)(nil).NatExists), lrName, natType, externalIP, logicalIP) } // PortGroupAddPorts mocks base method. -func (m *MockOvnClient) PortGroupAddPorts(pgName string, lspNames ...string) error { +func (m *MockNbClient) PortGroupAddPorts(pgName string, lspNames ...string) error { m.ctrl.T.Helper() varargs := []interface{}{pgName} for _, a := range lspNames { @@ -3228,14 +3229,14 @@ func (m *MockOvnClient) PortGroupAddPorts(pgName string, lspNames ...string) err } // PortGroupAddPorts indicates an expected call of PortGroupAddPorts. -func (mr *MockOvnClientMockRecorder) PortGroupAddPorts(pgName interface{}, lspNames ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) PortGroupAddPorts(pgName interface{}, lspNames ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{pgName}, lspNames...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortGroupAddPorts", reflect.TypeOf((*MockOvnClient)(nil).PortGroupAddPorts), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortGroupAddPorts", reflect.TypeOf((*MockNbClient)(nil).PortGroupAddPorts), varargs...) } // PortGroupExists mocks base method. -func (m *MockOvnClient) PortGroupExists(pgName string) (bool, error) { +func (m *MockNbClient) PortGroupExists(pgName string) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PortGroupExists", pgName) ret0, _ := ret[0].(bool) @@ -3244,13 +3245,13 @@ func (m *MockOvnClient) PortGroupExists(pgName string) (bool, error) { } // PortGroupExists indicates an expected call of PortGroupExists. -func (mr *MockOvnClientMockRecorder) PortGroupExists(pgName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) PortGroupExists(pgName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortGroupExists", reflect.TypeOf((*MockOvnClient)(nil).PortGroupExists), pgName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortGroupExists", reflect.TypeOf((*MockNbClient)(nil).PortGroupExists), pgName) } // PortGroupRemovePorts mocks base method. -func (m *MockOvnClient) PortGroupRemovePorts(pgName string, lspNames ...string) error { +func (m *MockNbClient) PortGroupRemovePorts(pgName string, lspNames ...string) error { m.ctrl.T.Helper() varargs := []interface{}{pgName} for _, a := range lspNames { @@ -3262,14 +3263,14 @@ func (m *MockOvnClient) PortGroupRemovePorts(pgName string, lspNames ...string) } // PortGroupRemovePorts indicates an expected call of PortGroupRemovePorts. -func (mr *MockOvnClientMockRecorder) PortGroupRemovePorts(pgName interface{}, lspNames ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) PortGroupRemovePorts(pgName interface{}, lspNames ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{pgName}, lspNames...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortGroupRemovePorts", reflect.TypeOf((*MockOvnClient)(nil).PortGroupRemovePorts), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortGroupRemovePorts", reflect.TypeOf((*MockNbClient)(nil).PortGroupRemovePorts), varargs...) } // PortGroupSetPorts mocks base method. -func (m *MockOvnClient) PortGroupSetPorts(pgName string, ports []string) error { +func (m *MockNbClient) PortGroupSetPorts(pgName string, ports []string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PortGroupSetPorts", pgName, ports) ret0, _ := ret[0].(error) @@ -3277,13 +3278,13 @@ func (m *MockOvnClient) PortGroupSetPorts(pgName string, ports []string) error { } // PortGroupSetPorts indicates an expected call of PortGroupSetPorts. -func (mr *MockOvnClientMockRecorder) PortGroupSetPorts(pgName, ports interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) PortGroupSetPorts(pgName, ports interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortGroupSetPorts", reflect.TypeOf((*MockOvnClient)(nil).PortGroupSetPorts), pgName, ports) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PortGroupSetPorts", reflect.TypeOf((*MockNbClient)(nil).PortGroupSetPorts), pgName, ports) } // RemoveLogicalPatchPort mocks base method. -func (m *MockOvnClient) RemoveLogicalPatchPort(lspName, lrpName string) error { +func (m *MockNbClient) RemoveLogicalPatchPort(lspName, lrpName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RemoveLogicalPatchPort", lspName, lrpName) ret0, _ := ret[0].(error) @@ -3291,13 +3292,13 @@ func (m *MockOvnClient) RemoveLogicalPatchPort(lspName, lrpName string) error { } // RemoveLogicalPatchPort indicates an expected call of RemoveLogicalPatchPort. -func (mr *MockOvnClientMockRecorder) RemoveLogicalPatchPort(lspName, lrpName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) RemoveLogicalPatchPort(lspName, lrpName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveLogicalPatchPort", reflect.TypeOf((*MockOvnClient)(nil).RemoveLogicalPatchPort), lspName, lrpName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveLogicalPatchPort", reflect.TypeOf((*MockNbClient)(nil).RemoveLogicalPatchPort), lspName, lrpName) } // SetAclLog mocks base method. -func (m *MockOvnClient) SetAclLog(pgName, protocol string, logEnable, isIngress bool) error { +func (m *MockNbClient) SetAclLog(pgName, protocol string, logEnable, isIngress bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetAclLog", pgName, protocol, logEnable, isIngress) ret0, _ := ret[0].(error) @@ -3305,13 +3306,13 @@ func (m *MockOvnClient) SetAclLog(pgName, protocol string, logEnable, isIngress } // SetAclLog indicates an expected call of SetAclLog. -func (mr *MockOvnClientMockRecorder) SetAclLog(pgName, protocol, logEnable, isIngress interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetAclLog(pgName, protocol, logEnable, isIngress interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAclLog", reflect.TypeOf((*MockOvnClient)(nil).SetAclLog), pgName, protocol, logEnable, isIngress) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAclLog", reflect.TypeOf((*MockNbClient)(nil).SetAclLog), pgName, protocol, logEnable, isIngress) } // SetAzName mocks base method. -func (m *MockOvnClient) SetAzName(azName string) error { +func (m *MockNbClient) SetAzName(azName string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetAzName", azName) ret0, _ := ret[0].(error) @@ -3319,13 +3320,13 @@ func (m *MockOvnClient) SetAzName(azName string) error { } // SetAzName indicates an expected call of SetAzName. -func (mr *MockOvnClientMockRecorder) SetAzName(azName interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetAzName(azName interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAzName", reflect.TypeOf((*MockOvnClient)(nil).SetAzName), azName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAzName", reflect.TypeOf((*MockNbClient)(nil).SetAzName), azName) } // SetICAutoRoute mocks base method. -func (m *MockOvnClient) SetICAutoRoute(enable bool, blackList []string) error { +func (m *MockNbClient) SetICAutoRoute(enable bool, blackList []string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetICAutoRoute", enable, blackList) ret0, _ := ret[0].(error) @@ -3333,13 +3334,13 @@ func (m *MockOvnClient) SetICAutoRoute(enable bool, blackList []string) error { } // SetICAutoRoute indicates an expected call of SetICAutoRoute. -func (mr *MockOvnClientMockRecorder) SetICAutoRoute(enable, blackList interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetICAutoRoute(enable, blackList interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetICAutoRoute", reflect.TypeOf((*MockOvnClient)(nil).SetICAutoRoute), enable, blackList) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetICAutoRoute", reflect.TypeOf((*MockNbClient)(nil).SetICAutoRoute), enable, blackList) } // SetLoadBalancerAffinityTimeout mocks base method. -func (m *MockOvnClient) SetLoadBalancerAffinityTimeout(lbName string, timeout int) error { +func (m *MockNbClient) SetLoadBalancerAffinityTimeout(lbName string, timeout int) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetLoadBalancerAffinityTimeout", lbName, timeout) ret0, _ := ret[0].(error) @@ -3347,13 +3348,13 @@ func (m *MockOvnClient) SetLoadBalancerAffinityTimeout(lbName string, timeout in } // SetLoadBalancerAffinityTimeout indicates an expected call of SetLoadBalancerAffinityTimeout. -func (mr *MockOvnClientMockRecorder) SetLoadBalancerAffinityTimeout(lbName, timeout interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLoadBalancerAffinityTimeout(lbName, timeout interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLoadBalancerAffinityTimeout", reflect.TypeOf((*MockOvnClient)(nil).SetLoadBalancerAffinityTimeout), lbName, timeout) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLoadBalancerAffinityTimeout", reflect.TypeOf((*MockNbClient)(nil).SetLoadBalancerAffinityTimeout), lbName, timeout) } // SetLogicalSwitchPortArpProxy mocks base method. -func (m *MockOvnClient) SetLogicalSwitchPortArpProxy(lspName string, enableArpProxy bool) error { +func (m *MockNbClient) SetLogicalSwitchPortArpProxy(lspName string, enableArpProxy bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetLogicalSwitchPortArpProxy", lspName, enableArpProxy) ret0, _ := ret[0].(error) @@ -3361,13 +3362,13 @@ func (m *MockOvnClient) SetLogicalSwitchPortArpProxy(lspName string, enableArpPr } // SetLogicalSwitchPortArpProxy indicates an expected call of SetLogicalSwitchPortArpProxy. -func (mr *MockOvnClientMockRecorder) SetLogicalSwitchPortArpProxy(lspName, enableArpProxy interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLogicalSwitchPortArpProxy(lspName, enableArpProxy interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortArpProxy", reflect.TypeOf((*MockOvnClient)(nil).SetLogicalSwitchPortArpProxy), lspName, enableArpProxy) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortArpProxy", reflect.TypeOf((*MockNbClient)(nil).SetLogicalSwitchPortArpProxy), lspName, enableArpProxy) } // SetLogicalSwitchPortExternalIds mocks base method. -func (m *MockOvnClient) SetLogicalSwitchPortExternalIds(lspName string, externalIds map[string]string) error { +func (m *MockNbClient) SetLogicalSwitchPortExternalIds(lspName string, externalIds map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetLogicalSwitchPortExternalIds", lspName, externalIds) ret0, _ := ret[0].(error) @@ -3375,13 +3376,13 @@ func (m *MockOvnClient) SetLogicalSwitchPortExternalIds(lspName string, external } // SetLogicalSwitchPortExternalIds indicates an expected call of SetLogicalSwitchPortExternalIds. -func (mr *MockOvnClientMockRecorder) SetLogicalSwitchPortExternalIds(lspName, externalIds interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLogicalSwitchPortExternalIds(lspName, externalIds interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortExternalIds", reflect.TypeOf((*MockOvnClient)(nil).SetLogicalSwitchPortExternalIds), lspName, externalIds) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortExternalIds", reflect.TypeOf((*MockNbClient)(nil).SetLogicalSwitchPortExternalIds), lspName, externalIds) } // SetLogicalSwitchPortSecurity mocks base method. -func (m *MockOvnClient) SetLogicalSwitchPortSecurity(portSecurity bool, lspName, mac, ips, vips string) error { +func (m *MockNbClient) SetLogicalSwitchPortSecurity(portSecurity bool, lspName, mac, ips, vips string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetLogicalSwitchPortSecurity", portSecurity, lspName, mac, ips, vips) ret0, _ := ret[0].(error) @@ -3389,13 +3390,13 @@ func (m *MockOvnClient) SetLogicalSwitchPortSecurity(portSecurity bool, lspName, } // SetLogicalSwitchPortSecurity indicates an expected call of SetLogicalSwitchPortSecurity. -func (mr *MockOvnClientMockRecorder) SetLogicalSwitchPortSecurity(portSecurity, lspName, mac, ips, vips interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLogicalSwitchPortSecurity(portSecurity, lspName, mac, ips, vips interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortSecurity", reflect.TypeOf((*MockOvnClient)(nil).SetLogicalSwitchPortSecurity), portSecurity, lspName, mac, ips, vips) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortSecurity", reflect.TypeOf((*MockNbClient)(nil).SetLogicalSwitchPortSecurity), portSecurity, lspName, mac, ips, vips) } // SetLogicalSwitchPortVirtualParents mocks base method. -func (m *MockOvnClient) SetLogicalSwitchPortVirtualParents(lsName, parents string, ips ...string) error { +func (m *MockNbClient) SetLogicalSwitchPortVirtualParents(lsName, parents string, ips ...string) error { m.ctrl.T.Helper() varargs := []interface{}{lsName, parents} for _, a := range ips { @@ -3407,14 +3408,14 @@ func (m *MockOvnClient) SetLogicalSwitchPortVirtualParents(lsName, parents strin } // SetLogicalSwitchPortVirtualParents indicates an expected call of SetLogicalSwitchPortVirtualParents. -func (mr *MockOvnClientMockRecorder) SetLogicalSwitchPortVirtualParents(lsName, parents interface{}, ips ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLogicalSwitchPortVirtualParents(lsName, parents interface{}, ips ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{lsName, parents}, ips...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortVirtualParents", reflect.TypeOf((*MockOvnClient)(nil).SetLogicalSwitchPortVirtualParents), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortVirtualParents", reflect.TypeOf((*MockNbClient)(nil).SetLogicalSwitchPortVirtualParents), varargs...) } // SetLogicalSwitchPortVlanTag mocks base method. -func (m *MockOvnClient) SetLogicalSwitchPortVlanTag(lspName string, vlanID int) error { +func (m *MockNbClient) SetLogicalSwitchPortVlanTag(lspName string, vlanID int) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetLogicalSwitchPortVlanTag", lspName, vlanID) ret0, _ := ret[0].(error) @@ -3422,13 +3423,13 @@ func (m *MockOvnClient) SetLogicalSwitchPortVlanTag(lspName string, vlanID int) } // SetLogicalSwitchPortVlanTag indicates an expected call of SetLogicalSwitchPortVlanTag. -func (mr *MockOvnClientMockRecorder) SetLogicalSwitchPortVlanTag(lspName, vlanID interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLogicalSwitchPortVlanTag(lspName, vlanID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortVlanTag", reflect.TypeOf((*MockOvnClient)(nil).SetLogicalSwitchPortVlanTag), lspName, vlanID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortVlanTag", reflect.TypeOf((*MockNbClient)(nil).SetLogicalSwitchPortVlanTag), lspName, vlanID) } // SetLogicalSwitchPortsSecurityGroup mocks base method. -func (m *MockOvnClient) SetLogicalSwitchPortsSecurityGroup(sgName, op string) error { +func (m *MockNbClient) SetLogicalSwitchPortsSecurityGroup(sgName, op string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetLogicalSwitchPortsSecurityGroup", sgName, op) ret0, _ := ret[0].(error) @@ -3436,27 +3437,27 @@ func (m *MockOvnClient) SetLogicalSwitchPortsSecurityGroup(sgName, op string) er } // SetLogicalSwitchPortsSecurityGroup indicates an expected call of SetLogicalSwitchPortsSecurityGroup. -func (mr *MockOvnClientMockRecorder) SetLogicalSwitchPortsSecurityGroup(sgName, op interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLogicalSwitchPortsSecurityGroup(sgName, op interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortsSecurityGroup", reflect.TypeOf((*MockOvnClient)(nil).SetLogicalSwitchPortsSecurityGroup), sgName, op) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPortsSecurityGroup", reflect.TypeOf((*MockNbClient)(nil).SetLogicalSwitchPortsSecurityGroup), sgName, op) } // SetLogicalSwitchPrivate mocks base method. -func (m *MockOvnClient) SetLogicalSwitchPrivate(lsName, cidrBlock string, allowSubnets []string) error { +func (m *MockNbClient) SetLogicalSwitchPrivate(lsName, cidrBlock, nodeSwitchCIDR string, allowSubnets []string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetLogicalSwitchPrivate", lsName, cidrBlock, allowSubnets) + ret := m.ctrl.Call(m, "SetLogicalSwitchPrivate", lsName, cidrBlock, nodeSwitchCIDR, allowSubnets) ret0, _ := ret[0].(error) return ret0 } // SetLogicalSwitchPrivate indicates an expected call of SetLogicalSwitchPrivate. -func (mr *MockOvnClientMockRecorder) SetLogicalSwitchPrivate(lsName, cidrBlock, allowSubnets interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLogicalSwitchPrivate(lsName, cidrBlock, nodeSwitchCIDR, allowSubnets interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPrivate", reflect.TypeOf((*MockOvnClient)(nil).SetLogicalSwitchPrivate), lsName, cidrBlock, allowSubnets) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLogicalSwitchPrivate", reflect.TypeOf((*MockNbClient)(nil).SetLogicalSwitchPrivate), lsName, cidrBlock, nodeSwitchCIDR, allowSubnets) } // SetLsDnatModDlDst mocks base method. -func (m *MockOvnClient) SetLsDnatModDlDst(enabled bool) error { +func (m *MockNbClient) SetLsDnatModDlDst(enabled bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetLsDnatModDlDst", enabled) ret0, _ := ret[0].(error) @@ -3464,13 +3465,13 @@ func (m *MockOvnClient) SetLsDnatModDlDst(enabled bool) error { } // SetLsDnatModDlDst indicates an expected call of SetLsDnatModDlDst. -func (mr *MockOvnClientMockRecorder) SetLsDnatModDlDst(enabled interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) SetLsDnatModDlDst(enabled interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLsDnatModDlDst", reflect.TypeOf((*MockOvnClient)(nil).SetLsDnatModDlDst), enabled) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLsDnatModDlDst", reflect.TypeOf((*MockNbClient)(nil).SetLsDnatModDlDst), enabled) } // SetUseCtInvMatch mocks base method. -func (m *MockOvnClient) SetUseCtInvMatch() error { +func (m *MockNbClient) SetUseCtInvMatch() error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetUseCtInvMatch") ret0, _ := ret[0].(error) @@ -3478,13 +3479,13 @@ func (m *MockOvnClient) SetUseCtInvMatch() error { } // SetUseCtInvMatch indicates an expected call of SetUseCtInvMatch. -func (mr *MockOvnClientMockRecorder) SetUseCtInvMatch() *gomock.Call { +func (mr *MockNbClientMockRecorder) SetUseCtInvMatch() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetUseCtInvMatch", reflect.TypeOf((*MockOvnClient)(nil).SetUseCtInvMatch)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetUseCtInvMatch", reflect.TypeOf((*MockNbClient)(nil).SetUseCtInvMatch)) } // Transact mocks base method. -func (m *MockOvnClient) Transact(method string, operations []ovsdb.Operation) error { +func (m *MockNbClient) Transact(method string, operations []ovsdb.Operation) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Transact", method, operations) ret0, _ := ret[0].(error) @@ -3492,13 +3493,13 @@ func (m *MockOvnClient) Transact(method string, operations []ovsdb.Operation) er } // Transact indicates an expected call of Transact. -func (mr *MockOvnClientMockRecorder) Transact(method, operations interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) Transact(method, operations interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Transact", reflect.TypeOf((*MockOvnClient)(nil).Transact), method, operations) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Transact", reflect.TypeOf((*MockNbClient)(nil).Transact), method, operations) } // UpdateDHCPOptions mocks base method. -func (m *MockOvnClient) UpdateDHCPOptions(subnet *v1.Subnet, mtu int) (*ovs.DHCPOptionsUUIDs, error) { +func (m *MockNbClient) UpdateDHCPOptions(subnet *v1.Subnet, mtu int) (*ovs.DHCPOptionsUUIDs, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateDHCPOptions", subnet, mtu) ret0, _ := ret[0].(*ovs.DHCPOptionsUUIDs) @@ -3507,13 +3508,13 @@ func (m *MockOvnClient) UpdateDHCPOptions(subnet *v1.Subnet, mtu int) (*ovs.DHCP } // UpdateDHCPOptions indicates an expected call of UpdateDHCPOptions. -func (mr *MockOvnClientMockRecorder) UpdateDHCPOptions(subnet, mtu interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateDHCPOptions(subnet, mtu interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDHCPOptions", reflect.TypeOf((*MockOvnClient)(nil).UpdateDHCPOptions), subnet, mtu) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDHCPOptions", reflect.TypeOf((*MockNbClient)(nil).UpdateDHCPOptions), subnet, mtu) } // UpdateDnatAndSnat mocks base method. -func (m *MockOvnClient) UpdateDnatAndSnat(lrName, externalIP, logicalIP, lspName, externalMac, gatewayType string) error { +func (m *MockNbClient) UpdateDnatAndSnat(lrName, externalIP, logicalIP, lspName, externalMac, gatewayType string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateDnatAndSnat", lrName, externalIP, logicalIP, lspName, externalMac, gatewayType) ret0, _ := ret[0].(error) @@ -3521,13 +3522,13 @@ func (m *MockOvnClient) UpdateDnatAndSnat(lrName, externalIP, logicalIP, lspName } // UpdateDnatAndSnat indicates an expected call of UpdateDnatAndSnat. -func (mr *MockOvnClientMockRecorder) UpdateDnatAndSnat(lrName, externalIP, logicalIP, lspName, externalMac, gatewayType interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateDnatAndSnat(lrName, externalIP, logicalIP, lspName, externalMac, gatewayType interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDnatAndSnat", reflect.TypeOf((*MockOvnClient)(nil).UpdateDnatAndSnat), lrName, externalIP, logicalIP, lspName, externalMac, gatewayType) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDnatAndSnat", reflect.TypeOf((*MockNbClient)(nil).UpdateDnatAndSnat), lrName, externalIP, logicalIP, lspName, externalMac, gatewayType) } // UpdateEgressAclOps mocks base method. -func (m *MockOvnClient) UpdateEgressAclOps(pgName, asEgressName, asExceptName, protocol string, npp []v10.NetworkPolicyPort, logEnable bool, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error) { +func (m *MockNbClient) UpdateEgressAclOps(pgName, asEgressName, asExceptName, protocol string, npp []v10.NetworkPolicyPort, logEnable bool, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateEgressAclOps", pgName, asEgressName, asExceptName, protocol, npp, logEnable, namedPortMap) ret0, _ := ret[0].([]ovsdb.Operation) @@ -3536,13 +3537,13 @@ func (m *MockOvnClient) UpdateEgressAclOps(pgName, asEgressName, asExceptName, p } // UpdateEgressAclOps indicates an expected call of UpdateEgressAclOps. -func (mr *MockOvnClientMockRecorder) UpdateEgressAclOps(pgName, asEgressName, asExceptName, protocol, npp, logEnable, namedPortMap interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateEgressAclOps(pgName, asEgressName, asExceptName, protocol, npp, logEnable, namedPortMap interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateEgressAclOps", reflect.TypeOf((*MockOvnClient)(nil).UpdateEgressAclOps), pgName, asEgressName, asExceptName, protocol, npp, logEnable, namedPortMap) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateEgressAclOps", reflect.TypeOf((*MockNbClient)(nil).UpdateEgressAclOps), pgName, asEgressName, asExceptName, protocol, npp, logEnable, namedPortMap) } // UpdateIngressAclOps mocks base method. -func (m *MockOvnClient) UpdateIngressAclOps(pgName, asIngressName, asExceptName, protocol string, npp []v10.NetworkPolicyPort, logEnable bool, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error) { +func (m *MockNbClient) UpdateIngressAclOps(pgName, asIngressName, asExceptName, protocol string, npp []v10.NetworkPolicyPort, logEnable bool, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateIngressAclOps", pgName, asIngressName, asExceptName, protocol, npp, logEnable, namedPortMap) ret0, _ := ret[0].([]ovsdb.Operation) @@ -3551,13 +3552,13 @@ func (m *MockOvnClient) UpdateIngressAclOps(pgName, asIngressName, asExceptName, } // UpdateIngressAclOps indicates an expected call of UpdateIngressAclOps. -func (mr *MockOvnClientMockRecorder) UpdateIngressAclOps(pgName, asIngressName, asExceptName, protocol, npp, logEnable, namedPortMap interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateIngressAclOps(pgName, asIngressName, asExceptName, protocol, npp, logEnable, namedPortMap interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateIngressAclOps", reflect.TypeOf((*MockOvnClient)(nil).UpdateIngressAclOps), pgName, asIngressName, asExceptName, protocol, npp, logEnable, namedPortMap) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateIngressAclOps", reflect.TypeOf((*MockNbClient)(nil).UpdateIngressAclOps), pgName, asIngressName, asExceptName, protocol, npp, logEnable, namedPortMap) } // UpdateLogicalRouterPortOptions mocks base method. -func (m *MockOvnClient) UpdateLogicalRouterPortOptions(lrpName string, options map[string]string) error { +func (m *MockNbClient) UpdateLogicalRouterPortOptions(lrpName string, options map[string]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateLogicalRouterPortOptions", lrpName, options) ret0, _ := ret[0].(error) @@ -3565,13 +3566,13 @@ func (m *MockOvnClient) UpdateLogicalRouterPortOptions(lrpName string, options m } // UpdateLogicalRouterPortOptions indicates an expected call of UpdateLogicalRouterPortOptions. -func (mr *MockOvnClientMockRecorder) UpdateLogicalRouterPortOptions(lrpName, options interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateLogicalRouterPortOptions(lrpName, options interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLogicalRouterPortOptions", reflect.TypeOf((*MockOvnClient)(nil).UpdateLogicalRouterPortOptions), lrpName, options) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLogicalRouterPortOptions", reflect.TypeOf((*MockNbClient)(nil).UpdateLogicalRouterPortOptions), lrpName, options) } // UpdateLogicalRouterPortRA mocks base method. -func (m *MockOvnClient) UpdateLogicalRouterPortRA(lrpName, ipv6RAConfigsStr string, enableIPv6RA bool) error { +func (m *MockNbClient) UpdateLogicalRouterPortRA(lrpName, ipv6RAConfigsStr string, enableIPv6RA bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateLogicalRouterPortRA", lrpName, ipv6RAConfigsStr, enableIPv6RA) ret0, _ := ret[0].(error) @@ -3579,13 +3580,13 @@ func (m *MockOvnClient) UpdateLogicalRouterPortRA(lrpName, ipv6RAConfigsStr stri } // UpdateLogicalRouterPortRA indicates an expected call of UpdateLogicalRouterPortRA. -func (mr *MockOvnClientMockRecorder) UpdateLogicalRouterPortRA(lrpName, ipv6RAConfigsStr, enableIPv6RA interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateLogicalRouterPortRA(lrpName, ipv6RAConfigsStr, enableIPv6RA interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLogicalRouterPortRA", reflect.TypeOf((*MockOvnClient)(nil).UpdateLogicalRouterPortRA), lrpName, ipv6RAConfigsStr, enableIPv6RA) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLogicalRouterPortRA", reflect.TypeOf((*MockNbClient)(nil).UpdateLogicalRouterPortRA), lrpName, ipv6RAConfigsStr, enableIPv6RA) } // UpdateLogicalSwitchAcl mocks base method. -func (m *MockOvnClient) UpdateLogicalSwitchAcl(lsName string, subnetAcls []v1.Acl) error { +func (m *MockNbClient) UpdateLogicalSwitchAcl(lsName string, subnetAcls []v1.Acl) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateLogicalSwitchAcl", lsName, subnetAcls) ret0, _ := ret[0].(error) @@ -3593,13 +3594,13 @@ func (m *MockOvnClient) UpdateLogicalSwitchAcl(lsName string, subnetAcls []v1.Ac } // UpdateLogicalSwitchAcl indicates an expected call of UpdateLogicalSwitchAcl. -func (mr *MockOvnClientMockRecorder) UpdateLogicalSwitchAcl(lsName, subnetAcls interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateLogicalSwitchAcl(lsName, subnetAcls interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLogicalSwitchAcl", reflect.TypeOf((*MockOvnClient)(nil).UpdateLogicalSwitchAcl), lsName, subnetAcls) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLogicalSwitchAcl", reflect.TypeOf((*MockNbClient)(nil).UpdateLogicalSwitchAcl), lsName, subnetAcls) } // UpdateNbGlobal mocks base method. -func (m *MockOvnClient) UpdateNbGlobal(nbGlobal *ovnnb.NBGlobal, fields ...interface{}) error { +func (m *MockNbClient) UpdateNbGlobal(nbGlobal *ovnnb.NBGlobal, fields ...interface{}) error { m.ctrl.T.Helper() varargs := []interface{}{nbGlobal} for _, a := range fields { @@ -3611,14 +3612,14 @@ func (m *MockOvnClient) UpdateNbGlobal(nbGlobal *ovnnb.NBGlobal, fields ...inter } // UpdateNbGlobal indicates an expected call of UpdateNbGlobal. -func (mr *MockOvnClientMockRecorder) UpdateNbGlobal(nbGlobal interface{}, fields ...interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateNbGlobal(nbGlobal interface{}, fields ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() varargs := append([]interface{}{nbGlobal}, fields...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateNbGlobal", reflect.TypeOf((*MockOvnClient)(nil).UpdateNbGlobal), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateNbGlobal", reflect.TypeOf((*MockNbClient)(nil).UpdateNbGlobal), varargs...) } // UpdateSgAcl mocks base method. -func (m *MockOvnClient) UpdateSgAcl(sg *v1.SecurityGroup, direction string) error { +func (m *MockNbClient) UpdateSgAcl(sg *v1.SecurityGroup, direction string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateSgAcl", sg, direction) ret0, _ := ret[0].(error) @@ -3626,13 +3627,13 @@ func (m *MockOvnClient) UpdateSgAcl(sg *v1.SecurityGroup, direction string) erro } // UpdateSgAcl indicates an expected call of UpdateSgAcl. -func (mr *MockOvnClientMockRecorder) UpdateSgAcl(sg, direction interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateSgAcl(sg, direction interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSgAcl", reflect.TypeOf((*MockOvnClient)(nil).UpdateSgAcl), sg, direction) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSgAcl", reflect.TypeOf((*MockNbClient)(nil).UpdateSgAcl), sg, direction) } // UpdateSnat mocks base method. -func (m *MockOvnClient) UpdateSnat(lrName, externalIP, logicalIP string) error { +func (m *MockNbClient) UpdateSnat(lrName, externalIP, logicalIP string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateSnat", lrName, externalIP, logicalIP) ret0, _ := ret[0].(error) @@ -3640,7 +3641,404 @@ func (m *MockOvnClient) UpdateSnat(lrName, externalIP, logicalIP string) error { } // UpdateSnat indicates an expected call of UpdateSnat. -func (mr *MockOvnClientMockRecorder) UpdateSnat(lrName, externalIP, logicalIP interface{}) *gomock.Call { +func (mr *MockNbClientMockRecorder) UpdateSnat(lrName, externalIP, logicalIP interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSnat", reflect.TypeOf((*MockOvnClient)(nil).UpdateSnat), lrName, externalIP, logicalIP) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSnat", reflect.TypeOf((*MockNbClient)(nil).UpdateSnat), lrName, externalIP, logicalIP) +} + +// MockSbClient is a mock of SbClient interface. +type MockSbClient struct { + ctrl *gomock.Controller + recorder *MockSbClientMockRecorder +} + +// MockSbClientMockRecorder is the mock recorder for MockSbClient. +type MockSbClientMockRecorder struct { + mock *MockSbClient +} + +// NewMockSbClient creates a new mock instance. +func NewMockSbClient(ctrl *gomock.Controller) *MockSbClient { + mock := &MockSbClient{ctrl: ctrl} + mock.recorder = &MockSbClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSbClient) EXPECT() *MockSbClientMockRecorder { + return m.recorder +} + +// DeleteChassis mocks base method. +func (m *MockSbClient) DeleteChassis(chassisName string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteChassis", chassisName) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteChassis indicates an expected call of DeleteChassis. +func (mr *MockSbClientMockRecorder) DeleteChassis(chassisName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteChassis", reflect.TypeOf((*MockSbClient)(nil).DeleteChassis), chassisName) +} + +// DeleteChassisByHost mocks base method. +func (m *MockSbClient) DeleteChassisByHost(node string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteChassisByHost", node) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteChassisByHost indicates an expected call of DeleteChassisByHost. +func (mr *MockSbClientMockRecorder) DeleteChassisByHost(node interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteChassisByHost", reflect.TypeOf((*MockSbClient)(nil).DeleteChassisByHost), node) +} + +// GetAllChassisByHost mocks base method. +func (m *MockSbClient) GetAllChassisByHost(nodeName string) (*[]ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllChassisByHost", nodeName) + ret0, _ := ret[0].(*[]ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAllChassisByHost indicates an expected call of GetAllChassisByHost. +func (mr *MockSbClientMockRecorder) GetAllChassisByHost(nodeName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllChassisByHost", reflect.TypeOf((*MockSbClient)(nil).GetAllChassisByHost), nodeName) +} + +// GetChassis mocks base method. +func (m *MockSbClient) GetChassis(chassisName string, ignoreNotFound bool) (*ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetChassis", chassisName, ignoreNotFound) + ret0, _ := ret[0].(*ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetChassis indicates an expected call of GetChassis. +func (mr *MockSbClientMockRecorder) GetChassis(chassisName, ignoreNotFound interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChassis", reflect.TypeOf((*MockSbClient)(nil).GetChassis), chassisName, ignoreNotFound) +} + +// GetChassisByHost mocks base method. +func (m *MockSbClient) GetChassisByHost(nodeName string) (*ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetChassisByHost", nodeName) + ret0, _ := ret[0].(*ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetChassisByHost indicates an expected call of GetChassisByHost. +func (mr *MockSbClientMockRecorder) GetChassisByHost(nodeName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChassisByHost", reflect.TypeOf((*MockSbClient)(nil).GetChassisByHost), nodeName) +} + +// GetEntityInfo mocks base method. +func (m *MockSbClient) GetEntityInfo(entity interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetEntityInfo", entity) + ret0, _ := ret[0].(error) + return ret0 +} + +// GetEntityInfo indicates an expected call of GetEntityInfo. +func (mr *MockSbClientMockRecorder) GetEntityInfo(entity interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEntityInfo", reflect.TypeOf((*MockSbClient)(nil).GetEntityInfo), entity) +} + +// GetKubeOvnChassisses mocks base method. +func (m *MockSbClient) GetKubeOvnChassisses() (*[]ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetKubeOvnChassisses") + ret0, _ := ret[0].(*[]ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetKubeOvnChassisses indicates an expected call of GetKubeOvnChassisses. +func (mr *MockSbClientMockRecorder) GetKubeOvnChassisses() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetKubeOvnChassisses", reflect.TypeOf((*MockSbClient)(nil).GetKubeOvnChassisses)) +} + +// ListChassis mocks base method. +func (m *MockSbClient) ListChassis() (*[]ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListChassis") + ret0, _ := ret[0].(*[]ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListChassis indicates an expected call of ListChassis. +func (mr *MockSbClientMockRecorder) ListChassis() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListChassis", reflect.TypeOf((*MockSbClient)(nil).ListChassis)) +} + +// Transact mocks base method. +func (m *MockSbClient) Transact(method string, operations []ovsdb.Operation) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Transact", method, operations) + ret0, _ := ret[0].(error) + return ret0 +} + +// Transact indicates an expected call of Transact. +func (mr *MockSbClientMockRecorder) Transact(method, operations interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Transact", reflect.TypeOf((*MockSbClient)(nil).Transact), method, operations) +} + +// UpdateChassis mocks base method. +func (m *MockSbClient) UpdateChassis(chassis *ovnsb.Chassis, fields ...interface{}) error { + m.ctrl.T.Helper() + varargs := []interface{}{chassis} + for _, a := range fields { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateChassis", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateChassis indicates an expected call of UpdateChassis. +func (mr *MockSbClientMockRecorder) UpdateChassis(chassis interface{}, fields ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{chassis}, fields...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateChassis", reflect.TypeOf((*MockSbClient)(nil).UpdateChassis), varargs...) +} + +// UpdateChassisTag mocks base method. +func (m *MockSbClient) UpdateChassisTag(chassisName, nodeName string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateChassisTag", chassisName, nodeName) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateChassisTag indicates an expected call of UpdateChassisTag. +func (mr *MockSbClientMockRecorder) UpdateChassisTag(chassisName, nodeName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateChassisTag", reflect.TypeOf((*MockSbClient)(nil).UpdateChassisTag), chassisName, nodeName) +} + +// MockCommon is a mock of Common interface. +type MockCommon struct { + ctrl *gomock.Controller + recorder *MockCommonMockRecorder +} + +// MockCommonMockRecorder is the mock recorder for MockCommon. +type MockCommonMockRecorder struct { + mock *MockCommon +} + +// NewMockCommon creates a new mock instance. +func NewMockCommon(ctrl *gomock.Controller) *MockCommon { + mock := &MockCommon{ctrl: ctrl} + mock.recorder = &MockCommonMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockCommon) EXPECT() *MockCommonMockRecorder { + return m.recorder +} + +// GetEntityInfo mocks base method. +func (m *MockCommon) GetEntityInfo(entity interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetEntityInfo", entity) + ret0, _ := ret[0].(error) + return ret0 +} + +// GetEntityInfo indicates an expected call of GetEntityInfo. +func (mr *MockCommonMockRecorder) GetEntityInfo(entity interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEntityInfo", reflect.TypeOf((*MockCommon)(nil).GetEntityInfo), entity) +} + +// Transact mocks base method. +func (m *MockCommon) Transact(method string, operations []ovsdb.Operation) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Transact", method, operations) + ret0, _ := ret[0].(error) + return ret0 +} + +// Transact indicates an expected call of Transact. +func (mr *MockCommonMockRecorder) Transact(method, operations interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Transact", reflect.TypeOf((*MockCommon)(nil).Transact), method, operations) +} + +// MockChassis is a mock of Chassis interface. +type MockChassis struct { + ctrl *gomock.Controller + recorder *MockChassisMockRecorder +} + +// MockChassisMockRecorder is the mock recorder for MockChassis. +type MockChassisMockRecorder struct { + mock *MockChassis +} + +// NewMockChassis creates a new mock instance. +func NewMockChassis(ctrl *gomock.Controller) *MockChassis { + mock := &MockChassis{ctrl: ctrl} + mock.recorder = &MockChassisMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockChassis) EXPECT() *MockChassisMockRecorder { + return m.recorder +} + +// DeleteChassis mocks base method. +func (m *MockChassis) DeleteChassis(chassisName string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteChassis", chassisName) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteChassis indicates an expected call of DeleteChassis. +func (mr *MockChassisMockRecorder) DeleteChassis(chassisName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteChassis", reflect.TypeOf((*MockChassis)(nil).DeleteChassis), chassisName) +} + +// DeleteChassisByHost mocks base method. +func (m *MockChassis) DeleteChassisByHost(node string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteChassisByHost", node) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteChassisByHost indicates an expected call of DeleteChassisByHost. +func (mr *MockChassisMockRecorder) DeleteChassisByHost(node interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteChassisByHost", reflect.TypeOf((*MockChassis)(nil).DeleteChassisByHost), node) +} + +// GetAllChassisByHost mocks base method. +func (m *MockChassis) GetAllChassisByHost(nodeName string) (*[]ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllChassisByHost", nodeName) + ret0, _ := ret[0].(*[]ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetAllChassisByHost indicates an expected call of GetAllChassisByHost. +func (mr *MockChassisMockRecorder) GetAllChassisByHost(nodeName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllChassisByHost", reflect.TypeOf((*MockChassis)(nil).GetAllChassisByHost), nodeName) +} + +// GetChassis mocks base method. +func (m *MockChassis) GetChassis(chassisName string, ignoreNotFound bool) (*ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetChassis", chassisName, ignoreNotFound) + ret0, _ := ret[0].(*ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetChassis indicates an expected call of GetChassis. +func (mr *MockChassisMockRecorder) GetChassis(chassisName, ignoreNotFound interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChassis", reflect.TypeOf((*MockChassis)(nil).GetChassis), chassisName, ignoreNotFound) +} + +// GetChassisByHost mocks base method. +func (m *MockChassis) GetChassisByHost(nodeName string) (*ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetChassisByHost", nodeName) + ret0, _ := ret[0].(*ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetChassisByHost indicates an expected call of GetChassisByHost. +func (mr *MockChassisMockRecorder) GetChassisByHost(nodeName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChassisByHost", reflect.TypeOf((*MockChassis)(nil).GetChassisByHost), nodeName) +} + +// GetKubeOvnChassisses mocks base method. +func (m *MockChassis) GetKubeOvnChassisses() (*[]ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetKubeOvnChassisses") + ret0, _ := ret[0].(*[]ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetKubeOvnChassisses indicates an expected call of GetKubeOvnChassisses. +func (mr *MockChassisMockRecorder) GetKubeOvnChassisses() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetKubeOvnChassisses", reflect.TypeOf((*MockChassis)(nil).GetKubeOvnChassisses)) +} + +// ListChassis mocks base method. +func (m *MockChassis) ListChassis() (*[]ovnsb.Chassis, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListChassis") + ret0, _ := ret[0].(*[]ovnsb.Chassis) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListChassis indicates an expected call of ListChassis. +func (mr *MockChassisMockRecorder) ListChassis() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListChassis", reflect.TypeOf((*MockChassis)(nil).ListChassis)) +} + +// UpdateChassis mocks base method. +func (m *MockChassis) UpdateChassis(chassis *ovnsb.Chassis, fields ...interface{}) error { + m.ctrl.T.Helper() + varargs := []interface{}{chassis} + for _, a := range fields { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateChassis", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateChassis indicates an expected call of UpdateChassis. +func (mr *MockChassisMockRecorder) UpdateChassis(chassis interface{}, fields ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{chassis}, fields...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateChassis", reflect.TypeOf((*MockChassis)(nil).UpdateChassis), varargs...) +} + +// UpdateChassisTag mocks base method. +func (m *MockChassis) UpdateChassisTag(chassisName, nodeName string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateChassisTag", chassisName, nodeName) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateChassisTag indicates an expected call of UpdateChassisTag. +func (mr *MockChassisMockRecorder) UpdateChassisTag(chassisName, nodeName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateChassisTag", reflect.TypeOf((*MockChassis)(nil).UpdateChassisTag), chassisName, nodeName) } diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 6b17db6e407..de3332d6be7 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -54,7 +54,9 @@ type Controller struct { namedPort *NamedPort ovnLegacyClient *ovs.LegacyClient - ovnClient ovs.OvnClient + + ovnNbClient ovs.NbClient + ovnSbClient ovs.SbClient // ExternalGatewayType define external gateway type, centralized ExternalGatewayType string @@ -310,7 +312,7 @@ func Run(ctx context.Context, config *Configuration) { vpcs: &sync.Map{}, podSubnetMap: &sync.Map{}, deletingPodObjMap: &sync.Map{}, - ovnLegacyClient: ovs.NewLegacyClient(config.OvnTimeout, config.OvnSbAddr, config.ClusterRouter, config.ClusterTcpLoadBalancer, config.ClusterUdpLoadBalancer, config.ClusterTcpSessionLoadBalancer, config.ClusterUdpSessionLoadBalancer, config.NodeSwitch, config.NodeSwitchCIDR), + ovnLegacyClient: ovs.NewLegacyClient(config.OvnTimeout), ipam: ovnipam.NewIPAM(), namedPort: NewNamedPort(), @@ -486,10 +488,12 @@ func Run(ctx context.Context, config *Configuration) { } var err error - if controller.ovnClient, err = ovs.NewOvnClient(config.OvnNbAddr, config.OvnTimeout, config.NodeSwitchCIDR); err != nil { - util.LogFatalAndExit(err, "failed to create ovn client") + if controller.ovnNbClient, err = ovs.NewOvnNbClient(config.OvnNbAddr, config.OvnTimeout); err != nil { + util.LogFatalAndExit(err, "failed to create ovn nb client") + } + if controller.ovnSbClient, err = ovs.NewOvnSbClient(config.OvnSbAddr, config.OvnTimeout); err != nil { + util.LogFatalAndExit(err, "failed to create ovn sb client") } - if config.EnableLb { controller.switchLBRuleLister = switchLBRuleInformer.Lister() controller.switchLBRuleSynced = switchLBRuleInformer.Informer().HasSynced @@ -768,11 +772,11 @@ func Run(ctx context.Context, config *Configuration) { func (c *Controller) Run(ctx context.Context) { // The init process can only be placed here if the init process do really affect the normal process of controller, such as Nodes/Pods/Subnets... // Otherwise, the init process should be placed after all workers have already started working - if err := c.ovnClient.SetLsDnatModDlDst(c.config.LsDnatModDlDst); err != nil { + if err := c.ovnNbClient.SetLsDnatModDlDst(c.config.LsDnatModDlDst); err != nil { util.LogFatalAndExit(err, "failed to set NB_Global option ls_dnat_mod_dl_dst") } - if err := c.ovnClient.SetUseCtInvMatch(); err != nil { + if err := c.ovnNbClient.SetUseCtInvMatch(); err != nil { util.LogFatalAndExit(err, "failed to set NB_Global option use_ct_inv_match to false") } @@ -1126,7 +1130,7 @@ func (c *Controller) startWorkers(ctx context.Context) { func (c *Controller) allSubnetReady(subnets ...string) (bool, error) { for _, lsName := range subnets { - exist, err := c.ovnClient.LogicalSwitchExists(lsName) + exist, err := c.ovnNbClient.LogicalSwitchExists(lsName) if err != nil { return false, fmt.Errorf("check logical switch %s exist: %v", lsName, err) } diff --git a/pkg/controller/controller_test.go b/pkg/controller/controller_test.go index 593dfe6d6a0..b19c463840d 100644 --- a/pkg/controller/controller_test.go +++ b/pkg/controller/controller_test.go @@ -26,7 +26,7 @@ type fakeControllerInformers struct { type fakeController struct { fakeController *Controller fakeinformers *fakeControllerInformers - mockOvnClient *mockovs.MockOvnClient + mockOvnClient *mockovs.MockNbClient } func alwaysReady() bool { return true } @@ -50,7 +50,7 @@ func newFakeController(t *testing.T) *fakeController { } /* ovn fake client */ - mockOvnClient := mockovs.NewMockOvnClient(gomock.NewController(t)) + mockOvnClient := mockovs.NewMockNbClient(gomock.NewController(t)) ctrl := &Controller{ servicesLister: serviceInformer.Lister(), @@ -58,7 +58,7 @@ func newFakeController(t *testing.T) *fakeController { vpcSynced: alwaysReady, subnetsLister: sbunetInformer.Lister(), subnetSynced: alwaysReady, - ovnClient: mockOvnClient, + ovnNbClient: mockOvnClient, syncVirtualPortsQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), ""), } diff --git a/pkg/controller/endpoint.go b/pkg/controller/endpoint.go index e53727717a4..642b495fa1b 100644 --- a/pkg/controller/endpoint.go +++ b/pkg/controller/endpoint.go @@ -197,18 +197,18 @@ func (c *Controller) handleUpdateEndpoint(key string) error { // for performance reason delete lb with no backends if len(backends) != 0 { klog.V(3).Infof("update vip %s with backends %s to LB %s", vip, backends, lb) - if err = c.ovnClient.LoadBalancerAddVip(lb, vip, backends...); err != nil { + if err = c.ovnNbClient.LoadBalancerAddVip(lb, vip, backends...); err != nil { klog.Errorf("failed to add vip %s with backends %s to LB %s: %v", vip, backends, lb, err) return err } } else { klog.V(3).Infof("delete vip %s from LB %s", vip, lb) - if err := c.ovnClient.LoadBalancerDeleteVip(lb, vip); err != nil { + if err := c.ovnNbClient.LoadBalancerDeleteVip(lb, vip); err != nil { klog.Errorf("failed to delete vip %s from LB %s: %v", vip, lb, err) return err } klog.V(3).Infof("delete vip %s from old LB %s", vip, lb) - if err := c.ovnClient.LoadBalancerDeleteVip(oldLb, vip); err != nil { + if err := c.ovnNbClient.LoadBalancerDeleteVip(oldLb, vip); err != nil { klog.Errorf("failed to delete vip %s from LB %s: %v", vip, lb, err) return err } diff --git a/pkg/controller/external-gw.go b/pkg/controller/external-gw.go index 5f5f66bcc24..02b96ca279f 100644 --- a/pkg/controller/external-gw.go +++ b/pkg/controller/external-gw.go @@ -118,7 +118,7 @@ func (c *Controller) removeExternalGateway() error { if !keepExternalSubnet { klog.Infof("delete external gateway switch %s", c.config.ExternalGatewaySwitch) - if err := c.ovnClient.DeleteLogicalGatewaySwitch(util.ExternalGatewaySwitch, c.config.ClusterRouter); err != nil { + if err := c.ovnNbClient.DeleteLogicalGatewaySwitch(util.ExternalGatewaySwitch, c.config.ClusterRouter); err != nil { klog.Errorf("delete external gateway switch %s: %v", util.ExternalGatewaySwitch, err) return err } @@ -126,7 +126,7 @@ func (c *Controller) removeExternalGateway() error { klog.Infof("should keep provider network vlan underlay external gateway switch %s", c.config.ExternalGatewaySwitch) lrpName := fmt.Sprintf("%s-%s", c.config.ClusterRouter, c.config.ExternalGatewaySwitch) klog.Infof("delete logical router port %s", lrpName) - if err := c.ovnClient.DeleteLogicalRouterPort(lrpName); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPort(lrpName); err != nil { klog.Errorf("failed to delete lrp %s, %v", lrpName, err) return err } @@ -142,7 +142,7 @@ func (c *Controller) establishExternalGateway(config map[string]string) error { } var lrpIp, lrpMac string lrpName := fmt.Sprintf("%s-%s", c.config.ClusterRouter, c.config.ExternalGatewaySwitch) - lrp, err := c.ovnClient.GetLogicalRouterPort(lrpName, true) + lrp, err := c.ovnNbClient.GetLogicalRouterPort(lrpName, true) if err != nil { klog.Errorf("failed to get lrp %s, %v", lrpName, err) return err @@ -160,7 +160,7 @@ func (c *Controller) establishExternalGateway(config map[string]string) error { lrpIp = config["nic-ip"] lrpMac = config["nic-mac"] } - if err := c.ovnClient.CreateGatewayLogicalSwitch(c.config.ExternalGatewaySwitch, c.config.ClusterRouter, c.config.ExternalGatewayNet, lrpIp, lrpMac, c.config.ExternalGatewayVlanID, chassises...); err != nil { + if err := c.ovnNbClient.CreateGatewayLogicalSwitch(c.config.ExternalGatewaySwitch, c.config.ClusterRouter, c.config.ExternalGatewayNet, lrpIp, lrpMac, c.config.ExternalGatewayVlanID, chassises...); err != nil { klog.Errorf("create external gateway switch %s: %v", c.config.ExternalGatewaySwitch, err) return err } @@ -249,15 +249,19 @@ func (c *Controller) getGatewayChassis(config map[string]string) ([]string, erro klog.Errorf("patch external gw node %s failed %v", gw, err) return chassises, err } - chassisID, err := c.ovnLegacyClient.GetChassis(gw) - if err != nil { - klog.Errorf("failed to get external gw %s chassisID, %v", gw, err) + annoChassisName := node.Annotations[util.ChassisAnnotation] + if annoChassisName == "" { + err := fmt.Errorf("node %s has no chassis annotation, kube-ovn-cni not ready", gw) + klog.Error(err) return chassises, err } - if chassisID == "" { - return chassises, fmt.Errorf("no chassisID for external gw %s", gw) + klog.Infof("get node %s chassis: %s", gw, annoChassisName) + chassis, err := c.ovnSbClient.GetChassis(annoChassisName, false) + if err != nil { + klog.Errorf("failed to get node %s chassis: %s, %v", node.Name, annoChassisName, err) + return chassises, err } - chassises = append(chassises, chassisID) + chassises = append(chassises, chassis.UUID) } if len(chassises) == 0 { klog.Error("no available external gw") diff --git a/pkg/controller/external_vpc.go b/pkg/controller/external_vpc.go index 0c08957d797..aa9e56935ac 100644 --- a/pkg/controller/external_vpc.go +++ b/pkg/controller/external_vpc.go @@ -83,7 +83,7 @@ func (c *Controller) syncExternalVpc() { func (c *Controller) getRouterStatus() (logicalRouters map[string]util.LogicalRouter, err error) { logicalRouters = make(map[string]util.LogicalRouter) - externalOvnRouters, err := c.ovnClient.ListLogicalRouter(false, func(lr *ovnnb.LogicalRouter) bool { + externalOvnRouters, err := c.ovnNbClient.ListLogicalRouter(false, func(lr *ovnnb.LogicalRouter) bool { return len(lr.ExternalIDs) == 0 || lr.ExternalIDs["vendor"] != util.CniTypeName }) if err != nil { @@ -101,7 +101,7 @@ func (c *Controller) getRouterStatus() (logicalRouters map[string]util.LogicalRo Ports: make([]util.Port, 0, len(externalLR.Ports)), } for _, uuid := range externalLR.Ports { - lrp, err := c.ovnClient.GetLogicalRouterPortByUUID(uuid) + lrp, err := c.ovnNbClient.GetLogicalRouterPortByUUID(uuid) if err != nil { klog.Warningf("failed to get LRP by UUID %s: %v", uuid, err) continue @@ -113,7 +113,7 @@ func (c *Controller) getRouterStatus() (logicalRouters map[string]util.LogicalRo for routerName, logicalRouter := range logicalRouters { tmpRouter := logicalRouter for _, port := range logicalRouter.Ports { - peerPorts, err := c.ovnClient.ListLogicalSwitchPorts(false, nil, func(lsp *ovnnb.LogicalSwitchPort) bool { + peerPorts, err := c.ovnNbClient.ListLogicalSwitchPorts(false, nil, func(lsp *ovnnb.LogicalSwitchPort) bool { return len(lsp.Options) != 0 && lsp.Options["router-port"] == port.Name }) if err != nil || len(peerPorts) > 1 { @@ -124,7 +124,7 @@ func (c *Controller) getRouterStatus() (logicalRouters map[string]util.LogicalRo continue } lsp := peerPorts[0] - switches, err := c.ovnClient.ListLogicalSwitch(false, func(ls *ovnnb.LogicalSwitch) bool { + switches, err := c.ovnNbClient.ListLogicalSwitch(false, func(ls *ovnnb.LogicalSwitch) bool { return util.ContainsString(ls.Ports, lsp.UUID) }) if err != nil || len(switches) > 1 { diff --git a/pkg/controller/gc.go b/pkg/controller/gc.go index 90b40489130..9807f5cf229 100644 --- a/pkg/controller/gc.go +++ b/pkg/controller/gc.go @@ -61,7 +61,7 @@ func (c *Controller) gcLogicalRouterPort() error { } } - if err = c.ovnClient.DeleteLogicalRouterPorts(nil, logicalRouterPortFilter(exceptPeerPorts)); err != nil { + if err = c.ovnNbClient.DeleteLogicalRouterPorts(nil, logicalRouterPortFilter(exceptPeerPorts)); err != nil { klog.Errorf("delete non-existent peer logical router port: %v", err) return err } @@ -126,7 +126,7 @@ func (c *Controller) gcLogicalSwitch() error { subnetNames.Add(s.Name) } - lss, err := c.ovnClient.ListLogicalSwitch(c.config.EnableExternalVpc, nil) + lss, err := c.ovnNbClient.ListLogicalSwitch(c.config.EnableExternalVpc, nil) if err != nil { klog.Errorf("list logical switch: %v", err) return err @@ -152,7 +152,7 @@ func (c *Controller) gcLogicalSwitch() error { } klog.Infof("start to gc dhcp options") - dhcpOptions, err := c.ovnClient.ListDHCPOptions(c.config.EnableExternalVpc, nil) + dhcpOptions, err := c.ovnNbClient.ListDHCPOptions(c.config.EnableExternalVpc, nil) if err != nil { klog.Errorf("failed to list dhcp options, %v", err) return err @@ -165,7 +165,7 @@ func (c *Controller) gcLogicalSwitch() error { } klog.Infof("gc dhcp options %v", uuidToDeleteList) if len(uuidToDeleteList) > 0 { - if err = c.ovnClient.DeleteDHCPOptionsByUUIDs(uuidToDeleteList...); err != nil { + if err = c.ovnNbClient.DeleteDHCPOptionsByUUIDs(uuidToDeleteList...); err != nil { klog.Errorf("failed to delete dhcp options by uuids, %v", err) return err } @@ -185,7 +185,7 @@ func (c *Controller) gcCustomLogicalRouter() error { vpcNames = append(vpcNames, s.Name) } - lrs, err := c.ovnClient.ListLogicalRouter(c.config.EnableExternalVpc, nil) + lrs, err := c.ovnNbClient.ListLogicalRouter(c.config.EnableExternalVpc, nil) if err != nil { klog.Errorf("failed to list logical router, %v", err) return err @@ -329,7 +329,7 @@ func (c *Controller) markAndCleanLSP() error { // The lsp for vm pod should not be deleted if vm still exists ipMap.Add(c.getVmLsps()...) - lsps, err := c.ovnClient.ListNormalLogicalSwitchPorts(c.config.EnableExternalVpc, nil) + lsps, err := c.ovnNbClient.ListNormalLogicalSwitchPorts(c.config.EnableExternalVpc, nil) if err != nil { klog.Errorf("failed to list logical switch port, %v", err) return err @@ -353,7 +353,7 @@ func (c *Controller) markAndCleanLSP() error { } klog.Infof("gc logical switch port %s", lsp.Name) - if err := c.ovnClient.DeleteLogicalSwitchPort(lsp.Name); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(lsp.Name); err != nil { klog.Errorf("failed to delete lsp %s: %v", lsp.Name, err) return err } @@ -406,7 +406,7 @@ func (c *Controller) gcLoadBalancer() error { } lbs := []string{vpc.Status.TcpLoadBalancer, vpc.Status.TcpSessionLoadBalancer, vpc.Status.UdpLoadBalancer, vpc.Status.UdpSessionLoadBalancer, vpc.Status.SctpLoadBalancer, vpc.Status.SctpSessionLoadBalancer} - if err := c.ovnClient.LogicalSwitchUpdateLoadBalancers(subnetName, ovsdb.MutateOperationDelete, lbs...); err != nil { + if err := c.ovnNbClient.LogicalSwitchUpdateLoadBalancers(subnetName, ovsdb.MutateOperationDelete, lbs...); err != nil { return err } } @@ -430,7 +430,7 @@ func (c *Controller) gcLoadBalancer() error { } // lbs will remove from logical switch automatically when delete lbs - if err = c.ovnClient.DeleteLoadBalancers(nil); err != nil { + if err = c.ovnNbClient.DeleteLoadBalancers(nil); err != nil { klog.Errorf("delete all load balancers: %v", err) return err } @@ -497,7 +497,7 @@ func (c *Controller) gcLoadBalancer() error { return nil } - lb, err := c.ovnClient.GetLoadBalancer(lbName, true) + lb, err := c.ovnNbClient.GetLoadBalancer(lbName, true) if err != nil { klog.Errorf("get LB %s: %v", lbName, err) return err @@ -509,7 +509,7 @@ func (c *Controller) gcLoadBalancer() error { for vip := range lb.Vips { if !svcVips.Has(vip) { - if err = c.ovnClient.LoadBalancerDeleteVip(lbName, vip); err != nil { + if err = c.ovnNbClient.LoadBalancerDeleteVip(lbName, vip); err != nil { klog.Errorf("failed to delete vip %s from LB %s: %v", vip, lbName, err) return err } @@ -539,7 +539,7 @@ func (c *Controller) gcLoadBalancer() error { } // delete lbs - if err = c.ovnClient.DeleteLoadBalancers(func(lb *ovnnb.LoadBalancer) bool { + if err = c.ovnNbClient.DeleteLoadBalancers(func(lb *ovnnb.LoadBalancer) bool { return !util.ContainsString(vpcLbs, lb.Name) }); err != nil { klog.Errorf("delete load balancers: %v", err) @@ -593,7 +593,7 @@ func (c *Controller) gcPortGroup() error { } // list all np port groups which externalIDs[np]!="" - pgs, err := c.ovnClient.ListPortGroups(map[string]string{networkPolicyKey: ""}) + pgs, err := c.ovnNbClient.ListPortGroups(map[string]string{networkPolicyKey: ""}) if err != nil { klog.Errorf("list np port group: %v", err) return err @@ -617,7 +617,7 @@ func (c *Controller) gcPortGroup() error { func (c *Controller) gcStaticRoute() error { klog.Infof("start to gc static routes") - routes, err := c.ovnClient.ListLogicalRouterStaticRoutes(c.config.ClusterRouter, nil, nil, "", nil) + routes, err := c.ovnNbClient.ListLogicalRouterStaticRoutes(c.config.ClusterRouter, nil, nil, "", nil) if err != nil { klog.Errorf("failed to list static route %v", err) return err @@ -640,7 +640,7 @@ func (c *Controller) gcStaticRoute() error { continue } if route.IPPrefix != "0.0.0.0/0" && route.IPPrefix != "::/0" && c.ipam.ContainAddress(route.IPPrefix) { - exist, err := c.ovnClient.NatExists(c.config.ClusterRouter, "", "", route.IPPrefix) + exist, err := c.ovnNbClient.NatExists(c.config.ClusterRouter, "", "", route.IPPrefix) if err != nil { klog.Errorf("failed to get NatRule by LogicalIP %s, %v", route.IPPrefix, err) continue @@ -649,7 +649,7 @@ func (c *Controller) gcStaticRoute() error { continue } klog.Infof("gc static route %s %v %s %s", route.RouteTable, route.Policy, route.IPPrefix, route.Nexthop) - if err = c.ovnClient.DeleteLogicalRouterStaticRoute(c.config.ClusterRouter, &route.RouteTable, route.Policy, route.IPPrefix, route.Nexthop); err != nil { + if err = c.ovnNbClient.DeleteLogicalRouterStaticRoute(c.config.ClusterRouter, &route.RouteTable, route.Policy, route.IPPrefix, route.Nexthop); err != nil { klog.Errorf("failed to delete stale route %s %v %s %s: %v", route.RouteTable, route.Policy, route.IPPrefix, route.Nexthop, err) } } @@ -659,27 +659,36 @@ func (c *Controller) gcStaticRoute() error { func (c *Controller) gcChassis() error { klog.Infof("start to gc chassis") - chassises, err := c.ovnLegacyClient.GetAllChassis() + chassises, err := c.ovnSbClient.GetKubeOvnChassisses() if err != nil { klog.Errorf("failed to get all chassis, %v", err) } + chassisNodes := make(map[string]string, len(*chassises)) + for _, chassis := range *chassises { + chassisNodes[chassis.Name] = chassis.Hostname + } nodes, err := c.nodesLister.List(labels.Everything()) if err != nil { klog.Errorf("failed to list nodes, %v", err) return err } - for _, chassis := range chassises { - matched := true - for _, node := range nodes { - if chassis == node.Annotations[util.ChassisAnnotation] { - matched = false - break - } + for _, node := range nodes { + chassisName := node.Annotations[util.ChassisAnnotation] + if chassisName == "" { + // kube-ovn-cni not ready to set chassis annotation + continue } - if matched { - if err := c.ovnLegacyClient.DeleteChassisByName(chassis); err != nil { - klog.Errorf("failed to delete chassis %s %v", chassis, err) - return err + if hostname, exist := chassisNodes[chassisName]; exist { + if hostname == node.Name { + // node is alive, matched chassis should be alive + continue + } else { + // maybe node name changed, delete chassis + klog.Infof("gc node %s chassis %s", node.Name, chassisName) + if err := c.ovnSbClient.DeleteChassis(chassisName); err != nil { + klog.Errorf("failed to delete node %s chassis %s %v", node.Name, chassisName, err) + return err + } } } } diff --git a/pkg/controller/init.go b/pkg/controller/init.go index 029ffb11174..1d834140909 100644 --- a/pkg/controller/init.go +++ b/pkg/controller/init.go @@ -193,7 +193,7 @@ func (c *Controller) initNodeSwitch() error { // InitClusterRouter init cluster router to connect different logical switches func (c *Controller) initClusterRouter() error { - return c.ovnClient.CreateLogicalRouter(c.config.ClusterRouter) + return c.ovnNbClient.CreateLogicalRouter(c.config.ClusterRouter) } func (c *Controller) initLB(name, protocol string, sessionAffinity bool) error { @@ -204,13 +204,13 @@ func (c *Controller) initLB(name, protocol string, sessionAffinity bool) error { selectFields = string(ovnnb.LoadBalancerSelectionFieldsIPSrc) } - if err := c.ovnClient.CreateLoadBalancer(name, protocol, selectFields); err != nil { + if err := c.ovnNbClient.CreateLoadBalancer(name, protocol, selectFields); err != nil { klog.Errorf("create load balancer %s: %v", name, err) return err } if sessionAffinity { - if err := c.ovnClient.SetLoadBalancerAffinityTimeout(name, util.DefaultServiceSessionStickinessTimeout); err != nil { + if err := c.ovnNbClient.SetLoadBalancerAffinityTimeout(name, util.DefaultServiceSessionStickinessTimeout); err != nil { klog.Errorf("failed to set affinity timeout of %s load balancer %s: %v", protocol, name, err) return err } @@ -722,13 +722,13 @@ func (c *Controller) migrateNodeRoute(af int, node, ip, nexthop string) error { } klog.V(3).Infof("add policy route for router: %s, priority: %d, match %s, action %s, nexthop %s, extrenalID %v", c.config.ClusterRouter, util.NodeRouterPolicyPriority, match, action, nexthop, externalIDs) - if err := c.ovnClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.NodeRouterPolicyPriority, match, action, []string{nexthop}, externalIDs); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.NodeRouterPolicyPriority, match, action, []string{nexthop}, externalIDs); err != nil { klog.Errorf("failed to add logical router policy for node %s: %v", node, err) return err } routeTable := util.MainRouteTable - if err := c.ovnClient.DeleteLogicalRouterStaticRoute(c.config.ClusterRouter, &routeTable, nil, ip, ""); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterStaticRoute(c.config.ClusterRouter, &routeTable, nil, ip, ""); err != nil { klog.Errorf("failed to delete obsolete static route for node %s: %v", node, err) return err } @@ -736,12 +736,12 @@ func (c *Controller) migrateNodeRoute(af int, node, ip, nexthop string) error { asName := nodeUnderlayAddressSetName(node, af) obsoleteMatch := fmt.Sprintf("ip%d.dst == %s && ip%d.src != $%s", af, ip, af, asName) klog.V(3).Infof("delete policy route for router: %s, priority: %d, match %s", c.config.ClusterRouter, util.NodeRouterPolicyPriority, obsoleteMatch) - if err := c.ovnClient.DeleteLogicalRouterPolicy(c.config.ClusterRouter, util.NodeRouterPolicyPriority, obsoleteMatch); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPolicy(c.config.ClusterRouter, util.NodeRouterPolicyPriority, obsoleteMatch); err != nil { klog.Errorf("failed to delete obsolete logical router policy for node %s: %v", node, err) return err } - if err := c.ovnClient.DeleteAddressSet(asName); err != nil { + if err := c.ovnNbClient.DeleteAddressSet(asName); err != nil { klog.Errorf("delete obsolete address set %s for node %s: %v", asName, node, err) return err } @@ -782,28 +782,19 @@ func (c *Controller) initNodeChassis() error { klog.Errorf("failed to list nodes: %v", err) return err } - chssisNodes, err := c.ovnLegacyClient.GetAllChassisMap() + chassises, err := c.ovnSbClient.GetKubeOvnChassisses() if err != nil { klog.Errorf("failed to get chassis nodes: %v", err) return err } + chassisNodes := make(map[string]string, len(*chassises)) + for _, chassis := range *chassises { + chassisNodes[chassis.Name] = chassis.Hostname + } for _, node := range nodes { - chassisName := node.Annotations[util.ChassisAnnotation] - if chassisName != "" { - if hostname, exist := chssisNodes[chassisName]; exist { - if hostname == node.Name { - continue - } else { - klog.Infof("node %s sbdb chassis %s host name %s", node.Name, chassisName, hostname) - err = c.ovnLegacyClient.InitChassisNodeTag(chassisName, node.Name) - if err != nil { - klog.Errorf("failed to set chassis nodeTag: %v", err) - return err - } - } - } + if err := c.UpdateChassisTag(node); err != nil { + return err } } - return nil } diff --git a/pkg/controller/inspection.go b/pkg/controller/inspection.go index 3333104ae75..0ff212b6915 100644 --- a/pkg/controller/inspection.go +++ b/pkg/controller/inspection.go @@ -41,7 +41,7 @@ func (c *Controller) inspectPod() error { for _, podNet := range filterSubnets(pod, podNets) { if podNet.Type != providerTypeIPAM { portName := ovs.PodNameToPortName(podName, pod.Namespace, podNet.ProviderName) - exists, err := c.ovnClient.LogicalSwitchPortExists(portName) + exists, err := c.ovnNbClient.LogicalSwitchPortExists(portName) if err != nil { klog.Errorf("failed to check port %s exists, %v", portName, err) return err diff --git a/pkg/controller/network_policy.go b/pkg/controller/network_policy.go index 61e2aba176e..7e80afbbf46 100644 --- a/pkg/controller/network_policy.go +++ b/pkg/controller/network_policy.go @@ -177,7 +177,7 @@ func (c *Controller) handleUpdateNp(key string) error { egressAllowAsNamePrefix := strings.Replace(fmt.Sprintf("%s.%s.egress.allow", np.Name, np.Namespace), "-", ".", -1) egressExceptAsNamePrefix := strings.Replace(fmt.Sprintf("%s.%s.egress.except", np.Name, np.Namespace), "-", ".", -1) - if err = c.ovnClient.CreatePortGroup(pgName, map[string]string{networkPolicyKey: np.Namespace + "/" + np.Name}); err != nil { + if err = c.ovnNbClient.CreatePortGroup(pgName, map[string]string{networkPolicyKey: np.Namespace + "/" + np.Name}); err != nil { klog.Errorf("create port group for np %s: %v", key, err) return err } @@ -199,7 +199,7 @@ func (c *Controller) handleUpdateNp(key string) error { subnets = append(subnets, subnet) } - if err = c.ovnClient.PortGroupSetPorts(pgName, ports); err != nil { + if err = c.ovnNbClient.PortGroupSetPorts(pgName, ports); err != nil { klog.Errorf("failed to set ports of port group %s to %v: %v", pgName, ports, err) return err } @@ -222,14 +222,14 @@ func (c *Controller) handleUpdateNp(key string) error { svcIPs = svcIpv6s } - if err = c.ovnClient.CreateAddressSet(svcAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(svcAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "service"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", svcAsName, key, err) return err } - if err = c.ovnClient.AddressSetUpdateAddress(svcAsName, svcIPs...); err != nil { + if err = c.ovnNbClient.AddressSetUpdateAddress(svcAsName, svcIPs...); err != nil { klog.Errorf("set service ips to address set %s: %v", svcAsName, err) return err } @@ -238,7 +238,7 @@ func (c *Controller) handleUpdateNp(key string) error { var ingressAclOps []ovsdb.Operation - clearIngressAclOps, err := c.ovnClient.DeleteAclsOps(pgName, portGroupKey, "to-lport", nil) + clearIngressAclOps, err := c.ovnNbClient.DeleteAclsOps(pgName, portGroupKey, "to-lport", nil) if err != nil { klog.Errorf("generate operations that clear np %s ingress acls: %v", key, err) return err @@ -277,26 +277,26 @@ func (c *Controller) handleUpdateNp(key string) error { } klog.Infof("UpdateNp Ingress, allows is %v, excepts is %v, log %v", allows, excepts, logEnable) - if err = c.ovnClient.CreateAddressSet(ingressAllowAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(ingressAllowAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "ingress"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", ingressAllowAsName, key, err) return err } - if err = c.ovnClient.AddressSetUpdateAddress(ingressAllowAsName, allows...); err != nil { + if err = c.ovnNbClient.AddressSetUpdateAddress(ingressAllowAsName, allows...); err != nil { klog.Errorf("set ingress allow ips to address set %s: %v", ingressAllowAsName, err) return err } - if err = c.ovnClient.CreateAddressSet(ingressExceptAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(ingressExceptAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "ingress"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", ingressExceptAsName, key, err) return err } - if err = c.ovnClient.AddressSetUpdateAddress(ingressExceptAsName, excepts...); err != nil { + if err = c.ovnNbClient.AddressSetUpdateAddress(ingressExceptAsName, excepts...); err != nil { klog.Errorf("set ingress except ips to address set %s: %v", ingressExceptAsName, err) return err } @@ -306,7 +306,7 @@ func (c *Controller) handleUpdateNp(key string) error { npp = npr.Ports } - ops, err := c.ovnClient.UpdateIngressAclOps(pgName, ingressAllowAsName, ingressExceptAsName, protocol, npp, logEnable, namedPortMap) + ops, err := c.ovnNbClient.UpdateIngressAclOps(pgName, ingressAllowAsName, ingressExceptAsName, protocol, npp, logEnable, namedPortMap) if err != nil { klog.Errorf("generate operations that add ingress acls to np %s: %v", key, err) return err @@ -318,21 +318,21 @@ func (c *Controller) handleUpdateNp(key string) error { ingressAllowAsName := fmt.Sprintf("%s.%s.all", ingressAllowAsNamePrefix, protocol) ingressExceptAsName := fmt.Sprintf("%s.%s.all", ingressExceptAsNamePrefix, protocol) - if err = c.ovnClient.CreateAddressSet(ingressAllowAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(ingressAllowAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "ingress"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", ingressAllowAsName, key, err) return err } - if err = c.ovnClient.CreateAddressSet(ingressExceptAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(ingressExceptAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "ingress"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", ingressExceptAsName, key, err) return err } - ops, err := c.ovnClient.UpdateIngressAclOps(pgName, ingressAllowAsName, ingressExceptAsName, protocol, []netv1.NetworkPolicyPort{}, logEnable, namedPortMap) + ops, err := c.ovnNbClient.UpdateIngressAclOps(pgName, ingressAllowAsName, ingressExceptAsName, protocol, []netv1.NetworkPolicyPort{}, logEnable, namedPortMap) if err != nil { klog.Errorf("generate operations that add ingress acls to np %s: %v", key, err) return err @@ -341,18 +341,18 @@ func (c *Controller) handleUpdateNp(key string) error { ingressAclOps = append(ingressAclOps, ops...) } - if err = c.ovnClient.Transact("add-ingress-acls", ingressAclOps); err != nil { + if err = c.ovnNbClient.Transact("add-ingress-acls", ingressAclOps); err != nil { return fmt.Errorf("add ingress acls to %s: %v", pgName, err) } - if err = c.ovnClient.SetAclLog(pgName, protocol, logEnable, true); err != nil { + if err = c.ovnNbClient.SetAclLog(pgName, protocol, logEnable, true); err != nil { // just log and do not return err here klog.Errorf("failed to set ingress acl log for np %s, %v", key, err) } } } - ass, err := c.ovnClient.ListAddressSets(map[string]string{ + ass, err := c.ovnNbClient.ListAddressSets(map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "ingress"), }) if err != nil { @@ -372,19 +372,19 @@ func (c *Controller) handleUpdateNp(key string) error { } idx, _ := strconv.Atoi(idxStr) if idx >= len(np.Spec.Ingress) { - if err = c.ovnClient.DeleteAddressSet(as.Name); err != nil { + if err = c.ovnNbClient.DeleteAddressSet(as.Name); err != nil { klog.Errorf("failed to delete np %s address set, %v", key, err) return err } } } } else { - if err = c.ovnClient.DeleteAcls(pgName, portGroupKey, "to-lport", nil); err != nil { + if err = c.ovnNbClient.DeleteAcls(pgName, portGroupKey, "to-lport", nil); err != nil { klog.Errorf("delete np %s ingress acls: %v", key, err) return err } - if err := c.ovnClient.DeleteAddressSets(map[string]string{ + if err := c.ovnNbClient.DeleteAddressSets(map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "ingress"), }); err != nil { klog.Errorf("delete np %s ingress address set: %v", key, err) @@ -394,7 +394,7 @@ func (c *Controller) handleUpdateNp(key string) error { var egressAclOps []ovsdb.Operation - clearEgressAclOps, err := c.ovnClient.DeleteAclsOps(pgName, portGroupKey, "from-lport", nil) + clearEgressAclOps, err := c.ovnNbClient.DeleteAclsOps(pgName, portGroupKey, "from-lport", nil) if err != nil { klog.Errorf("generate operations that clear np %s egress acls: %v", key, err) return err @@ -433,32 +433,32 @@ func (c *Controller) handleUpdateNp(key string) error { } klog.Infof("UpdateNp Egress, allows is %v, excepts is %v, log %v", allows, excepts, logEnable) - if err = c.ovnClient.CreateAddressSet(egressAllowAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(egressAllowAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "egress"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", egressAllowAsName, key, err) return err } - if err = c.ovnClient.AddressSetUpdateAddress(egressAllowAsName, allows...); err != nil { + if err = c.ovnNbClient.AddressSetUpdateAddress(egressAllowAsName, allows...); err != nil { klog.Errorf("set egress allow ips to address set %s: %v", egressAllowAsName, err) return err } - if err = c.ovnClient.CreateAddressSet(egressExceptAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(egressExceptAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "egress"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", egressExceptAsName, key, err) return err } - if err = c.ovnClient.AddressSetUpdateAddress(egressExceptAsName, excepts...); err != nil { + if err = c.ovnNbClient.AddressSetUpdateAddress(egressExceptAsName, excepts...); err != nil { klog.Errorf("set egress except ips to address set %s: %v", egressExceptAsName, err) return err } if len(allows) != 0 || len(excepts) != 0 { - ops, err := c.ovnClient.UpdateEgressAclOps(pgName, egressAllowAsName, egressExceptAsName, protocol, npr.Ports, logEnable, namedPortMap) + ops, err := c.ovnNbClient.UpdateEgressAclOps(pgName, egressAllowAsName, egressExceptAsName, protocol, npr.Ports, logEnable, namedPortMap) if err != nil { klog.Errorf("generate operations that add egress acls to np %s: %v", key, err) return err @@ -471,21 +471,21 @@ func (c *Controller) handleUpdateNp(key string) error { egressAllowAsName := fmt.Sprintf("%s.%s.all", egressAllowAsNamePrefix, protocol) egressExceptAsName := fmt.Sprintf("%s.%s.all", egressExceptAsNamePrefix, protocol) - if err = c.ovnClient.CreateAddressSet(egressAllowAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(egressAllowAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "egress"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", egressAllowAsName, key, err) return err } - if err = c.ovnClient.CreateAddressSet(egressExceptAsName, map[string]string{ + if err = c.ovnNbClient.CreateAddressSet(egressExceptAsName, map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "egress"), }); err != nil { klog.Errorf("create address set %s for np %s: %v", egressExceptAsName, key, err) return err } - ops, err := c.ovnClient.UpdateEgressAclOps(pgName, egressAllowAsName, egressExceptAsName, protocol, []netv1.NetworkPolicyPort{}, logEnable, namedPortMap) + ops, err := c.ovnNbClient.UpdateEgressAclOps(pgName, egressAllowAsName, egressExceptAsName, protocol, []netv1.NetworkPolicyPort{}, logEnable, namedPortMap) if err != nil { klog.Errorf("generate operations that add egress acls to np %s: %v", key, err) return err @@ -494,18 +494,18 @@ func (c *Controller) handleUpdateNp(key string) error { egressAclOps = append(egressAclOps, ops...) } - if err = c.ovnClient.Transact("add-egress-acls", egressAclOps); err != nil { + if err = c.ovnNbClient.Transact("add-egress-acls", egressAclOps); err != nil { return fmt.Errorf("add egress acls to %s: %v", pgName, err) } - if err = c.ovnClient.SetAclLog(pgName, protocol, logEnable, false); err != nil { + if err = c.ovnNbClient.SetAclLog(pgName, protocol, logEnable, false); err != nil { // just log and do not return err here klog.Errorf("failed to set egress acl log for np %s, %v", key, err) } } } - ass, err := c.ovnClient.ListAddressSets(map[string]string{ + ass, err := c.ovnNbClient.ListAddressSets(map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "egress"), }) if err != nil { @@ -526,19 +526,19 @@ func (c *Controller) handleUpdateNp(key string) error { idx, _ := strconv.Atoi(idxStr) if idx >= len(np.Spec.Egress) { - if err = c.ovnClient.DeleteAddressSet(as.Name); err != nil { + if err = c.ovnNbClient.DeleteAddressSet(as.Name); err != nil { klog.Errorf("delete np %s address set: %v", key, err) return err } } } } else { - if err = c.ovnClient.DeleteAcls(pgName, portGroupKey, "from-lport", nil); err != nil { + if err = c.ovnNbClient.DeleteAcls(pgName, portGroupKey, "from-lport", nil); err != nil { klog.Errorf("delete np %s egress acls: %v", key, err) return err } - if err := c.ovnClient.DeleteAddressSets(map[string]string{ + if err := c.ovnNbClient.DeleteAddressSets(map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", np.Namespace, np.Name, "egress"), }); err != nil { klog.Errorf("delete np %s egress address set: %v", key, err) @@ -547,7 +547,7 @@ func (c *Controller) handleUpdateNp(key string) error { } for _, subnet := range subnets { - if err = c.ovnClient.CreateGatewayAcl("", pgName, subnet.Spec.Gateway); err != nil { + if err = c.ovnNbClient.CreateGatewayAcl("", pgName, subnet.Spec.Gateway); err != nil { klog.Errorf("create gateway acl: %v", err) return err } @@ -573,25 +573,25 @@ func (c *Controller) handleDeleteNp(key string) error { } pgName := strings.Replace(fmt.Sprintf("%s.%s", name, namespace), "-", ".", -1) - if err = c.ovnClient.DeletePortGroup(pgName); err != nil { + if err = c.ovnNbClient.DeletePortGroup(pgName); err != nil { klog.Errorf("delete np %s port group: %v", key, err) } - if err := c.ovnClient.DeleteAddressSets(map[string]string{ + if err := c.ovnNbClient.DeleteAddressSets(map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", namespace, npName, "service"), }); err != nil { klog.Errorf("delete np %s service address set: %v", key, err) return err } - if err := c.ovnClient.DeleteAddressSets(map[string]string{ + if err := c.ovnNbClient.DeleteAddressSets(map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", namespace, npName, "ingress"), }); err != nil { klog.Errorf("delete np %s ingress address set: %v", key, err) return err } - if err := c.ovnClient.DeleteAddressSets(map[string]string{ + if err := c.ovnNbClient.DeleteAddressSets(map[string]string{ networkPolicyKey: fmt.Sprintf("%s/%s/%s", namespace, npName, "egress"), }); err != nil { klog.Errorf("delete np %s egress address set: %v", key, err) diff --git a/pkg/controller/node.go b/pkg/controller/node.go index feb30064663..475a8a901d4 100644 --- a/pkg/controller/node.go +++ b/pkg/controller/node.go @@ -3,7 +3,6 @@ package controller import ( "context" "encoding/json" - "errors" "fmt" "reflect" "strconv" @@ -258,7 +257,7 @@ func (c *Controller) handleAddNode(key string) error { } ipStr := util.GetStringIP(v4IP, v6IP) - if err := c.ovnClient.CreateBareLogicalSwitchPort(c.config.NodeSwitch, portName, ipStr, mac); err != nil { + if err := c.ovnNbClient.CreateBareLogicalSwitchPort(c.config.NodeSwitch, portName, ipStr, mac); err != nil { return err } @@ -280,7 +279,7 @@ func (c *Controller) handleAddNode(key string) error { "address-family": strconv.Itoa(af), } klog.Infof("add policy route for router: %s, match %s, action %s, nexthop %s, externalID %v", c.config.ClusterRouter, match, action, ip, externalIDs) - if err = c.ovnClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.NodeRouterPolicyPriority, match, action, []string{ip}, externalIDs); err != nil { + if err = c.ovnNbClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.NodeRouterPolicyPriority, match, action, []string{ip}, externalIDs); err != nil { klog.Errorf("failed to add logical router policy for node %s: %v", node.Name, err) return err } @@ -352,7 +351,7 @@ func (c *Controller) handleAddNode(key string) error { // ovn acl doesn't support address_set name with '-', so replace '-' by '.' pgName := strings.Replace(node.Annotations[util.PortNameAnnotation], "-", ".", -1) - if err = c.ovnClient.CreatePortGroup(pgName, map[string]string{networkPolicyKey: "node" + "/" + key}); err != nil { + if err = c.ovnNbClient.CreatePortGroup(pgName, map[string]string{networkPolicyKey: "node" + "/" + key}); err != nil { klog.Errorf("create port group %s for node %s: %v", pgName, key, err) return err } @@ -362,11 +361,11 @@ func (c *Controller) handleAddNode(key string) error { return err } - if err := c.validateChassis(node); err != nil { + if err := c.UpdateChassisTag(node); err != nil { return err } - if err := c.retryDelDupChassis(util.ChasRetryTime, util.ChasRetryIntev+2, c.checkChassisDupl, node); err != nil { + if err := c.retryDelDupChassis(util.ChasRetryTime, util.ChasRetryIntev+2, c.cleanDuplicatedChassis, node); err != nil { return err } @@ -466,11 +465,11 @@ func (c *Controller) handleDeleteNode(key string) error { portName := fmt.Sprintf("node-%s", key) klog.Infof("delete logical switch port %s", portName) - if err := c.ovnClient.DeleteLogicalSwitchPort(portName); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(portName); err != nil { klog.Errorf("failed to delete node switch port node-%s: %v", key, err) return err } - if err := c.ovnLegacyClient.DeleteChassisByNode(key); err != nil { + if err := c.ovnSbClient.DeleteChassisByHost(key); err != nil { klog.Errorf("failed to delete chassis for node %s: %v", key, err) return err } @@ -488,7 +487,7 @@ func (c *Controller) handleDeleteNode(key string) error { // ovn acl doesn't support address_set name with '-', so replace '-' by '.' pgName := strings.Replace(portName, "-", ".", -1) - if err := c.ovnClient.DeletePortGroup(pgName); err != nil { + if err := c.ovnNbClient.DeletePortGroup(pgName); err != nil { klog.Errorf("delete port group %s for node: %v", portName, err) return err } @@ -503,16 +502,16 @@ func (c *Controller) handleDeleteNode(key string) error { if addr.Ip == "" { continue } - if err := c.ovnClient.DeleteLogicalRouterPolicyByNexthop(c.config.ClusterRouter, util.NodeRouterPolicyPriority, addr.Ip); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPolicyByNexthop(c.config.ClusterRouter, util.NodeRouterPolicyPriority, addr.Ip); err != nil { klog.Errorf("failed to delete router policy for node %s: %v", key, err) return err } } - if err := c.ovnClient.DeleteAddressSet(nodeUnderlayAddressSetName(key, 4)); err != nil { + if err := c.ovnNbClient.DeleteAddressSet(nodeUnderlayAddressSetName(key, 4)); err != nil { klog.Errorf("failed to delete address set for node %s: %v", key, err) return err } - if err := c.ovnClient.DeleteAddressSet(nodeUnderlayAddressSetName(key, 6)); err != nil { + if err := c.ovnNbClient.DeleteAddressSet(nodeUnderlayAddressSetName(key, 6)); err != nil { klog.Errorf("failed to delete address set for node %s: %v", key, err) return err } @@ -612,10 +611,10 @@ func (c *Controller) handleUpdateNode(key string) error { return err } - if err := c.validateChassis(node); err != nil { + if err := c.UpdateChassisTag(node); err != nil { return err } - if err := c.retryDelDupChassis(util.ChasRetryTime, util.ChasRetryIntev+2, c.checkChassisDupl, node); err != nil { + if err := c.retryDelDupChassis(util.ChasRetryTime, util.ChasRetryIntev+2, c.cleanDuplicatedChassis, node); err != nil { return err } @@ -860,28 +859,21 @@ func (c *Controller) checkGatewayReady() error { return nil } -func (c *Controller) checkChassisDupl(node *v1.Node) error { - // notice that multiple chassises may arise and we are not prepared - chassisAdd, err := c.ovnLegacyClient.GetChassis(node.Name) +func (c *Controller) cleanDuplicatedChassis(node *v1.Node) error { + // if multi chassis has the same node name, delete all of them + chassises, err := c.ovnSbClient.GetAllChassisByHost(node.Name) if err != nil { - klog.Errorf("failed to get node %s chassisID, %v", node.Name, err) + klog.Errorf("failed to list chassis %v", err) return err } - if chassisAdd == "" { - klog.Errorf("chassis of node %s is empty", node.Name) - return err - } - chassisAnn := node.Annotations[util.ChassisAnnotation] - if chassisAnn == chassisAdd || chassisAnn == "" { - return nil - } - - klog.Errorf("duplicate chassis for node %s and new chassis %s", node.Name, chassisAdd) - if err := c.ovnLegacyClient.DeleteChassisByNode(node.Name); err != nil { - klog.Errorf("failed to delete chassis for node %s %v", node.Name, err) - return err + if len(*chassises) > 1 { + klog.Warningf("node %s has multiple chassis", node.Name) + if err := c.ovnSbClient.DeleteChassisByHost(node.Name); err != nil { + klog.Errorf("failed to delete chassis for node %s: %v", node.Name, err) + return err + } } - return errors.New("deleting dismatch chassis id") + return nil } func (c *Controller) retryDelDupChassis(attempts int, sleep int, f func(node *v1.Node) error, node *v1.Node) (err error) { @@ -977,18 +969,18 @@ func (c *Controller) checkAndUpdateNodePortGroup() error { return err } - if err = c.ovnClient.PortGroupSetPorts(pgName, nodePorts); err != nil { + if err = c.ovnNbClient.PortGroupSetPorts(pgName, nodePorts); err != nil { klog.Errorf("add ports to port group %s: %v", pgName, err) return err } if networkPolicyExists { - if err := c.ovnClient.CreateNodeAcl(pgName, nodeIP, joinIP); err != nil { + if err := c.ovnNbClient.CreateNodeAcl(pgName, nodeIP, joinIP); err != nil { klog.Errorf("create node acl for node pg %s: %v", pgName, err) } } else { // clear all acl - if err = c.ovnClient.DeleteAcls(pgName, portGroupKey, "", nil); err != nil { + if err = c.ovnNbClient.DeleteAcls(pgName, portGroupKey, "", nil); err != nil { klog.Errorf("delete node acl for node pg %s: %v", pgName, err) } } @@ -997,41 +989,31 @@ func (c *Controller) checkAndUpdateNodePortGroup() error { return nil } -func (c *Controller) validateChassis(node *v1.Node) error { - if node.Annotations[util.ChassisAnnotation] == "" { +func (c *Controller) UpdateChassisTag(node *v1.Node) error { + annoChassisName := node.Annotations[util.ChassisAnnotation] + if annoChassisName == "" { + // kube-ovn-cni not ready to set chassis return nil } - chassisAdd, err := c.ovnLegacyClient.GetChassis(node.Name) + chassis, err := c.ovnSbClient.GetChassis(annoChassisName, false) if err != nil { - klog.Errorf("failed to get node %s chassisID, %v", node.Name, err) + klog.Errorf("failed to get node %s chassis: %s, %v", node.Name, annoChassisName, err) return err } - if node.Annotations[util.ChassisAnnotation] == chassisAdd { - if err = c.ovnLegacyClient.InitChassisNodeTag(chassisAdd, node.Name); err != nil { + if chassis.ExternalIDs == nil || chassis.ExternalIDs["vendor"] != util.CniTypeName { + klog.Infof("init tag %s for node %s chassis", util.CniTypeName, node.Name) + if err = c.ovnSbClient.UpdateChassisTag(chassis.Name, node.Name); err != nil { return fmt.Errorf("failed to init chassis tag, %v", err) } return nil } - if chassisAdd == "" { - // If no chassisID for this node is obtained, we need to perform GC in order for the chassis to be re-registered - if err = c.gcChassis(); err != nil { - return fmt.Errorf("failed to gc chassis, %v", err) - } - } else { - // When the ids are obtained but are inconsistent, it is usually because there are duplicate chassis records. - // All chassis related to Node need to be deleted so that the correct chassis can be registered again - if err := c.ovnLegacyClient.DeleteChassisByNode(node.Name); err != nil { - klog.Errorf("failed to delete chassis for node %s %v", node.Name, err) - return err - } - } - return errors.New("chassis reset, reboot ovs-ovn on this node: " + node.Name) + return nil } func (c *Controller) addNodeGwStaticRoute() error { // If user not manage static route for default vpc, just add route about ovn-default to join if vpc, err := c.vpcsLister.Get(c.config.ClusterRouter); err != nil || vpc.Spec.StaticRoutes != nil { - existRoute, err := c.ovnClient.ListLogicalRouterStaticRoutes(c.config.ClusterRouter, nil, nil, "", nil) + existRoute, err := c.ovnNbClient.ListLogicalRouterStaticRoutes(c.config.ClusterRouter, nil, nil, "", nil) if err != nil { klog.Errorf("failed to get vpc %s static route list, %v", c.config.ClusterRouter, err) } @@ -1046,7 +1028,7 @@ func (c *Controller) addNodeGwStaticRoute() error { if util.CheckProtocol(cidrBlock) != util.CheckProtocol(nextHop) { continue } - if err := c.ovnClient.AddLogicalRouterStaticRoute(c.config.ClusterRouter, util.MainRouteTable, ovnnb.LogicalRouterStaticRoutePolicyDstIP, cidrBlock, nil, nextHop); err != nil { + if err := c.ovnNbClient.AddLogicalRouterStaticRoute(c.config.ClusterRouter, util.MainRouteTable, ovnnb.LogicalRouterStaticRoutePolicyDstIP, cidrBlock, nil, nextHop); err != nil { klog.Errorf("failed to add static route for node gw: %v", err) return err } @@ -1061,7 +1043,7 @@ func (c *Controller) getPolicyRouteParas(cidr string, priority int) (*strset.Set ipSuffix = "ip6" } match := fmt.Sprintf("%s.src == %s", ipSuffix, cidr) - policyList, err := c.ovnClient.GetLogicalRouterPolicy(c.config.ClusterRouter, priority, match, true) + policyList, err := c.ovnNbClient.GetLogicalRouterPolicy(c.config.ClusterRouter, priority, match, true) if err != nil { klog.Errorf("failed to get logical router policy: %v", err) return nil, nil, err @@ -1098,7 +1080,7 @@ func (c *Controller) deletePolicyRouteForNode(nodeName string) error { if subnet.Spec.GatewayType == kubeovnv1.GWDistributedType { pgName := getOverlaySubnetsPortGroupName(subnet.Name, nodeName) - if err = c.ovnClient.DeletePortGroup(pgName); err != nil { + if err = c.ovnNbClient.DeletePortGroup(pgName); err != nil { klog.Errorf("delete port group for subnet %s and node %s: %v", subnet.Name, nodeName, err) return err } @@ -1229,7 +1211,7 @@ func (c *Controller) addPolicyRouteForLocalDnsCacheOnNode(nodePortName, nodeIP, match := fmt.Sprintf("ip%d.src == $%s && ip%d.dst == %s", af, pgAs, af, c.config.NodeLocalDnsIP) action := ovnnb.LogicalRouterPolicyActionReroute klog.Infof("add node local dns cache policy route for router: %s, match %s, action %s, nexthop %s, externalID %v", c.config.ClusterRouter, match, action, nodeIP, externalIDs) - if err := c.ovnClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.NodeLocalDnsPolicyPriority, match, action, []string{nodeIP}, externalIDs); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.NodeLocalDnsPolicyPriority, match, action, []string{nodeIP}, externalIDs); err != nil { klog.Errorf("failed to add logical router policy for node %s: %v", nodeName, err) return err } @@ -1237,7 +1219,7 @@ func (c *Controller) addPolicyRouteForLocalDnsCacheOnNode(nodePortName, nodeIP, } func (c *Controller) deletePolicyRouteForLocalDnsCacheOnNode(nodeName string, af int) error { - policies, err := c.ovnClient.ListLogicalRouterPolicies(c.config.ClusterRouter, -1, map[string]string{ + policies, err := c.ovnNbClient.ListLogicalRouterPolicies(c.config.ClusterRouter, -1, map[string]string{ "vendor": util.CniTypeName, "node": nodeName, "address-family": strconv.Itoa(af), @@ -1254,7 +1236,7 @@ func (c *Controller) deletePolicyRouteForLocalDnsCacheOnNode(nodeName string, af for _, policy := range policies { klog.Infof("delete node local dns cache policy route for router %s with match %s", c.config.ClusterRouter, policy.Match) - if err := c.ovnClient.DeleteLogicalRouterPolicyByUUID(c.config.ClusterRouter, policy.UUID); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPolicyByUUID(c.config.ClusterRouter, policy.UUID); err != nil { klog.Errorf("failed to delete policy route for node local dns in router %s with match %s: %v", c.config.ClusterRouter, policy.Match, err) return err } diff --git a/pkg/controller/ovn-ic.go b/pkg/controller/ovn-ic.go index a285f7969ac..c6267f822f1 100644 --- a/pkg/controller/ovn-ic.go +++ b/pkg/controller/ovn-ic.go @@ -88,7 +88,7 @@ func (c *Controller) resyncInterConnection() { blackList = append(blackList, ipv6) } } - if err := c.ovnClient.SetICAutoRoute(autoRoute, blackList); err != nil { + if err := c.ovnNbClient.SetICAutoRoute(autoRoute, blackList); err != nil { klog.Errorf("failed to config auto route, %v", err) return } @@ -170,7 +170,7 @@ func (c *Controller) removeInterConnection(azName string) error { if azName != "" { lspName := fmt.Sprintf("ts-%s", azName) lrpName := fmt.Sprintf("%s-ts", azName) - if err := c.ovnClient.RemoveLogicalPatchPort(lspName, lrpName); err != nil { + if err := c.ovnNbClient.RemoveLogicalPatchPort(lspName, lrpName); err != nil { klog.Errorf("delete ovn-ic logical port %s and %s: %v", lspName, lrpName, err) return err } @@ -191,7 +191,7 @@ func (c *Controller) establishInterConnection(config map[string]string) error { } tsPort := fmt.Sprintf("ts-%s", config["az-name"]) - exist, err := c.ovnClient.LogicalSwitchPortExists(tsPort) + exist, err := c.ovnNbClient.LogicalSwitchPortExists(tsPort) if err != nil { klog.Errorf("failed to list logical switch ports, %v", err) return err @@ -202,7 +202,7 @@ func (c *Controller) establishInterConnection(config map[string]string) error { return nil } - if err := c.ovnClient.SetAzName(config["az-name"]); err != nil { + if err := c.ovnNbClient.SetAzName(config["az-name"]); err != nil { klog.Errorf("failed to set az name. %v", err) return err } @@ -235,15 +235,19 @@ func (c *Controller) establishInterConnection(config map[string]string) error { klog.Errorf("patch gw node %s failed %v", gw, err) return err } - chassisID, err := c.ovnLegacyClient.GetChassis(gw) - if err != nil { - klog.Errorf("failed to get gw %s chassisID, %v", gw, err) + annoChassisName := node.Annotations[util.ChassisAnnotation] + if annoChassisName == "" { + err := fmt.Errorf("node %s has no chassis annotation, kube-ovn-cni not ready", gw) + klog.Error(err) return err } - if chassisID == "" { - return fmt.Errorf("no chassisID for gw %s", gw) + klog.Infof("gw node %s chassis %s", gw, annoChassisName) + chassis, err := c.ovnSbClient.GetChassis(annoChassisName, false) + if err != nil { + klog.Errorf("failed to get node chassis %s, %v", annoChassisName, err) + return err } - chassises = append(chassises, chassisID) + chassises = append(chassises, chassis.Name) } if len(chassises) == 0 { klog.Error("no available ic gw") @@ -261,7 +265,7 @@ func (c *Controller) establishInterConnection(config map[string]string) error { } lrpName := fmt.Sprintf("%s-ts", config["az-name"]) - if err := c.ovnClient.CreateLogicalPatchPort(util.InterconnectionSwitch, c.config.ClusterRouter, tsPort, lrpName, lrpIP, util.GenerateMac(), chassises...); err != nil { + if err := c.ovnNbClient.CreateLogicalPatchPort(util.InterconnectionSwitch, c.config.ClusterRouter, tsPort, lrpName, lrpIP, util.GenerateMac(), chassises...); err != nil { klog.Errorf("failed to create ovn-ic lrp %v", err) return err } @@ -360,19 +364,19 @@ func (c *Controller) waitTsReady() error { } func (c *Controller) delLearnedRoute() error { - lrList, err := c.ovnClient.ListLogicalRouter(false, nil) + lrList, err := c.ovnNbClient.ListLogicalRouter(false, nil) if err != nil { klog.Errorf("failed to list logical routers: %v", err) return err } for _, lr := range lrList { - routeList, err := c.ovnClient.ListLogicalRouterStaticRoutes(lr.Name, nil, nil, "", map[string]string{"ic-learned-route": ""}) + routeList, err := c.ovnNbClient.ListLogicalRouterStaticRoutes(lr.Name, nil, nil, "", map[string]string{"ic-learned-route": ""}) if err != nil { klog.Errorf("failed to list learned static routes on logical router %s: %v", lr.Name, err) return err } for _, r := range routeList { - if err = c.ovnClient.DeleteLogicalRouterStaticRoute(lr.Name, &r.RouteTable, r.Policy, r.IPPrefix, r.Nexthop); err != nil { + if err = c.ovnNbClient.DeleteLogicalRouterStaticRoute(lr.Name, &r.RouteTable, r.Policy, r.IPPrefix, r.Nexthop); err != nil { klog.Errorf("failed to delete learned static route %#v on logical router %s: %v", r, lr.Name, err) return err } @@ -444,19 +448,19 @@ func stripPrefix(policyMatch string) (string, error) { } func (c *Controller) syncOneRouteToPolicy(key, value string) { - lr, err := c.ovnClient.GetLogicalRouter(c.config.ClusterRouter, false) + lr, err := c.ovnNbClient.GetLogicalRouter(c.config.ClusterRouter, false) if err != nil { klog.Errorf("logical router does not exist %v at %v", err, time.Now()) return } - lrRouteList, err := c.ovnClient.ListLogicalRouterStaticRoutesByOption(lr.Name, util.MainRouteTable, key, value) + lrRouteList, err := c.ovnNbClient.ListLogicalRouterStaticRoutesByOption(lr.Name, util.MainRouteTable, key, value) if err != nil { klog.Errorf("failed to list lr ovn-ic route %v", err) return } if len(lrRouteList) == 0 { klog.V(5).Info("lr ovn-ic route does not exist") - err := c.ovnClient.DeleteLogicalRouterPolicies(lr.Name, util.OvnICPolicyPriority, map[string]string{key: value}) + err := c.ovnNbClient.DeleteLogicalRouterPolicies(lr.Name, util.OvnICPolicyPriority, map[string]string{key: value}) if err != nil { klog.Errorf("failed to delete ovn-ic lr policy: %v", err) return @@ -465,7 +469,7 @@ func (c *Controller) syncOneRouteToPolicy(key, value string) { } policyMap := map[string]string{} - lrPolicyList, err := c.ovnClient.ListLogicalRouterPolicies(lr.Name, util.OvnICPolicyPriority, map[string]string{key: value}) + lrPolicyList, err := c.ovnNbClient.ListLogicalRouterPolicies(lr.Name, util.OvnICPolicyPriority, map[string]string{key: value}) if err != nil { klog.Errorf("failed to list ovn-ic lr policy ", err) return @@ -485,28 +489,28 @@ func (c *Controller) syncOneRouteToPolicy(key, value string) { var matchFiled string if util.CheckProtocol(lrRoute.IPPrefix) == kubeovnv1.ProtocolIPv4 { matchFiled = util.MatchV4Dst + " == " + lrRoute.IPPrefix - if err := c.ovnClient.AddLogicalRouterPolicy(lr.Name, util.OvnICPolicyPriority, matchFiled, ovnnb.LogicalRouterPolicyActionAllow, nil, map[string]string{key: value, "vendor": util.CniTypeName}); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(lr.Name, util.OvnICPolicyPriority, matchFiled, ovnnb.LogicalRouterPolicyActionAllow, nil, map[string]string{key: value, "vendor": util.CniTypeName}); err != nil { klog.Errorf("adding router policy failed %v", err) } } if util.CheckProtocol(lrRoute.IPPrefix) == kubeovnv1.ProtocolIPv6 { matchFiled = util.MatchV6Dst + " == " + lrRoute.IPPrefix - if err := c.ovnClient.AddLogicalRouterPolicy(lr.Name, util.OvnICPolicyPriority, matchFiled, ovnnb.LogicalRouterPolicyActionAllow, nil, map[string]string{key: value, "vendor": util.CniTypeName}); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(lr.Name, util.OvnICPolicyPriority, matchFiled, ovnnb.LogicalRouterPolicyActionAllow, nil, map[string]string{key: value, "vendor": util.CniTypeName}); err != nil { klog.Errorf("adding router policy failed %v", err) } } } } for _, uuid := range policyMap { - if err := c.ovnClient.DeleteLogicalRouterPolicyByUUID(lr.Name, uuid); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPolicyByUUID(lr.Name, uuid); err != nil { klog.Errorf("deleting router policy failed %v", err) } } } func (c *Controller) listRemoteLogicalSwitchPortAddress() (*strset.Set, error) { - lsps, err := c.ovnClient.ListLogicalSwitchPorts(true, nil, func(lsp *ovnnb.LogicalSwitchPort) bool { + lsps, err := c.ovnNbClient.ListLogicalSwitchPorts(true, nil, func(lsp *ovnnb.LogicalSwitchPort) bool { return lsp.Type == "remote" }) if err != nil { diff --git a/pkg/controller/ovn_dnat.go b/pkg/controller/ovn_dnat.go index 34372d30f7f..52417b28595 100644 --- a/pkg/controller/ovn_dnat.go +++ b/pkg/controller/ovn_dnat.go @@ -586,17 +586,17 @@ func (c *Controller) AddDnatRule(vpcName, dnatName, externalIp, internalIp, exte externalEndpoint := net.JoinHostPort(externalIp, externalPort) internalEndpoint := net.JoinHostPort(internalIp, internalPort) - if err := c.ovnClient.CreateLoadBalancer(dnatName, protocol, ""); err != nil { + if err := c.ovnNbClient.CreateLoadBalancer(dnatName, protocol, ""); err != nil { klog.Errorf("create loadBalancer %s: %v", dnatName, err) return err } - if err := c.ovnClient.LoadBalancerAddVip(dnatName, externalEndpoint, internalEndpoint); err != nil { + if err := c.ovnNbClient.LoadBalancerAddVip(dnatName, externalEndpoint, internalEndpoint); err != nil { klog.Errorf("add vip %s with backends %s to LB %s: %v", externalEndpoint, internalEndpoint, dnatName, err) return err } - if err := c.ovnClient.LogicalRouterUpdateLoadBalancers(vpcName, ovsdb.MutateOperationInsert, dnatName); err != nil { + if err := c.ovnNbClient.LogicalRouterUpdateLoadBalancers(vpcName, ovsdb.MutateOperationInsert, dnatName); err != nil { klog.Errorf("add lb %s to vpc %s: %v", dnatName, vpcName, err) return err } @@ -606,12 +606,12 @@ func (c *Controller) AddDnatRule(vpcName, dnatName, externalIp, internalIp, exte func (c *Controller) DelDnatRule(vpcName, dnatName, externalIp, externalPort string) error { externalEndpoint := net.JoinHostPort(externalIp, externalPort) - if err := c.ovnClient.LoadBalancerDeleteVip(dnatName, externalEndpoint); err != nil { + if err := c.ovnNbClient.LoadBalancerDeleteVip(dnatName, externalEndpoint); err != nil { klog.Errorf("delete loadBalancer vips %s: %v", externalEndpoint, err) return err } - if err := c.ovnClient.LogicalRouterUpdateLoadBalancers(vpcName, ovsdb.MutateOperationDelete, dnatName); err != nil { + if err := c.ovnNbClient.LogicalRouterUpdateLoadBalancers(vpcName, ovsdb.MutateOperationDelete, dnatName); err != nil { klog.Errorf("failed to remove lb %s from vpc %s: %v", dnatName, vpcName, err) return err } diff --git a/pkg/controller/ovn_eip.go b/pkg/controller/ovn_eip.go index ef9d406975e..89444a86ccf 100644 --- a/pkg/controller/ovn_eip.go +++ b/pkg/controller/ovn_eip.go @@ -247,7 +247,7 @@ func (c *Controller) handleAddOvnEip(key string) error { if cachedEip.Spec.Type == util.Lsp { mergedIp := util.GetStringIP(v4ip, v6ip) - if err := c.ovnClient.CreateBareLogicalSwitchPort(subnet.Name, portName, mergedIp, mac); err != nil { + if err := c.ovnNbClient.CreateBareLogicalSwitchPort(subnet.Name, portName, mergedIp, mac); err != nil { klog.Error("failed to create lsp for ovn eip %s, %v", key, err) return err } @@ -346,14 +346,14 @@ func (c *Controller) handleDelOvnEip(key string) error { } if eip.Spec.Type == util.Lsp { - if err = c.ovnClient.DeleteLogicalSwitchPort(eip.Name); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(eip.Name); err != nil { klog.Errorf("failed to delete lsp %s, %v", eip.Name, err) return err } } if eip.Spec.Type == util.Lrp { - if err = c.ovnClient.DeleteLogicalRouterPort(eip.Name); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPort(eip.Name); err != nil { klog.Errorf("failed to delete lrp %s, %v", eip.Name, err) return err } diff --git a/pkg/controller/ovn_fip.go b/pkg/controller/ovn_fip.go index ff8250bf548..ecf1dbebef2 100644 --- a/pkg/controller/ovn_fip.go +++ b/pkg/controller/ovn_fip.go @@ -287,7 +287,7 @@ func (c *Controller) handleAddOvnFip(key string) error { return err } // ovn add fip - if err = c.ovnClient.AddNat(vpcName, ovnnb.NATTypeDNATAndSNAT, cachedEip.Status.V4Ip, + if err = c.ovnNbClient.AddNat(vpcName, ovnnb.NATTypeDNATAndSNAT, cachedEip.Status.V4Ip, internalV4Ip, mac, cachedFip.Spec.IpName, map[string]string{"staleless": strconv.FormatBool(c.ExternalGatewayType == kubeovnv1.GWDistributedType)}); err != nil { klog.Errorf("failed to create v4 fip, %v", err) @@ -383,7 +383,7 @@ func (c *Controller) handleUpdateOvnFip(key string) error { return err } vpcName := subnet.Spec.Vpc - if err = c.ovnClient.AddNat(vpcName, ovnnb.NATTypeDNATAndSNAT, cachedEip.Status.V4Ip, + if err = c.ovnNbClient.AddNat(vpcName, ovnnb.NATTypeDNATAndSNAT, cachedEip.Status.V4Ip, internalV4Ip, mac, cachedFip.Spec.IpName, map[string]string{"staleless": strconv.FormatBool(c.ExternalGatewayType == kubeovnv1.GWDistributedType)}); err != nil { klog.Errorf("failed to create v4 fip, %v", err) @@ -393,12 +393,12 @@ func (c *Controller) handleUpdateOvnFip(key string) error { // fip change eip if c.ovnFipChangeEip(fip, cachedEip) { klog.Infof("fip change ip, old ip '%s', new ip %s", fip.Status.V4Ip, cachedEip.Status.V4Ip) - if err = c.ovnClient.DeleteNat(vpcName, ovnnb.NATTypeDNATAndSNAT, fip.Status.V4Ip, internalV4Ip); err != nil { + if err = c.ovnNbClient.DeleteNat(vpcName, ovnnb.NATTypeDNATAndSNAT, fip.Status.V4Ip, internalV4Ip); err != nil { klog.Errorf("failed to create fip, %v", err) return err } // ovn add fip - if err = c.ovnClient.AddNat(vpcName, ovnnb.NATTypeDNATAndSNAT, cachedEip.Status.V4Ip, + if err = c.ovnNbClient.AddNat(vpcName, ovnnb.NATTypeDNATAndSNAT, cachedEip.Status.V4Ip, internalV4Ip, mac, cachedFip.Spec.IpName, map[string]string{"staleless": strconv.FormatBool(c.ExternalGatewayType == kubeovnv1.GWDistributedType)}); err != nil { klog.Errorf("failed to create fip, %v", err) @@ -434,7 +434,7 @@ func (c *Controller) handleDelOvnFip(key string) error { } // ovn delete fip nat if cachedFip.Status.Vpc != "" && cachedFip.Status.V4Eip != "" && cachedFip.Status.V4Ip != "" { - if err = c.ovnClient.DeleteNat(cachedFip.Status.Vpc, ovnnb.NATTypeDNATAndSNAT, cachedFip.Status.V4Eip, cachedFip.Status.V4Ip); err != nil { + if err = c.ovnNbClient.DeleteNat(cachedFip.Status.Vpc, ovnnb.NATTypeDNATAndSNAT, cachedFip.Status.V4Eip, cachedFip.Status.V4Ip); err != nil { klog.Errorf("failed to delete fip %s, %v", key, err) return err } diff --git a/pkg/controller/ovn_snat.go b/pkg/controller/ovn_snat.go index bacd2d02191..d43234d239b 100644 --- a/pkg/controller/ovn_snat.go +++ b/pkg/controller/ovn_snat.go @@ -252,7 +252,7 @@ func (c *Controller) handleAddOvnSnatRule(key string) error { return err } // ovn add snat - if err = c.ovnClient.AddNat(vpcName, ovnnb.NATTypeSNAT, cachedEip.Spec.V4Ip, v4IpCidr, "", "", nil); err != nil { + if err = c.ovnNbClient.AddNat(vpcName, ovnnb.NATTypeSNAT, cachedEip.Spec.V4Ip, v4IpCidr, "", "", nil); err != nil { klog.Errorf("failed to create snat, %v", err) return err } @@ -300,6 +300,20 @@ func (c *Controller) handleUpdateOvnSnatRule(key string) error { klog.Errorf("failed to get eip, %v", err) return err } + // should delete + if !cachedSnat.DeletionTimestamp.IsZero() { + klog.V(3).Infof("ovn delete snat %s", key) + // ovn delete snat + if cachedSnat.Status.Vpc != "" && cachedSnat.Status.V4Eip != "" && cachedSnat.Status.V4IpCidr != "" { + if err = c.ovnNbClient.DeleteNat(cachedSnat.Status.Vpc, ovnnb.NATTypeSNAT, cachedSnat.Status.V4Eip, cachedSnat.Status.V4IpCidr); err != nil { + klog.Errorf("failed to delete snat, %v", err) + return err + } + } + // reset eip + c.resetOvnEipQueue.Add(cachedSnat.Spec.OvnEip) + return nil + } if cachedEip.Spec.Type == util.Lsp { // eip is using by ecmp nexthop lsp, nat can not use @@ -341,12 +355,12 @@ func (c *Controller) handleUpdateOvnSnatRule(key string) error { // snat change eip if c.ovnSnatChangeEip(cachedSnat, cachedEip) { klog.Infof("snat change ip, old ip %s, new ip %s", cachedEip.Status.V4Ip, cachedEip.Spec.V4Ip) - if err = c.ovnClient.DeleteNat(vpcName, ovnnb.NATTypeSNAT, cachedEip.Status.V4Ip, v4IpCidr); err != nil { + if err = c.ovnNbClient.DeleteNat(vpcName, ovnnb.NATTypeSNAT, cachedEip.Status.V4Ip, v4IpCidr); err != nil { klog.Errorf("failed to delte snat, %v", err) return err } // ovn add snat with new eip - if err = c.ovnClient.AddNat(vpcName, ovnnb.NATTypeSNAT, cachedEip.Spec.V4Ip, v4IpCidr, "", "", nil); err != nil { + if err = c.ovnNbClient.AddNat(vpcName, ovnnb.NATTypeSNAT, cachedEip.Spec.V4Ip, v4IpCidr, "", "", nil); err != nil { klog.Errorf("failed to create snat, %v", err) return err } @@ -379,7 +393,7 @@ func (c *Controller) handleDelOvnSnatRule(key string) error { } // ovn delete snat if cachedSnat.Status.Vpc != "" && cachedSnat.Status.V4Eip != "" && cachedSnat.Status.V4IpCidr != "" { - if err = c.ovnClient.DeleteNat(cachedSnat.Status.Vpc, ovnnb.NATTypeSNAT, + if err = c.ovnNbClient.DeleteNat(cachedSnat.Status.Vpc, ovnnb.NATTypeSNAT, cachedSnat.Status.V4Eip, cachedSnat.Status.V4IpCidr); err != nil { klog.Errorf("failed to delete snat %s, %v", key, err) return err diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index 98dcda78b7e..8b108419f4c 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -525,7 +525,7 @@ func (c *Controller) changeVMSubnet(vmName, namespace, providerName, subnetName if ipCr != nil { if ipCr.Spec.Subnet != subnetName { key := fmt.Sprintf("%s/%s", pod.Namespace, vmName) - ports, err := c.ovnClient.ListNormalLogicalSwitchPorts(true, map[string]string{"pod": key}) + ports, err := c.ovnNbClient.ListNormalLogicalSwitchPorts(true, map[string]string{"pod": key}) if err != nil { klog.Errorf("failed to list lsps of pod '%s', %v", pod.Name, err) return err @@ -533,7 +533,7 @@ func (c *Controller) changeVMSubnet(vmName, namespace, providerName, subnetName for _, port := range ports { // when lsp is deleted, the port of pod is deleted from any port-group automatically. klog.Infof("gc logical switch port %s", port.Name) - if err := c.ovnClient.DeleteLogicalSwitchPort(port.Name); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(port.Name); err != nil { klog.Errorf("failed to delete lsp %s, %v", port.Name, err) return err } @@ -700,7 +700,7 @@ func (c *Controller) reconcileAllocateSubnets(cachedPod, pod *v1.Pod, needAlloca DHCPv6OptionsUUID: subnet.Status.DHCPv6OptionsUUID, } - if err := c.ovnClient.CreateLogicalSwitchPort(subnet.Name, portName, ipStr, mac, podName, pod.Namespace, portSecurity, securityGroupAnnotation, vips, podNet.Subnet.Spec.EnableDHCP, dhcpOptions, subnet.Spec.Vpc); err != nil { + if err := c.ovnNbClient.CreateLogicalSwitchPort(subnet.Name, portName, ipStr, mac, podName, pod.Namespace, portSecurity, securityGroupAnnotation, vips, podNet.Subnet.Spec.EnableDHCP, dhcpOptions, subnet.Spec.Vpc); err != nil { c.recorder.Eventf(pod, v1.EventTypeWarning, "CreateOVNPortFailed", err.Error()) klog.Errorf("%v", err) return nil, err @@ -802,7 +802,7 @@ func (c *Controller) reconcileRouteSubnets(cachedPod, pod *v1.Pod, needRoutePodN nextHop = strings.Split(nextHop, "/")[0] } - if err := c.ovnClient.AddLogicalRouterStaticRoute( + if err := c.ovnNbClient.AddLogicalRouterStaticRoute( c.config.ClusterRouter, subnet.Spec.RouteTable, ovnnb.LogicalRouterStaticRoutePolicySrcIP, podIP, nil, nextHop, ); err != nil { klog.Errorf("failed to add static route, %v", err) @@ -811,7 +811,7 @@ func (c *Controller) reconcileRouteSubnets(cachedPod, pod *v1.Pod, needRoutePodN // remove lsp from port group to make EIP/SNAT work portName := ovs.PodNameToPortName(podName, pod.Namespace, podNet.ProviderName) - if err = c.ovnClient.PortGroupRemovePorts(pgName, portName); err != nil { + if err = c.ovnNbClient.PortGroupRemovePorts(pgName, portName); err != nil { return err } @@ -831,7 +831,7 @@ func (c *Controller) reconcileRouteSubnets(cachedPod, pod *v1.Pod, needRoutePodN } portName := ovs.PodNameToPortName(podName, pod.Namespace, podNet.ProviderName) - if err := c.ovnClient.PortGroupAddPorts(pgName, portName); err != nil { + if err := c.ovnNbClient.PortGroupAddPorts(pgName, portName); err != nil { klog.Errorf("add port to port group %s: %v", pgName, err) return err } @@ -846,14 +846,14 @@ func (c *Controller) reconcileRouteSubnets(cachedPod, pod *v1.Pod, needRoutePodN } if pod.Annotations[util.NorthGatewayAnnotation] != "" { - if err := c.ovnClient.AddLogicalRouterStaticRoute( + if err := c.ovnNbClient.AddLogicalRouterStaticRoute( c.config.ClusterRouter, subnet.Spec.RouteTable, ovnnb.LogicalRouterStaticRoutePolicySrcIP, podIP, nil, pod.Annotations[util.NorthGatewayAnnotation], ); err != nil { klog.Errorf("failed to add static route, %v", err) return err } } else if c.config.EnableEipSnat { - if err = c.ovnClient.DeleteLogicalRouterStaticRoute( + if err = c.ovnNbClient.DeleteLogicalRouterStaticRoute( c.config.ClusterRouter, &subnet.Spec.RouteTable, nil, podIP, "", ); err != nil { return err @@ -864,21 +864,21 @@ func (c *Controller) reconcileRouteSubnets(cachedPod, pod *v1.Pod, needRoutePodN if c.config.EnableEipSnat { for _, ipStr := range strings.Split(podIP, ",") { if eip := pod.Annotations[util.EipAnnotation]; eip == "" { - if err = c.ovnClient.DeleteNats(c.config.ClusterRouter, ovnnb.NATTypeDNATAndSNAT, ipStr); err != nil { + if err = c.ovnNbClient.DeleteNats(c.config.ClusterRouter, ovnnb.NATTypeDNATAndSNAT, ipStr); err != nil { klog.Errorf("failed to delete nat rules: %v", err) } } else if util.CheckProtocol(eip) == util.CheckProtocol(ipStr) { - if err = c.ovnClient.UpdateDnatAndSnat(c.config.ClusterRouter, eip, ipStr, fmt.Sprintf("%s.%s", podName, pod.Namespace), pod.Annotations[util.MacAddressAnnotation], c.ExternalGatewayType); err != nil { + if err = c.ovnNbClient.UpdateDnatAndSnat(c.config.ClusterRouter, eip, ipStr, fmt.Sprintf("%s.%s", podName, pod.Namespace), pod.Annotations[util.MacAddressAnnotation], c.ExternalGatewayType); err != nil { klog.Errorf("failed to add nat rules, %v", err) return err } } if eip := pod.Annotations[util.SnatAnnotation]; eip == "" { - if err = c.ovnClient.DeleteNats(c.config.ClusterRouter, ovnnb.NATTypeSNAT, ipStr); err != nil { + if err = c.ovnNbClient.DeleteNats(c.config.ClusterRouter, ovnnb.NATTypeSNAT, ipStr); err != nil { klog.Errorf("failed to delete nat rules: %v", err) } } else if util.CheckProtocol(eip) == util.CheckProtocol(ipStr) { - if err = c.ovnClient.UpdateSnat(c.config.ClusterRouter, eip, ipStr); err != nil { + if err = c.ovnNbClient.UpdateSnat(c.config.ClusterRouter, eip, ipStr); err != nil { klog.Errorf("failed to add nat rules, %v", err) return err } @@ -927,7 +927,7 @@ func (c *Controller) handleDeletePod(key string) error { return nil } - ports, err := c.ovnClient.ListNormalLogicalSwitchPorts(true, map[string]string{"pod": key}) + ports, err := c.ovnNbClient.ListNormalLogicalSwitchPorts(true, map[string]string{"pod": key}) if err != nil { klog.Errorf("failed to list lsps of pod '%s', %v", pod.Name, err) return err @@ -955,12 +955,12 @@ func (c *Controller) handleDeletePod(key string) error { } // If pod has snat or eip, also need delete staticRoute when delete pod if vpc.Name == c.config.ClusterRouter { - if err = c.ovnClient.DeleteLogicalRouterStaticRoute(vpc.Name, &subnet.Spec.RouteTable, nil, address.Ip, ""); err != nil { + if err = c.ovnNbClient.DeleteLogicalRouterStaticRoute(vpc.Name, &subnet.Spec.RouteTable, nil, address.Ip, ""); err != nil { return err } } if exGwEnabled == "true" { - if err := c.ovnClient.DeleteNat(vpc.Name, "", "", address.Ip); err != nil { + if err := c.ovnNbClient.DeleteNat(vpc.Name, "", "", address.Ip); err != nil { return err } } @@ -995,7 +995,7 @@ func (c *Controller) handleDeletePod(key string) error { for _, port := range ports { // when lsp is deleted, the port of pod is deleted from any port-group automatically. klog.Infof("gc logical switch port %s", port.Name) - if err := c.ovnClient.DeleteLogicalSwitchPort(port.Name); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(port.Name); err != nil { klog.Errorf("failed to delete lsp %s, %v", port.Name, err) return err } @@ -1065,7 +1065,7 @@ func (c *Controller) handleUpdatePodSecurity(key string) error { ipStr := pod.Annotations[fmt.Sprintf(util.IpAddressAnnotationTemplate, podNet.ProviderName)] vips := pod.Annotations[fmt.Sprintf(util.PortVipAnnotationTemplate, podNet.ProviderName)] - if err = c.ovnClient.SetLogicalSwitchPortSecurity(portSecurity, ovs.PodNameToPortName(podName, namespace, podNet.ProviderName), mac, ipStr, vips); err != nil { + if err = c.ovnNbClient.SetLogicalSwitchPortSecurity(portSecurity, ovs.PodNameToPortName(podName, namespace, podNet.ProviderName), mac, ipStr, vips); err != nil { klog.Errorf("set logical switch port security: %v", err) return err } @@ -1097,7 +1097,7 @@ func (c *Controller) syncKubeOvnNet(cachedPod, pod *v1.Pod, podNets []*kubeovnNe targetPortNameList.Add(portName) } - ports, err := c.ovnClient.ListNormalLogicalSwitchPorts(true, map[string]string{"pod": key}) + ports, err := c.ovnNbClient.ListNormalLogicalSwitchPorts(true, map[string]string{"pod": key}) if err != nil { klog.Errorf("failed to list lsps of pod '%s', %v", pod.Name, err) return nil, err @@ -1126,7 +1126,7 @@ func (c *Controller) syncKubeOvnNet(cachedPod, pod *v1.Pod, podNets []*kubeovnNe subnet.ReleaseAddressWithNicName(podName, portNeedDel) } - if err := c.ovnClient.DeleteLogicalSwitchPort(portNeedDel); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(portNeedDel); err != nil { klog.Errorf("failed to delete lsp %s, %v", portNeedDel, err) return nil, err } diff --git a/pkg/controller/security_group.go b/pkg/controller/security_group.go index daa73ec6e0b..6b338ae9acd 100644 --- a/pkg/controller/security_group.go +++ b/pkg/controller/security_group.go @@ -168,7 +168,7 @@ func (c *Controller) processNextDeleteSgWorkItem() bool { func (c *Controller) initDenyAllSecurityGroup() error { pgName := ovs.GetSgPortGroupName(util.DenyAllSecurityGroup) - if err := c.ovnClient.CreatePortGroup(pgName, map[string]string{ + if err := c.ovnNbClient.CreatePortGroup(pgName, map[string]string{ "type": "security_group", sgKey: util.DenyAllSecurityGroup, }); err != nil { @@ -176,7 +176,7 @@ func (c *Controller) initDenyAllSecurityGroup() error { return err } - if err := c.ovnClient.CreateSgDenyAllAcl(util.DenyAllSecurityGroup); err != nil { + if err := c.ovnNbClient.CreateSgDenyAllAcl(util.DenyAllSecurityGroup); err != nil { klog.Errorf("create deny all acl for sg %s: %v", util.DenyAllSecurityGroup, err) return err } @@ -188,7 +188,7 @@ func (c *Controller) initDenyAllSecurityGroup() error { // updateDenyAllSgPorts set lsp to deny which security_groups is not empty func (c *Controller) updateDenyAllSgPorts() error { // list all lsp which security_groups is not empty - lsps, err := c.ovnClient.ListNormalLogicalSwitchPorts(true, map[string]string{sgsKey: ""}) + lsps, err := c.ovnNbClient.ListNormalLogicalSwitchPorts(true, map[string]string{sgsKey: ""}) if err != nil { klog.Errorf("list logical switch ports with security_groups is not empty: %v", err) return err @@ -219,7 +219,7 @@ func (c *Controller) updateDenyAllSgPorts() error { pgName := ovs.GetSgPortGroupName(util.DenyAllSecurityGroup) klog.V(6).Infof("setting ports of port group %s to %v", pgName, addPorts) - if err = c.ovnClient.PortGroupSetPorts(pgName, addPorts); err != nil { + if err = c.ovnNbClient.PortGroupSetPorts(pgName, addPorts); err != nil { klog.Error(err) return err } @@ -255,7 +255,7 @@ func (c *Controller) handleAddOrUpdateSg(key string) error { } pgName := ovs.GetSgPortGroupName(sg.Name) - if err := c.ovnClient.CreatePortGroup(pgName, map[string]string{ + if err := c.ovnNbClient.CreatePortGroup(pgName, map[string]string{ "type": "security_group", sgKey: sg.Name, }); err != nil { @@ -269,12 +269,12 @@ func (c *Controller) handleAddOrUpdateSg(key string) error { sgKey: sg.Name, } - if err = c.ovnClient.CreateAddressSet(v4AsName, externalIDs); err != nil { + if err = c.ovnNbClient.CreateAddressSet(v4AsName, externalIDs); err != nil { klog.Errorf("create address set %s for sg %s: %v", v4AsName, key, err) return err } - if err = c.ovnClient.CreateAddressSet(v6AsName, externalIDs); err != nil { + if err = c.ovnNbClient.CreateAddressSet(v6AsName, externalIDs); err != nil { klog.Errorf("create address set %s for sg %s: %v", v6AsName, key, err) return err } @@ -303,13 +303,13 @@ func (c *Controller) handleAddOrUpdateSg(key string) error { // update sg rule if ingressNeedUpdate { - if err = c.ovnClient.UpdateSgAcl(sg, ovnnb.ACLDirectionToLport); err != nil { + if err = c.ovnNbClient.UpdateSgAcl(sg, ovnnb.ACLDirectionToLport); err != nil { sg.Status.IngressLastSyncSuccess = false c.patchSgStatus(sg) return err } - if err := c.ovnClient.CreateSgBaseACL(sg.Name, ovnnb.ACLDirectionToLport); err != nil { + if err := c.ovnNbClient.CreateSgBaseACL(sg.Name, ovnnb.ACLDirectionToLport); err != nil { return err } sg.Status.IngressMd5 = newIngressMd5 @@ -317,13 +317,13 @@ func (c *Controller) handleAddOrUpdateSg(key string) error { c.patchSgStatus(sg) } if egressNeedUpdate { - if err = c.ovnClient.UpdateSgAcl(sg, ovnnb.ACLDirectionFromLport); err != nil { + if err = c.ovnNbClient.UpdateSgAcl(sg, ovnnb.ACLDirectionFromLport); err != nil { sg.Status.IngressLastSyncSuccess = false c.patchSgStatus(sg) return err } - if err := c.ovnClient.CreateSgBaseACL(sg.Name, ovnnb.ACLDirectionFromLport); err != nil { + if err := c.ovnNbClient.CreateSgBaseACL(sg.Name, ovnnb.ACLDirectionFromLport); err != nil { return err } @@ -401,7 +401,7 @@ func (c *Controller) handleDeleteSg(key string) error { defer func() { _ = c.sgKeyMutex.UnlockKey(key) }() klog.Infof("handle delete security group %s", key) - if err := c.ovnClient.DeleteSecurityGroup(key); err != nil { + if err := c.ovnNbClient.DeleteSecurityGroup(key); err != nil { klog.Errorf("delete sg %s: %v", key, err) return err } @@ -424,7 +424,7 @@ func (c *Controller) syncSgLogicalPort(key string) error { return err } - results, err := c.ovnClient.ListLogicalSwitchPorts(false, map[string]string{"external_ids:associated_sg_" + key: "true"}, nil) + results, err := c.ovnNbClient.ListLogicalSwitchPorts(false, map[string]string{"external_ids:associated_sg_" + key: "true"}, nil) if err != nil { klog.Errorf("failed to find logical port, %v", err) return err @@ -451,19 +451,19 @@ func (c *Controller) syncSgLogicalPort(key string) error { } } - if err = c.ovnClient.PortGroupSetPorts(sg.Status.PortGroup, ports); err != nil { + if err = c.ovnNbClient.PortGroupSetPorts(sg.Status.PortGroup, ports); err != nil { klog.Errorf("add ports to port group %s: %v", sg.Status.PortGroup, err) return err } v4AsName := ovs.GetSgV4AssociatedName(key) - if err := c.ovnClient.AddressSetUpdateAddress(v4AsName, v4s...); err != nil { + if err := c.ovnNbClient.AddressSetUpdateAddress(v4AsName, v4s...); err != nil { klog.Errorf("set ips to address set %s: %v", v4AsName, err) return err } v6AsName := ovs.GetSgV6AssociatedName(key) - if err := c.ovnClient.AddressSetUpdateAddress(v6AsName, v6s...); err != nil { + if err := c.ovnNbClient.AddressSetUpdateAddress(v6AsName, v6s...); err != nil { klog.Errorf("set ips to address set %s: %v", v6AsName, err) return err } @@ -484,7 +484,7 @@ func (c *Controller) getPortSg(port *ovnnb.LogicalSwitchPort) ([]string, error) } func (c *Controller) reconcilePortSg(portName, securityGroups string) error { - port, err := c.ovnClient.GetLogicalSwitchPort(portName, false) + port, err := c.ovnNbClient.GetLogicalSwitchPort(portName, false) if err != nil { klog.Errorf("failed to get logical switch port %s: %v", portName, err) return err @@ -507,14 +507,14 @@ func (c *Controller) reconcilePortSg(portName, securityGroups string) error { needAssociated = "true" } - if err = c.ovnClient.SetLogicalSwitchPortExternalIds(portName, map[string]string{fmt.Sprintf("associated_sg_%s", sgName): needAssociated}); err != nil { + if err = c.ovnNbClient.SetLogicalSwitchPortExternalIds(portName, map[string]string{fmt.Sprintf("associated_sg_%s", sgName): needAssociated}); err != nil { klog.Errorf("set logical switch port %s external_ids: %v", portName, err) return err } c.syncSgPortsQueue.Add(sgName) } - if err = c.ovnClient.SetLogicalSwitchPortExternalIds(portName, map[string]string{"security_groups": strings.ReplaceAll(securityGroups, ",", "/")}); err != nil { + if err = c.ovnNbClient.SetLogicalSwitchPortExternalIds(portName, map[string]string{"security_groups": strings.ReplaceAll(securityGroups, ",", "/")}); err != nil { klog.Errorf("set logical switch port %s external_ids: %v", portName, err) return err } @@ -531,7 +531,7 @@ func (c *Controller) securityGroupAllNotExist(sgs []string) (bool, error) { notExistsCount := 0 // sgs format: sg1/sg2/sg3 for _, sg := range sgs { - ok, err := c.ovnClient.PortGroupExists(ovs.GetSgPortGroupName(sg)) + ok, err := c.ovnNbClient.PortGroupExists(ovs.GetSgPortGroupName(sg)) if err != nil { klog.Error(err) return true, err diff --git a/pkg/controller/service.go b/pkg/controller/service.go index c9d7252c31d..044b91e2482 100644 --- a/pkg/controller/service.go +++ b/pkg/controller/service.go @@ -276,7 +276,7 @@ func (c *Controller) handleDeleteService(service *vpcService) error { } for _, lb := range vpcLB { - if err := c.ovnClient.LoadBalancerDeleteVip(lb, vip); err != nil { + if err := c.ovnNbClient.LoadBalancerDeleteVip(lb, vip); err != nil { klog.Errorf("failed to delete vip %s from LB %s: %v", vip, lb, err) return err } @@ -360,14 +360,14 @@ func (c *Controller) handleUpdateService(key string) error { return nil } - lb, err := c.ovnClient.GetLoadBalancer(lbName, false) + lb, err := c.ovnNbClient.GetLoadBalancer(lbName, false) if err != nil { klog.Errorf("failed to get LB %s: %v", lbName, err) return err } klog.V(3).Infof("existing vips of LB %s: %v", lbName, lb.Vips) for _, vip := range svcVips { - if err := c.ovnClient.LoadBalancerDeleteVip(oLbName, vip); err != nil { + if err := c.ovnNbClient.LoadBalancerDeleteVip(oLbName, vip); err != nil { klog.Errorf("failed to delete vip %s from LB %s: %v", vip, oLbName, err) return err } @@ -382,7 +382,7 @@ func (c *Controller) handleUpdateService(key string) error { for vip := range lb.Vips { if ip := parseVipAddr(vip); (util.ContainsString(ips, ip) && !util.IsStringIn(vip, svcVips)) || util.ContainsString(ipsToDel, ip) { klog.Infof("remove stale vip %s from LB %s", vip, lb) - if err := c.ovnClient.LoadBalancerDeleteVip(lbName, vip); err != nil { + if err := c.ovnNbClient.LoadBalancerDeleteVip(lbName, vip); err != nil { klog.Errorf("failed to delete vip %s from LB %s: %v", vip, lb, err) return err } @@ -393,7 +393,7 @@ func (c *Controller) handleUpdateService(key string) error { return nil } - oLb, err := c.ovnClient.GetLoadBalancer(oLbName, false) + oLb, err := c.ovnNbClient.GetLoadBalancer(oLbName, false) if err != nil { klog.Errorf("failed to get LB %s: %v", oLbName, err) return err @@ -402,7 +402,7 @@ func (c *Controller) handleUpdateService(key string) error { for vip := range oLb.Vips { if ip := parseVipAddr(vip); util.ContainsString(ips, ip) || util.ContainsString(ipsToDel, ip) { klog.Infof("remove stale vip %s from LB %s", vip, oLbName) - if err = c.ovnClient.LoadBalancerDeleteVip(oLbName, vip); err != nil { + if err = c.ovnNbClient.LoadBalancerDeleteVip(oLbName, vip); err != nil { klog.Errorf("failed to delete vip %s from LB %s: %v", vip, oLbName, err) return err } diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index f3893dd5f02..f02fa6cf684 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -619,7 +619,7 @@ func (c *Controller) updateSubnetDHCPOption(subnet *kubeovnv1.Subnet, needRouter } } - dhcpOptionsUUIDs, err := c.ovnClient.UpdateDHCPOptions(subnet, mtu) + dhcpOptionsUUIDs, err := c.ovnNbClient.UpdateDHCPOptions(subnet, mtu) if err != nil { klog.Errorf("failed to update dhcp options for switch %s, %v", subnet.Name, err) return err @@ -633,7 +633,7 @@ func (c *Controller) updateSubnetDHCPOption(subnet *kubeovnv1.Subnet, needRouter if needRouter { lrpName := fmt.Sprintf("%s-%s", vpc.Status.Router, subnet.Name) - if err := c.ovnClient.UpdateLogicalRouterPortRA(lrpName, subnet.Spec.IPv6RAConfigs, subnet.Spec.EnableIPv6RA); err != nil { + if err := c.ovnNbClient.UpdateLogicalRouterPortRA(lrpName, subnet.Spec.IPv6RAConfigs, subnet.Spec.EnableIPv6RA); err != nil { klog.Errorf("update ipv6 ra configs for logical router port %s, %v", lrpName, err) return err } @@ -754,19 +754,19 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { } // create or update logical switch - if err := c.ovnClient.CreateLogicalSwitch(subnet.Name, vpc.Status.Router, subnet.Spec.CIDRBlock, gateway, needRouter, randomAllocateGW); err != nil { + if err := c.ovnNbClient.CreateLogicalSwitch(subnet.Name, vpc.Status.Router, subnet.Spec.CIDRBlock, gateway, needRouter, randomAllocateGW); err != nil { klog.Errorf("create logical switch %s: %v", subnet.Name, err) return err } multicastSnoopFlag := map[string]string{"mcast_snoop": "true", "mcast_querier": "false"} if subnet.Spec.EnableMulicastSnoop { - if err := c.ovnClient.LogicalSwitchUpdateOtherConfig(subnet.Name, ovsdb.MutateOperationInsert, multicastSnoopFlag); err != nil { + if err := c.ovnNbClient.LogicalSwitchUpdateOtherConfig(subnet.Name, ovsdb.MutateOperationInsert, multicastSnoopFlag); err != nil { klog.Errorf("enable logical switch multicast snoop %s: %v", subnet.Name, err) return err } } else { - if err := c.ovnClient.LogicalSwitchUpdateOtherConfig(subnet.Name, ovsdb.MutateOperationDelete, multicastSnoopFlag); err != nil { + if err := c.ovnNbClient.LogicalSwitchUpdateOtherConfig(subnet.Name, ovsdb.MutateOperationDelete, multicastSnoopFlag); err != nil { klog.Errorf("disable logical switch multicast snoop %s: %v", subnet.Name, err) return err } @@ -789,12 +789,12 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { vpc.Status.SctpSessionLoadBalancer, } if subnet.Spec.EnableLb != nil && *subnet.Spec.EnableLb { - if err := c.ovnClient.LogicalSwitchUpdateLoadBalancers(subnet.Name, ovsdb.MutateOperationInsert, lbs...); err != nil { + if err := c.ovnNbClient.LogicalSwitchUpdateLoadBalancers(subnet.Name, ovsdb.MutateOperationInsert, lbs...); err != nil { c.patchSubnetStatus(subnet, "AddLbToLogicalSwitchFailed", err.Error()) return err } } else { - if err := c.ovnClient.LogicalSwitchUpdateLoadBalancers(subnet.Name, ovsdb.MutateOperationDelete, lbs...); err != nil { + if err := c.ovnNbClient.LogicalSwitchUpdateLoadBalancers(subnet.Name, ovsdb.MutateOperationDelete, lbs...); err != nil { klog.Error("remove load-balancer from subnet %s failed: %v", subnet.Name, err) return err } @@ -817,7 +817,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { } if subnet.Spec.Private { - if err := c.ovnClient.SetLogicalSwitchPrivate(subnet.Name, subnet.Spec.CIDRBlock, subnet.Spec.AllowSubnets); err != nil { + if err := c.ovnNbClient.SetLogicalSwitchPrivate(subnet.Name, subnet.Spec.CIDRBlock, c.config.NodeSwitchCIDR, subnet.Spec.AllowSubnets); err != nil { c.patchSubnetStatus(subnet, "SetPrivateLogicalSwitchFailed", err.Error()) return err } @@ -825,7 +825,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { c.patchSubnetStatus(subnet, "SetPrivateLogicalSwitchSuccess", "") } else { // clear acl when direction is "" - if err = c.ovnClient.DeleteAcls(subnet.Name, logicalSwitchKey, "", nil); err != nil { + if err = c.ovnNbClient.DeleteAcls(subnet.Name, logicalSwitchKey, "", nil); err != nil { c.patchSubnetStatus(subnet, "ResetLogicalSwitchAclFailed", err.Error()) return err } @@ -833,7 +833,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { c.patchSubnetStatus(subnet, "ResetLogicalSwitchAclSuccess", "") } - if err := c.ovnClient.UpdateLogicalSwitchAcl(subnet.Name, subnet.Spec.Acls); err != nil { + if err := c.ovnNbClient.UpdateLogicalSwitchAcl(subnet.Name, subnet.Spec.Acls); err != nil { c.patchSubnetStatus(subnet, "SetLogicalSwitchAclsFailed", err.Error()) return err } @@ -890,7 +890,7 @@ func (c *Controller) handleUpdateSubnetStatus(key string) error { func (c *Controller) handleDeleteLogicalSwitch(key string) (err error) { c.ipam.DeleteSubnet(key) - exist, err := c.ovnClient.LogicalSwitchExists(key) + exist, err := c.ovnNbClient.LogicalSwitchExists(key) if err != nil { klog.Errorf("check logical switch %s exist: %v", key, err) return err @@ -902,17 +902,17 @@ func (c *Controller) handleDeleteLogicalSwitch(key string) (err error) { } // clear acl when direction is "" - if err = c.ovnClient.DeleteAcls(key, logicalSwitchKey, "", nil); err != nil { + if err = c.ovnNbClient.DeleteAcls(key, logicalSwitchKey, "", nil); err != nil { klog.Errorf("clear logical switch %s acls: %v", key, err) return err } - if err = c.ovnClient.DeleteDHCPOptions(key, kubeovnv1.ProtocolDual); err != nil { + if err = c.ovnNbClient.DeleteDHCPOptions(key, kubeovnv1.ProtocolDual); err != nil { klog.Errorf("failed to delete dhcp options of logical switch %s %v", key, err) return err } - if err = c.ovnClient.DeleteLogicalSwitch(key); err != nil { + if err = c.ovnNbClient.DeleteLogicalSwitch(key); err != nil { klog.Errorf("delete logical switch %s: %v", key, err) return err } @@ -990,7 +990,7 @@ func (c *Controller) handleDeleteSubnet(subnet *kubeovnv1.Subnet) error { lspName := fmt.Sprintf("%s-%s", subnet.Name, router) lrpName := fmt.Sprintf("%s-%s", router, subnet.Name) - if err = c.ovnClient.RemoveLogicalPatchPort(lspName, lrpName); err != nil { + if err = c.ovnNbClient.RemoveLogicalPatchPort(lspName, lrpName); err != nil { klog.Errorf("delete router port %s and %s:%v", lspName, lrpName, err) return err } @@ -1065,7 +1065,7 @@ func (c *Controller) reconcileSubnet(subnet *kubeovnv1.Subnet) error { func (c *Controller) reconcileVips(subnet *kubeovnv1.Subnet) error { /* get all virtual port belongs to this logical switch */ - lsps, err := c.ovnClient.ListLogicalSwitchPorts(true, map[string]string{logicalSwitchKey: subnet.Name}, func(lsp *ovnnb.LogicalSwitchPort) bool { + lsps, err := c.ovnNbClient.ListLogicalSwitchPorts(true, map[string]string{logicalSwitchKey: subnet.Name}, func(lsp *ovnnb.LogicalSwitchPort) bool { return lsp.Type == "virtual" }) @@ -1103,14 +1103,14 @@ func (c *Controller) reconcileVips(subnet *kubeovnv1.Subnet) error { // delete old virtual ports for _, lspName := range existVips { - if err = c.ovnClient.DeleteLogicalSwitchPort(lspName); err != nil { + if err = c.ovnNbClient.DeleteLogicalSwitchPort(lspName); err != nil { klog.Errorf("delete virtual port %s lspName from logical switch %s: %v", lspName, subnet.Name, err) return err } } // add new virtual port - if err = c.ovnClient.CreateVirtualLogicalSwitchPorts(subnet.Name, newVips...); err != nil { + if err = c.ovnNbClient.CreateVirtualLogicalSwitchPorts(subnet.Name, newVips...); err != nil { klog.Errorf("create virtual port with vips %v from logical switch %s: %v", newVips, subnet.Name, err) return err } @@ -1138,7 +1138,7 @@ func (c *Controller) syncVirtualPort(key string) error { "attach-vips": "true", } - lsps, err := c.ovnClient.ListNormalLogicalSwitchPorts(true, externalIDs) + lsps, err := c.ovnNbClient.ListNormalLogicalSwitchPorts(true, externalIDs) if err != nil { klog.Errorf("list logical switch %s ports: %v", subnet.Name, err) return err @@ -1167,7 +1167,7 @@ func (c *Controller) syncVirtualPort(key string) error { continue } - if err = c.ovnClient.SetLogicalSwitchPortVirtualParents(subnet.Name, strings.Join(virtualParents, ","), vip); err != nil { + if err = c.ovnNbClient.SetLogicalSwitchPortVirtualParents(subnet.Name, strings.Join(virtualParents, ","), vip); err != nil { klog.Errorf("set vip %s virtual parents %v: %v", vip, virtualParents, err) return err } @@ -1248,7 +1248,7 @@ func (c *Controller) reconcileCustomVpcBfdStaticRoute(vpcName, subnetName string klog.Error(err) return err } - bfd, err := c.ovnClient.CreateBFD(lrpEipName, eip.Status.V4Ip, c.config.BfdMinRx, c.config.BfdMinTx, c.config.BfdDetectMult) + bfd, err := c.ovnNbClient.CreateBFD(lrpEipName, eip.Status.V4Ip, c.config.BfdMinRx, c.config.BfdMinTx, c.config.BfdDetectMult) if err != nil { klog.Error(err) return err @@ -1495,7 +1495,7 @@ func (c *Controller) reconcileDistributedSubnetRouteInDefaultVpc(subnet *kubeovn if pod.Annotations[util.NorthGatewayAnnotation] != "" { nextHop := pod.Annotations[util.NorthGatewayAnnotation] - if err := c.ovnClient.AddLogicalRouterStaticRoute( + if err := c.ovnNbClient.AddLogicalRouterStaticRoute( c.config.ClusterRouter, util.MainRouteTable, ovnnb.LogicalRouterStaticRoutePolicySrcIP, pod.Annotations[fmt.Sprintf(util.IpAddressAnnotationTemplate, podNet.ProviderName)], nil, nextHop, ); err != nil { @@ -1516,7 +1516,7 @@ func (c *Controller) reconcileDistributedSubnetRouteInDefaultVpc(subnet *kubeovn pgName := getOverlaySubnetsPortGroupName(subnet.Name, pod.Spec.NodeName) portsToAdd := make([]string, 0, len(podPorts)) for _, port := range podPorts { - exist, err := c.ovnClient.LogicalSwitchPortExists(port) + exist, err := c.ovnNbClient.LogicalSwitchPortExists(port) if err != nil { klog.Error(err) return err @@ -1530,7 +1530,7 @@ func (c *Controller) reconcileDistributedSubnetRouteInDefaultVpc(subnet *kubeovn portsToAdd = append(portsToAdd, port) } - if err = c.ovnClient.PortGroupAddPorts(pgName, portsToAdd...); err != nil { + if err = c.ovnNbClient.PortGroupAddPorts(pgName, portsToAdd...); err != nil { klog.Errorf("add ports to port group %s: %v", pgName, err) return err } @@ -1706,13 +1706,13 @@ func (c *Controller) reconcileOvnDefaultVpcRoute(subnet *kubeovnv1.Subnet) error if !subnet.Spec.LogicalGateway && subnet.Name != c.config.ExternalGatewaySwitch && !subnet.Spec.U2OInterconnection { lspName := fmt.Sprintf("%s-%s", subnet.Name, c.config.ClusterRouter) klog.Infof("delete logical switch port %s", lspName) - if err := c.ovnClient.DeleteLogicalSwitchPort(lspName); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(lspName); err != nil { klog.Errorf("failed to delete lsp %s-%s, %v", subnet.Name, c.config.ClusterRouter, err) return err } lrpName := fmt.Sprintf("%s-%s", c.config.ClusterRouter, subnet.Name) klog.Infof("delete logical router port %s", lrpName) - if err := c.ovnClient.DeleteLogicalRouterPort(lrpName); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPort(lrpName); err != nil { klog.Errorf("failed to delete lrp %s: %v", lrpName, err) return err } @@ -1826,7 +1826,7 @@ func (c *Controller) reconcileCustomVpcStaticRoute(subnet *kubeovnv1.Subnet) err func (c *Controller) deleteStaticRoute(ip, router, routeTable string) error { for _, ipStr := range strings.Split(ip, ",") { - if err := c.ovnClient.DeleteLogicalRouterStaticRoute(router, &routeTable, nil, ipStr, ""); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterStaticRoute(router, &routeTable, nil, ipStr, ""); err != nil { klog.Errorf("failed to delete static route %s, %v", ipStr, err) return err } @@ -1854,7 +1854,7 @@ func (c *Controller) reconcileVlan(subnet *kubeovnv1.Subnet) error { } localnetPort := ovs.GetLocalnetName(subnet.Name) - if err := c.ovnClient.CreateLocalnetLogicalSwitchPort(subnet.Name, localnetPort, vlan.Spec.Provider, vlan.Spec.ID); err != nil { + if err := c.ovnNbClient.CreateLocalnetLogicalSwitchPort(subnet.Name, localnetPort, vlan.Spec.Provider, vlan.Spec.ID); err != nil { klog.Errorf("create localnet port for subnet %s: %v", subnet.Name, err) return err } @@ -2247,7 +2247,7 @@ func (c *Controller) addCommonRoutesForSubnet(subnet *kubeovnv1.Subnet) error { action := ovnnb.LogicalRouterPolicyActionAllow externalIDs := map[string]string{"vendor": util.CniTypeName, "subnet": subnet.Name} klog.Infof("add policy route for router: %s, match %s, action %s, externalID %v", subnet.Spec.Vpc, match, action, externalIDs) - if err := c.ovnClient.AddLogicalRouterPolicy(subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match, action, nil, externalIDs); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match, action, nil, externalIDs); err != nil { klog.Errorf("failed to add logical router policy for CIDR %s of subnet %s: %v", cidr, subnet.Name, err) return err } @@ -2268,7 +2268,7 @@ func (c *Controller) createPortGroupForDistributedSubnet(node *v1.Node, subnet * } pgName := getOverlaySubnetsPortGroupName(subnet.Name, node.Name) - if err := c.ovnClient.CreatePortGroup(pgName, map[string]string{networkPolicyKey: subnet.Name + "/" + node.Name}); err != nil { + if err := c.ovnNbClient.CreatePortGroup(pgName, map[string]string{networkPolicyKey: subnet.Name + "/" + node.Name}); err != nil { klog.Errorf("create port group for subnet %s and node %s: %v", subnet.Name, node.Name, err) return err } @@ -2297,7 +2297,7 @@ func (c *Controller) updatePolicyRouteForCentralizedSubnet(subnetName, cidr stri externalIDs[node] = ip } klog.Infof("add policy route for router: %s, match %s, action %s, nexthops %v, extrenalID %s", c.config.ClusterRouter, match, action, nextHops, externalIDs) - if err := c.ovnClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match, action, nextHops, externalIDs); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match, action, nextHops, externalIDs); err != nil { klog.Errorf("failed to add policy route for centralized subnet %s: %v", subnetName, err) return err } @@ -2337,7 +2337,7 @@ func (c *Controller) deletePolicyRouteForCentralizedSubnet(subnet *kubeovnv1.Sub } match := fmt.Sprintf("%s.src == %s", ipSuffix, cidr) klog.Infof("delete policy route for router: %s, priority: %d, match %s", c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match) - if err := c.ovnClient.DeleteLogicalRouterPolicy(c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPolicy(c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match); err != nil { klog.Errorf("failed to delete policy route for centralized subnet %s: %v", subnet.Name, err) return err } @@ -2372,7 +2372,7 @@ func (c *Controller) addPolicyRouteForDistributedSubnet(subnet *kubeovnv1.Subnet "node": nodeName, } klog.Infof("add policy route for router: %s, match %s, action %s, extrenalID %v", c.config.ClusterRouter, match, action, externalIDs) - if err := c.ovnClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match, action, []string{nodeIP}, externalIDs); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match, action, []string{nodeIP}, externalIDs); err != nil { klog.Errorf("failed to add logical router policy for port-group address-set %s: %v", pgAs, err) return err } @@ -2390,7 +2390,7 @@ func (c *Controller) deletePolicyRouteForDistributedSubnet(subnet *kubeovnv1.Sub pgAs := fmt.Sprintf("%s_%s", pgName, ipSuffix) match := fmt.Sprintf("%s.src == $%s", ipSuffix, pgAs) klog.Infof("delete policy route for router: %s, priority: %d, match %s", c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match) - if err := c.ovnClient.DeleteLogicalRouterPolicy(c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPolicy(c.config.ClusterRouter, util.GatewayRouterPolicyPriority, match); err != nil { klog.Errorf("failed to delete policy route for subnet %s: %v", subnet.Name, err) return err } @@ -2414,7 +2414,7 @@ func (c *Controller) deletePolicyRouteByGatewayType(subnet *kubeovnv1.Subnet, ga } match := fmt.Sprintf("ip%d.dst == %s", af, cidr) klog.Infof("delete policy route for router: %s, priority: %d, match %s", c.config.ClusterRouter, util.SubnetRouterPolicyPriority, match) - if err := c.ovnClient.DeleteLogicalRouterPolicy(c.config.ClusterRouter, util.SubnetRouterPolicyPriority, match); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPolicy(c.config.ClusterRouter, util.SubnetRouterPolicyPriority, match); err != nil { klog.Errorf("failed to delete logical router policy for CIDR %s of subnet %s: %v", cidr, subnet.Name, err) return err } @@ -2431,7 +2431,7 @@ func (c *Controller) deletePolicyRouteByGatewayType(subnet *kubeovnv1.Subnet, ga } for _, node := range nodes { pgName := getOverlaySubnetsPortGroupName(subnet.Name, node.Name) - if err = c.ovnClient.DeletePortGroup(pgName); err != nil { + if err = c.ovnNbClient.DeletePortGroup(pgName); err != nil { klog.Errorf("delete port group for subnet %s and node %s: %v", subnet.Name, node.Name, err) return err } @@ -2493,25 +2493,25 @@ func (c *Controller) addPolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) err u2oExcludeIp4Ag := strings.Replace(fmt.Sprintf(util.U2OExcludeIPAg, subnet.Name, "ip4"), "-", ".", -1) u2oExcludeIp6Ag := strings.Replace(fmt.Sprintf(util.U2OExcludeIPAg, subnet.Name, "ip6"), "-", ".", -1) - if err := c.ovnClient.CreateAddressSet(u2oExcludeIp4Ag, externalIDs); err != nil { + if err := c.ovnNbClient.CreateAddressSet(u2oExcludeIp4Ag, externalIDs); err != nil { klog.Errorf("create address set %s: %v", u2oExcludeIp4Ag, err) return err } - if err := c.ovnClient.CreateAddressSet(u2oExcludeIp6Ag, externalIDs); err != nil { + if err := c.ovnNbClient.CreateAddressSet(u2oExcludeIp6Ag, externalIDs); err != nil { klog.Errorf("create address set %s: %v", u2oExcludeIp6Ag, err) return err } if len(nodesIPv4) > 0 { - if err := c.ovnClient.AddressSetUpdateAddress(u2oExcludeIp4Ag, nodesIPv4...); err != nil { + if err := c.ovnNbClient.AddressSetUpdateAddress(u2oExcludeIp4Ag, nodesIPv4...); err != nil { klog.Errorf("set v4 address set %s with address %v: %v", u2oExcludeIp4Ag, nodesIPv4, err) return err } } if len(nodesIPv6) > 0 { - if err := c.ovnClient.AddressSetUpdateAddress(u2oExcludeIp6Ag, nodesIPv6...); err != nil { + if err := c.ovnNbClient.AddressSetUpdateAddress(u2oExcludeIp6Ag, nodesIPv6...); err != nil { klog.Errorf("set v6 address set %s with address %v: %v", u2oExcludeIp6Ag, nodesIPv6, err) return err } @@ -2548,14 +2548,14 @@ func (c *Controller) addPolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) err action := ovnnb.LogicalRouterPolicyActionAllow if subnet.Spec.Vpc == c.config.ClusterRouter { klog.Infof("add u2o interconnection policy for router: %s, match %s, action %s", subnet.Spec.Vpc, match1, action) - if err := c.ovnClient.AddLogicalRouterPolicy(subnet.Spec.Vpc, util.U2OSubnetPolicyPriority, match1, action, nil, externalIDs); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(subnet.Spec.Vpc, util.U2OSubnetPolicyPriority, match1, action, nil, externalIDs); err != nil { klog.Errorf("failed to add u2o interconnection policy1 for subnet %s %v", subnet.Name, err) return err } action = ovnnb.LogicalRouterPolicyActionReroute klog.Infof("add u2o interconnection policy for router: %s, match %s, action %s", subnet.Spec.Vpc, match2, action) - if err := c.ovnClient.AddLogicalRouterPolicy(subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match2, action, []string{nextHop}, externalIDs); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match2, action, []string{nextHop}, externalIDs); err != nil { klog.Errorf("failed to add u2o interconnection policy2 for subnet %s %v", subnet.Name, err) return err } @@ -2563,7 +2563,7 @@ func (c *Controller) addPolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) err action = ovnnb.LogicalRouterPolicyActionReroute klog.Infof("add u2o interconnection policy for router: %s, match %s, action %s, nexthop %s", subnet.Spec.Vpc, match3, action, nextHop) - if err := c.ovnClient.AddLogicalRouterPolicy(subnet.Spec.Vpc, util.GatewayRouterPolicyPriority, match3, action, []string{nextHop}, externalIDs); err != nil { + if err := c.ovnNbClient.AddLogicalRouterPolicy(subnet.Spec.Vpc, util.GatewayRouterPolicyPriority, match3, action, []string{nextHop}, externalIDs); err != nil { klog.Errorf("failed to add u2o interconnection policy3 for subnet %s %v", subnet.Name, err) return err } @@ -2572,12 +2572,12 @@ func (c *Controller) addPolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) err } func (c *Controller) deletePolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) error { - logicalRouter, err := c.ovnClient.GetLogicalRouter(subnet.Spec.Vpc, true) + logicalRouter, err := c.ovnNbClient.GetLogicalRouter(subnet.Spec.Vpc, true) if err == nil && logicalRouter == nil { klog.Infof("logical router %s already deleted", subnet.Spec.Vpc) return nil } - policies, err := c.ovnClient.ListLogicalRouterPolicies(subnet.Spec.Vpc, -1, map[string]string{ + policies, err := c.ovnNbClient.ListLogicalRouterPolicies(subnet.Spec.Vpc, -1, map[string]string{ "isU2ORoutePolicy": "true", "vendor": util.CniTypeName, "subnet": subnet.Name, @@ -2598,7 +2598,7 @@ func (c *Controller) deletePolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) for _, policy := range policies { klog.Infof("delete u2o interconnection policy for router %s with match %s priority %d", lr, policy.Match, policy.Priority) - if err = c.ovnClient.DeleteLogicalRouterPolicyByUUID(lr, policy.UUID); err != nil { + if err = c.ovnNbClient.DeleteLogicalRouterPolicyByUUID(lr, policy.UUID); err != nil { klog.Errorf("failed to delete u2o interconnection policy for subnet %s: %v", subnet.Name, err) return err } @@ -2607,12 +2607,12 @@ func (c *Controller) deletePolicyRouteForU2OInterconn(subnet *kubeovnv1.Subnet) u2oExcludeIp4Ag := strings.Replace(fmt.Sprintf(util.U2OExcludeIPAg, subnet.Name, "ip4"), "-", ".", -1) u2oExcludeIp6Ag := strings.Replace(fmt.Sprintf(util.U2OExcludeIPAg, subnet.Name, "ip6"), "-", ".", -1) - if err := c.ovnClient.DeleteAddressSet(u2oExcludeIp4Ag); err != nil { + if err := c.ovnNbClient.DeleteAddressSet(u2oExcludeIp4Ag); err != nil { klog.Errorf("delete address set %s: %v", u2oExcludeIp4Ag, err) return err } - if err := c.ovnClient.DeleteAddressSet(u2oExcludeIp6Ag); err != nil { + if err := c.ovnNbClient.DeleteAddressSet(u2oExcludeIp6Ag); err != nil { klog.Errorf("delete address set %s: %v", u2oExcludeIp6Ag, err) return err } @@ -2626,7 +2626,7 @@ func (c *Controller) reconcileRouteTableForSubnet(subnet *kubeovnv1.Subnet) erro } routerPortName := ovs.LogicalRouterPortName(subnet.Spec.Vpc, subnet.Name) - lrp, err := c.ovnClient.GetLogicalRouterPort(routerPortName, false) + lrp, err := c.ovnNbClient.GetLogicalRouterPort(routerPortName, false) if err != nil { klog.Error(err) return err @@ -2641,7 +2641,7 @@ func (c *Controller) reconcileRouteTableForSubnet(subnet *kubeovnv1.Subnet) erro klog.Infof("reconcile route table %q for subnet %s", subnet.Spec.RouteTable, subnet.Name) opt := map[string]string{"route_table": subnet.Spec.RouteTable} - if err = c.ovnClient.UpdateLogicalRouterPortOptions(routerPortName, opt); err != nil { + if err = c.ovnNbClient.UpdateLogicalRouterPortOptions(routerPortName, opt); err != nil { klog.Errorf("failed to set route table of logical router port %s to %s: %v", routerPortName, subnet.Spec.RouteTable, err) return err } @@ -2654,7 +2654,7 @@ func (c *Controller) addCustomVPCPolicyRoutesForSubnet(subnet *kubeovnv1.Subnet) } func (c *Controller) deleteCustomVPCPolicyRoutesForSubnet(subnet *kubeovnv1.Subnet) error { - logicalRouter, err := c.ovnClient.GetLogicalRouter(subnet.Spec.Vpc, true) + logicalRouter, err := c.ovnNbClient.GetLogicalRouter(subnet.Spec.Vpc, true) if err == nil && logicalRouter == nil { klog.Infof("logical router %s already deleted", subnet.Spec.Vpc) return nil @@ -2666,7 +2666,7 @@ func (c *Controller) deleteCustomVPCPolicyRoutesForSubnet(subnet *kubeovnv1.Subn } match := fmt.Sprintf("ip%d.dst == %s", af, cidr) klog.Infof("delete policy route for router: %s, priority: %d, match %s", subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match) - if err := c.ovnClient.DeleteLogicalRouterPolicy(subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPolicy(subnet.Spec.Vpc, util.SubnetRouterPolicyPriority, match); err != nil { klog.Errorf("failed to delete logical router policy for CIDR %s of subnet %s: %v", cidr, subnet.Name, err) return err } @@ -2681,12 +2681,12 @@ func (c *Controller) clearOldU2OResource(subnet *kubeovnv1.Subnet) error { lspName := fmt.Sprintf("%s-%s", subnet.Name, subnet.Status.U2OInterconnectionVPC) lrpName := fmt.Sprintf("%s-%s", subnet.Status.U2OInterconnectionVPC, subnet.Name) klog.Infof("clean subnet %s old u2o resource with lsp %s lrp %s ", subnet.Name, lspName, lrpName) - if err := c.ovnClient.DeleteLogicalSwitchPort(lspName); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(lspName); err != nil { klog.Errorf("failed to delete u2o logical switch port %s: %v", lspName, err) return err } - if err := c.ovnClient.DeleteLogicalRouterPort(lrpName); err != nil { + if err := c.ovnNbClient.DeleteLogicalRouterPort(lrpName); err != nil { klog.Errorf("failed to delete u2o logical router port %s: %v", lrpName, err) return err } diff --git a/pkg/controller/vip.go b/pkg/controller/vip.go index 68d5b01cb43..3c4b987c508 100644 --- a/pkg/controller/vip.go +++ b/pkg/controller/vip.go @@ -207,7 +207,7 @@ func (c *Controller) handleAddVirtualIp(key string) error { // create a lsp use subnet gw mac, and set it option as arp_proxy lrpName := fmt.Sprintf("%s-%s", subnet.Spec.Vpc, subnet.Name) klog.Infof("get logical router port %s", lrpName) - lrp, err := c.ovnClient.GetLogicalRouterPort(lrpName, false) + lrp, err := c.ovnNbClient.GetLogicalRouterPort(lrpName, false) if err != nil { klog.Errorf("failed to get lrp %s: %v", lrpName, err) return err @@ -219,12 +219,12 @@ func (c *Controller) handleAddVirtualIp(key string) error { } mac = lrp.MAC ipStr := util.GetStringIP(v4ip, v6ip) - if err := c.ovnClient.CreateLogicalSwitchPort(subnet.Name, portName, ipStr, mac, vip.Name, vip.Spec.Namespace, false, "", "", false, nil, subnet.Spec.Vpc); err != nil { + if err := c.ovnNbClient.CreateLogicalSwitchPort(subnet.Name, portName, ipStr, mac, vip.Name, vip.Spec.Namespace, false, "", "", false, nil, subnet.Spec.Vpc); err != nil { err = fmt.Errorf("failed to create lsp %s: %v", portName, err) klog.Error(err) return err } - if err := c.ovnClient.SetLogicalSwitchPortArpProxy(portName, true); err != nil { + if err := c.ovnNbClient.SetLogicalSwitchPortArpProxy(portName, true); err != nil { err = fmt.Errorf("failed to enable lsp arp proxy for vip %s: %v", portName, err) klog.Error(err) return err @@ -308,7 +308,7 @@ func (c *Controller) handleDelVirtualIp(vip *kubeovnv1.Vip) error { } portName := ovs.PodNameToPortName(vip.Name, vip.Spec.Namespace, subnet.Spec.Provider) klog.Infof("delete vip arp proxy lsp %s", portName) - if err := c.ovnClient.DeleteLogicalSwitchPort(portName); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(portName); err != nil { err = fmt.Errorf("failed to delete lsp %s: %v", vip.Name, err) klog.Error(err) return err diff --git a/pkg/controller/vlan.go b/pkg/controller/vlan.go index 00d0e7f32c9..a24c206c18a 100644 --- a/pkg/controller/vlan.go +++ b/pkg/controller/vlan.go @@ -318,7 +318,7 @@ func (c *Controller) updateProviderNetworkStatusForVlanDeletion(pn *kubeovnv1.Pr func (c *Controller) setLocalnetTag(subnet string, vlanID int) error { localnetPort := ovs.GetLocalnetName(subnet) - if err := c.ovnClient.SetLogicalSwitchPortVlanTag(localnetPort, vlanID); err != nil { + if err := c.ovnNbClient.SetLogicalSwitchPortVlanTag(localnetPort, vlanID); err != nil { klog.Errorf("set localnet port %s vlan tag %d: %v", localnetPort, vlanID, err) return err } @@ -328,7 +328,7 @@ func (c *Controller) setLocalnetTag(subnet string, vlanID int) error { func (c *Controller) delLocalnet(subnet string) error { localnetPort := ovs.GetLocalnetName(subnet) - if err := c.ovnClient.DeleteLogicalSwitchPort(localnetPort); err != nil { + if err := c.ovnNbClient.DeleteLogicalSwitchPort(localnetPort); err != nil { klog.Errorf("delete localnet port %s: %v", localnetPort, err) return err } diff --git a/pkg/controller/vpc.go b/pkg/controller/vpc.go index 422e1c75945..553991c41c2 100644 --- a/pkg/controller/vpc.go +++ b/pkg/controller/vpc.go @@ -256,14 +256,14 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { } newPeers = append(newPeers, peering.RemoteVpc) - if err := c.ovnClient.CreatePeerRouterPort(vpc.Name, peering.RemoteVpc, peering.LocalConnectIP); err != nil { + if err := c.ovnNbClient.CreatePeerRouterPort(vpc.Name, peering.RemoteVpc, peering.LocalConnectIP); err != nil { klog.Errorf("create peer router port for vpc %s, %v", vpc.Name, err) return err } } for _, oldPeer := range vpc.Status.VpcPeerings { if !util.ContainsString(newPeers, oldPeer) { - if err = c.ovnClient.DeleteLogicalRouterPort(fmt.Sprintf("%s-%s", vpc.Name, oldPeer)); err != nil { + if err = c.ovnNbClient.DeleteLogicalRouterPort(fmt.Sprintf("%s-%s", vpc.Name, oldPeer)); err != nil { klog.Errorf("delete peer router port for vpc %s, %v", vpc.Name, err) return err } @@ -271,7 +271,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { } // handle static route - existRoute, err := c.ovnClient.ListLogicalRouterStaticRoutes(vpc.Name, nil, nil, "", nil) + existRoute, err := c.ovnNbClient.ListLogicalRouterStaticRoutes(vpc.Name, nil, nil, "", nil) if err != nil { klog.Errorf("failed to get vpc %s static route list, %v", vpc.Name, err) return err @@ -332,14 +332,14 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { nextHop = strings.Split(nextHop, "/")[0] } - lr, err := c.ovnClient.GetLogicalRouter(vpc.Name, false) + lr, err := c.ovnNbClient.GetLogicalRouter(vpc.Name, false) if err != nil { klog.Errorf("failed to get logical router %s: %v", vpc.Name, err) return err } for _, nat := range lr.Nat { - info, err := c.ovnClient.GetNATByUUID(nat) + info, err := c.ovnNbClient.GetNATByUUID(nat) if err != nil { klog.Errorf("failed to get nat ip info for vpc %s, %v", vpc.Name, err) return err @@ -367,7 +367,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { for _, item := range routeNeedDel { klog.Infof("vpc %s del static route: %v", vpc.Name, item) policy := convertPolicy(item.Policy) - if err = c.ovnClient.DeleteLogicalRouterStaticRoute(vpc.Name, &item.RouteTable, &policy, item.CIDR, item.NextHopIP); err != nil { + if err = c.ovnNbClient.DeleteLogicalRouterStaticRoute(vpc.Name, &item.RouteTable, &policy, item.CIDR, item.NextHopIP); err != nil { klog.Errorf("del vpc %s static route failed, %v", vpc.Name, err) return err } @@ -376,7 +376,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { for _, item := range routeNeedAdd { if item.BfdId != "" { klog.Infof("vpc %s add static ecmp route: %+v", vpc.Name, item) - if err = c.ovnClient.AddLogicalRouterStaticRoute( + if err = c.ovnNbClient.AddLogicalRouterStaticRoute( vpc.Name, item.RouteTable, convertPolicy(item.Policy), item.CIDR, &item.BfdId, item.NextHopIP, ); err != nil { klog.Errorf("failed to add bfd static route to vpc %s , %v", vpc.Name, err) @@ -384,7 +384,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { } } else { klog.Infof("vpc %s add static route: %+v", vpc.Name, item) - if err = c.ovnClient.AddLogicalRouterStaticRoute( + if err = c.ovnNbClient.AddLogicalRouterStaticRoute( vpc.Name, item.RouteTable, convertPolicy(item.Policy), item.CIDR, nil, item.NextHopIP, ); err != nil { klog.Errorf("failed to add normal static route to vpc %s , %v", vpc.Name, err) @@ -395,7 +395,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { if vpc.Name != c.config.ClusterRouter && vpc.Spec.PolicyRoutes == nil { // do not clean default vpc policy routes - if err = c.ovnClient.ClearLogicalRouterPolicy(vpc.Name); err != nil { + if err = c.ovnNbClient.ClearLogicalRouterPolicy(vpc.Name); err != nil { klog.Errorf("clean all vpc %s policy route failed, %v", vpc.Name, err) return err } @@ -403,7 +403,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { if vpc.Spec.PolicyRoutes != nil { // diff update vpc policy route - policyList, err := c.ovnClient.ListLogicalRouterPolicies(vpc.Name, -1, nil) + policyList, err := c.ovnNbClient.ListLogicalRouterPolicies(vpc.Name, -1, nil) if err != nil { klog.Errorf("failed to get vpc %s policy route list, %v", vpc.Name, err) return err @@ -415,7 +415,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { } for _, item := range policyRouteNeedDel { klog.Infof("delete policy route for router: %s, priority: %d, match %s", vpc.Name, item.Priority, item.Match) - if err = c.ovnClient.DeleteLogicalRouterPolicy(vpc.Name, item.Priority, item.Match); err != nil { + if err = c.ovnNbClient.DeleteLogicalRouterPolicy(vpc.Name, item.Priority, item.Match); err != nil { klog.Errorf("del vpc %s policy route failed, %v", vpc.Name, err) return err } @@ -423,7 +423,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { for _, item := range policyRouteNeedAdd { externalIDs := map[string]string{"vendor": util.CniTypeName} klog.Infof("add policy route for router: %s, match %s, action %s, nexthop %s, externalID %v", c.config.ClusterRouter, item.Match, string(item.Action), item.NextHopIP, externalIDs) - if err = c.ovnClient.AddLogicalRouterPolicy(vpc.Name, item.Priority, item.Match, string(item.Action), []string{item.NextHopIP}, externalIDs); err != nil { + if err = c.ovnNbClient.AddLogicalRouterPolicy(vpc.Name, item.Priority, item.Match, string(item.Action), []string{item.NextHopIP}, externalIDs); err != nil { klog.Errorf("add policy route to vpc %s failed, %v", vpc.Name, err) return err } @@ -506,7 +506,7 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error { if !cachedVpc.Spec.EnableBfd && cachedVpc.Status.EnableBfd { lrpEipName := fmt.Sprintf("%s-%s", key, c.config.ExternalGatewaySwitch) - if err := c.ovnClient.DeleteBFD(lrpEipName, ""); err != nil { + if err := c.ovnNbClient.DeleteBFD(lrpEipName, ""); err != nil { klog.Error(err) return err } @@ -777,12 +777,12 @@ func (c *Controller) getVpcSubnets(vpc *kubeovnv1.Vpc) (subnets []string, defaul // createVpcRouter create router to connect logical switches in vpc func (c *Controller) createVpcRouter(lr string) error { - return c.ovnClient.CreateLogicalRouter(lr) + return c.ovnNbClient.CreateLogicalRouter(lr) } // deleteVpcRouter delete router to connect logical switches in vpc func (c *Controller) deleteVpcRouter(lr string) error { - return c.ovnClient.DeleteLogicalRouter(lr) + return c.ovnNbClient.DeleteLogicalRouter(lr) } func (c *Controller) handleAddVpcExternal(key string) error { @@ -844,7 +844,7 @@ func (c *Controller) handleAddVpcExternal(key string) error { lspName := fmt.Sprintf("%s-%s", c.config.ExternalGatewaySwitch, key) lrpName := fmt.Sprintf("%s-%s", key, c.config.ExternalGatewaySwitch) - if err := c.ovnClient.CreateLogicalPatchPort(c.config.ExternalGatewaySwitch, key, lspName, lrpName, v4ipCidr, mac, chassises...); err != nil { + if err := c.ovnNbClient.CreateLogicalPatchPort(c.config.ExternalGatewaySwitch, key, lspName, lrpName, v4ipCidr, mac, chassises...); err != nil { klog.Errorf("failed to connect router '%s' to external: %v", key, err) return err } @@ -914,7 +914,7 @@ func (c *Controller) handleDelVpcExternal(key string) error { lspName := fmt.Sprintf("%s-%s", c.config.ExternalGatewaySwitch, key) lrpName := fmt.Sprintf("%s-%s", key, c.config.ExternalGatewaySwitch) klog.V(3).Infof("delete vpc lrp %s", lrpName) - if err := c.ovnClient.RemoveLogicalPatchPort(lspName, lrpName); err != nil { + if err := c.ovnNbClient.RemoveLogicalPatchPort(lspName, lrpName); err != nil { klog.Errorf("failed to disconnect router '%s' to external, %v", key, err) return err } @@ -925,7 +925,7 @@ func (c *Controller) handleDelVpcExternal(key string) error { return err } } - if err := c.ovnClient.DeleteBFD(lrpName, ""); err != nil { + if err := c.ovnNbClient.DeleteBFD(lrpName, ""); err != nil { klog.Error(err) return err } diff --git a/pkg/ovs/interface.go b/pkg/ovs/interface.go index c8eded24184..0d8e28f4401 100644 --- a/pkg/ovs/interface.go +++ b/pkg/ovs/interface.go @@ -7,6 +7,7 @@ import ( kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnnb" + "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnsb" "github.com/kubeovn/kube-ovn/pkg/util" ) @@ -108,7 +109,7 @@ type ACL interface { UpdateSgAcl(sg *kubeovnv1.SecurityGroup, direction string) error UpdateLogicalSwitchAcl(lsName string, subnetAcls []kubeovnv1.Acl) error SetAclLog(pgName, protocol string, logEnable, isIngress bool) error - SetLogicalSwitchPrivate(lsName, cidrBlock string, allowSubnets []string) error + SetLogicalSwitchPrivate(lsName, cidrBlock, nodeSwitchCIDR string, allowSubnets []string) error DeleteAcls(parentName, parentType string, direction string, externalIDs map[string]string) error DeleteAclsOps(parentName, parentType string, direction string, externalIDs map[string]string) ([]ovsdb.Operation, error) } @@ -159,12 +160,11 @@ type DHCPOptions interface { ListDHCPOptions(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.DHCPOptions, error) } -type OvnClient interface { +type NbClient interface { ACL AddressSet BFD DHCPOptions - // GatewayChassis LoadBalancer LogicalRouterPolicy LogicalRouterPort @@ -180,6 +180,27 @@ type OvnClient interface { RemoveLogicalPatchPort(lspName, lrpName string) error DeleteLogicalGatewaySwitch(lsName, lrName string) error DeleteSecurityGroup(sgName string) error - GetEntityInfo(entity interface{}) error + Common +} + +type SbClient interface { + Chassis + Common +} + +type Common interface { Transact(method string, operations []ovsdb.Operation) error + GetEntityInfo(entity interface{}) error +} + +type Chassis interface { + DeleteChassis(chassisName string) error + DeleteChassisByHost(node string) error + GetAllChassisByHost(nodeName string) (*[]ovnsb.Chassis, error) + GetChassisByHost(nodeName string) (*ovnsb.Chassis, error) + GetChassis(chassisName string, ignoreNotFound bool) (*ovnsb.Chassis, error) + GetKubeOvnChassisses() (*[]ovnsb.Chassis, error) + UpdateChassisTag(chassisName string, nodeName string) error + UpdateChassis(chassis *ovnsb.Chassis, fields ...interface{}) error + ListChassis() (*[]ovnsb.Chassis, error) } diff --git a/pkg/ovs/ovn-nb-acl.go b/pkg/ovs/ovn-nb-acl.go index 3ef0b5b658b..dc66cc90260 100644 --- a/pkg/ovs/ovn-nb-acl.go +++ b/pkg/ovs/ovn-nb-acl.go @@ -19,7 +19,7 @@ import ( ) // UpdateIngressAclOps return operation that creates an ingress ACL -func (c *ovnClient) UpdateIngressAclOps(pgName, asIngressName, asExceptName, protocol string, npp []netv1.NetworkPolicyPort, logEnable bool, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) UpdateIngressAclOps(pgName, asIngressName, asExceptName, protocol string, npp []netv1.NetworkPolicyPort, logEnable bool, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error) { acls := make([]*ovnnb.ACL, 0) ipSuffix := "ip4" @@ -66,7 +66,7 @@ func (c *ovnClient) UpdateIngressAclOps(pgName, asIngressName, asExceptName, pro } // UpdateEgressAclOps return operation that creates an egress ACL -func (c *ovnClient) UpdateEgressAclOps(pgName, asEgressName, asExceptName, protocol string, npp []netv1.NetworkPolicyPort, logEnable bool, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) UpdateEgressAclOps(pgName, asEgressName, asExceptName, protocol string, npp []netv1.NetworkPolicyPort, logEnable bool, namedPortMap map[string]*util.NamedPortInfo) ([]ovsdb.Operation, error) { acls := make([]*ovnnb.ACL, 0) ipSuffix := "ip4" @@ -126,7 +126,7 @@ func (c *ovnClient) UpdateEgressAclOps(pgName, asEgressName, asExceptName, proto } // CreateGatewayACL create allow acl for subnet gateway -func (c *ovnClient) CreateGatewayAcl(lsName, pgName, gateway string) error { +func (c *ovnNbClient) CreateGatewayAcl(lsName, pgName, gateway string) error { acls := make([]*ovnnb.ACL, 0) var parentName, parentType string @@ -186,7 +186,7 @@ func (c *ovnClient) CreateGatewayAcl(lsName, pgName, gateway string) error { } // CreateNodeAcl create allow acl for node join ip -func (c *ovnClient) CreateNodeAcl(pgName, nodeIpStr, joinIpStr string) error { +func (c *ovnNbClient) CreateNodeAcl(pgName, nodeIpStr, joinIpStr string) error { acls := make([]*ovnnb.ACL, 0) nodeIPs := strings.Split(nodeIpStr, ",") for _, nodeIP := range nodeIPs { @@ -250,7 +250,7 @@ func (c *ovnClient) CreateNodeAcl(pgName, nodeIpStr, joinIpStr string) error { return nil } -func (c *ovnClient) CreateSgDenyAllAcl(sgName string) error { +func (c *ovnNbClient) CreateSgDenyAllAcl(sgName string) error { pgName := GetSgPortGroupName(sgName) ingressAcl, err := c.newAcl(pgName, ovnnb.ACLDirectionToLport, util.SecurityGroupDropPriority, fmt.Sprintf("outport == @%s && ip", pgName), ovnnb.ACLActionDrop) @@ -272,7 +272,7 @@ func (c *ovnClient) CreateSgDenyAllAcl(sgName string) error { return nil } -func (c *ovnClient) CreateSgBaseACL(sgName string, direction string) error { +func (c *ovnNbClient) CreateSgBaseACL(sgName string, direction string) error { pgName := GetSgPortGroupName(sgName) // ingress rule @@ -338,7 +338,7 @@ func (c *ovnClient) CreateSgBaseACL(sgName string, direction string) error { return nil } -func (c *ovnClient) UpdateSgAcl(sg *kubeovnv1.SecurityGroup, direction string) error { +func (c *ovnNbClient) UpdateSgAcl(sg *kubeovnv1.SecurityGroup, direction string) error { pgName := GetSgPortGroupName(sg.Name) // clear acl @@ -396,7 +396,7 @@ func (c *ovnClient) UpdateSgAcl(sg *kubeovnv1.SecurityGroup, direction string) e return nil } -func (c *ovnClient) UpdateLogicalSwitchAcl(lsName string, subnetAcls []kubeovnv1.Acl) error { +func (c *ovnNbClient) UpdateLogicalSwitchAcl(lsName string, subnetAcls []kubeovnv1.Acl) error { if err := c.DeleteAcls(lsName, logicalSwitchKey, "", map[string]string{"subnet": lsName}); err != nil { return fmt.Errorf("delete subnet acls from %s: %v", lsName, err) } @@ -431,7 +431,7 @@ func (c *ovnClient) UpdateLogicalSwitchAcl(lsName string, subnetAcls []kubeovnv1 } // UpdateAcl update acl -func (c *ovnClient) UpdateAcl(acl *ovnnb.ACL, fields ...interface{}) error { +func (c *ovnNbClient) UpdateAcl(acl *ovnnb.ACL, fields ...interface{}) error { if acl == nil { return fmt.Errorf("address_set is nil") } @@ -450,7 +450,7 @@ func (c *ovnClient) UpdateAcl(acl *ovnnb.ACL, fields ...interface{}) error { } // SetLogicalSwitchPrivate will drop all ingress traffic except allow subnets, same subnet and node subnet -func (c *ovnClient) SetLogicalSwitchPrivate(lsName, cidrBlock string, allowSubnets []string) error { +func (c *ovnNbClient) SetLogicalSwitchPrivate(lsName, cidrBlock, nodeSwitchCIDR string, allowSubnets []string) error { // clear acls if err := c.DeleteAcls(lsName, logicalSwitchKey, "", nil); err != nil { return fmt.Errorf("clear logical switch %s acls: %v", lsName, err) @@ -476,7 +476,7 @@ func (c *ovnClient) SetLogicalSwitchPrivate(lsName, cidrBlock string, allowSubne acls = append(acls, defaultDropAcl) nodeSubnetAclFunc := func(protocol, ipSuffix string) error { - for _, nodeCidr := range strings.Split(c.NodeSwitchCIDR, ",") { + for _, nodeCidr := range strings.Split(nodeSwitchCIDR, ",") { // skip different address family if protocol != util.CheckProtocol(nodeCidr) { continue @@ -574,7 +574,7 @@ func (c *ovnClient) SetLogicalSwitchPrivate(lsName, cidrBlock string, allowSubne return nil } -func (c *ovnClient) SetAclLog(pgName, protocol string, logEnable, isIngress bool) error { +func (c *ovnNbClient) SetAclLog(pgName, protocol string, logEnable, isIngress bool) error { direction := ovnnb.ACLDirectionToLport portDirection := "outport" if !isIngress { @@ -616,7 +616,7 @@ func (c *ovnClient) SetAclLog(pgName, protocol string, logEnable, isIngress bool // CreateAcls create several acl once // parentType is 'ls' or 'pg' -func (c *ovnClient) CreateAcls(parentName, parentType string, acls ...*ovnnb.ACL) error { +func (c *ovnNbClient) CreateAcls(parentName, parentType string, acls ...*ovnnb.ACL) error { ops, err := c.CreateAclsOps(parentName, parentType, acls...) if err != nil { klog.Error(err) @@ -630,14 +630,14 @@ func (c *ovnClient) CreateAcls(parentName, parentType string, acls ...*ovnnb.ACL return nil } -func (c *ovnClient) CreateBareAcl(parentName, direction, priority, match, action string) error { +func (c *ovnNbClient) CreateBareAcl(parentName, direction, priority, match, action string) error { acl, err := c.newAcl(parentName, direction, priority, match, action) if err != nil { klog.Error(err) return fmt.Errorf("new acl direction %s priority %s match %s action %s: %v", direction, priority, match, action, err) } - op, err := c.ovnNbClient.Create(acl) + op, err := c.ovsDbClient.Create(acl) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for creating acl direction %s priority %s match %s action %s: %v", direction, priority, match, action, err) @@ -653,7 +653,7 @@ func (c *ovnClient) CreateBareAcl(parentName, direction, priority, match, action // DeleteAcls delete several acl once, // delete to-lport and from-lport direction acl when direction is empty, otherwise one-way // parentType is 'ls' or 'pg' -func (c *ovnClient) DeleteAcls(parentName, parentType string, direction string, externalIDs map[string]string) error { +func (c *ovnNbClient) DeleteAcls(parentName, parentType string, direction string, externalIDs map[string]string) error { ops, err := c.DeleteAclsOps(parentName, parentType, direction, externalIDs) if err != nil { klog.Error(err) @@ -667,7 +667,7 @@ func (c *ovnClient) DeleteAcls(parentName, parentType string, direction string, return nil } -func (c *ovnClient) DeleteAcl(parentName, parentType, direction, priority, match string) error { +func (c *ovnNbClient) DeleteAcl(parentName, parentType, direction, priority, match string) error { acl, err := c.GetAcl(parentName, direction, priority, match, true) if err != nil { klog.Error(err) @@ -704,7 +704,7 @@ func (c *ovnClient) DeleteAcl(parentName, parentType, direction, priority, match // GetAcl get acl by direction, priority and match, // be consistent with ovn-nbctl which direction, priority and match determine one acl in port group or logical switch -func (c *ovnClient) GetAcl(parent, direction, priority, match string, ignoreNotFound bool) (*ovnnb.ACL, error) { +func (c *ovnNbClient) GetAcl(parent, direction, priority, match string, ignoreNotFound bool) (*ovnnb.ACL, error) { // this is necessary because may exist same direction, priority and match acl in different port group or logical switch if len(parent) == 0 { return nil, fmt.Errorf("the parent name is required") @@ -716,7 +716,7 @@ func (c *ovnClient) GetAcl(parent, direction, priority, match string, ignoreNotF intPriority, _ := strconv.Atoi(priority) aclList := make([]ovnnb.ACL, 0) - if err := c.ovnNbClient.WhereCache(func(acl *ovnnb.ACL) bool { + if err := c.ovsDbClient.WhereCache(func(acl *ovnnb.ACL) bool { return len(acl.ExternalIDs) != 0 && acl.ExternalIDs[aclParentKey] == parent && acl.Direction == direction && acl.Priority == intPriority && acl.Match == match }).List(ctx, &aclList); err != nil { return nil, fmt.Errorf("get acl with 'parent %s direction %s priority %s match %s': %v", parent, direction, priority, match, err) @@ -742,7 +742,7 @@ func (c *ovnClient) GetAcl(parent, direction, priority, match string, ignoreNotF // result should include all acls when externalIDs is empty, // result should include all acls which externalIDs[key] is not empty when externalIDs[key] is "" // TODO: maybe add other filter conditions(priority or match) -func (c *ovnClient) ListAcls(direction string, externalIDs map[string]string) ([]ovnnb.ACL, error) { +func (c *ovnNbClient) ListAcls(direction string, externalIDs map[string]string) ([]ovnnb.ACL, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -756,13 +756,13 @@ func (c *ovnClient) ListAcls(direction string, externalIDs map[string]string) ([ return aclList, nil } -func (c *ovnClient) AclExists(parent, direction, priority, match string) (bool, error) { +func (c *ovnNbClient) AclExists(parent, direction, priority, match string) (bool, error) { acl, err := c.GetAcl(parent, direction, priority, match, true) return acl != nil, err } // newAcl return acl with basic information -func (c *ovnClient) newAcl(parent, direction, priority, match, action string, options ...func(acl *ovnnb.ACL)) (*ovnnb.ACL, error) { +func (c *ovnNbClient) newAcl(parent, direction, priority, match, action string, options ...func(acl *ovnnb.ACL)) (*ovnnb.ACL, error) { if len(parent) == 0 { return nil, fmt.Errorf("the parent name is required") } @@ -805,7 +805,7 @@ func (c *ovnClient) newAcl(parent, direction, priority, match, action string, op // newAclWithoutCheck return acl with basic information without check acl exists, // this would cause duplicated acl, so don't use this function to create acl normally, // but maybe used for updating network policy acl -func (c *ovnClient) newAclWithoutCheck(parent, direction, priority, match, action string, options ...func(acl *ovnnb.ACL)) (*ovnnb.ACL, error) { +func (c *ovnNbClient) newAclWithoutCheck(parent, direction, priority, match, action string, options ...func(acl *ovnnb.ACL)) (*ovnnb.ACL, error) { if len(parent) == 0 { return nil, fmt.Errorf("the parent name is required") } @@ -835,7 +835,7 @@ func (c *ovnClient) newAclWithoutCheck(parent, direction, priority, match, actio } // createSgRuleACL create security group rule acl -func (c *ovnClient) newSgRuleACL(sgName string, direction string, rule *kubeovnv1.SgRule) (*ovnnb.ACL, error) { +func (c *ovnNbClient) newSgRuleACL(sgName string, direction string, rule *kubeovnv1.SgRule) (*ovnnb.ACL, error) { ipSuffix := "ip4" if rule.IPVersion == "ipv6" { ipSuffix = "ip6" @@ -1044,7 +1044,7 @@ func aclFilter(direction string, externalIDs map[string]string) func(acl *ovnnb. // CreateAcls return operations which create several acl once // parentType is 'ls' or 'pg' -func (c *ovnClient) CreateAclsOps(parentName, parentType string, acls ...*ovnnb.ACL) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) CreateAclsOps(parentName, parentType string, acls ...*ovnnb.ACL) ([]ovsdb.Operation, error) { if parentType != portGroupKey && parentType != logicalSwitchKey { return nil, fmt.Errorf("acl parent type must be '%s' or '%s'", portGroupKey, logicalSwitchKey) } @@ -1062,7 +1062,7 @@ func (c *ovnClient) CreateAclsOps(parentName, parentType string, acls ...*ovnnb. } } - createAclsOp, err := c.ovnNbClient.Create(models...) + createAclsOp, err := c.ovsDbClient.Create(models...) if err != nil { klog.Error(err) return nil, fmt.Errorf("generate operations for creating acls: %v", err) @@ -1093,7 +1093,7 @@ func (c *ovnClient) CreateAclsOps(parentName, parentType string, acls ...*ovnnb. // DeleteAcls return operation which delete several acl once, // delete to-lport and from-lport direction acl when direction is empty, otherwise one-way // parentType is 'ls' or 'pg' -func (c *ovnClient) DeleteAclsOps(parentName, parentType string, direction string, externalIDs map[string]string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) DeleteAclsOps(parentName, parentType string, direction string, externalIDs map[string]string) ([]ovsdb.Operation, error) { if externalIDs == nil { externalIDs = make(map[string]string) } diff --git a/pkg/ovs/ovn-nb-acl_test.go b/pkg/ovs/ovn-nb-acl_test.go index c6155714160..069e43e4bc7 100644 --- a/pkg/ovs/ovn-nb-acl_test.go +++ b/pkg/ovs/ovn-nb-acl_test.go @@ -741,6 +741,7 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPrivate() { ovnClient := suite.ovnClient + nodeSwitchCidrBlock := "100.64.0.0/16,fd00:100:64::/112" cidrBlock := "10.244.0.0/16,fc00::af4:0/112" allowSubnets := []string{ "10.230.0.0/16", @@ -757,7 +758,7 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPrivate() { err := ovnClient.CreateBareLogicalSwitch(lsName) require.NoError(t, err) - err = ovnClient.SetLogicalSwitchPrivate(lsName, cidrBlock, allowSubnets) + err = ovnClient.SetLogicalSwitchPrivate(lsName, cidrBlock, nodeSwitchCidrBlock, allowSubnets) require.NoError(t, err) ls, err := ovnClient.GetLogicalSwitch(lsName, false) @@ -804,7 +805,7 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPrivate() { } // node subnet acl - for _, cidr := range strings.Split(ovnClient.NodeSwitchCIDR, ",") { + for _, cidr := range strings.Split(nodeSwitchCidrBlock, ",") { protocol := util.CheckProtocol(cidr) match := fmt.Sprintf(`ip4.src == %s`, cidr) @@ -826,7 +827,7 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPrivate() { require.NoError(t, err) cidrBlock := "10.244.0.0/16" - err = ovnClient.SetLogicalSwitchPrivate(lsName, cidrBlock, allowSubnets) + err = ovnClient.SetLogicalSwitchPrivate(lsName, cidrBlock, nodeSwitchCidrBlock, allowSubnets) require.NoError(t, err) ls, err := ovnClient.GetLogicalSwitch(lsName, false) @@ -873,7 +874,7 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPrivate() { } // node subnet acl - for _, cidr := range strings.Split(ovnClient.NodeSwitchCIDR, ",") { + for _, cidr := range strings.Split(nodeSwitchCidrBlock, ",") { protocol := util.CheckProtocol(cidr) match := fmt.Sprintf(`ip4.src == %s`, cidr) diff --git a/pkg/ovs/ovn-nb-address_set.go b/pkg/ovs/ovn-nb-address_set.go index c06cf51a0b1..afbf3076f3a 100644 --- a/pkg/ovs/ovn-nb-address_set.go +++ b/pkg/ovs/ovn-nb-address_set.go @@ -14,7 +14,7 @@ import ( ) // CreateAddressSet create address set with external ids -func (c *ovnClient) CreateAddressSet(asName string, externalIDs map[string]string) error { +func (c *ovnNbClient) CreateAddressSet(asName string, externalIDs map[string]string) error { // ovn acl doesn't support address_set name with '-' if matched := matchAddressSetName(asName); !matched { return fmt.Errorf("address set %s must match `[a-zA-Z_.][a-zA-Z_.0-9]*`", asName) @@ -36,7 +36,7 @@ func (c *ovnClient) CreateAddressSet(asName string, externalIDs map[string]strin ExternalIDs: externalIDs, } - ops, err := c.ovnNbClient.Create(as) + ops, err := c.ovsDbClient.Create(as) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for creating address set %s: %v", asName, err) @@ -51,7 +51,7 @@ func (c *ovnClient) CreateAddressSet(asName string, externalIDs map[string]strin // AddressSetUpdateAddress update addresses, // clear addresses when addresses is empty -func (c *ovnClient) AddressSetUpdateAddress(asName string, addresses ...string) error { +func (c *ovnNbClient) AddressSetUpdateAddress(asName string, addresses ...string) error { as, err := c.GetAddressSet(asName, false) if err != nil { klog.Error(err) @@ -84,7 +84,7 @@ func (c *ovnClient) AddressSetUpdateAddress(asName string, addresses ...string) } // UpdateAddressSet update address set -func (c *ovnClient) UpdateAddressSet(as *ovnnb.AddressSet, fields ...interface{}) error { +func (c *ovnNbClient) UpdateAddressSet(as *ovnnb.AddressSet, fields ...interface{}) error { if as == nil { return fmt.Errorf("address_set is nil") } @@ -103,7 +103,7 @@ func (c *ovnClient) UpdateAddressSet(as *ovnnb.AddressSet, fields ...interface{} return nil } -func (c *ovnClient) DeleteAddressSet(asName string) error { +func (c *ovnNbClient) DeleteAddressSet(asName string) error { as, err := c.GetAddressSet(asName, true) if err != nil { klog.Error(err) @@ -129,7 +129,7 @@ func (c *ovnClient) DeleteAddressSet(asName string) error { } // DeleteAddressSets delete several address set once -func (c *ovnClient) DeleteAddressSets(externalIDs map[string]string) error { +func (c *ovnNbClient) DeleteAddressSets(externalIDs map[string]string) error { // it's dangerous when externalIDs is empty, it will delete all address set if len(externalIDs) == 0 { return nil @@ -149,12 +149,12 @@ func (c *ovnClient) DeleteAddressSets(externalIDs map[string]string) error { } // GetAddressSet get address set by name -func (c *ovnClient) GetAddressSet(asName string, ignoreNotFound bool) (*ovnnb.AddressSet, error) { +func (c *ovnNbClient) GetAddressSet(asName string, ignoreNotFound bool) (*ovnnb.AddressSet, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() as := &ovnnb.AddressSet{Name: asName} - if err := c.ovnNbClient.Get(ctx, as); err != nil { + if err := c.ovsDbClient.Get(ctx, as); err != nil { if ignoreNotFound && err == client.ErrNotFound { return nil, nil } @@ -165,13 +165,13 @@ func (c *ovnClient) GetAddressSet(asName string, ignoreNotFound bool) (*ovnnb.Ad return as, nil } -func (c *ovnClient) AddressSetExists(name string) (bool, error) { +func (c *ovnNbClient) AddressSetExists(name string) (bool, error) { as, err := c.GetAddressSet(name, true) return as != nil, err } // ListAddressSets list address set by external_ids -func (c *ovnClient) ListAddressSets(externalIDs map[string]string) ([]ovnnb.AddressSet, error) { +func (c *ovnNbClient) ListAddressSets(externalIDs map[string]string) ([]ovnnb.AddressSet, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() diff --git a/pkg/ovs/ovn-nb-bfd.go b/pkg/ovs/ovn-nb-bfd.go index 4dc7c841c45..d5160690ae3 100644 --- a/pkg/ovs/ovn-nb-bfd.go +++ b/pkg/ovs/ovn-nb-bfd.go @@ -8,12 +8,12 @@ import ( "k8s.io/klog/v2" ) -func (c *ovnClient) ListBFD(lrpName, dstIP string) ([]ovnnb.BFD, error) { +func (c *ovnNbClient) ListBFD(lrpName, dstIP string) ([]ovnnb.BFD, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() bfdList := make([]ovnnb.BFD, 0) - if err := c.ovnNbClient.WhereCache(func(bfd *ovnnb.BFD) bool { + if err := c.ovsDbClient.WhereCache(func(bfd *ovnnb.BFD) bool { if bfd.LogicalPort != lrpName { return false } @@ -25,7 +25,7 @@ func (c *ovnClient) ListBFD(lrpName, dstIP string) ([]ovnnb.BFD, error) { return bfdList, nil } -func (c *ovnClient) CreateBFD(lrpName, dstIP string, minRx, minTx, detectMult int) (*ovnnb.BFD, error) { +func (c *ovnNbClient) CreateBFD(lrpName, dstIP string, minRx, minTx, detectMult int) (*ovnnb.BFD, error) { bfdList, err := c.ListBFD(lrpName, dstIP) if err != nil { klog.Error(err) @@ -59,7 +59,7 @@ func (c *ovnClient) CreateBFD(lrpName, dstIP string, minRx, minTx, detectMult in return &bfdList[0], nil } -func (c *ovnClient) DeleteBFD(lrpName, dstIP string) error { +func (c *ovnNbClient) DeleteBFD(lrpName, dstIP string) error { bfdList, err := c.ListBFD(lrpName, dstIP) if err != nil { klog.Error(err) diff --git a/pkg/ovs/ovn-nb-dhcp_options.go b/pkg/ovs/ovn-nb-dhcp_options.go index 96b98060cf1..e344ddbe42b 100644 --- a/pkg/ovs/ovn-nb-dhcp_options.go +++ b/pkg/ovs/ovn-nb-dhcp_options.go @@ -18,14 +18,14 @@ type DHCPOptionsUUIDs struct { DHCPv6OptionsUUID string } -func (c *ovnClient) CreateDHCPOptions(lsName, cidr, options string) error { +func (c *ovnNbClient) CreateDHCPOptions(lsName, cidr, options string) error { dhcpOpt, err := newDHCPOptions(lsName, cidr, options) if err != nil { klog.Error(err) return err } - op, err := c.ovnNbClient.Create(dhcpOpt) + op, err := c.ovsDbClient.Create(dhcpOpt) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for creating dhcp options 'cidr %s options %s': %v", cidr, options, err) @@ -39,7 +39,7 @@ func (c *ovnClient) CreateDHCPOptions(lsName, cidr, options string) error { return nil } -func (c *ovnClient) UpdateDHCPOptions(subnet *kubeovnv1.Subnet, mtu int) (*DHCPOptionsUUIDs, error) { +func (c *ovnNbClient) UpdateDHCPOptions(subnet *kubeovnv1.Subnet, mtu int) (*DHCPOptionsUUIDs, error) { lsName := subnet.Name cidrBlock := subnet.Spec.CIDRBlock gateway := subnet.Spec.Gateway @@ -87,7 +87,7 @@ func (c *ovnClient) UpdateDHCPOptions(subnet *kubeovnv1.Subnet, mtu int) (*DHCPO }, nil } -func (c *ovnClient) updateDHCPv4Options(lsName, cidr, gateway, options string, mtu int) (uuid string, err error) { +func (c *ovnNbClient) updateDHCPv4Options(lsName, cidr, gateway, options string, mtu int) (uuid string, err error) { protocol := util.CheckProtocol(cidr) if protocol != kubeovnv1.ProtocolIPv4 { return "", fmt.Errorf("cidr %s must be a valid ipv4 address", cidr) @@ -129,7 +129,7 @@ func (c *ovnClient) updateDHCPv4Options(lsName, cidr, gateway, options string, m return dhcpOpt.UUID, nil } -func (c *ovnClient) updateDHCPv6Options(lsName, cidr, options string) (uuid string, err error) { +func (c *ovnNbClient) updateDHCPv6Options(lsName, cidr, options string) (uuid string, err error) { protocol := util.CheckProtocol(cidr) if protocol != kubeovnv1.ProtocolIPv6 { return "", fmt.Errorf("cidr %s must be a valid ipv4 address", cidr) @@ -172,12 +172,12 @@ func (c *ovnClient) updateDHCPv6Options(lsName, cidr, options string) (uuid stri } // updateDHCPOptions update dhcp options -func (c *ovnClient) updateDHCPOptions(dhcpOpt *ovnnb.DHCPOptions, fields ...interface{}) error { +func (c *ovnNbClient) updateDHCPOptions(dhcpOpt *ovnnb.DHCPOptions, fields ...interface{}) error { if dhcpOpt == nil { return fmt.Errorf("dhcp_options is nil") } - op, err := c.ovnNbClient.Where(dhcpOpt).Update(dhcpOpt, fields...) + op, err := c.ovsDbClient.Where(dhcpOpt).Update(dhcpOpt, fields...) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for updating dhcp options %s: %v", dhcpOpt.UUID, err) @@ -191,7 +191,7 @@ func (c *ovnClient) updateDHCPOptions(dhcpOpt *ovnnb.DHCPOptions, fields ...inte } // DeleteDHCPOptionsByUUIDs delete dhcp options by uuid -func (c *ovnClient) DeleteDHCPOptionsByUUIDs(uuidList ...string) error { +func (c *ovnNbClient) DeleteDHCPOptionsByUUIDs(uuidList ...string) error { ops := make([]ovsdb.Operation, 0, len(uuidList)) for _, uuid := range uuidList { dhcpOptions := &ovnnb.DHCPOptions{ @@ -214,7 +214,7 @@ func (c *ovnClient) DeleteDHCPOptionsByUUIDs(uuidList ...string) error { } // DeleteDHCPOptions delete dhcp options which belongs to logical switch -func (c *ovnClient) DeleteDHCPOptions(lsName string, protocol string) error { +func (c *ovnNbClient) DeleteDHCPOptions(lsName string, protocol string) error { if protocol == kubeovnv1.ProtocolDual { protocol = "" } @@ -239,7 +239,7 @@ func (c *ovnClient) DeleteDHCPOptions(lsName string, protocol string) error { // GetDHCPOptions get dhcp options, // a dhcp options is uniquely identified by switch(lsName) and protocol -func (c *ovnClient) GetDHCPOptions(lsName, protocol string, ignoreNotFound bool) (*ovnnb.DHCPOptions, error) { +func (c *ovnNbClient) GetDHCPOptions(lsName, protocol string, ignoreNotFound bool) (*ovnnb.DHCPOptions, error) { if len(lsName) == 0 { return nil, fmt.Errorf("the logical router name is required") } @@ -275,7 +275,7 @@ func (c *ovnClient) GetDHCPOptions(lsName, protocol string, ignoreNotFound bool) } // ListDHCPOptions list dhcp options which match the given externalIDs -func (c *ovnClient) ListDHCPOptions(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.DHCPOptions, error) { +func (c *ovnNbClient) ListDHCPOptions(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.DHCPOptions, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -288,7 +288,7 @@ func (c *ovnClient) ListDHCPOptions(needVendorFilter bool, externalIDs map[strin return dhcpOptList, nil } -func (c *ovnClient) DHCPOptionsExists(lsName, cidr string) (bool, error) { +func (c *ovnNbClient) DHCPOptionsExists(lsName, cidr string) (bool, error) { dhcpOpt, err := c.GetDHCPOptions(lsName, cidr, true) return dhcpOpt != nil, err } diff --git a/pkg/ovs/ovn-nb-gateway_chassis.go b/pkg/ovs/ovn-nb-gateway_chassis.go index 489b1917c52..3cf8d20647e 100644 --- a/pkg/ovs/ovn-nb-gateway_chassis.go +++ b/pkg/ovs/ovn-nb-gateway_chassis.go @@ -14,7 +14,7 @@ import ( ) // CreateGatewayChassises create multiple gateway chassis once -func (c *ovnClient) CreateGatewayChassises(lrpName string, chassises ...string) error { +func (c *ovnNbClient) CreateGatewayChassises(lrpName string, chassises ...string) error { op, err := c.CreateGatewayChassisesOp(lrpName, chassises) if err != nil { return fmt.Errorf("generate operations for creating gateway chassis %v", err) @@ -28,7 +28,7 @@ func (c *ovnClient) CreateGatewayChassises(lrpName string, chassises ...string) } // DeleteGatewayChassises delete multiple gateway chassis once -func (c *ovnClient) DeleteGatewayChassises(lrpName string, chassises []string) error { +func (c *ovnNbClient) DeleteGatewayChassises(lrpName string, chassises []string) error { if len(chassises) == 0 { return nil } @@ -59,7 +59,7 @@ func (c *ovnClient) DeleteGatewayChassises(lrpName string, chassises []string) e } // GetGatewayChassis get gateway chassis by name -func (c *ovnClient) GetGatewayChassis(name string, ignoreNotFound bool) (*ovnnb.GatewayChassis, error) { +func (c *ovnNbClient) GetGatewayChassis(name string, ignoreNotFound bool) (*ovnnb.GatewayChassis, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -75,13 +75,13 @@ func (c *ovnClient) GetGatewayChassis(name string, ignoreNotFound bool) (*ovnnb. return gwChassis, nil } -func (c *ovnClient) GatewayChassisExist(name string) (bool, error) { +func (c *ovnNbClient) GatewayChassisExist(name string) (bool, error) { gwChassis, err := c.GetGatewayChassis(name, true) return gwChassis != nil, err } // newGatewayChassis return gateway chassis with basic information -func (c *ovnClient) newGatewayChassis(gwChassisName, chassisName string, priority int) (*ovnnb.GatewayChassis, error) { +func (c *ovnNbClient) newGatewayChassis(gwChassisName, chassisName string, priority int) (*ovnnb.GatewayChassis, error) { exists, err := c.GatewayChassisExist(gwChassisName) if err != nil { klog.Error(err) @@ -104,7 +104,7 @@ func (c *ovnClient) newGatewayChassis(gwChassisName, chassisName string, priorit } // DeleteGatewayChassisOp create operation which create gateway chassis -func (c *ovnClient) CreateGatewayChassisesOp(lrpName string, chassises []string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) CreateGatewayChassisesOp(lrpName string, chassises []string) ([]ovsdb.Operation, error) { if len(chassises) == 0 { return nil, nil } @@ -148,7 +148,7 @@ func (c *ovnClient) CreateGatewayChassisesOp(lrpName string, chassises []string) } // DeleteGatewayChassisOp create operation which delete gateway chassis -func (c *ovnClient) DeleteGatewayChassisOp(chassisName string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) DeleteGatewayChassisOp(chassisName string) ([]ovsdb.Operation, error) { gwChassis, err := c.GetGatewayChassis(chassisName, true) if err != nil { diff --git a/pkg/ovs/ovn-nb-load_balancer.go b/pkg/ovs/ovn-nb-load_balancer.go index b21d1ad92ed..bcca458657b 100644 --- a/pkg/ovs/ovn-nb-load_balancer.go +++ b/pkg/ovs/ovn-nb-load_balancer.go @@ -16,7 +16,7 @@ import ( ) // CreateLoadBalancer create loadbalancer -func (c *ovnClient) CreateLoadBalancer(lbName, protocol, selectFields string) error { +func (c *ovnNbClient) CreateLoadBalancer(lbName, protocol, selectFields string) error { exist, err := c.LoadBalancerExists(lbName) if err != nil { klog.Error(err) @@ -38,7 +38,7 @@ func (c *ovnClient) CreateLoadBalancer(lbName, protocol, selectFields string) er lb.SelectionFields = []string{selectFields} } - op, err := c.ovnNbClient.Create(lb) + op, err := c.ovsDbClient.Create(lb) if err != nil { return fmt.Errorf("generate operations for creating load balancer %s: %v", lbName, err) } @@ -51,8 +51,8 @@ func (c *ovnClient) CreateLoadBalancer(lbName, protocol, selectFields string) er } // UpdateLoadBalancer update load balancer -func (c *ovnClient) UpdateLoadBalancer(lb *ovnnb.LoadBalancer, fields ...interface{}) error { - op, err := c.ovnNbClient.Where(lb).Update(lb, fields...) +func (c *ovnNbClient) UpdateLoadBalancer(lb *ovnnb.LoadBalancer, fields ...interface{}) error { + op, err := c.ovsDbClient.Where(lb).Update(lb, fields...) if err != nil { return fmt.Errorf("generate operations for updating load balancer %s: %v", lb.Name, err) } @@ -65,7 +65,7 @@ func (c *ovnClient) UpdateLoadBalancer(lb *ovnnb.LoadBalancer, fields ...interfa } // LoadBalancerAddVips adds or updates a vip -func (c *ovnClient) LoadBalancerAddVip(lbName, vip string, backends ...string) error { +func (c *ovnNbClient) LoadBalancerAddVip(lbName, vip string, backends ...string) error { sort.Strings(backends) ops, err := c.LoadBalancerOp(lbName, func(lb *ovnnb.LoadBalancer) []model.Mutation { mutations := make([]model.Mutation, 0, 2) @@ -97,7 +97,7 @@ func (c *ovnClient) LoadBalancerAddVip(lbName, vip string, backends ...string) e } // LoadBalancerDeleteVip deletes load balancer vip -func (c *ovnClient) LoadBalancerDeleteVip(lbName string, vip string) error { +func (c *ovnNbClient) LoadBalancerDeleteVip(lbName string, vip string) error { ops, err := c.LoadBalancerOp(lbName, func(lb *ovnnb.LoadBalancer) []model.Mutation { if len(lb.Vips) == 0 { return nil @@ -125,7 +125,7 @@ func (c *ovnClient) LoadBalancerDeleteVip(lbName string, vip string) error { } // SetLoadBalancerAffinityTimeout sets the LB's affinity timeout in seconds -func (c *ovnClient) SetLoadBalancerAffinityTimeout(lbName string, timeout int) error { +func (c *ovnNbClient) SetLoadBalancerAffinityTimeout(lbName string, timeout int) error { lb, err := c.GetLoadBalancer(lbName, false) if err != nil { klog.Error(err) @@ -150,8 +150,8 @@ func (c *ovnClient) SetLoadBalancerAffinityTimeout(lbName string, timeout int) e } // DeleteLoadBalancers delete several loadbalancer once -func (c *ovnClient) DeleteLoadBalancers(filter func(lb *ovnnb.LoadBalancer) bool) error { - op, err := c.ovnNbClient.WhereCache(func(lb *ovnnb.LoadBalancer) bool { +func (c *ovnNbClient) DeleteLoadBalancers(filter func(lb *ovnnb.LoadBalancer) bool) error { + op, err := c.ovsDbClient.WhereCache(func(lb *ovnnb.LoadBalancer) bool { if filter != nil { return filter(lb) } @@ -171,7 +171,7 @@ func (c *ovnClient) DeleteLoadBalancers(filter func(lb *ovnnb.LoadBalancer) bool } // DeleteLoadBalancer delete loadbalancer -func (c *ovnClient) DeleteLoadBalancer(lbName string) error { +func (c *ovnNbClient) DeleteLoadBalancer(lbName string) error { op, err := c.DeleteLoadBalancerOp(lbName) if err != nil { klog.Error(err) @@ -188,12 +188,12 @@ func (c *ovnClient) DeleteLoadBalancer(lbName string) error { // GetLoadBalancer get load balancer by name, // it is because of lack name index that does't use ovnNbClient.Get -func (c *ovnClient) GetLoadBalancer(lbName string, ignoreNotFound bool) (*ovnnb.LoadBalancer, error) { +func (c *ovnNbClient) GetLoadBalancer(lbName string, ignoreNotFound bool) (*ovnnb.LoadBalancer, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() lbList := make([]ovnnb.LoadBalancer, 0) - if err := c.ovnNbClient.WhereCache(func(lb *ovnnb.LoadBalancer) bool { + if err := c.ovsDbClient.WhereCache(func(lb *ovnnb.LoadBalancer) bool { return lb.Name == lbName }).List(ctx, &lbList); err != nil { return nil, fmt.Errorf("list load balancer %q: %v", lbName, err) @@ -214,18 +214,18 @@ func (c *ovnClient) GetLoadBalancer(lbName string, ignoreNotFound bool) (*ovnnb. return &lbList[0], nil } -func (c *ovnClient) LoadBalancerExists(lbName string) (bool, error) { +func (c *ovnNbClient) LoadBalancerExists(lbName string) (bool, error) { lrp, err := c.GetLoadBalancer(lbName, true) return lrp != nil, err } // ListLoadBalancers list all load balancers -func (c *ovnClient) ListLoadBalancers(filter func(lb *ovnnb.LoadBalancer) bool) ([]ovnnb.LoadBalancer, error) { +func (c *ovnNbClient) ListLoadBalancers(filter func(lb *ovnnb.LoadBalancer) bool) ([]ovnnb.LoadBalancer, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() lbList := make([]ovnnb.LoadBalancer, 0) - if err := c.ovnNbClient.WhereCache(func(lb *ovnnb.LoadBalancer) bool { + if err := c.ovsDbClient.WhereCache(func(lb *ovnnb.LoadBalancer) bool { if filter != nil { return filter(lb) } @@ -238,7 +238,7 @@ func (c *ovnClient) ListLoadBalancers(filter func(lb *ovnnb.LoadBalancer) bool) return lbList, nil } -func (c *ovnClient) LoadBalancerOp(lbName string, mutationsFunc ...func(lb *ovnnb.LoadBalancer) []model.Mutation) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LoadBalancerOp(lbName string, mutationsFunc ...func(lb *ovnnb.LoadBalancer) []model.Mutation) ([]ovsdb.Operation, error) { lb, err := c.GetLoadBalancer(lbName, false) if err != nil { klog.Error(err) @@ -259,7 +259,7 @@ func (c *ovnClient) LoadBalancerOp(lbName string, mutationsFunc ...func(lb *ovnn return nil, nil } - ops, err := c.ovnNbClient.Where(lb).Mutate(lb, mutations...) + ops, err := c.ovsDbClient.Where(lb).Mutate(lb, mutations...) if err != nil { klog.Error(err) return nil, fmt.Errorf("generate operations for mutating load balancer %s: %v", lb.Name, err) @@ -269,7 +269,7 @@ func (c *ovnClient) LoadBalancerOp(lbName string, mutationsFunc ...func(lb *ovnn } // DeleteLoadBalancerOp create operation which delete load balancer -func (c *ovnClient) DeleteLoadBalancerOp(lbName string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) DeleteLoadBalancerOp(lbName string) ([]ovsdb.Operation, error) { lb, err := c.GetLoadBalancer(lbName, true) if err != nil { diff --git a/pkg/ovs/ovn-nb-logical_router.go b/pkg/ovs/ovn-nb-logical_router.go index 80f6550282d..26ef2288534 100644 --- a/pkg/ovs/ovn-nb-logical_router.go +++ b/pkg/ovs/ovn-nb-logical_router.go @@ -14,7 +14,7 @@ import ( ) // CreateLogicalRouter create logical router in ovn -func (c *ovnClient) CreateLogicalRouter(lrName string) error { +func (c *ovnNbClient) CreateLogicalRouter(lrName string) error { exist, err := c.LogicalRouterExists(lrName) if err != nil { return err @@ -30,7 +30,7 @@ func (c *ovnClient) CreateLogicalRouter(lrName string) error { ExternalIDs: map[string]string{"vendor": util.CniTypeName}, } - op, err := c.ovnNbClient.Create(lr) + op, err := c.ovsDbClient.Create(lr) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for creating logical router %s: %v", lrName, err) @@ -44,7 +44,7 @@ func (c *ovnClient) CreateLogicalRouter(lrName string) error { } // UpdateLogicalRouter update logical router -func (c *ovnClient) UpdateLogicalRouter(lr *ovnnb.LogicalRouter, fields ...interface{}) error { +func (c *ovnNbClient) UpdateLogicalRouter(lr *ovnnb.LogicalRouter, fields ...interface{}) error { op, err := c.UpdateLogicalRouterOp(lr, fields...) if err != nil { klog.Error(err) @@ -59,7 +59,7 @@ func (c *ovnClient) UpdateLogicalRouter(lr *ovnnb.LogicalRouter, fields ...inter } // DeleteLogicalRouter delete logical router in ovn -func (c *ovnClient) DeleteLogicalRouter(lrName string) error { +func (c *ovnNbClient) DeleteLogicalRouter(lrName string) error { lr, err := c.GetLogicalRouter(lrName, true) if err != nil { klog.Error(err) @@ -86,12 +86,12 @@ func (c *ovnClient) DeleteLogicalRouter(lrName string) error { // GetLogicalRouter get logical router by name, // it is because of lack name index that does't use ovnNbClient.Get -func (c *ovnClient) GetLogicalRouter(lrName string, ignoreNotFound bool) (*ovnnb.LogicalRouter, error) { +func (c *ovnNbClient) GetLogicalRouter(lrName string, ignoreNotFound bool) (*ovnnb.LogicalRouter, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() lrList := make([]ovnnb.LogicalRouter, 0) - if err := c.ovnNbClient.WhereCache(func(lr *ovnnb.LogicalRouter) bool { + if err := c.ovsDbClient.WhereCache(func(lr *ovnnb.LogicalRouter) bool { return lr.Name == lrName }).List(ctx, &lrList); err != nil { return nil, fmt.Errorf("list logical router %q: %v", lrName, err) @@ -112,19 +112,19 @@ func (c *ovnClient) GetLogicalRouter(lrName string, ignoreNotFound bool) (*ovnnb return &lrList[0], nil } -func (c *ovnClient) LogicalRouterExists(name string) (bool, error) { +func (c *ovnNbClient) LogicalRouterExists(name string) (bool, error) { lrp, err := c.GetLogicalRouter(name, true) return lrp != nil, err } // ListLogicalRouter list logical router -func (c *ovnClient) ListLogicalRouter(needVendorFilter bool, filter func(lr *ovnnb.LogicalRouter) bool) ([]ovnnb.LogicalRouter, error) { +func (c *ovnNbClient) ListLogicalRouter(needVendorFilter bool, filter func(lr *ovnnb.LogicalRouter) bool) ([]ovnnb.LogicalRouter, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() lrList := make([]ovnnb.LogicalRouter, 0) - if err := c.ovnNbClient.WhereCache(func(lr *ovnnb.LogicalRouter) bool { + if err := c.ovsDbClient.WhereCache(func(lr *ovnnb.LogicalRouter) bool { if needVendorFilter && (len(lr.ExternalIDs) == 0 || lr.ExternalIDs["vendor"] != util.CniTypeName) { return false } @@ -142,7 +142,7 @@ func (c *ovnClient) ListLogicalRouter(needVendorFilter bool, filter func(lr *ovn } // LogicalRouterUpdateLoadBalancers add several lb to or from logical router once -func (c *ovnClient) LogicalRouterUpdateLoadBalancers(lrName string, op ovsdb.Mutator, lbNames ...string) error { +func (c *ovnNbClient) LogicalRouterUpdateLoadBalancers(lrName string, op ovsdb.Mutator, lbNames ...string) error { if len(lbNames) == 0 { return nil } @@ -187,12 +187,12 @@ func (c *ovnClient) LogicalRouterUpdateLoadBalancers(lrName string, op ovsdb.Mut } // UpdateLogicalRouterOp generate operations which update logical router -func (c *ovnClient) UpdateLogicalRouterOp(lr *ovnnb.LogicalRouter, fields ...interface{}) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) UpdateLogicalRouterOp(lr *ovnnb.LogicalRouter, fields ...interface{}) ([]ovsdb.Operation, error) { if lr == nil { return nil, fmt.Errorf("logical_router is nil") } - op, err := c.ovnNbClient.Where(lr).Update(lr, fields...) + op, err := c.ovsDbClient.Where(lr).Update(lr, fields...) if err != nil { klog.Error(err) return nil, fmt.Errorf("generate operations for updating logical router %s: %v", lr.Name, err) @@ -202,7 +202,7 @@ func (c *ovnClient) UpdateLogicalRouterOp(lr *ovnnb.LogicalRouter, fields ...int } // LogicalRouterUpdatePortOp create operations add to or delete port from logical router -func (c *ovnClient) LogicalRouterUpdatePortOp(lrName, lrpUUID string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalRouterUpdatePortOp(lrName, lrpUUID string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(lrpUUID) == 0 { return nil, nil } @@ -246,7 +246,7 @@ func (c *ovnClient) LogicalRouterUpdatePortOp(lrName, lrpUUID string, op ovsdb.M } // LogicalRouterUpdatePolicyOp create operations add to or delete policy from logical router -func (c *ovnClient) LogicalRouterUpdatePolicyOp(lrName string, policyUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalRouterUpdatePolicyOp(lrName string, policyUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(policyUUIDs) == 0 { return nil, nil } @@ -265,7 +265,7 @@ func (c *ovnClient) LogicalRouterUpdatePolicyOp(lrName string, policyUUIDs []str } // LogicalRouterUpdateNatOp create operations add to or delete nat rule from logical router -func (c *ovnClient) LogicalRouterUpdateNatOp(lrName string, natUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalRouterUpdateNatOp(lrName string, natUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(natUUIDs) == 0 { return nil, nil } @@ -284,7 +284,7 @@ func (c *ovnClient) LogicalRouterUpdateNatOp(lrName string, natUUIDs []string, o } // LogicalRouterUpdateStaticRouteOp create operations add to or delete static route from logical router -func (c *ovnClient) LogicalRouterUpdateStaticRouteOp(lrName string, routeUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalRouterUpdateStaticRouteOp(lrName string, routeUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(routeUUIDs) == 0 { return nil, nil } @@ -303,7 +303,7 @@ func (c *ovnClient) LogicalRouterUpdateStaticRouteOp(lrName string, routeUUIDs [ } // LogicalRouterOp create operations about logical router -func (c *ovnClient) LogicalRouterOp(lrName string, mutationsFunc ...func(lr *ovnnb.LogicalRouter) *model.Mutation) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalRouterOp(lrName string, mutationsFunc ...func(lr *ovnnb.LogicalRouter) *model.Mutation) ([]ovsdb.Operation, error) { lr, err := c.GetLogicalRouter(lrName, false) if err != nil { klog.Error(err) @@ -324,7 +324,7 @@ func (c *ovnClient) LogicalRouterOp(lrName string, mutationsFunc ...func(lr *ovn } } - ops, err := c.ovnNbClient.Where(lr).Mutate(lr, mutations...) + ops, err := c.ovsDbClient.Where(lr).Mutate(lr, mutations...) if err != nil { klog.Error(err) return nil, fmt.Errorf("generate operations for mutating logical router %s: %v", lrName, err) diff --git a/pkg/ovs/ovn-nb-logical_router_policy.go b/pkg/ovs/ovn-nb-logical_router_policy.go index 2e53cc62469..64834b1a469 100644 --- a/pkg/ovs/ovn-nb-logical_router_policy.go +++ b/pkg/ovs/ovn-nb-logical_router_policy.go @@ -17,7 +17,7 @@ import ( ) // AddLogicalRouterPolicy add a policy route to logical router -func (c *ovnClient) AddLogicalRouterPolicy(lrName string, priority int, match, action string, nextHops []string, externalIDs map[string]string) error { +func (c *ovnNbClient) AddLogicalRouterPolicy(lrName string, priority int, match, action string, nextHops []string, externalIDs map[string]string) error { fnFilter := func(policy *ovnnb.LogicalRouterPolicy) bool { return policy.Priority == priority && policy.Match == match } @@ -51,7 +51,7 @@ func (c *ovnClient) AddLogicalRouterPolicy(lrName string, priority int, match, a } // CreateLogicalRouterPolicies create several logical router policy once -func (c *ovnClient) CreateLogicalRouterPolicies(lrName string, policies ...*ovnnb.LogicalRouterPolicy) error { +func (c *ovnNbClient) CreateLogicalRouterPolicies(lrName string, policies ...*ovnnb.LogicalRouterPolicy) error { if len(policies) == 0 { return nil } @@ -65,7 +65,7 @@ func (c *ovnClient) CreateLogicalRouterPolicies(lrName string, policies ...*ovnn } } - createPoliciesOp, err := c.ovnNbClient.Create(models...) + createPoliciesOp, err := c.ovsDbClient.Create(models...) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for creating policies: %v", err) @@ -89,7 +89,7 @@ func (c *ovnClient) CreateLogicalRouterPolicies(lrName string, policies ...*ovnn } // DeleteLogicalRouterPolicy delete policy from logical router -func (c *ovnClient) DeleteLogicalRouterPolicy(lrName string, priority int, match string) error { +func (c *ovnNbClient) DeleteLogicalRouterPolicy(lrName string, priority int, match string) error { policyList, err := c.GetLogicalRouterPolicy(lrName, priority, match, true) if err != nil { klog.Error(err) @@ -107,7 +107,7 @@ func (c *ovnClient) DeleteLogicalRouterPolicy(lrName string, priority int, match } // DeleteLogicalRouterPolicy delete some policies from logical router once -func (c *ovnClient) DeleteLogicalRouterPolicies(lrName string, priority int, externalIDs map[string]string) error { +func (c *ovnNbClient) DeleteLogicalRouterPolicies(lrName string, priority int, externalIDs map[string]string) error { // remove policies from logical router policies, err := c.ListLogicalRouterPolicies(lrName, priority, externalIDs) if err != nil { @@ -133,7 +133,7 @@ func (c *ovnClient) DeleteLogicalRouterPolicies(lrName string, priority int, ext return nil } -func (c *ovnClient) DeleteLogicalRouterPolicyByUUID(lrName, uuid string) error { +func (c *ovnNbClient) DeleteLogicalRouterPolicyByUUID(lrName, uuid string) error { // remove policy from logical router ops, err := c.LogicalRouterUpdatePolicyOp(lrName, []string{uuid}, ovsdb.MutateOperationDelete) if err != nil { @@ -145,7 +145,7 @@ func (c *ovnClient) DeleteLogicalRouterPolicyByUUID(lrName, uuid string) error { return nil } -func (c *ovnClient) DeleteLogicalRouterPolicyByNexthop(lrName string, priority int, nexthop string) error { +func (c *ovnNbClient) DeleteLogicalRouterPolicyByNexthop(lrName string, priority int, nexthop string) error { policyList, err := c.listLogicalRouterPoliciesByFilter(lrName, func(route *ovnnb.LogicalRouterPolicy) bool { if route.Priority != priority { return false @@ -165,7 +165,7 @@ func (c *ovnClient) DeleteLogicalRouterPolicyByNexthop(lrName string, priority i } // ClearLogicalRouterPolicy clear policy from logical router once -func (c *ovnClient) ClearLogicalRouterPolicy(lrName string) error { +func (c *ovnNbClient) ClearLogicalRouterPolicy(lrName string) error { lr, err := c.GetLogicalRouter(lrName, false) if err != nil { return fmt.Errorf("get logical router %s: %v", lrName, err) @@ -186,7 +186,7 @@ func (c *ovnClient) ClearLogicalRouterPolicy(lrName string) error { // GetLogicalRouterPolicy get logical router policy by priority and match, // be consistent with ovn-nbctl which priority and match determine one policy in logical router -func (c *ovnClient) GetLogicalRouterPolicy(lrName string, priority int, match string, ignoreNotFound bool) ([]*ovnnb.LogicalRouterPolicy, error) { +func (c *ovnNbClient) GetLogicalRouterPolicy(lrName string, priority int, match string, ignoreNotFound bool) ([]*ovnnb.LogicalRouterPolicy, error) { // this is necessary because may exist same priority and match policy in different logical router if len(lrName) == 0 { return nil, fmt.Errorf("the logical router name is required") @@ -212,7 +212,7 @@ func (c *ovnClient) GetLogicalRouterPolicy(lrName string, priority int, match st } // GetLogicalRouterPolicyByUUID get logical router policy by UUID -func (c *ovnClient) GetLogicalRouterPolicyByUUID(uuid string) (*ovnnb.LogicalRouterPolicy, error) { +func (c *ovnNbClient) GetLogicalRouterPolicyByUUID(uuid string) (*ovnnb.LogicalRouterPolicy, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -224,7 +224,7 @@ func (c *ovnClient) GetLogicalRouterPolicyByUUID(uuid string) (*ovnnb.LogicalRou return policy, nil } -func (c *ovnClient) GetLogicalRouterPoliciesByExtID(lrName, key, value string) ([]*ovnnb.LogicalRouterPolicy, error) { +func (c *ovnNbClient) GetLogicalRouterPoliciesByExtID(lrName, key, value string) ([]*ovnnb.LogicalRouterPolicy, error) { fnFilter := func(policy *ovnnb.LogicalRouterPolicy) bool { return len(policy.ExternalIDs) != 0 && policy.ExternalIDs[key] == value } @@ -232,12 +232,12 @@ func (c *ovnClient) GetLogicalRouterPoliciesByExtID(lrName, key, value string) ( } // ListLogicalRouterPolicies list route policy which match the given externalIDs -func (c *ovnClient) ListLogicalRouterPolicies(lrName string, priority int, externalIDs map[string]string) ([]*ovnnb.LogicalRouterPolicy, error) { +func (c *ovnNbClient) ListLogicalRouterPolicies(lrName string, priority int, externalIDs map[string]string) ([]*ovnnb.LogicalRouterPolicy, error) { return c.listLogicalRouterPoliciesByFilter(lrName, policyFilter(priority, externalIDs)) } // newLogicalRouterPolicy return logical router policy with basic information -func (c *ovnClient) newLogicalRouterPolicy(priority int, match, action string, nextHops []string, externalIDs map[string]string) *ovnnb.LogicalRouterPolicy { +func (c *ovnNbClient) newLogicalRouterPolicy(priority int, match, action string, nextHops []string, externalIDs map[string]string) *ovnnb.LogicalRouterPolicy { return &ovnnb.LogicalRouterPolicy{ UUID: ovsclient.NamedUUID(), Priority: priority, @@ -279,8 +279,8 @@ func policyFilter(priority int, externalIDs map[string]string) func(policy *ovnn } } -func (c *ovnClient) DeleteRouterPolicy(lr *ovnnb.LogicalRouter, uuid string) error { - ops, err := c.ovnNbClient.Where(lr).Mutate(lr, model.Mutation{ +func (c *ovnNbClient) DeleteRouterPolicy(lr *ovnnb.LogicalRouter, uuid string) error { + ops, err := c.ovsDbClient.Where(lr).Mutate(lr, model.Mutation{ Field: &lr.Policies, Mutator: ovsdb.MutateOperationDelete, Value: []string{uuid}, @@ -294,7 +294,7 @@ func (c *ovnClient) DeleteRouterPolicy(lr *ovnnb.LogicalRouter, uuid string) err return nil } -func (c *ovnClient) listLogicalRouterPoliciesByFilter(lrName string, filter func(route *ovnnb.LogicalRouterPolicy) bool) ([]*ovnnb.LogicalRouterPolicy, error) { +func (c *ovnNbClient) listLogicalRouterPoliciesByFilter(lrName string, filter func(route *ovnnb.LogicalRouterPolicy) bool) ([]*ovnnb.LogicalRouterPolicy, error) { lr, err := c.GetLogicalRouter(lrName, false) if err != nil { klog.Error(err) diff --git a/pkg/ovs/ovn-nb-logical_router_port.go b/pkg/ovs/ovn-nb-logical_router_port.go index 915aaf5b292..7c310427485 100644 --- a/pkg/ovs/ovn-nb-logical_router_port.go +++ b/pkg/ovs/ovn-nb-logical_router_port.go @@ -15,7 +15,7 @@ import ( "github.com/kubeovn/kube-ovn/pkg/util" ) -func (c *ovnClient) CreatePeerRouterPort(localRouter, remoteRouter, localRouterPortIP string) error { +func (c *ovnNbClient) CreatePeerRouterPort(localRouter, remoteRouter, localRouterPortIP string) error { localRouterPort := fmt.Sprintf("%s-%s", localRouter, remoteRouter) remoteRouterPort := fmt.Sprintf("%s-%s", remoteRouter, localRouter) @@ -56,7 +56,7 @@ func (c *ovnClient) CreatePeerRouterPort(localRouter, remoteRouter, localRouterP return nil } -func (c *ovnClient) UpdateLogicalRouterPortRA(lrpName, ipv6RAConfigsStr string, enableIPv6RA bool) error { +func (c *ovnNbClient) UpdateLogicalRouterPortRA(lrpName, ipv6RAConfigsStr string, enableIPv6RA bool) error { lrp, err := c.GetLogicalRouterPort(lrpName, false) if err != nil { klog.Error(err) @@ -80,7 +80,7 @@ func (c *ovnClient) UpdateLogicalRouterPortRA(lrpName, ipv6RAConfigsStr string, return c.UpdateLogicalRouterPort(lrp, &lrp.Ipv6Prefix, &lrp.Ipv6RaConfigs) } -func (c *ovnClient) UpdateLogicalRouterPortOptions(lrpName string, options map[string]string) error { +func (c *ovnNbClient) UpdateLogicalRouterPortOptions(lrpName string, options map[string]string) error { if len(options) == 0 { return nil } @@ -106,7 +106,7 @@ func (c *ovnClient) UpdateLogicalRouterPortOptions(lrpName string, options map[s } // UpdateLogicalRouterPort update logical router port -func (c *ovnClient) UpdateLogicalRouterPort(lrp *ovnnb.LogicalRouterPort, fields ...interface{}) error { +func (c *ovnNbClient) UpdateLogicalRouterPort(lrp *ovnnb.LogicalRouterPort, fields ...interface{}) error { if lrp == nil { return fmt.Errorf("logical_router_port is nil") } @@ -125,7 +125,7 @@ func (c *ovnClient) UpdateLogicalRouterPort(lrp *ovnnb.LogicalRouterPort, fields } // CreateLogicalRouterPort create logical router port with basic configuration -func (c *ovnClient) CreateLogicalRouterPort(lrName string, lrpName, mac string, networks []string) error { +func (c *ovnNbClient) CreateLogicalRouterPort(lrName string, lrpName, mac string, networks []string) error { exists, err := c.LogicalRouterPortExists(lrpName) if err != nil { klog.Error(err) @@ -162,7 +162,7 @@ func (c *ovnClient) CreateLogicalRouterPort(lrName string, lrpName, mac string, } // DeleteLogicalRouterPort delete logical router port from logical router -func (c *ovnClient) DeleteLogicalRouterPorts(externalIDs map[string]string, filter func(lrp *ovnnb.LogicalRouterPort) bool) error { +func (c *ovnNbClient) DeleteLogicalRouterPorts(externalIDs map[string]string, filter func(lrp *ovnnb.LogicalRouterPort) bool) error { lrpList, err := c.ListLogicalRouterPorts(externalIDs, filter) if err != nil { klog.Error(err) @@ -187,7 +187,7 @@ func (c *ovnClient) DeleteLogicalRouterPorts(externalIDs map[string]string, filt } // DeleteLogicalRouterPort delete logical router port from logical router -func (c *ovnClient) DeleteLogicalRouterPort(lrpName string) error { +func (c *ovnNbClient) DeleteLogicalRouterPort(lrpName string) error { ops, err := c.DeleteLogicalRouterPortOp(lrpName) if err != nil { klog.Error(err) @@ -202,7 +202,7 @@ func (c *ovnClient) DeleteLogicalRouterPort(lrpName string) error { } // GetLogicalRouterPort get logical router port by name -func (c *ovnClient) GetLogicalRouterPort(lrpName string, ignoreNotFound bool) (*ovnnb.LogicalRouterPort, error) { +func (c *ovnNbClient) GetLogicalRouterPort(lrpName string, ignoreNotFound bool) (*ovnnb.LogicalRouterPort, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -219,7 +219,7 @@ func (c *ovnClient) GetLogicalRouterPort(lrpName string, ignoreNotFound bool) (* } // GetLogicalRouterPortByUUID get logical router port by UUID -func (c *ovnClient) GetLogicalRouterPortByUUID(uuid string) (*ovnnb.LogicalRouterPort, error) { +func (c *ovnNbClient) GetLogicalRouterPortByUUID(uuid string) (*ovnnb.LogicalRouterPort, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -232,7 +232,7 @@ func (c *ovnClient) GetLogicalRouterPortByUUID(uuid string) (*ovnnb.LogicalRoute } // ListLogicalRouterPorts list logical router ports -func (c *ovnClient) ListLogicalRouterPorts(externalIDs map[string]string, filter func(lrp *ovnnb.LogicalRouterPort) bool) ([]ovnnb.LogicalRouterPort, error) { +func (c *ovnNbClient) ListLogicalRouterPorts(externalIDs map[string]string, filter func(lrp *ovnnb.LogicalRouterPort) bool) ([]ovnnb.LogicalRouterPort, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -245,13 +245,13 @@ func (c *ovnClient) ListLogicalRouterPorts(externalIDs map[string]string, filter return lrpList, nil } -func (c *ovnClient) LogicalRouterPortExists(lrpName string) (bool, error) { +func (c *ovnNbClient) LogicalRouterPortExists(lrpName string) (bool, error) { lrp, err := c.GetLogicalRouterPort(lrpName, true) return lrp != nil, err } // LogicalRouterPortUpdateGatewayChassisOp create operations add to or delete gateway chassis from logical router port -func (c *ovnClient) LogicalRouterPortUpdateGatewayChassisOp(lrpName string, uuids []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalRouterPortUpdateGatewayChassisOp(lrpName string, uuids []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(uuids) == 0 { return nil, nil } @@ -270,7 +270,7 @@ func (c *ovnClient) LogicalRouterPortUpdateGatewayChassisOp(lrpName string, uuid } // CreateLogicalRouterPortOp create operation which create logical router port -func (c *ovnClient) CreateLogicalRouterPortOp(lrp *ovnnb.LogicalRouterPort, lrName string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) CreateLogicalRouterPortOp(lrp *ovnnb.LogicalRouterPort, lrName string) ([]ovsdb.Operation, error) { if lrp == nil { return nil, fmt.Errorf("logical_router_port is nil") } @@ -305,7 +305,7 @@ func (c *ovnClient) CreateLogicalRouterPortOp(lrp *ovnnb.LogicalRouterPort, lrNa } // DeleteLogicalRouterPortOp create operation which delete logical router port -func (c *ovnClient) DeleteLogicalRouterPortOp(lrpName string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) DeleteLogicalRouterPortOp(lrpName string) ([]ovsdb.Operation, error) { lrp, err := c.GetLogicalRouterPort(lrpName, true) if err != nil { klog.Error(err) @@ -323,7 +323,7 @@ func (c *ovnClient) DeleteLogicalRouterPortOp(lrpName string) ([]ovsdb.Operation } // LogicalRouterPortOp create operations about logical router port -func (c *ovnClient) LogicalRouterPortOp(lrpName string, mutationsFunc ...func(lrp *ovnnb.LogicalRouterPort) *model.Mutation) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalRouterPortOp(lrpName string, mutationsFunc ...func(lrp *ovnnb.LogicalRouterPort) *model.Mutation) ([]ovsdb.Operation, error) { lrp, err := c.GetLogicalRouterPort(lrpName, false) if err != nil { klog.Error(err) @@ -344,7 +344,7 @@ func (c *ovnClient) LogicalRouterPortOp(lrpName string, mutationsFunc ...func(lr } } - ops, err := c.ovnNbClient.Where(lrp).Mutate(lrp, mutations...) + ops, err := c.ovsDbClient.Where(lrp).Mutate(lrp, mutations...) if err != nil { klog.Error(err) return nil, fmt.Errorf("generate operations for mutating logical router port %s: %v", lrpName, err) @@ -385,7 +385,7 @@ func logicalRouterPortFilter(externalIDs map[string]string, filter func(lrp *ovn } } -func (c *ovnClient) AddLogicalRouterPort(lr, name, mac, networks string) error { +func (c *ovnNbClient) AddLogicalRouterPort(lr, name, mac, networks string) error { router, err := c.GetLogicalRouter(lr, false) if err != nil { klog.Error(err) @@ -408,14 +408,14 @@ func (c *ovnClient) AddLogicalRouterPort(lr, name, mac, networks string) error { waitOp := ConstructWaitForNameNotExistsOperation(name, "Logical_Router_Port") ops := []ovsdb.Operation{waitOp} - createOps, err := c.ovnNbClient.Create(lrp) + createOps, err := c.ovsDbClient.Create(lrp) if err != nil { klog.Error(err) return err } ops = append(ops, createOps...) - mutationOps, err := c.ovnNbClient. + mutationOps, err := c.ovsDbClient. Where(router). Mutate(router, model.Mutation{ diff --git a/pkg/ovs/ovn-nb-logical_router_port_test.go b/pkg/ovs/ovn-nb-logical_router_port_test.go index c90c873536b..b83c563526b 100644 --- a/pkg/ovs/ovn-nb-logical_router_port_test.go +++ b/pkg/ovs/ovn-nb-logical_router_port_test.go @@ -25,7 +25,7 @@ func newLogicalRouterPort(lrName, lrpName, mac string, networks []string) *ovnnb } } -func createLogicalRouterPort(c *ovnClient, lrp *ovnnb.LogicalRouterPort) error { +func createLogicalRouterPort(c *ovnNbClient, lrp *ovnnb.LogicalRouterPort) error { op, err := c.Create(lrp) if err != nil { return fmt.Errorf("generate operations for creating logical router port %s: %v", lrp.Name, err) diff --git a/pkg/ovs/ovn-nb-logical_router_route.go b/pkg/ovs/ovn-nb-logical_router_route.go index ee23ee56e29..2e220a0eef5 100644 --- a/pkg/ovs/ovn-nb-logical_router_route.go +++ b/pkg/ovs/ovn-nb-logical_router_route.go @@ -16,7 +16,7 @@ import ( "github.com/kubeovn/kube-ovn/pkg/util" ) -func (c *ovnClient) ListLogicalRouterStaticRoutesByOption(lrName, routeTable, key, value string) ([]*ovnnb.LogicalRouterStaticRoute, error) { +func (c *ovnNbClient) ListLogicalRouterStaticRoutesByOption(lrName, routeTable, key, value string) ([]*ovnnb.LogicalRouterStaticRoute, error) { fnFilter := func(route *ovnnb.LogicalRouterStaticRoute) bool { return len(route.Options) != 0 && route.Options[key] == value } @@ -24,7 +24,7 @@ func (c *ovnClient) ListLogicalRouterStaticRoutesByOption(lrName, routeTable, ke } // CreateLogicalRouterStaticRoutes create several logical router static route once -func (c *ovnClient) CreateLogicalRouterStaticRoutes(lrName string, routes ...*ovnnb.LogicalRouterStaticRoute) error { +func (c *ovnNbClient) CreateLogicalRouterStaticRoutes(lrName string, routes ...*ovnnb.LogicalRouterStaticRoute) error { if len(routes) == 0 { return nil } @@ -38,7 +38,7 @@ func (c *ovnClient) CreateLogicalRouterStaticRoutes(lrName string, routes ...*ov } } - createRoutesOp, err := c.ovnNbClient.Create(models...) + createRoutesOp, err := c.ovsDbClient.Create(models...) if err != nil { return fmt.Errorf("generate operations for creating static routes: %v", err) } @@ -60,7 +60,7 @@ func (c *ovnClient) CreateLogicalRouterStaticRoutes(lrName string, routes ...*ov } // AddLogicalRouterStaticRoute add a logical router static route -func (c *ovnClient) AddLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix string, bfdId *string, nexthops ...string) error { +func (c *ovnNbClient) AddLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix string, bfdId *string, nexthops ...string) error { if len(policy) == 0 { policy = ovnnb.LogicalRouterStaticRoutePolicyDstIP } @@ -111,12 +111,12 @@ func (c *ovnClient) AddLogicalRouterStaticRoute(lrName, routeTable, policy, ipPr } // UpdateLogicalRouterStaticRoute update logical router static route -func (c *ovnClient) UpdateLogicalRouterStaticRoute(route *ovnnb.LogicalRouterStaticRoute, fields ...interface{}) error { +func (c *ovnNbClient) UpdateLogicalRouterStaticRoute(route *ovnnb.LogicalRouterStaticRoute, fields ...interface{}) error { if route == nil { return fmt.Errorf("route is nil") } - op, err := c.ovnNbClient.Where(route).Update(route, fields...) + op, err := c.ovsDbClient.Where(route).Update(route, fields...) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for updating logical router static route 'policy %s ip_prefix %s': %v", *route.Policy, route.IPPrefix, err) @@ -130,7 +130,7 @@ func (c *ovnClient) UpdateLogicalRouterStaticRoute(route *ovnnb.LogicalRouterSta } // DeleteLogicalRouterStaticRoute add a logical router static route -func (c *ovnClient) DeleteLogicalRouterStaticRoute(lrName string, routeTable, policy *string, ipPrefix, nexthop string) error { +func (c *ovnNbClient) DeleteLogicalRouterStaticRoute(lrName string, routeTable, policy *string, ipPrefix, nexthop string) error { if policy == nil || len(*policy) == 0 { policy = &ovnnb.LogicalRouterStaticRoutePolicyDstIP } @@ -168,7 +168,7 @@ func (c *ovnClient) DeleteLogicalRouterStaticRoute(lrName string, routeTable, po } // ClearLogicalRouterStaticRoute clear static route from logical router once -func (c *ovnClient) ClearLogicalRouterStaticRoute(lrName string) error { +func (c *ovnNbClient) ClearLogicalRouterStaticRoute(lrName string) error { lr, err := c.GetLogicalRouter(lrName, false) if err != nil { klog.Error(err) @@ -191,7 +191,7 @@ func (c *ovnClient) ClearLogicalRouterStaticRoute(lrName string) error { } // GetLogicalRouterStaticRouteByUUID get logical router static route by UUID -func (c *ovnClient) GetLogicalRouterStaticRouteByUUID(uuid string) (*ovnnb.LogicalRouterStaticRoute, error) { +func (c *ovnNbClient) GetLogicalRouterStaticRouteByUUID(uuid string) (*ovnnb.LogicalRouterStaticRoute, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -207,7 +207,7 @@ func (c *ovnClient) GetLogicalRouterStaticRouteByUUID(uuid string) (*ovnnb.Logic // GetLogicalRouterStaticRoute get logical router static route by some attribute, // a static route is uniquely identified by router(lrName), policy and ipPrefix when route is not ecmp // a static route is uniquely identified by router(lrName), policy, ipPrefix and nexthop when route is ecmp -func (c *ovnClient) GetLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, nexthop string, ignoreNotFound bool) (*ovnnb.LogicalRouterStaticRoute, error) { +func (c *ovnNbClient) GetLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, nexthop string, ignoreNotFound bool) (*ovnnb.LogicalRouterStaticRoute, error) { // this is necessary because may exist same static route in different logical router if len(lrName) == 0 { return nil, fmt.Errorf("the logical router name is required") @@ -238,7 +238,7 @@ func (c *ovnClient) GetLogicalRouterStaticRoute(lrName, routeTable, policy, ipPr } // ListLogicalRouterStaticRoutes list route which match the given externalIDs -func (c *ovnClient) ListLogicalRouterStaticRoutes(lrName string, routeTable, policy *string, ipPrefix string, externalIDs map[string]string) ([]*ovnnb.LogicalRouterStaticRoute, error) { +func (c *ovnNbClient) ListLogicalRouterStaticRoutes(lrName string, routeTable, policy *string, ipPrefix string, externalIDs map[string]string) ([]*ovnnb.LogicalRouterStaticRoute, error) { fnFilter := func(route *ovnnb.LogicalRouterStaticRoute) bool { if len(route.ExternalIDs) < len(externalIDs) { return false @@ -282,13 +282,13 @@ func (c *ovnClient) ListLogicalRouterStaticRoutes(lrName string, routeTable, pol return c.listLogicalRouterStaticRoutesByFilter(lrName, fnFilter) } -func (c *ovnClient) LogicalRouterStaticRouteExists(lrName, routeTable, policy, ipPrefix, nexthop string) (bool, error) { +func (c *ovnNbClient) LogicalRouterStaticRouteExists(lrName, routeTable, policy, ipPrefix, nexthop string) (bool, error) { route, err := c.GetLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, nexthop, true) return route != nil, err } // newLogicalRouterStaticRoute return logical router static route with basic information -func (c *ovnClient) newLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, nexthop string, bfdId *string, options ...func(route *ovnnb.LogicalRouterStaticRoute)) (*ovnnb.LogicalRouterStaticRoute, error) { +func (c *ovnNbClient) newLogicalRouterStaticRoute(lrName, routeTable, policy, ipPrefix, nexthop string, bfdId *string, options ...func(route *ovnnb.LogicalRouterStaticRoute)) (*ovnnb.LogicalRouterStaticRoute, error) { if len(lrName) == 0 { return nil, fmt.Errorf("the logical router name is required") } @@ -328,7 +328,7 @@ func (c *ovnClient) newLogicalRouterStaticRoute(lrName, routeTable, policy, ipPr return route, nil } -func (c *ovnClient) listLogicalRouterStaticRoutesByFilter(lrName string, filter func(route *ovnnb.LogicalRouterStaticRoute) bool) ([]*ovnnb.LogicalRouterStaticRoute, error) { +func (c *ovnNbClient) listLogicalRouterStaticRoutesByFilter(lrName string, filter func(route *ovnnb.LogicalRouterStaticRoute) bool) ([]*ovnnb.LogicalRouterStaticRoute, error) { lr, err := c.GetLogicalRouter(lrName, false) if err != nil { klog.Error(err) diff --git a/pkg/ovs/ovn-nb-logical_router_test.go b/pkg/ovs/ovn-nb-logical_router_test.go index 99422645f2d..7a3e4215127 100644 --- a/pkg/ovs/ovn-nb-logical_router_test.go +++ b/pkg/ovs/ovn-nb-logical_router_test.go @@ -15,8 +15,8 @@ import ( ) // createLogicalRouter delete logical router in ovn -func createLogicalRouter(c *ovnClient, lr *ovnnb.LogicalRouter) error { - op, err := c.ovnNbClient.Create(lr) +func createLogicalRouter(c *ovnNbClient, lr *ovnnb.LogicalRouter) error { + op, err := c.ovsDbClient.Create(lr) if err != nil { return err } diff --git a/pkg/ovs/ovn-nb-logical_switch.go b/pkg/ovs/ovn-nb-logical_switch.go index 7024de8720d..491ab6ae774 100644 --- a/pkg/ovs/ovn-nb-logical_switch.go +++ b/pkg/ovs/ovn-nb-logical_switch.go @@ -14,7 +14,7 @@ import ( ) // CreateLogicalSwitch create logical switch -func (c *ovnClient) CreateLogicalSwitch(lsName, lrName, cidrBlock, gateway string, needRouter, randomAllocateGW bool) error { +func (c *ovnNbClient) CreateLogicalSwitch(lsName, lrName, cidrBlock, gateway string, needRouter, randomAllocateGW bool) error { lspName := fmt.Sprintf("%s-%s", lsName, lrName) lrpName := fmt.Sprintf("%s-%s", lrName, lsName) @@ -62,7 +62,7 @@ func (c *ovnClient) CreateLogicalSwitch(lsName, lrName, cidrBlock, gateway strin } // CreateBareLogicalSwitch create logical switch with basic configuration -func (c *ovnClient) CreateBareLogicalSwitch(lsName string) error { +func (c *ovnNbClient) CreateBareLogicalSwitch(lsName string) error { exist, err := c.LogicalSwitchExists(lsName) if err != nil { klog.Error(err) @@ -79,7 +79,7 @@ func (c *ovnClient) CreateBareLogicalSwitch(lsName string) error { ExternalIDs: map[string]string{"vendor": util.CniTypeName}, } - op, err := c.ovnNbClient.Create(ls) + op, err := c.ovsDbClient.Create(ls) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for creating logical switch %s: %v", lsName, err) @@ -93,7 +93,7 @@ func (c *ovnClient) CreateBareLogicalSwitch(lsName string) error { } // LogicalSwitchAddPort add port to logical switch -func (c *ovnClient) LogicalSwitchAddPort(lsName, lspName string) error { +func (c *ovnNbClient) LogicalSwitchAddPort(lsName, lspName string) error { lsp, err := c.GetLogicalSwitchPort(lspName, false) if err != nil { klog.Error(err) @@ -115,7 +115,7 @@ func (c *ovnClient) LogicalSwitchAddPort(lsName, lspName string) error { } // LogicalSwitchDelPort del port from logical switch -func (c *ovnClient) LogicalSwitchDelPort(lsName, lspName string) error { +func (c *ovnNbClient) LogicalSwitchDelPort(lsName, lspName string) error { lsp, err := c.GetLogicalSwitchPort(lspName, false) if err != nil { klog.Error(err) @@ -136,7 +136,7 @@ func (c *ovnClient) LogicalSwitchDelPort(lsName, lspName string) error { } // LogicalSwitchUpdateLoadBalancers add several lb to or from logical switch once -func (c *ovnClient) LogicalSwitchUpdateLoadBalancers(lsName string, op ovsdb.Mutator, lbNames ...string) error { +func (c *ovnNbClient) LogicalSwitchUpdateLoadBalancers(lsName string, op ovsdb.Mutator, lbNames ...string) error { if len(lbNames) == 0 { return nil } @@ -171,7 +171,7 @@ func (c *ovnClient) LogicalSwitchUpdateLoadBalancers(lsName string, op ovsdb.Mut } // LogicalSwitchUpdateOtherConfig add other config to or from logical switch once -func (c *ovnClient) LogicalSwitchUpdateOtherConfig(lsName string, op ovsdb.Mutator, otherConfig map[string]string) error { +func (c *ovnNbClient) LogicalSwitchUpdateOtherConfig(lsName string, op ovsdb.Mutator, otherConfig map[string]string) error { if len(otherConfig) == 0 { return nil } @@ -190,7 +190,7 @@ func (c *ovnClient) LogicalSwitchUpdateOtherConfig(lsName string, op ovsdb.Mutat } // DeleteLogicalSwitch delete logical switch -func (c *ovnClient) DeleteLogicalSwitch(lsName string) error { +func (c *ovnNbClient) DeleteLogicalSwitch(lsName string) error { op, err := c.DeleteLogicalSwitchOp(lsName) if err != nil { klog.Error(err) @@ -206,12 +206,12 @@ func (c *ovnClient) DeleteLogicalSwitch(lsName string) error { // GetLogicalSwitch get logical switch by name, // it is because of lack name index that does't use ovnNbClient.Get -func (c *ovnClient) GetLogicalSwitch(lsName string, ignoreNotFound bool) (*ovnnb.LogicalSwitch, error) { +func (c *ovnNbClient) GetLogicalSwitch(lsName string, ignoreNotFound bool) (*ovnnb.LogicalSwitch, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() lsList := make([]ovnnb.LogicalSwitch, 0) - if err := c.ovnNbClient.WhereCache(func(ls *ovnnb.LogicalSwitch) bool { + if err := c.ovsDbClient.WhereCache(func(ls *ovnnb.LogicalSwitch) bool { return ls.Name == lsName }).List(ctx, &lsList); err != nil { return nil, fmt.Errorf("list switch switch %q: %v", lsName, err) @@ -232,19 +232,19 @@ func (c *ovnClient) GetLogicalSwitch(lsName string, ignoreNotFound bool) (*ovnnb return &lsList[0], nil } -func (c *ovnClient) LogicalSwitchExists(lsName string) (bool, error) { +func (c *ovnNbClient) LogicalSwitchExists(lsName string) (bool, error) { ls, err := c.GetLogicalSwitch(lsName, true) return ls != nil, err } // ListLogicalSwitch list logical switch -func (c *ovnClient) ListLogicalSwitch(needVendorFilter bool, filter func(ls *ovnnb.LogicalSwitch) bool) ([]ovnnb.LogicalSwitch, error) { +func (c *ovnNbClient) ListLogicalSwitch(needVendorFilter bool, filter func(ls *ovnnb.LogicalSwitch) bool) ([]ovnnb.LogicalSwitch, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() lsList := make([]ovnnb.LogicalSwitch, 0) - if err := c.ovnNbClient.WhereCache(func(ls *ovnnb.LogicalSwitch) bool { + if err := c.ovsDbClient.WhereCache(func(ls *ovnnb.LogicalSwitch) bool { if needVendorFilter && (len(ls.ExternalIDs) == 0 || ls.ExternalIDs["vendor"] != util.CniTypeName) { return false } @@ -262,7 +262,7 @@ func (c *ovnClient) ListLogicalSwitch(needVendorFilter bool, filter func(ls *ovn } // LogicalSwitchUpdatePortOp create operations add port to or delete port from logical switch -func (c *ovnClient) LogicalSwitchUpdatePortOp(lsName string, lspUUID string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalSwitchUpdatePortOp(lsName string, lspUUID string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(lspUUID) == 0 { return nil, nil } @@ -306,7 +306,7 @@ func (c *ovnClient) LogicalSwitchUpdatePortOp(lsName string, lspUUID string, op } // LogicalSwitchUpdateOtherConfigOp create operations add otherConfig to or delete otherConfig from logical switch -func (c *ovnClient) LogicalSwitchUpdateOtherConfigOp(lsName string, otherConfig map[string]string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalSwitchUpdateOtherConfigOp(lsName string, otherConfig map[string]string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(otherConfig) == 0 { return nil, nil } @@ -325,7 +325,7 @@ func (c *ovnClient) LogicalSwitchUpdateOtherConfigOp(lsName string, otherConfig } // LogicalSwitchUpdateLoadBalancerOp create operations add lb to or delete lb from logical switch -func (c *ovnClient) LogicalSwitchUpdateLoadBalancerOp(lsName string, lbUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalSwitchUpdateLoadBalancerOp(lsName string, lbUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(lbUUIDs) == 0 { return nil, nil } @@ -344,7 +344,7 @@ func (c *ovnClient) LogicalSwitchUpdateLoadBalancerOp(lsName string, lbUUIDs []s } // logicalSwitchUpdateAclOp create operations add acl to or delete acl from logical switch -func (c *ovnClient) logicalSwitchUpdateAclOp(lsName string, aclUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) logicalSwitchUpdateAclOp(lsName string, aclUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(aclUUIDs) == 0 { return nil, nil } @@ -363,7 +363,7 @@ func (c *ovnClient) logicalSwitchUpdateAclOp(lsName string, aclUUIDs []string, o } // LogicalSwitchOp create operations about logical switch -func (c *ovnClient) LogicalSwitchOp(lsName string, mutationsFunc ...func(ls *ovnnb.LogicalSwitch) *model.Mutation) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) LogicalSwitchOp(lsName string, mutationsFunc ...func(ls *ovnnb.LogicalSwitch) *model.Mutation) ([]ovsdb.Operation, error) { ls, err := c.GetLogicalSwitch(lsName, false) if err != nil { klog.Error(err) @@ -384,7 +384,7 @@ func (c *ovnClient) LogicalSwitchOp(lsName string, mutationsFunc ...func(ls *ovn } } - ops, err := c.ovnNbClient.Where(ls).Mutate(ls, mutations...) + ops, err := c.ovsDbClient.Where(ls).Mutate(ls, mutations...) if err != nil { klog.Error(err) return nil, fmt.Errorf("generate operations for mutating logical switch %s: %v", lsName, err) @@ -394,7 +394,7 @@ func (c *ovnClient) LogicalSwitchOp(lsName string, mutationsFunc ...func(ls *ovn } // DeleteLogicalSwitchOp create operations that delete logical switch -func (c *ovnClient) DeleteLogicalSwitchOp(lsName string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) DeleteLogicalSwitchOp(lsName string) ([]ovsdb.Operation, error) { ls, err := c.GetLogicalSwitch(lsName, true) if err != nil { klog.Error(err) diff --git a/pkg/ovs/ovn-nb-logical_switch_port.go b/pkg/ovs/ovn-nb-logical_switch_port.go index 4ba3c89e7ff..f2db2d481b9 100644 --- a/pkg/ovs/ovn-nb-logical_switch_port.go +++ b/pkg/ovs/ovn-nb-logical_switch_port.go @@ -16,7 +16,7 @@ import ( "github.com/kubeovn/kube-ovn/pkg/util" ) -func (c *ovnClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, namespace string, portSecurity bool, securityGroups, vips string, enableDHCP bool, dhcpOptions *DHCPOptionsUUIDs, vpc string) error { +func (c *ovnNbClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, namespace string, portSecurity bool, securityGroups, vips string, enableDHCP bool, dhcpOptions *DHCPOptionsUUIDs, vpc string) error { exist, err := c.LogicalSwitchPortExists(lspName) if err != nil { klog.Error(err) @@ -102,7 +102,7 @@ func (c *ovnClient) CreateLogicalSwitchPort(lsName, lspName, ip, mac, podName, n } // CreateLocalnetLogicalSwitchPort create localnet type logical switch port -func (c *ovnClient) CreateLocalnetLogicalSwitchPort(lsName, lspName, provider string, vlanID int) error { +func (c *ovnNbClient) CreateLocalnetLogicalSwitchPort(lsName, lspName, provider string, vlanID int) error { exist, err := c.LogicalSwitchPortExists(lspName) if err != nil { klog.Error(err) @@ -143,7 +143,7 @@ func (c *ovnClient) CreateLocalnetLogicalSwitchPort(lsName, lspName, provider st } // CreateVirtualLogicalSwitchPorts create several virtual type logical switch port once -func (c *ovnClient) CreateVirtualLogicalSwitchPorts(lsName string, ips ...string) error { +func (c *ovnNbClient) CreateVirtualLogicalSwitchPorts(lsName string, ips ...string) error { ops := make([]ovsdb.Operation, 0, len(ips)) for _, ip := range ips { @@ -186,7 +186,7 @@ func (c *ovnClient) CreateVirtualLogicalSwitchPorts(lsName string, ips ...string } // CreateBareLogicalSwitchPort create logical switch port with basic configuration -func (c *ovnClient) CreateBareLogicalSwitchPort(lsName, lspName, ip, mac string) error { +func (c *ovnNbClient) CreateBareLogicalSwitchPort(lsName, lspName, ip, mac string) error { exist, err := c.LogicalSwitchPortExists(lspName) if err != nil { klog.Error(err) @@ -224,7 +224,7 @@ func (c *ovnClient) CreateBareLogicalSwitchPort(lsName, lspName, ip, mac string) } // CreateVirtualLogicalSwitchPorts update several virtual type logical switch port virtual-parents once -func (c *ovnClient) SetLogicalSwitchPortVirtualParents(lsName, parents string, ips ...string) error { +func (c *ovnNbClient) SetLogicalSwitchPortVirtualParents(lsName, parents string, ips ...string) error { ops := make([]ovsdb.Operation, 0, len(ips)) for _, ip := range ips { lspName := fmt.Sprintf("%s-vip-%s", lsName, ip) @@ -255,7 +255,7 @@ func (c *ovnClient) SetLogicalSwitchPortVirtualParents(lsName, parents string, i return nil } -func (c *ovnClient) SetLogicalSwitchPortArpProxy(lspName string, enableArpProxy bool) error { +func (c *ovnNbClient) SetLogicalSwitchPortArpProxy(lspName string, enableArpProxy bool) error { lsp, err := c.GetLogicalSwitchPort(lspName, false) if err != nil { return fmt.Errorf("get logical switch port %s: %v", lspName, err) @@ -280,7 +280,7 @@ func (c *ovnClient) SetLogicalSwitchPortArpProxy(lspName string, enableArpProxy } // SetLogicalSwitchPortSecurity set logical switch port port_security -func (c *ovnClient) SetLogicalSwitchPortSecurity(portSecurity bool, lspName, mac, ips, vips string) error { +func (c *ovnNbClient) SetLogicalSwitchPortSecurity(portSecurity bool, lspName, mac, ips, vips string) error { lsp, err := c.GetLogicalSwitchPort(lspName, false) if err != nil { klog.Error(err) @@ -325,7 +325,7 @@ func (c *ovnClient) SetLogicalSwitchPortSecurity(portSecurity bool, lspName, mac } // SetLogicalSwitchPortExternalIds set logical switch port external ids -func (c *ovnClient) SetLogicalSwitchPortExternalIds(lspName string, externalIds map[string]string) error { +func (c *ovnNbClient) SetLogicalSwitchPortExternalIds(lspName string, externalIds map[string]string) error { lsp, err := c.GetLogicalSwitchPort(lspName, false) if err != nil { klog.Error(err) @@ -349,7 +349,7 @@ func (c *ovnClient) SetLogicalSwitchPortExternalIds(lspName string, externalIds // SetLogicalSwitchPortSecurityGroup set logical switch port security group, // op is 'add' or 'remove' -func (c *ovnClient) SetLogicalSwitchPortSecurityGroup(lsp *ovnnb.LogicalSwitchPort, op string, sgs ...string) ([]string, error) { +func (c *ovnNbClient) SetLogicalSwitchPortSecurityGroup(lsp *ovnnb.LogicalSwitchPort, op string, sgs ...string) ([]string, error) { if len(sgs) == 0 { return nil, nil } @@ -395,7 +395,7 @@ func (c *ovnClient) SetLogicalSwitchPortSecurityGroup(lsp *ovnnb.LogicalSwitchPo // SetLogicalSwitchPortsSecurityGroup set logical switch port security group, // op is 'add' or 'remove' -func (c *ovnClient) SetLogicalSwitchPortsSecurityGroup(sgName string, op string) error { +func (c *ovnNbClient) SetLogicalSwitchPortsSecurityGroup(sgName string, op string) error { if op != "add" && op != "remove" { return fmt.Errorf("op must be 'add' or 'remove'") } @@ -425,7 +425,7 @@ func (c *ovnClient) SetLogicalSwitchPortsSecurityGroup(sgName string, op string) } // EnablePortLayer2forward set logical switch port addresses as 'unknown' -func (c *ovnClient) EnablePortLayer2forward(lspName string) error { +func (c *ovnNbClient) EnablePortLayer2forward(lspName string) error { lsp, err := c.GetLogicalSwitchPort(lspName, false) if err != nil { klog.Error(err) @@ -441,7 +441,7 @@ func (c *ovnClient) EnablePortLayer2forward(lspName string) error { return nil } -func (c *ovnClient) SetLogicalSwitchPortVlanTag(lspName string, vlanID int) error { +func (c *ovnNbClient) SetLogicalSwitchPortVlanTag(lspName string, vlanID int) error { // valid vlan id is 0~4095 if vlanID < 0 || vlanID > 4095 { return fmt.Errorf("invalid vlan id %d", vlanID) @@ -471,7 +471,7 @@ func (c *ovnClient) SetLogicalSwitchPortVlanTag(lspName string, vlanID int) erro } // UpdateLogicalSwitchPort update logical switch port -func (c *ovnClient) UpdateLogicalSwitchPort(lsp *ovnnb.LogicalSwitchPort, fields ...interface{}) error { +func (c *ovnNbClient) UpdateLogicalSwitchPort(lsp *ovnnb.LogicalSwitchPort, fields ...interface{}) error { if lsp == nil { return fmt.Errorf("logical_switch_port is nil") } @@ -490,7 +490,7 @@ func (c *ovnClient) UpdateLogicalSwitchPort(lsp *ovnnb.LogicalSwitchPort, fields } // DeleteLogicalSwitchPort delete logical switch port in ovn -func (c *ovnClient) DeleteLogicalSwitchPort(lspName string) error { +func (c *ovnNbClient) DeleteLogicalSwitchPort(lspName string) error { ops, err := c.DeleteLogicalSwitchPortOp(lspName) if err != nil { klog.Error(err) @@ -505,7 +505,7 @@ func (c *ovnClient) DeleteLogicalSwitchPort(lspName string) error { } // GetLogicalSwitchPort get logical switch port by name -func (c *ovnClient) GetLogicalSwitchPort(lspName string, ignoreNotFound bool) (*ovnnb.LogicalSwitchPort, error) { +func (c *ovnNbClient) GetLogicalSwitchPort(lspName string, ignoreNotFound bool) (*ovnnb.LogicalSwitchPort, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() lsp := &ovnnb.LogicalSwitchPort{Name: lspName} @@ -520,7 +520,7 @@ func (c *ovnClient) GetLogicalSwitchPort(lspName string, ignoreNotFound bool) (* } // ListNormalLogicalSwitchPorts list logical switch ports which type is "" -func (c *ovnClient) ListNormalLogicalSwitchPorts(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.LogicalSwitchPort, error) { +func (c *ovnNbClient) ListNormalLogicalSwitchPorts(needVendorFilter bool, externalIDs map[string]string) ([]ovnnb.LogicalSwitchPort, error) { lsps, err := c.ListLogicalSwitchPorts(needVendorFilter, externalIDs, func(lsp *ovnnb.LogicalSwitchPort) bool { return lsp.Type == "" }) @@ -533,7 +533,7 @@ func (c *ovnClient) ListNormalLogicalSwitchPorts(needVendorFilter bool, external } // ListLogicalSwitchPortsWithLegacyExternalIDs list logical switch ports with legacy external-ids -func (c *ovnClient) ListLogicalSwitchPortsWithLegacyExternalIDs() ([]ovnnb.LogicalSwitchPort, error) { +func (c *ovnNbClient) ListLogicalSwitchPortsWithLegacyExternalIDs() ([]ovnnb.LogicalSwitchPort, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -548,7 +548,7 @@ func (c *ovnClient) ListLogicalSwitchPortsWithLegacyExternalIDs() ([]ovnnb.Logic } // ListLogicalSwitchPorts list logical switch ports -func (c *ovnClient) ListLogicalSwitchPorts(needVendorFilter bool, externalIDs map[string]string, filter func(lsp *ovnnb.LogicalSwitchPort) bool) ([]ovnnb.LogicalSwitchPort, error) { +func (c *ovnNbClient) ListLogicalSwitchPorts(needVendorFilter bool, externalIDs map[string]string, filter func(lsp *ovnnb.LogicalSwitchPort) bool) ([]ovnnb.LogicalSwitchPort, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -561,13 +561,13 @@ func (c *ovnClient) ListLogicalSwitchPorts(needVendorFilter bool, externalIDs ma return lspList, nil } -func (c *ovnClient) LogicalSwitchPortExists(name string) (bool, error) { +func (c *ovnNbClient) LogicalSwitchPortExists(name string) (bool, error) { lsp, err := c.GetLogicalSwitchPort(name, true) return lsp != nil, err } // CreateLogicalSwitchPortOp create operations which create logical switch port -func (c *ovnClient) CreateLogicalSwitchPortOp(lsp *ovnnb.LogicalSwitchPort, lsName string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) CreateLogicalSwitchPortOp(lsp *ovnnb.LogicalSwitchPort, lsName string) ([]ovsdb.Operation, error) { if lsp == nil { return nil, fmt.Errorf("logical_switch_port is nil") } @@ -602,7 +602,7 @@ func (c *ovnClient) CreateLogicalSwitchPortOp(lsp *ovnnb.LogicalSwitchPort, lsNa } // DeleteLogicalSwitchPortOp create operations which delete logical switch port -func (c *ovnClient) DeleteLogicalSwitchPortOp(lspName string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) DeleteLogicalSwitchPortOp(lspName string) ([]ovsdb.Operation, error) { lsp, err := c.GetLogicalSwitchPort(lspName, true) if err != nil { klog.Error(err) @@ -624,7 +624,7 @@ func (c *ovnClient) DeleteLogicalSwitchPortOp(lspName string) ([]ovsdb.Operation } // UpdateLogicalSwitchPortOp create operations which update logical switch port -func (c *ovnClient) UpdateLogicalSwitchPortOp(lsp *ovnnb.LogicalSwitchPort, fields ...interface{}) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) UpdateLogicalSwitchPortOp(lsp *ovnnb.LogicalSwitchPort, fields ...interface{}) ([]ovsdb.Operation, error) { // not found, skip if lsp == nil { return nil, nil diff --git a/pkg/ovs/ovn-nb-logical_switch_port_test.go b/pkg/ovs/ovn-nb-logical_switch_port_test.go index 5305bb35539..a0d843b6c2b 100644 --- a/pkg/ovs/ovn-nb-logical_switch_port_test.go +++ b/pkg/ovs/ovn-nb-logical_switch_port_test.go @@ -14,7 +14,7 @@ import ( "github.com/kubeovn/kube-ovn/pkg/util" ) -func createLogicalSwitchPort(c *ovnClient, lsp *ovnnb.LogicalSwitchPort) error { +func createLogicalSwitchPort(c *ovnNbClient, lsp *ovnnb.LogicalSwitchPort) error { if lsp == nil { return fmt.Errorf("logical_switch_port is nil") } diff --git a/pkg/ovs/ovn-nb-logical_switch_test.go b/pkg/ovs/ovn-nb-logical_switch_test.go index b9ec6322c88..8fd391e86a7 100644 --- a/pkg/ovs/ovn-nb-logical_switch_test.go +++ b/pkg/ovs/ovn-nb-logical_switch_test.go @@ -14,7 +14,7 @@ import ( "github.com/kubeovn/kube-ovn/pkg/util" ) -func createLogicalSwitch(c *ovnClient, ls *ovnnb.LogicalSwitch) error { +func createLogicalSwitch(c *ovnNbClient, ls *ovnnb.LogicalSwitch) error { op, err := c.Create(ls) if err != nil { return err diff --git a/pkg/ovs/ovn-nb-nat.go b/pkg/ovs/ovn-nb-nat.go index 4728e3e1fb3..4e9514912d7 100644 --- a/pkg/ovs/ovn-nb-nat.go +++ b/pkg/ovs/ovn-nb-nat.go @@ -15,7 +15,7 @@ import ( "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnnb" ) -func (c *ovnClient) AddNat(lrName, natType, externalIP, logicalIP, logicalMac, port string, options map[string]string) error { +func (c *ovnNbClient) AddNat(lrName, natType, externalIP, logicalIP, logicalMac, port string, options map[string]string) error { nat, err := c.newNat(lrName, natType, externalIP, logicalIP, logicalMac, port, func(nat *ovnnb.NAT) { if len(options) == 0 { return @@ -35,7 +35,7 @@ func (c *ovnClient) AddNat(lrName, natType, externalIP, logicalIP, logicalMac, p } // CreateNats create several logical router nat rule once -func (c *ovnClient) CreateNats(lrName string, nats ...*ovnnb.NAT) error { +func (c *ovnNbClient) CreateNats(lrName string, nats ...*ovnnb.NAT) error { if len(nats) == 0 { return nil } @@ -49,7 +49,7 @@ func (c *ovnClient) CreateNats(lrName string, nats ...*ovnnb.NAT) error { } } - createNatsOp, err := c.ovnNbClient.Create(models...) + createNatsOp, err := c.ovsDbClient.Create(models...) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for creating nats: %v", err) @@ -73,7 +73,7 @@ func (c *ovnClient) CreateNats(lrName string, nats ...*ovnnb.NAT) error { } // UpdateSnat update snat rule -func (c *ovnClient) UpdateSnat(lrName, externalIP, logicalIP string) error { +func (c *ovnNbClient) UpdateSnat(lrName, externalIP, logicalIP string) error { natType := ovnnb.NATTypeSNAT nat, err := c.GetNat(lrName, natType, "", logicalIP, true) @@ -103,7 +103,7 @@ func (c *ovnClient) UpdateSnat(lrName, externalIP, logicalIP string) error { } // UpdateDnatAndSnat update dnat_and_snat rule -func (c *ovnClient) UpdateDnatAndSnat(lrName, externalIP, logicalIP, lspName, externalMac, gatewayType string) error { +func (c *ovnNbClient) UpdateDnatAndSnat(lrName, externalIP, logicalIP, lspName, externalMac, gatewayType string) error { natType := ovnnb.NATTypeDNATAndSNAT nat, err := c.GetNat(lrName, natType, externalIP, "", true) @@ -150,12 +150,12 @@ func (c *ovnClient) UpdateDnatAndSnat(lrName, externalIP, logicalIP, lspName, ex } // UpdateNat update nat -func (c *ovnClient) UpdateNat(nat *ovnnb.NAT, fields ...interface{}) error { +func (c *ovnNbClient) UpdateNat(nat *ovnnb.NAT, fields ...interface{}) error { if nat == nil { return fmt.Errorf("nat is nil") } - op, err := c.ovnNbClient.Where(nat).Update(nat, fields...) + op, err := c.ovsDbClient.Where(nat).Update(nat, fields...) if err != nil { klog.Error(err) return fmt.Errorf("generate operations for updating nat 'type %s external ip %s logical ip %s': %v", nat.Type, nat.ExternalIP, nat.LogicalIP, err) @@ -170,7 +170,7 @@ func (c *ovnClient) UpdateNat(nat *ovnnb.NAT, fields ...interface{}) error { } // DeleteNat delete several nat rule once -func (c *ovnClient) DeleteNats(lrName, natType, logicalIP string) error { +func (c *ovnNbClient) DeleteNats(lrName, natType, logicalIP string) error { /* delete nats from logical router */ nats, err := c.ListNats(lrName, natType, logicalIP, nil) if err != nil { @@ -196,7 +196,7 @@ func (c *ovnClient) DeleteNats(lrName, natType, logicalIP string) error { } // DeleteNat delete nat rule -func (c *ovnClient) DeleteNat(lrName, natType, externalIP, logicalIP string) error { +func (c *ovnNbClient) DeleteNat(lrName, natType, externalIP, logicalIP string) error { nat, err := c.GetNat(lrName, natType, externalIP, logicalIP, false) if err != nil { klog.Error(err) @@ -217,7 +217,7 @@ func (c *ovnClient) DeleteNat(lrName, natType, externalIP, logicalIP string) err } // GetNATByUUID get NAT by UUID -func (c *ovnClient) GetNATByUUID(uuid string) (*ovnnb.NAT, error) { +func (c *ovnNbClient) GetNATByUUID(uuid string) (*ovnnb.NAT, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -232,7 +232,7 @@ func (c *ovnClient) GetNATByUUID(uuid string) (*ovnnb.NAT, error) { // GetNat get nat by some attribute, // a nat rule is uniquely identified by router(lrName), type(natType) and logical_ip when snat // a nat rule is uniquely identified by router(lrName), type(natType) and external_ip when dnat_and_snat -func (c *ovnClient) GetNat(lrName, natType, externalIP, logicalIP string, ignoreNotFound bool) (*ovnnb.NAT, error) { +func (c *ovnNbClient) GetNat(lrName, natType, externalIP, logicalIP string, ignoreNotFound bool) (*ovnnb.NAT, error) { // this is necessary because may exist same nat rule in different logical router if len(lrName) == 0 { return nil, fmt.Errorf("the logical router name is required") @@ -273,17 +273,17 @@ func (c *ovnClient) GetNat(lrName, natType, externalIP, logicalIP string, ignore } // ListNats list acls which match the given externalIDs -func (c *ovnClient) ListNats(lrName, natType, logicalIP string, externalIDs map[string]string) ([]*ovnnb.NAT, error) { +func (c *ovnNbClient) ListNats(lrName, natType, logicalIP string, externalIDs map[string]string) ([]*ovnnb.NAT, error) { return c.listLogicalRouterNatByFilter(lrName, natFilter(natType, logicalIP, externalIDs)) } -func (c *ovnClient) NatExists(lrName, natType, externalIP, logicalIP string) (bool, error) { +func (c *ovnNbClient) NatExists(lrName, natType, externalIP, logicalIP string) (bool, error) { nat, err := c.GetNat(lrName, natType, externalIP, logicalIP, true) return nat != nil, err } // newNat return net with basic information -func (c *ovnClient) newNat(lrName, natType, externalIP, logicalIP, logicalMac, port string, options ...func(nat *ovnnb.NAT)) (*ovnnb.NAT, error) { +func (c *ovnNbClient) newNat(lrName, natType, externalIP, logicalIP, logicalMac, port string, options ...func(nat *ovnnb.NAT)) (*ovnnb.NAT, error) { if len(lrName) == 0 { return nil, fmt.Errorf("the logical router name is required") } @@ -365,7 +365,7 @@ func natFilter(natType, logicalIP string, externalIDs map[string]string) func(na } } -func (c *ovnClient) listLogicalRouterNatByFilter(lrName string, filter func(route *ovnnb.NAT) bool) ([]*ovnnb.NAT, error) { +func (c *ovnNbClient) listLogicalRouterNatByFilter(lrName string, filter func(route *ovnnb.NAT) bool) ([]*ovnnb.NAT, error) { lr, err := c.GetLogicalRouter(lrName, false) if err != nil { klog.Error(err) diff --git a/pkg/ovs/ovn-nb-port_group.go b/pkg/ovs/ovn-nb-port_group.go index cbba9f56672..705a061df66 100644 --- a/pkg/ovs/ovn-nb-port_group.go +++ b/pkg/ovs/ovn-nb-port_group.go @@ -13,7 +13,7 @@ import ( "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnnb" ) -func (c *ovnClient) CreatePortGroup(pgName string, externalIDs map[string]string) error { +func (c *ovnNbClient) CreatePortGroup(pgName string, externalIDs map[string]string) error { exist, err := c.PortGroupExists(pgName) if err != nil { klog.Error(err) @@ -30,7 +30,7 @@ func (c *ovnClient) CreatePortGroup(pgName string, externalIDs map[string]string ExternalIDs: externalIDs, } - ops, err := c.ovnNbClient.Create(pg) + ops, err := c.ovsDbClient.Create(pg) if err != nil { return fmt.Errorf("generate operations for creating port group %s: %v", pgName, err) } @@ -43,16 +43,16 @@ func (c *ovnClient) CreatePortGroup(pgName string, externalIDs map[string]string } // PortGroupAddPorts add ports to port group -func (c *ovnClient) PortGroupAddPorts(pgName string, lspNames ...string) error { +func (c *ovnNbClient) PortGroupAddPorts(pgName string, lspNames ...string) error { return c.PortGroupUpdatePorts(pgName, ovsdb.MutateOperationInsert, lspNames...) } // PortGroupRemovePorts remove ports from port group -func (c *ovnClient) PortGroupRemovePorts(pgName string, lspNames ...string) error { +func (c *ovnNbClient) PortGroupRemovePorts(pgName string, lspNames ...string) error { return c.PortGroupUpdatePorts(pgName, ovsdb.MutateOperationDelete, lspNames...) } -func (c *ovnClient) PortGroupSetPorts(pgName string, ports []string) error { +func (c *ovnNbClient) PortGroupSetPorts(pgName string, ports []string) error { pg, err := c.GetPortGroup(pgName, false) if err != nil { return fmt.Errorf("get port group %s: %v", pgName, err) @@ -91,7 +91,7 @@ func (c *ovnClient) PortGroupSetPorts(pgName string, ports []string) error { } // UpdatePortGroup update port group -func (c *ovnClient) UpdatePortGroup(pg *ovnnb.PortGroup, fields ...interface{}) error { +func (c *ovnNbClient) UpdatePortGroup(pg *ovnnb.PortGroup, fields ...interface{}) error { op, err := c.Where(pg).Update(pg, fields...) if err != nil { return fmt.Errorf("generate operations for updating port group %s: %v", pg.Name, err) @@ -105,7 +105,7 @@ func (c *ovnClient) UpdatePortGroup(pg *ovnnb.PortGroup, fields ...interface{}) } // PortGroupUpdatePorts add several ports to or from port group once -func (c *ovnClient) PortGroupUpdatePorts(pgName string, op ovsdb.Mutator, lspNames ...string) error { +func (c *ovnNbClient) PortGroupUpdatePorts(pgName string, op ovsdb.Mutator, lspNames ...string) error { if len(lspNames) == 0 { return nil } @@ -137,7 +137,7 @@ func (c *ovnClient) PortGroupUpdatePorts(pgName string, op ovsdb.Mutator, lspNam return nil } -func (c *ovnClient) DeletePortGroup(pgName string) error { +func (c *ovnNbClient) DeletePortGroup(pgName string) error { pg, err := c.GetPortGroup(pgName, true) if err != nil { return fmt.Errorf("get port group %s when delete: %v", pgName, err) @@ -162,12 +162,12 @@ func (c *ovnClient) DeletePortGroup(pgName string) error { } // GetPortGroup get port group by name -func (c *ovnClient) GetPortGroup(pgName string, ignoreNotFound bool) (*ovnnb.PortGroup, error) { +func (c *ovnNbClient) GetPortGroup(pgName string, ignoreNotFound bool) (*ovnnb.PortGroup, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() pg := &ovnnb.PortGroup{Name: pgName} - if err := c.ovnNbClient.Get(ctx, pg); err != nil { + if err := c.ovsDbClient.Get(ctx, pg); err != nil { if ignoreNotFound && err == client.ErrNotFound { return nil, nil } @@ -180,7 +180,7 @@ func (c *ovnClient) GetPortGroup(pgName string, ignoreNotFound bool) (*ovnnb.Por // ListPortGroups list port groups which match the given externalIDs, // result should include all port groups when externalIDs is empty, // result should include all port groups which externalIDs[key] is not empty when externalIDs[key] is "" -func (c *ovnClient) ListPortGroups(externalIDs map[string]string) ([]ovnnb.PortGroup, error) { +func (c *ovnNbClient) ListPortGroups(externalIDs map[string]string) ([]ovnnb.PortGroup, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -217,13 +217,13 @@ func (c *ovnClient) ListPortGroups(externalIDs map[string]string) ([]ovnnb.PortG return pgs, nil } -func (c *ovnClient) PortGroupExists(pgName string) (bool, error) { +func (c *ovnNbClient) PortGroupExists(pgName string) (bool, error) { lsp, err := c.GetPortGroup(pgName, true) return lsp != nil, err } // portGroupUpdatePortOp create operations add port to or delete port from port group -func (c *ovnClient) portGroupUpdatePortOp(pgName string, lspUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) portGroupUpdatePortOp(pgName string, lspUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(lspUUIDs) == 0 { return nil, nil } @@ -242,7 +242,7 @@ func (c *ovnClient) portGroupUpdatePortOp(pgName string, lspUUIDs []string, op o } // portGroupUpdateAclOp create operations add acl to or delete acl from port group -func (c *ovnClient) portGroupUpdateAclOp(pgName string, aclUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) portGroupUpdateAclOp(pgName string, aclUUIDs []string, op ovsdb.Mutator) ([]ovsdb.Operation, error) { if len(aclUUIDs) == 0 { return nil, nil } @@ -261,7 +261,7 @@ func (c *ovnClient) portGroupUpdateAclOp(pgName string, aclUUIDs []string, op ov } // portGroupOp create operations about port group -func (c *ovnClient) portGroupOp(pgName string, mutationsFunc ...func(pg *ovnnb.PortGroup) *model.Mutation) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) portGroupOp(pgName string, mutationsFunc ...func(pg *ovnnb.PortGroup) *model.Mutation) ([]ovsdb.Operation, error) { pg, err := c.GetPortGroup(pgName, false) if err != nil { return nil, fmt.Errorf("get port group %s: %v", pgName, err) @@ -281,7 +281,7 @@ func (c *ovnClient) portGroupOp(pgName string, mutationsFunc ...func(pg *ovnnb.P } } - ops, err := c.ovnNbClient.Where(pg).Mutate(pg, mutations...) + ops, err := c.ovsDbClient.Where(pg).Mutate(pg, mutations...) if err != nil { return nil, fmt.Errorf("generate operations for mutating port group %s: %v", pgName, err) } diff --git a/pkg/ovs/ovn-nb-suite_test.go b/pkg/ovs/ovn-nb-suite_test.go index 5529621a145..16824262397 100644 --- a/pkg/ovs/ovn-nb-suite_test.go +++ b/pkg/ovs/ovn-nb-suite_test.go @@ -26,7 +26,7 @@ import ( type OvnClientTestSuite struct { suite.Suite - ovnClient *ovnClient + ovnClient *ovnNbClient } func (suite *OvnClientTestSuite) SetupSuite() { @@ -39,7 +39,7 @@ func (suite *OvnClientTestSuite) SetupSuite() { endpoint := fmt.Sprintf("unix:%s", sock) require.FileExists(suite.T(), sock) - ovnClient, err := newOvnClient(suite.T(), endpoint, 10, "100.64.0.0/16,fd00:100:64::/64") + ovnClient, err := newOvnNbClient(suite.T(), endpoint, 10) require.NoError(suite.T(), err) suite.ovnClient = ovnClient @@ -649,7 +649,7 @@ func (suite *OvnClientTestSuite) Test_GetEntityInfo() { func Test_scratch(t *testing.T) { t.SkipNow() endpoint := "tcp:[172.20.149.35]:6641" - ovnClient, err := newOvnClient(t, endpoint, 10, "") + ovnClient, err := newOvnNbClient(t, endpoint, 10) require.NoError(t, err) err = ovnClient.DeleteAcls("test_pg", portGroupKey, ovnnb.ACLDirectionToLport, nil) @@ -692,16 +692,15 @@ func newOVSDBServer(t *testing.T, dbModel model.ClientDBModel, schema ovsdb.Data return server, tmpfile } -func newOvnClient(t *testing.T, ovnNbAddr string, ovnNbTimeout int, nodeSwitchCIDR string) (*ovnClient, error) { +func newOvnNbClient(t *testing.T, ovnNbAddr string, ovnNbTimeout int) (*ovnNbClient, error) { nbClient, err := newNbClient(ovnNbAddr, ovnNbTimeout) require.NoError(t, err) - return &ovnClient{ - ovnNbClient: ovnNbClient{ + return &ovnNbClient{ + ovsDbClient: ovsDbClient{ Client: nbClient, Timeout: time.Duration(ovnNbTimeout) * time.Second, }, - NodeSwitchCIDR: nodeSwitchCIDR, }, nil } diff --git a/pkg/ovs/ovn-nb.go b/pkg/ovs/ovn-nb.go index 751057d8306..69963bdf549 100644 --- a/pkg/ovs/ovn-nb.go +++ b/pkg/ovs/ovn-nb.go @@ -1,9 +1,7 @@ package ovs import ( - "context" "fmt" - "reflect" "strings" "github.com/ovn-org/libovsdb/ovsdb" @@ -24,7 +22,7 @@ const ( ) // CreateGatewayLogicalSwitch create gateway switch connect external networks -func (c *ovnClient) CreateGatewayLogicalSwitch(lsName, lrName, provider, ip, mac string, vlanID int, chassises ...string) error { +func (c *ovnNbClient) CreateGatewayLogicalSwitch(lsName, lrName, provider, ip, mac string, vlanID int, chassises ...string) error { lspName := fmt.Sprintf("%s-%s", lsName, lrName) lrpName := fmt.Sprintf("%s-%s", lrName, lsName) @@ -51,7 +49,7 @@ func (c *ovnClient) CreateGatewayLogicalSwitch(lsName, lrName, provider, ip, mac } // CreateLogicalPatchPort create logical router port and associated logical switch port which type is router -func (c *ovnClient) CreateLogicalPatchPort(lsName, lrName, lspName, lrpName, ip, mac string, chassises ...string) error { +func (c *ovnNbClient) CreateLogicalPatchPort(lsName, lrName, lspName, lrpName, ip, mac string, chassises ...string) error { if len(ip) != 0 { // check ip format: 192.168.231.1/24,fc00::0af4:01/112 if err := util.CheckCidrs(ip); err != nil { @@ -78,7 +76,7 @@ func (c *ovnClient) CreateLogicalPatchPort(lsName, lrName, lspName, lrpName, ip, } // DeleteLogicalGatewaySwitch delete gateway switch and corresponding port -func (c *ovnClient) DeleteLogicalGatewaySwitch(lsName, lrName string) error { +func (c *ovnNbClient) DeleteLogicalGatewaySwitch(lsName, lrName string) error { lrpName := fmt.Sprintf("%s-%s", lrName, lsName) // all corresponding logical switch port(e.g. localnet port and normal port) will be deleted when delete logical switch @@ -103,7 +101,7 @@ func (c *ovnClient) DeleteLogicalGatewaySwitch(lsName, lrName string) error { return nil } -func (c *ovnClient) DeleteSecurityGroup(sgName string) error { +func (c *ovnNbClient) DeleteSecurityGroup(sgName string) error { pgName := GetSgPortGroupName(sgName) // clear acl @@ -130,7 +128,7 @@ func (c *ovnClient) DeleteSecurityGroup(sgName string) error { return nil } -func (c *ovnClient) CreateRouterPortOp(lsName, lrName, lspName, lrpName, ip, mac string) ([]ovsdb.Operation, error) { +func (c *ovnNbClient) CreateRouterPortOp(lsName, lrName, lspName, lrpName, ip, mac string) ([]ovsdb.Operation, error) { /* do nothing if logical switch port exist */ lspExist, err := c.LogicalSwitchPortExists(lspName) if err != nil { @@ -179,7 +177,7 @@ func (c *ovnClient) CreateRouterPortOp(lsName, lrName, lspName, lrpName, ip, mac } // RemoveLogicalPatchPort delete logical router port and associated logical switch port which type is router -func (c *ovnClient) RemoveLogicalPatchPort(lspName, lrpName string) error { +func (c *ovnNbClient) RemoveLogicalPatchPort(lspName, lrpName string) error { /* delete logical switch port*/ lspDelOp, err := c.DeleteLogicalSwitchPortOp(lspName) if err != nil { @@ -202,23 +200,3 @@ func (c *ovnClient) RemoveLogicalPatchPort(lspName, lrpName string) error { return nil } - -// GetEntityInfo get entity info by column which is the index, -// reference to ovn-nb.ovsschema(ovsdb-client get-schema unix:/var/run/ovn/ovnnb_db.sock OVN_Northbound) for more information, -// UUID is index -func (c *ovnClient) GetEntityInfo(entity interface{}) error { - ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) - defer cancel() - - entityPtr := reflect.ValueOf(entity) - if entityPtr.Kind() != reflect.Pointer { - return fmt.Errorf("entity must be pointer") - } - - err := c.Get(ctx, entity) - if err != nil { - return err - } - - return nil -} diff --git a/pkg/ovs/ovn-nb_global.go b/pkg/ovs/ovn-nb_global.go index 091e424a988..96df1836d43 100644 --- a/pkg/ovs/ovn-nb_global.go +++ b/pkg/ovs/ovn-nb_global.go @@ -10,8 +10,8 @@ import ( "k8s.io/klog/v2" ) -func (c *ovnClient) CreateNbGlobal(nbGlobal *ovnnb.NBGlobal) error { - op, err := c.ovnNbClient.Create(nbGlobal) +func (c *ovnNbClient) CreateNbGlobal(nbGlobal *ovnnb.NBGlobal) error { + op, err := c.ovsDbClient.Create(nbGlobal) if err != nil { return fmt.Errorf("generate operations for creating nb global: %v", err) } @@ -19,7 +19,7 @@ func (c *ovnClient) CreateNbGlobal(nbGlobal *ovnnb.NBGlobal) error { return c.Transact("nb-global-create", op) } -func (c *ovnClient) DeleteNbGlobal() error { +func (c *ovnNbClient) DeleteNbGlobal() error { nbGlobal, err := c.GetNbGlobal() if err != nil { klog.Error(err) @@ -35,7 +35,7 @@ func (c *ovnClient) DeleteNbGlobal() error { return c.Transact("nb-global-delete", op) } -func (c *ovnClient) GetNbGlobal() (*ovnnb.NBGlobal, error) { +func (c *ovnNbClient) GetNbGlobal() (*ovnnb.NBGlobal, error) { ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) defer cancel() @@ -58,7 +58,7 @@ func (c *ovnClient) GetNbGlobal() (*ovnnb.NBGlobal, error) { return &nbGlobalList[0], nil } -func (c *ovnClient) UpdateNbGlobal(nbGlobal *ovnnb.NBGlobal, fields ...interface{}) error { +func (c *ovnNbClient) UpdateNbGlobal(nbGlobal *ovnnb.NBGlobal, fields ...interface{}) error { op, err := c.Where(nbGlobal).Update(nbGlobal, fields...) if err != nil { return fmt.Errorf("generate operations for updating nb global: %v", err) @@ -71,7 +71,7 @@ func (c *ovnClient) UpdateNbGlobal(nbGlobal *ovnnb.NBGlobal, fields ...interface return nil } -func (c *ovnClient) SetAzName(azName string) error { +func (c *ovnNbClient) SetAzName(azName string) error { nbGlobal, err := c.GetNbGlobal() if err != nil { return fmt.Errorf("get nb global: %v", err) @@ -88,7 +88,7 @@ func (c *ovnClient) SetAzName(azName string) error { return nil } -func (c *ovnClient) SetNbGlobalOptions(key string, value interface{}) error { +func (c *ovnNbClient) SetNbGlobalOptions(key string, value interface{}) error { nbGlobal, err := c.GetNbGlobal() if err != nil { return fmt.Errorf("failed to get nb global: %v", err) @@ -111,11 +111,11 @@ func (c *ovnClient) SetNbGlobalOptions(key string, value interface{}) error { return nil } -func (c *ovnClient) SetUseCtInvMatch() error { +func (c *ovnNbClient) SetUseCtInvMatch() error { return c.SetNbGlobalOptions("use_ct_inv_match", false) } -func (c *ovnClient) SetICAutoRoute(enable bool, blackList []string) error { +func (c *ovnNbClient) SetICAutoRoute(enable bool, blackList []string) error { nbGlobal, err := c.GetNbGlobal() if err != nil { return fmt.Errorf("get nb global: %v", err) @@ -146,10 +146,10 @@ func (c *ovnClient) SetICAutoRoute(enable bool, blackList []string) error { return nil } -func (c *ovnClient) SetLBCIDR(serviceCIDR string) error { +func (c *ovnNbClient) SetLBCIDR(serviceCIDR string) error { return c.SetNbGlobalOptions("svc_ipv4_cidr", serviceCIDR) } -func (c *ovnClient) SetLsDnatModDlDst(enabled bool) error { +func (c *ovnNbClient) SetLsDnatModDlDst(enabled bool) error { return c.SetNbGlobalOptions("ls_dnat_mod_dl_dst", enabled) } diff --git a/pkg/ovs/ovn-sb-chassis.go b/pkg/ovs/ovn-sb-chassis.go new file mode 100644 index 00000000000..804bc04ad06 --- /dev/null +++ b/pkg/ovs/ovn-sb-chassis.go @@ -0,0 +1,193 @@ +package ovs + +import ( + "context" + "fmt" + + "github.com/ovn-org/libovsdb/client" + "k8s.io/klog/v2" + + "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnsb" + "github.com/kubeovn/kube-ovn/pkg/util" +) + +func (c *ovnSbClient) UpdateChassis(chassis *ovnsb.Chassis, fields ...interface{}) error { + op, err := c.ovsDbClient.Where(chassis).Update(chassis, fields...) + if err != nil { + err := fmt.Errorf("failed to generate update operations for chassis: %v", err) + klog.Error(err) + return err + } + if err = c.Transact("chassis-update", op); err != nil { + err := fmt.Errorf("failed to update chassis %s: %v", chassis.Name, err) + klog.Error(err) + return err + } + return nil +} + +// DeleteChassis delete one chassis by name +func (c *ovnSbClient) DeleteChassis(chassisName string) error { + chassis, err := c.GetChassis(chassisName, true) + if err != nil { + klog.Error(err) + return err + } + if chassis == nil { + return nil + } + ops, err := c.ovsDbClient.Where(chassis).Delete() + if err != nil { + return fmt.Errorf("failed to generate delete operations for chassis %s: %v", chassis.UUID, err) + } + if err = c.Transact("chassis-del", ops); err != nil { + return fmt.Errorf("failed to delete chassis with with UUID %s: %v", chassis.UUID, err) + } + return nil +} + +// GetChassis return south bound db chassis from cache +func (c *ovnSbClient) GetChassis(chassisName string, ignoreNotFound bool) (*ovnsb.Chassis, error) { + ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) + defer cancel() + if chassisName == "" { + err := fmt.Errorf("chassis name is empty") + klog.Error(err) + return nil, err + } + chassis := &ovnsb.Chassis{Name: chassisName} + if err := c.ovsDbClient.Get(ctx, chassis); err != nil { + if ignoreNotFound && err == client.ErrNotFound { + return nil, nil + } + return nil, fmt.Errorf("failed to get chassis %s: %v", chassisName, err) + } + klog.V(3).Infof("get chassis: %+v", chassis) + return chassis, nil +} + +// ListChassis return south bound db chassis from cache +func (c *ovnSbClient) ListChassis() (*[]ovnsb.Chassis, error) { + ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) + defer cancel() + + css := []ovnsb.Chassis{} + if err := c.ovsDbClient.List(ctx, &css); err != nil { + return nil, fmt.Errorf("failed to list Chassis: %v", err) + } + return &css, nil +} + +func (c *ovnSbClient) GetAllChassisByHost(nodeName string) (*[]ovnsb.Chassis, error) { + ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) + defer cancel() + + chassisList := make([]ovnsb.Chassis, 0) + if err := c.ovsDbClient.WhereCache(func(chassis *ovnsb.Chassis) bool { + return chassis.Hostname == nodeName + }).List(ctx, &chassisList); err != nil { + return nil, fmt.Errorf("failed to list Chassis with host name=%s: %v", nodeName, err) + } + if len(chassisList) == 0 { + err := fmt.Errorf("failed to get Chassis with with host name=%s", nodeName) + klog.Error(err) + return nil, err + } + if len(chassisList) != 1 { + err := fmt.Errorf("found more than one Chassis with with host name=%s", nodeName) + klog.Error(err) + return nil, err + } + return &chassisList, nil +} + +func (c *ovnSbClient) GetChassisByHost(nodeName string) (*ovnsb.Chassis, error) { + ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) + defer cancel() + + chassisList := make([]ovnsb.Chassis, 0) + if err := c.ovsDbClient.WhereCache(func(chassis *ovnsb.Chassis) bool { + return chassis.Hostname == nodeName + }).List(ctx, &chassisList); err != nil { + return nil, fmt.Errorf("failed to list Chassis with host name=%s: %v", nodeName, err) + } + if len(chassisList) == 0 { + err := fmt.Errorf("failed to get Chassis with with host name=%s", nodeName) + klog.Error(err) + return nil, err + } + if len(chassisList) != 1 { + err := fmt.Errorf("found more than one Chassis with with host name=%s", nodeName) + klog.Error(err) + return nil, err + } + return &chassisList[0], nil +} + +// DeleteChassisByHost delete all chassis by node name +func (c *ovnSbClient) DeleteChassisByHost(nodeName string) error { + ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) + defer cancel() + + chassisList := make([]ovnsb.Chassis, 0) + if err := c.ovsDbClient.WhereCache(func(chassis *ovnsb.Chassis) bool { + return chassis.Hostname == nodeName || (chassis.ExternalIDs != nil && chassis.ExternalIDs["node"] == nodeName) + }).List(ctx, &chassisList); err != nil { + return fmt.Errorf("failed to list Chassis with host name=%s: %v", nodeName, err) + } + + for _, chassis := range chassisList { + klog.Infof("delete chassis: %+v", chassis) + if err := c.DeleteChassis(chassis.Name); err != nil { + err := fmt.Errorf("failed to delete chassis %s, %v", chassis.Name, err) + klog.Error(err) + return err + } + } + return nil +} + +func (c *ovnSbClient) UpdateChassisTag(chassisName string, nodeName string) error { + chassis, err := c.GetChassis(chassisName, true) + if err != nil { + klog.Error(err) + return err + } + if chassis == nil { + err := fmt.Errorf("faile to get chassis by name=%s", chassisName) + // restart kube-ovn-cni, chassis will be created + klog.Error(err) + return err + } + if chassis.ExternalIDs == nil || chassis.ExternalIDs["node"] != nodeName { + externalIDs := make(map[string]string, len(chassis.ExternalIDs)+2) + for k, v := range chassis.ExternalIDs { + externalIDs[k] = v + } + externalIDs["vendor"] = util.CniTypeName + // externalIDs["node"] = nodeName + // not need filter chassis by node name if we use libovsdb + chassis.ExternalIDs = externalIDs + if err := c.UpdateChassis(chassis, &chassis.ExternalIDs); err != nil { + return fmt.Errorf("failed to init chassis node %s: %v", nodeName, err) + } + } + return nil +} + +// GetKubeOvnChassisses return all chassis which vendor is kube-ovn +func (c *ovnSbClient) GetKubeOvnChassisses() (*[]ovnsb.Chassis, error) { + ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) + defer cancel() + + chassisList := make([]ovnsb.Chassis, 0) + if err := c.ovsDbClient.WhereCache(func(chassis *ovnsb.Chassis) bool { + if chassis.ExternalIDs != nil && chassis.ExternalIDs["vendor"] == util.CniTypeName { + return true + } + return false + }).List(ctx, &chassisList); err != nil { + return nil, fmt.Errorf("failed to list Chassis with vendor=%s: %v", util.CniTypeName, err) + } + return &chassisList, nil +} diff --git a/pkg/ovs/ovn-sbctl.go b/pkg/ovs/ovn-sbctl.go deleted file mode 100644 index 34dd9595f7d..00000000000 --- a/pkg/ovs/ovn-sbctl.go +++ /dev/null @@ -1,173 +0,0 @@ -package ovs - -import ( - "fmt" - "os" - "os/exec" - "strings" - "time" - - "k8s.io/klog/v2" - - "github.com/kubeovn/kube-ovn/pkg/util" -) - -func (c LegacyClient) ovnSbCommand(cmdArgs ...string) (string, error) { - start := time.Now() - if os.Getenv("ENABLE_SSL") == "true" { - cmdArgs = append([]string{ - fmt.Sprintf("--timeout=%d", c.OvnTimeout), - fmt.Sprintf("--db=%s", c.OvnSbAddress), - "-p", "/var/run/tls/key", - "-c", "/var/run/tls/cert", - "-C", "/var/run/tls/cacert"}, cmdArgs...) - } else { - cmdArgs = append([]string{ - fmt.Sprintf("--timeout=%d", c.OvnTimeout), - fmt.Sprintf("--db=%s", c.OvnSbAddress)}, cmdArgs...) - } - raw, err := exec.Command(OvnSbCtl, cmdArgs...).CombinedOutput() - elapsed := float64((time.Since(start)) / time.Millisecond) - klog.V(4).Infof("command %s %s in %vms", OvnSbCtl, strings.Join(cmdArgs, " "), elapsed) - method := "" - for _, arg := range cmdArgs { - if !strings.HasPrefix(arg, "--") { - method = arg - break - } - } - code := "0" - defer func() { - ovsClientRequestLatency.WithLabelValues("ovn-sb", method, code).Observe(elapsed) - }() - - if err != nil { - code = "1" - klog.Warningf("ovn-sbctl command error: %s %s in %vms", OvnSbCtl, strings.Join(cmdArgs, " "), elapsed) - return "", fmt.Errorf("%s, %q", raw, err) - } else if elapsed > 500 { - klog.Warningf("ovn-sbctl command took too long: %s %s in %vms", OvnSbCtl, strings.Join(cmdArgs, " "), elapsed) - } - return trimCommandOutput(raw), nil -} - -func (c LegacyClient) GetVersion() (string, error) { - if c.Version != "" { - return c.Version, nil - } - output, err := c.ovnSbCommand("--version") - if err != nil { - klog.Error(err) - return "", fmt.Errorf("failed to get version,%v", err) - } - lines := strings.Split(output, "\n") - if len(lines) > 0 { - c.Version = strings.Fields(lines[0])[1] - } - return c.Version, nil -} - -func (c LegacyClient) DeleteChassisByNode(node string) error { - chassis, err := c.GetChassis(node) - if err != nil { - klog.Error(err) - return fmt.Errorf("failed to get node chassis %s, %v", node, err) - } - if chassis == "" { - return nil - } - - return c.DeleteChassisByName(chassis) -} - -func (c LegacyClient) DeleteChassisByName(chassisName string) error { - ovnVersion, err := c.GetVersion() - if err != nil { - klog.Error(err) - return fmt.Errorf("failed to get ovn version, %v", err) - } - - cmdArg := []string{"chassis-del", strings.TrimSpace(chassisName)} - if util.CompareVersion(ovnVersion, "20.09") >= 0 { - cmdArg = append(cmdArg, "--", "destroy", "chassis_private", strings.TrimSpace(chassisName)) - } - if _, err := c.ovnSbCommand(cmdArg...); err != nil { - return err - } - return nil -} - -func (c LegacyClient) GetChassis(node string) (string, error) { - output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("external_ids:node=%s", node)) - if err != nil { - klog.Error(err) - return "", fmt.Errorf("failed to find node chassis %s, %v", node, err) - } - if len(output) == 0 { - output, err = c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("hostname=%s", node)) - if err != nil { - klog.Error(err) - return "", fmt.Errorf("failed to find node chassis %s, %v", node, err) - } - } - return strings.TrimSpace(output), nil -} - -func (c LegacyClient) ChassisExist(chassisName string) (bool, error) { - output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("name=%s", chassisName)) - if err != nil { - klog.Error(err) - return false, fmt.Errorf("failed to find node chassis %s, %v", chassisName, err) - } - if len(output) == 0 { - return false, nil - } - return true, nil -} - -func (c LegacyClient) InitChassisNodeTag(chassisName string, nodeName string) error { - _, err := c.ovnSbCommand("set", "chassis", chassisName, fmt.Sprintf("external_ids:vendor=%s", util.CniTypeName), fmt.Sprintf("external_ids:node=%s", nodeName)) - if err != nil { - klog.Error(err) - return fmt.Errorf("failed to set chassis external_ids, %v", err) - } - return nil -} - -// GetAllChassis get all chassis init by kube-ovn -func (c LegacyClient) GetAllChassis() ([]string, error) { - output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("external_ids:vendor=%s", util.CniTypeName)) - if err != nil { - klog.Error(err) - return nil, fmt.Errorf("failed to find node chassis, %v", err) - } - lines := strings.Split(output, "\n") - result := make([]string, 0, len(lines)) - for _, l := range lines { - if len(strings.TrimSpace(l)) == 0 { - continue - } - result = append(result, strings.TrimSpace(l)) - } - return result, nil -} - -// GetAllChassisMap return a map of chassis uuid : node name -func (c LegacyClient) GetAllChassisMap() (map[string]string, error) { - output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name,hostname", "find", "chassis", fmt.Sprintf("external_ids:vendor=%s", util.CniTypeName)) - if err != nil { - return nil, fmt.Errorf("failed to find node chassis, %v", err) - } - lines := strings.Split(output, "\n") - result := make(map[string]string, len(lines)) - for _, l := range lines { - if len(strings.TrimSpace(l)) == 0 { - continue - } - res := strings.Split(l, ",") - if len(res) == 2 { - result[res[0]] = res[1] - } - } - return result, nil -} diff --git a/pkg/ovs/ovn.go b/pkg/ovs/ovn.go index 22c820a6d6e..84afd459a1c 100644 --- a/pkg/ovs/ovn.go +++ b/pkg/ovs/ovn.go @@ -2,7 +2,8 @@ package ovs import ( "context" - "errors" + "fmt" + "reflect" "time" "github.com/ovn-org/libovsdb/client" @@ -10,43 +11,32 @@ import ( "k8s.io/klog/v2" ovsclient "github.com/kubeovn/kube-ovn/pkg/ovsdb/client" -) - -var ( - ErrNoAddr = errors.New("no address") - ErrNotFound = errors.New("not found") + "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnnb" + "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnsb" ) // LegacyClient is the legacy ovn client type LegacyClient struct { - OvnTimeout int - OvnSbAddress string - OvnICNbAddress string - OvnICSbAddress string - ClusterRouter string - ClusterTcpLoadBalancer string - ClusterUdpLoadBalancer string - ClusterTcpSessionLoadBalancer string - ClusterUdpSessionLoadBalancer string - NodeSwitch string - NodeSwitchCIDR string - Version string + OvnTimeout int + OvnICNbAddress string + OvnICSbAddress string } -type ovnClient struct { - ovnNbClient - ClusterRouter string - NodeSwitchCIDR string +type ovnNbClient struct { + ovsDbClient + ClusterRouter string } -type ovnNbClient struct { +type ovnSbClient struct { + ovsDbClient +} + +type ovsDbClient struct { client.Client Timeout time.Duration } const ( - OvnNbCtl = "ovn-nbctl" - OvnSbCtl = "ovn-sbctl" OVNIcNbCtl = "ovn-ic-nbctl" OVNIcSbCtl = "ovn-ic-sbctl" OvsVsCtl = "ovs-vsctl" @@ -57,38 +47,79 @@ const ( ) // NewLegacyClient init a legacy ovn client -func NewLegacyClient(timeout int, ovnSbAddr, clusterRouter, clusterTcpLoadBalancer, clusterUdpLoadBalancer, clusterTcpSessionLoadBalancer, clusterUdpSessionLoadBalancer, nodeSwitch, nodeSwitchCIDR string) *LegacyClient { +func NewLegacyClient(timeout int) *LegacyClient { return &LegacyClient{ - OvnSbAddress: ovnSbAddr, - OvnTimeout: timeout, - ClusterRouter: clusterRouter, - ClusterTcpLoadBalancer: clusterTcpLoadBalancer, - ClusterUdpLoadBalancer: clusterUdpLoadBalancer, - ClusterTcpSessionLoadBalancer: clusterTcpSessionLoadBalancer, - ClusterUdpSessionLoadBalancer: clusterUdpSessionLoadBalancer, - NodeSwitch: nodeSwitch, - NodeSwitchCIDR: nodeSwitchCIDR, + OvnTimeout: timeout, } } -// TODO: support sb/ic-nb client -func NewOvnClient(ovnNbAddr string, ovnNbTimeout int, nodeSwitchCIDR string) (*ovnClient, error) { - nbClient, err := ovsclient.NewNbClient(ovnNbAddr) +func NewOvnNbClient(ovnNbAddr string, ovnNbTimeout int) (*ovnNbClient, error) { + dbModel, err := ovnnb.FullDatabaseModel() + if err != nil { + klog.Error(err) + return nil, err + } + + monitors := []client.MonitorOption{ + client.WithTable(&ovnnb.ACL{}), + client.WithTable(&ovnnb.AddressSet{}), + client.WithTable(&ovnnb.BFD{}), + client.WithTable(&ovnnb.DHCPOptions{}), + client.WithTable(&ovnnb.GatewayChassis{}), + client.WithTable(&ovnnb.LoadBalancer{}), + client.WithTable(&ovnnb.LogicalRouterPolicy{}), + client.WithTable(&ovnnb.LogicalRouterPort{}), + client.WithTable(&ovnnb.LogicalRouterStaticRoute{}), + client.WithTable(&ovnnb.LogicalRouter{}), + client.WithTable(&ovnnb.LogicalSwitchPort{}), + client.WithTable(&ovnnb.LogicalSwitch{}), + client.WithTable(&ovnnb.NAT{}), + client.WithTable(&ovnnb.NBGlobal{}), + client.WithTable(&ovnnb.PortGroup{}), + } + nbClient, err := ovsclient.NewOvsDbClient(ovsclient.NBDB, ovnNbAddr, dbModel, monitors) if err != nil { klog.Errorf("failed to create OVN NB client: %v", err) return nil, err } - c := &ovnClient{ - ovnNbClient: ovnNbClient{ + c := &ovnNbClient{ + ovsDbClient: ovsDbClient{ Client: nbClient, Timeout: time.Duration(ovnNbTimeout) * time.Second, }, - NodeSwitchCIDR: nodeSwitchCIDR, } return c, nil } +func NewOvnSbClient(ovnSbAddr string, ovnSbTimeout int) (*ovnSbClient, error) { + dbModel, err := ovnsb.FullDatabaseModel() + if err != nil { + klog.Error(err) + return nil, err + } + + monitors := []client.MonitorOption{ + client.WithTable(&ovnsb.Chassis{}), + // TODO:// monitor other neccessary tables in ovsdb/ovnsb/model.go + } + sbClient, err := ovsclient.NewOvsDbClient(ovsclient.SBDB, ovnSbAddr, dbModel, monitors) + if err != nil { + klog.Errorf("failed to create OVN SB client: %v", err) + return nil, err + } + + c := &ovnSbClient{ + ovsDbClient: ovsDbClient{ + Client: sbClient, + Timeout: time.Duration(ovnSbTimeout) * time.Second, + }, + } + return c, nil +} + +// TODO: support ic-nb ic-sb client + func ConstructWaitForNameNotExistsOperation(name string, table string) ovsdb.Operation { return ConstructWaitForUniqueOperation(table, "name", name) } @@ -106,7 +137,7 @@ func ConstructWaitForUniqueOperation(table string, column string, value interfac } } -func (c *ovnClient) Transact(method string, operations []ovsdb.Operation) error { +func (c *ovsDbClient) Transact(method string, operations []ovsdb.Operation) error { if len(operations) == 0 { klog.V(6).Info("operations should not be empty") return nil @@ -116,13 +147,15 @@ func (c *ovnClient) Transact(method string, operations []ovsdb.Operation) error defer cancel() start := time.Now() - results, err := c.ovnNbClient.Transact(ctx, operations...) + results, err := c.Client.Transact(ctx, operations...) elapsed := float64((time.Since(start)) / time.Millisecond) var dbType string switch c.Schema().Name { case "OVN_Northbound": dbType = "ovn-nb" + case "OVN_Southbound": + dbType = "ovn-sb" } code := "0" @@ -148,3 +181,23 @@ func (c *ovnClient) Transact(method string, operations []ovsdb.Operation) error return nil } + +// GetEntityInfo get entity info by column which is the index, +// reference to ovn-nb.ovsschema(ovsdb-client get-schema unix:/var/run/ovn/ovnnb_db.sock OVN_Northbound) for more information, +// UUID is index +func (c *ovsDbClient) GetEntityInfo(entity interface{}) error { + ctx, cancel := context.WithTimeout(context.Background(), c.Timeout) + defer cancel() + + entityPtr := reflect.ValueOf(entity) + if entityPtr.Kind() != reflect.Pointer { + return fmt.Errorf("entity must be pointer") + } + + err := c.Get(ctx, entity) + if err != nil { + return err + } + + return nil +} diff --git a/pkg/ovsdb/client/client.go b/pkg/ovsdb/client/client.go index bc5dccb6acb..38371fa204c 100644 --- a/pkg/ovsdb/client/client.go +++ b/pkg/ovsdb/client/client.go @@ -14,12 +14,17 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/ovn-org/libovsdb/client" + "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" "k8s.io/klog/v2" - - "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnnb" ) +const ( + NBDB = "nbdb" + SBDB = "sbdb" + ICNBDB = "icnbdb" + ICSBDB = "icsbdb" +) const timeout = 3 * time.Second var namedUUIDCounter uint32 @@ -36,21 +41,15 @@ func NamedUUID() string { return fmt.Sprintf("u%010d", atomic.AddUint32(&namedUUIDCounter, 1)) } -// NewNbClient creates a new OVN NB client -func NewNbClient(addr string) (client.Client, error) { - dbModel, err := ovnnb.FullDatabaseModel() - if err != nil { - klog.Error(err) - return nil, err - } - - logger := klog.NewKlogr().WithName("libovsdb") +// NewOvsDbClient creates a new ovsdb client +func NewOvsDbClient(db, addr string, dbModel model.ClientDBModel, monitors []client.MonitorOption) (client.Client, error) { + logger := klog.NewKlogr().WithName("libovsdb").WithValues("db", db) options := []client.Option{ client.WithReconnect(timeout, &backoff.ConstantBackOff{Interval: time.Second}), client.WithLeaderOnly(true), client.WithLogger(&logger), } - + klog.Infof("connecting to OVN %s server %s", db, addr) var ssl bool endpoints := strings.Split(addr, ",") for _, ep := range endpoints { @@ -59,7 +58,6 @@ func NewNbClient(addr string) (client.Client, error) { } options = append(options, client.WithEndpoint(ep)) } - if ssl { cert, err := tls.LoadX509KeyPair("/var/run/tls/cert", "/var/run/tls/key") if err != nil { @@ -71,7 +69,6 @@ func NewNbClient(addr string) (client.Client, error) { klog.Error(err) return nil, fmt.Errorf("failed to read ca cert: %v", err) } - certPool := x509.NewCertPool() certPool.AppendCertsFromPEM(caCert) // #nosec @@ -80,16 +77,13 @@ func NewNbClient(addr string) (client.Client, error) { RootCAs: certPool, InsecureSkipVerify: true, } - options = append(options, client.WithTLSConfig(tlsConfig)) } - c, err := client.NewOVSDBClient(dbModel, options...) if err != nil { klog.Error(err) return nil, err } - ctx, cancel := context.WithTimeout(context.Background(), time.Duration(len(endpoints)+1)*timeout) defer cancel() if err = c.Connect(ctx); err != nil { @@ -97,28 +91,11 @@ func NewNbClient(addr string) (client.Client, error) { return nil, err } - monitor := c.NewMonitor( - client.WithTable(&ovnnb.ACL{}), - client.WithTable(&ovnnb.AddressSet{}), - client.WithTable(&ovnnb.BFD{}), - client.WithTable(&ovnnb.DHCPOptions{}), - client.WithTable(&ovnnb.GatewayChassis{}), - client.WithTable(&ovnnb.LoadBalancer{}), - client.WithTable(&ovnnb.LogicalRouterPolicy{}), - client.WithTable(&ovnnb.LogicalRouterPort{}), - client.WithTable(&ovnnb.LogicalRouterStaticRoute{}), - client.WithTable(&ovnnb.LogicalRouter{}), - client.WithTable(&ovnnb.LogicalSwitchPort{}), - client.WithTable(&ovnnb.LogicalSwitch{}), - client.WithTable(&ovnnb.NAT{}), - client.WithTable(&ovnnb.NBGlobal{}), - client.WithTable(&ovnnb.PortGroup{}), - ) + monitor := c.NewMonitor(monitors...) monitor.Method = ovsdb.ConditionalMonitorRPC if _, err = c.Monitor(context.TODO(), monitor); err != nil { - klog.Errorf("failed to monitor database on OVN NB server %s: %v", addr, err) + klog.Errorf("failed to monitor database on OVN %s server %s: %v", db, addr, err) return nil, err } - return c, nil } diff --git a/pkg/ovsdb/ovnsb/address_set.go b/pkg/ovsdb/ovnsb/address_set.go new file mode 100644 index 00000000000..f9495ce25cb --- /dev/null +++ b/pkg/ovsdb/ovnsb/address_set.go @@ -0,0 +1,13 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const AddressSetTable = "Address_Set" + +// AddressSet defines an object in Address_Set table +type AddressSet struct { + UUID string `ovsdb:"_uuid"` + Addresses []string `ovsdb:"addresses"` + Name string `ovsdb:"name"` +} diff --git a/pkg/ovsdb/ovnsb/bfd.go b/pkg/ovsdb/ovnsb/bfd.go new file mode 100644 index 00000000000..ab4aae34b58 --- /dev/null +++ b/pkg/ovsdb/ovnsb/bfd.go @@ -0,0 +1,32 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const BFDTable = "BFD" + +type ( + BFDStatus = string +) + +var ( + BFDStatusDown BFDStatus = "down" + BFDStatusInit BFDStatus = "init" + BFDStatusUp BFDStatus = "up" + BFDStatusAdminDown BFDStatus = "admin_down" +) + +// BFD defines an object in BFD table +type BFD struct { + UUID string `ovsdb:"_uuid"` + DetectMult int `ovsdb:"detect_mult"` + Disc int `ovsdb:"disc"` + DstIP string `ovsdb:"dst_ip"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + LogicalPort string `ovsdb:"logical_port"` + MinRx int `ovsdb:"min_rx"` + MinTx int `ovsdb:"min_tx"` + Options map[string]string `ovsdb:"options"` + SrcPort int `ovsdb:"src_port"` + Status BFDStatus `ovsdb:"status"` +} diff --git a/pkg/ovsdb/ovnsb/chassis.go b/pkg/ovsdb/ovnsb/chassis.go new file mode 100644 index 00000000000..88eccc6abab --- /dev/null +++ b/pkg/ovsdb/ovnsb/chassis.go @@ -0,0 +1,19 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const ChassisTable = "Chassis" + +// Chassis defines an object in Chassis table +type Chassis struct { + UUID string `ovsdb:"_uuid"` + Encaps []string `ovsdb:"encaps"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + Hostname string `ovsdb:"hostname"` + Name string `ovsdb:"name"` + NbCfg int `ovsdb:"nb_cfg"` + OtherConfig map[string]string `ovsdb:"other_config"` + TransportZones []string `ovsdb:"transport_zones"` + VtepLogicalSwitches []string `ovsdb:"vtep_logical_switches"` +} diff --git a/pkg/ovsdb/ovnsb/chassis_private.go b/pkg/ovsdb/ovnsb/chassis_private.go new file mode 100644 index 00000000000..b8163b90436 --- /dev/null +++ b/pkg/ovsdb/ovnsb/chassis_private.go @@ -0,0 +1,16 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const ChassisPrivateTable = "Chassis_Private" + +// ChassisPrivate defines an object in Chassis_Private table +type ChassisPrivate struct { + UUID string `ovsdb:"_uuid"` + Chassis *string `ovsdb:"chassis"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + Name string `ovsdb:"name"` + NbCfg int `ovsdb:"nb_cfg"` + NbCfgTimestamp int `ovsdb:"nb_cfg_timestamp"` +} diff --git a/pkg/ovsdb/ovnsb/chassis_template_var.go b/pkg/ovsdb/ovnsb/chassis_template_var.go new file mode 100644 index 00000000000..e89a9fed953 --- /dev/null +++ b/pkg/ovsdb/ovnsb/chassis_template_var.go @@ -0,0 +1,13 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const ChassisTemplateVarTable = "Chassis_Template_Var" + +// ChassisTemplateVar defines an object in Chassis_Template_Var table +type ChassisTemplateVar struct { + UUID string `ovsdb:"_uuid"` + Chassis string `ovsdb:"chassis"` + Variables map[string]string `ovsdb:"variables"` +} diff --git a/pkg/ovsdb/ovnsb/connection.go b/pkg/ovsdb/ovnsb/connection.go new file mode 100644 index 00000000000..57c0e6ba93e --- /dev/null +++ b/pkg/ovsdb/ovnsb/connection.go @@ -0,0 +1,20 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const ConnectionTable = "Connection" + +// Connection defines an object in Connection table +type Connection struct { + UUID string `ovsdb:"_uuid"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + InactivityProbe *int `ovsdb:"inactivity_probe"` + IsConnected bool `ovsdb:"is_connected"` + MaxBackoff *int `ovsdb:"max_backoff"` + OtherConfig map[string]string `ovsdb:"other_config"` + ReadOnly bool `ovsdb:"read_only"` + Role string `ovsdb:"role"` + Status map[string]string `ovsdb:"status"` + Target string `ovsdb:"target"` +} diff --git a/pkg/ovsdb/ovnsb/controller_event.go b/pkg/ovsdb/ovnsb/controller_event.go new file mode 100644 index 00000000000..d358d0a3055 --- /dev/null +++ b/pkg/ovsdb/ovnsb/controller_event.go @@ -0,0 +1,23 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const ControllerEventTable = "Controller_Event" + +type ( + ControllerEventEventType = string +) + +var ( + ControllerEventEventTypeEmptyLbBackends ControllerEventEventType = "empty_lb_backends" +) + +// ControllerEvent defines an object in Controller_Event table +type ControllerEvent struct { + UUID string `ovsdb:"_uuid"` + Chassis *string `ovsdb:"chassis"` + EventInfo map[string]string `ovsdb:"event_info"` + EventType ControllerEventEventType `ovsdb:"event_type"` + SeqNum int `ovsdb:"seq_num"` +} diff --git a/pkg/ovsdb/ovnsb/datapath_binding.go b/pkg/ovsdb/ovnsb/datapath_binding.go new file mode 100644 index 00000000000..32cd63462f3 --- /dev/null +++ b/pkg/ovsdb/ovnsb/datapath_binding.go @@ -0,0 +1,14 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const DatapathBindingTable = "Datapath_Binding" + +// DatapathBinding defines an object in Datapath_Binding table +type DatapathBinding struct { + UUID string `ovsdb:"_uuid"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + LoadBalancers []string `ovsdb:"load_balancers"` + TunnelKey int `ovsdb:"tunnel_key"` +} diff --git a/pkg/ovsdb/ovnsb/dhcp_options.go b/pkg/ovsdb/ovnsb/dhcp_options.go new file mode 100644 index 00000000000..bd9f9a87593 --- /dev/null +++ b/pkg/ovsdb/ovnsb/dhcp_options.go @@ -0,0 +1,30 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const DHCPOptionsTable = "DHCP_Options" + +type ( + DHCPOptionsType = string +) + +var ( + DHCPOptionsTypeBool DHCPOptionsType = "bool" + DHCPOptionsTypeUint8 DHCPOptionsType = "uint8" + DHCPOptionsTypeUint16 DHCPOptionsType = "uint16" + DHCPOptionsTypeUint32 DHCPOptionsType = "uint32" + DHCPOptionsTypeIpv4 DHCPOptionsType = "ipv4" + DHCPOptionsTypeStaticRoutes DHCPOptionsType = "static_routes" + DHCPOptionsTypeStr DHCPOptionsType = "str" + DHCPOptionsTypeHostID DHCPOptionsType = "host_id" + DHCPOptionsTypeDomains DHCPOptionsType = "domains" +) + +// DHCPOptions defines an object in DHCP_Options table +type DHCPOptions struct { + UUID string `ovsdb:"_uuid"` + Code int `ovsdb:"code"` + Name string `ovsdb:"name"` + Type DHCPOptionsType `ovsdb:"type"` +} diff --git a/pkg/ovsdb/ovnsb/dhcpv6_options.go b/pkg/ovsdb/ovnsb/dhcpv6_options.go new file mode 100644 index 00000000000..a8d58a755dc --- /dev/null +++ b/pkg/ovsdb/ovnsb/dhcpv6_options.go @@ -0,0 +1,24 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const DHCPv6OptionsTable = "DHCPv6_Options" + +type ( + DHCPv6OptionsType = string +) + +var ( + DHCPv6OptionsTypeIpv6 DHCPv6OptionsType = "ipv6" + DHCPv6OptionsTypeStr DHCPv6OptionsType = "str" + DHCPv6OptionsTypeMAC DHCPv6OptionsType = "mac" +) + +// DHCPv6Options defines an object in DHCPv6_Options table +type DHCPv6Options struct { + UUID string `ovsdb:"_uuid"` + Code int `ovsdb:"code"` + Name string `ovsdb:"name"` + Type DHCPv6OptionsType `ovsdb:"type"` +} diff --git a/pkg/ovsdb/ovnsb/dns.go b/pkg/ovsdb/ovnsb/dns.go new file mode 100644 index 00000000000..d05a378d25f --- /dev/null +++ b/pkg/ovsdb/ovnsb/dns.go @@ -0,0 +1,14 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const DNSTable = "DNS" + +// DNS defines an object in DNS table +type DNS struct { + UUID string `ovsdb:"_uuid"` + Datapaths []string `ovsdb:"datapaths"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + Records map[string]string `ovsdb:"records"` +} diff --git a/pkg/ovsdb/ovnsb/encap.go b/pkg/ovsdb/ovnsb/encap.go new file mode 100644 index 00000000000..f99ff52eb29 --- /dev/null +++ b/pkg/ovsdb/ovnsb/encap.go @@ -0,0 +1,25 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const EncapTable = "Encap" + +type ( + EncapType = string +) + +var ( + EncapTypeGeneve EncapType = "geneve" + EncapTypeSTT EncapType = "stt" + EncapTypeVxlan EncapType = "vxlan" +) + +// Encap defines an object in Encap table +type Encap struct { + UUID string `ovsdb:"_uuid"` + ChassisName string `ovsdb:"chassis_name"` + IP string `ovsdb:"ip"` + Options map[string]string `ovsdb:"options"` + Type EncapType `ovsdb:"type"` +} diff --git a/pkg/ovsdb/ovnsb/fdb.go b/pkg/ovsdb/ovnsb/fdb.go new file mode 100644 index 00000000000..6ff0e4f50dc --- /dev/null +++ b/pkg/ovsdb/ovnsb/fdb.go @@ -0,0 +1,14 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const FDBTable = "FDB" + +// FDB defines an object in FDB table +type FDB struct { + UUID string `ovsdb:"_uuid"` + DpKey int `ovsdb:"dp_key"` + MAC string `ovsdb:"mac"` + PortKey int `ovsdb:"port_key"` +} diff --git a/pkg/ovsdb/ovnsb/gateway_chassis.go b/pkg/ovsdb/ovnsb/gateway_chassis.go new file mode 100644 index 00000000000..8e4e302a14a --- /dev/null +++ b/pkg/ovsdb/ovnsb/gateway_chassis.go @@ -0,0 +1,16 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const GatewayChassisTable = "Gateway_Chassis" + +// GatewayChassis defines an object in Gateway_Chassis table +type GatewayChassis struct { + UUID string `ovsdb:"_uuid"` + Chassis *string `ovsdb:"chassis"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + Name string `ovsdb:"name"` + Options map[string]string `ovsdb:"options"` + Priority int `ovsdb:"priority"` +} diff --git a/pkg/ovsdb/ovnsb/ha_chassis.go b/pkg/ovsdb/ovnsb/ha_chassis.go new file mode 100644 index 00000000000..16efb80529d --- /dev/null +++ b/pkg/ovsdb/ovnsb/ha_chassis.go @@ -0,0 +1,14 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const HAChassisTable = "HA_Chassis" + +// HAChassis defines an object in HA_Chassis table +type HAChassis struct { + UUID string `ovsdb:"_uuid"` + Chassis *string `ovsdb:"chassis"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + Priority int `ovsdb:"priority"` +} diff --git a/pkg/ovsdb/ovnsb/ha_chassis_group.go b/pkg/ovsdb/ovnsb/ha_chassis_group.go new file mode 100644 index 00000000000..1f61b94d6b5 --- /dev/null +++ b/pkg/ovsdb/ovnsb/ha_chassis_group.go @@ -0,0 +1,15 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const HAChassisGroupTable = "HA_Chassis_Group" + +// HAChassisGroup defines an object in HA_Chassis_Group table +type HAChassisGroup struct { + UUID string `ovsdb:"_uuid"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + HaChassis []string `ovsdb:"ha_chassis"` + Name string `ovsdb:"name"` + RefChassis []string `ovsdb:"ref_chassis"` +} diff --git a/pkg/ovsdb/ovnsb/igmp_group.go b/pkg/ovsdb/ovnsb/igmp_group.go new file mode 100644 index 00000000000..bb91fbacc3a --- /dev/null +++ b/pkg/ovsdb/ovnsb/igmp_group.go @@ -0,0 +1,15 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const IGMPGroupTable = "IGMP_Group" + +// IGMPGroup defines an object in IGMP_Group table +type IGMPGroup struct { + UUID string `ovsdb:"_uuid"` + Address string `ovsdb:"address"` + Chassis *string `ovsdb:"chassis"` + Datapath *string `ovsdb:"datapath"` + Ports []string `ovsdb:"ports"` +} diff --git a/pkg/ovsdb/ovnsb/ip_multicast.go b/pkg/ovsdb/ovnsb/ip_multicast.go new file mode 100644 index 00000000000..0cb9684c0bb --- /dev/null +++ b/pkg/ovsdb/ovnsb/ip_multicast.go @@ -0,0 +1,22 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const IPMulticastTable = "IP_Multicast" + +// IPMulticast defines an object in IP_Multicast table +type IPMulticast struct { + UUID string `ovsdb:"_uuid"` + Datapath string `ovsdb:"datapath"` + Enabled *bool `ovsdb:"enabled"` + EthSrc string `ovsdb:"eth_src"` + IdleTimeout *int `ovsdb:"idle_timeout"` + Ip4Src string `ovsdb:"ip4_src"` + Ip6Src string `ovsdb:"ip6_src"` + Querier *bool `ovsdb:"querier"` + QueryInterval *int `ovsdb:"query_interval"` + QueryMaxResp *int `ovsdb:"query_max_resp"` + SeqNo int `ovsdb:"seq_no"` + TableSize *int `ovsdb:"table_size"` +} diff --git a/pkg/ovsdb/ovnsb/load_balancer.go b/pkg/ovsdb/ovnsb/load_balancer.go new file mode 100644 index 00000000000..0c428e6a467 --- /dev/null +++ b/pkg/ovsdb/ovnsb/load_balancer.go @@ -0,0 +1,28 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const LoadBalancerTable = "Load_Balancer" + +type ( + LoadBalancerProtocol = string +) + +var ( + LoadBalancerProtocolTCP LoadBalancerProtocol = "tcp" + LoadBalancerProtocolUDP LoadBalancerProtocol = "udp" + LoadBalancerProtocolSCTP LoadBalancerProtocol = "sctp" +) + +// LoadBalancer defines an object in Load_Balancer table +type LoadBalancer struct { + UUID string `ovsdb:"_uuid"` + DatapathGroup *string `ovsdb:"datapath_group"` + Datapaths []string `ovsdb:"datapaths"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + Name string `ovsdb:"name"` + Options map[string]string `ovsdb:"options"` + Protocol *LoadBalancerProtocol `ovsdb:"protocol"` + Vips map[string]string `ovsdb:"vips"` +} diff --git a/pkg/ovsdb/ovnsb/logical_dp_group.go b/pkg/ovsdb/ovnsb/logical_dp_group.go new file mode 100644 index 00000000000..58f34ad38a8 --- /dev/null +++ b/pkg/ovsdb/ovnsb/logical_dp_group.go @@ -0,0 +1,12 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const LogicalDPGroupTable = "Logical_DP_Group" + +// LogicalDPGroup defines an object in Logical_DP_Group table +type LogicalDPGroup struct { + UUID string `ovsdb:"_uuid"` + Datapaths []string `ovsdb:"datapaths"` +} diff --git a/pkg/ovsdb/ovnsb/logical_flow.go b/pkg/ovsdb/ovnsb/logical_flow.go new file mode 100644 index 00000000000..e1029d6a531 --- /dev/null +++ b/pkg/ovsdb/ovnsb/logical_flow.go @@ -0,0 +1,30 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const LogicalFlowTable = "Logical_Flow" + +type ( + LogicalFlowPipeline = string +) + +var ( + LogicalFlowPipelineIngress LogicalFlowPipeline = "ingress" + LogicalFlowPipelineEgress LogicalFlowPipeline = "egress" +) + +// LogicalFlow defines an object in Logical_Flow table +type LogicalFlow struct { + UUID string `ovsdb:"_uuid"` + Actions string `ovsdb:"actions"` + ControllerMeter *string `ovsdb:"controller_meter"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + LogicalDatapath *string `ovsdb:"logical_datapath"` + LogicalDpGroup *string `ovsdb:"logical_dp_group"` + Match string `ovsdb:"match"` + Pipeline LogicalFlowPipeline `ovsdb:"pipeline"` + Priority int `ovsdb:"priority"` + TableID int `ovsdb:"table_id"` + Tags map[string]string `ovsdb:"tags"` +} diff --git a/pkg/ovsdb/ovnsb/mac_binding.go b/pkg/ovsdb/ovnsb/mac_binding.go new file mode 100644 index 00000000000..e72ece30aa8 --- /dev/null +++ b/pkg/ovsdb/ovnsb/mac_binding.go @@ -0,0 +1,16 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const MACBindingTable = "MAC_Binding" + +// MACBinding defines an object in MAC_Binding table +type MACBinding struct { + UUID string `ovsdb:"_uuid"` + Datapath string `ovsdb:"datapath"` + IP string `ovsdb:"ip"` + LogicalPort string `ovsdb:"logical_port"` + MAC string `ovsdb:"mac"` + Timestamp int `ovsdb:"timestamp"` +} diff --git a/pkg/ovsdb/ovnsb/meter.go b/pkg/ovsdb/ovnsb/meter.go new file mode 100644 index 00000000000..80a2402efde --- /dev/null +++ b/pkg/ovsdb/ovnsb/meter.go @@ -0,0 +1,23 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const MeterTable = "Meter" + +type ( + MeterUnit = string +) + +var ( + MeterUnitKbps MeterUnit = "kbps" + MeterUnitPktps MeterUnit = "pktps" +) + +// Meter defines an object in Meter table +type Meter struct { + UUID string `ovsdb:"_uuid"` + Bands []string `ovsdb:"bands"` + Name string `ovsdb:"name"` + Unit MeterUnit `ovsdb:"unit"` +} diff --git a/pkg/ovsdb/ovnsb/meter_band.go b/pkg/ovsdb/ovnsb/meter_band.go new file mode 100644 index 00000000000..58d1426a1aa --- /dev/null +++ b/pkg/ovsdb/ovnsb/meter_band.go @@ -0,0 +1,22 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const MeterBandTable = "Meter_Band" + +type ( + MeterBandAction = string +) + +var ( + MeterBandActionDrop MeterBandAction = "drop" +) + +// MeterBand defines an object in Meter_Band table +type MeterBand struct { + UUID string `ovsdb:"_uuid"` + Action MeterBandAction `ovsdb:"action"` + BurstSize int `ovsdb:"burst_size"` + Rate int `ovsdb:"rate"` +} diff --git a/pkg/ovsdb/ovnsb/mirror.go b/pkg/ovsdb/ovnsb/mirror.go new file mode 100644 index 00000000000..50ce73eeece --- /dev/null +++ b/pkg/ovsdb/ovnsb/mirror.go @@ -0,0 +1,29 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const MirrorTable = "Mirror" + +type ( + MirrorFilter = string + MirrorType = string +) + +var ( + MirrorFilterFromLport MirrorFilter = "from-lport" + MirrorFilterToLport MirrorFilter = "to-lport" + MirrorTypeGre MirrorType = "gre" + MirrorTypeErspan MirrorType = "erspan" +) + +// Mirror defines an object in Mirror table +type Mirror struct { + UUID string `ovsdb:"_uuid"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + Filter MirrorFilter `ovsdb:"filter"` + Index int `ovsdb:"index"` + Name string `ovsdb:"name"` + Sink string `ovsdb:"sink"` + Type MirrorType `ovsdb:"type"` +} diff --git a/pkg/ovsdb/ovnsb/model.go b/pkg/ovsdb/ovnsb/model.go new file mode 100644 index 00000000000..da9f6aea7c7 --- /dev/null +++ b/pkg/ovsdb/ovnsb/model.go @@ -0,0 +1,1798 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +import ( + "encoding/json" + + "github.com/ovn-org/libovsdb/model" + "github.com/ovn-org/libovsdb/ovsdb" +) + +// FullDatabaseModel returns the DatabaseModel object to be used in libovsdb +func FullDatabaseModel() (model.ClientDBModel, error) { + return model.NewClientDBModel("OVN_Southbound", map[string]model.Model{ + "Address_Set": &AddressSet{}, + "BFD": &BFD{}, + "Chassis": &Chassis{}, + "Chassis_Private": &ChassisPrivate{}, + "Chassis_Template_Var": &ChassisTemplateVar{}, + "Connection": &Connection{}, + "Controller_Event": &ControllerEvent{}, + "DHCP_Options": &DHCPOptions{}, + "DHCPv6_Options": &DHCPv6Options{}, + "DNS": &DNS{}, + "Datapath_Binding": &DatapathBinding{}, + "Encap": &Encap{}, + "FDB": &FDB{}, + "Gateway_Chassis": &GatewayChassis{}, + "HA_Chassis": &HAChassis{}, + "HA_Chassis_Group": &HAChassisGroup{}, + "IGMP_Group": &IGMPGroup{}, + "IP_Multicast": &IPMulticast{}, + "Load_Balancer": &LoadBalancer{}, + "Logical_DP_Group": &LogicalDPGroup{}, + "Logical_Flow": &LogicalFlow{}, + "MAC_Binding": &MACBinding{}, + "Meter": &Meter{}, + "Meter_Band": &MeterBand{}, + "Mirror": &Mirror{}, + "Multicast_Group": &MulticastGroup{}, + "Port_Binding": &PortBinding{}, + "Port_Group": &PortGroup{}, + "RBAC_Permission": &RBACPermission{}, + "RBAC_Role": &RBACRole{}, + "SB_Global": &SBGlobal{}, + "SSL": &SSL{}, + "Service_Monitor": &ServiceMonitor{}, + "Static_MAC_Binding": &StaticMACBinding{}, + }) +} + +var schema = `{ + "name": "OVN_Southbound", + "version": "20.27.0", + "tables": { + "Address_Set": { + "columns": { + "addresses": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "name": { + "type": "string" + } + }, + "indexes": [ + [ + "name" + ] + ] + }, + "BFD": { + "columns": { + "detect_mult": { + "type": "integer" + }, + "disc": { + "type": "integer" + }, + "dst_ip": { + "type": "string" + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "logical_port": { + "type": "string" + }, + "min_rx": { + "type": "integer" + }, + "min_tx": { + "type": "integer" + }, + "options": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "src_port": { + "type": { + "key": { + "type": "integer", + "minInteger": 49152, + "maxInteger": 65535 + } + } + }, + "status": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "down", + "init", + "up", + "admin_down" + ] + ] + } + } + } + }, + "indexes": [ + [ + "logical_port", + "dst_ip", + "src_port", + "disc" + ] + ] + }, + "Chassis": { + "columns": { + "encaps": { + "type": { + "key": { + "type": "uuid", + "refTable": "Encap" + }, + "min": 1, + "max": "unlimited" + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "hostname": { + "type": "string" + }, + "name": { + "type": "string" + }, + "nb_cfg": { + "type": "integer" + }, + "other_config": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "transport_zones": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "vtep_logical_switches": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + } + }, + "indexes": [ + [ + "name" + ] + ] + }, + "Chassis_Private": { + "columns": { + "chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "name": { + "type": "string" + }, + "nb_cfg": { + "type": "integer" + }, + "nb_cfg_timestamp": { + "type": "integer" + } + }, + "indexes": [ + [ + "name" + ] + ] + }, + "Chassis_Template_Var": { + "columns": { + "chassis": { + "type": "string" + }, + "variables": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + } + }, + "indexes": [ + [ + "chassis" + ] + ] + }, + "Connection": { + "columns": { + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "inactivity_probe": { + "type": { + "key": { + "type": "integer" + }, + "min": 0, + "max": 1 + } + }, + "is_connected": { + "type": "boolean", + "ephemeral": true + }, + "max_backoff": { + "type": { + "key": { + "type": "integer", + "minInteger": 1000 + }, + "min": 0, + "max": 1 + } + }, + "other_config": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "read_only": { + "type": "boolean" + }, + "role": { + "type": "string" + }, + "status": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + }, + "ephemeral": true + }, + "target": { + "type": "string" + } + }, + "indexes": [ + [ + "target" + ] + ] + }, + "Controller_Event": { + "columns": { + "chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "event_info": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "event_type": { + "type": { + "key": { + "type": "string", + "enum": "empty_lb_backends" + } + } + }, + "seq_num": { + "type": "integer" + } + } + }, + "DHCP_Options": { + "columns": { + "code": { + "type": { + "key": { + "type": "integer", + "minInteger": 0, + "maxInteger": 254 + } + } + }, + "name": { + "type": "string" + }, + "type": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "bool", + "uint8", + "uint16", + "uint32", + "ipv4", + "static_routes", + "str", + "host_id", + "domains" + ] + ] + } + } + } + } + }, + "DHCPv6_Options": { + "columns": { + "code": { + "type": { + "key": { + "type": "integer", + "minInteger": 0, + "maxInteger": 254 + } + } + }, + "name": { + "type": "string" + }, + "type": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "ipv6", + "str", + "mac" + ] + ] + } + } + } + } + }, + "DNS": { + "columns": { + "datapaths": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding" + }, + "min": 1, + "max": "unlimited" + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "records": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + } + } + }, + "Datapath_Binding": { + "columns": { + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "load_balancers": { + "type": { + "key": { + "type": "uuid" + }, + "min": 0, + "max": "unlimited" + } + }, + "tunnel_key": { + "type": { + "key": { + "type": "integer", + "minInteger": 1, + "maxInteger": 16777215 + } + } + } + }, + "indexes": [ + [ + "tunnel_key" + ] + ] + }, + "Encap": { + "columns": { + "chassis_name": { + "type": "string" + }, + "ip": { + "type": "string" + }, + "options": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "type": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "geneve", + "stt", + "vxlan" + ] + ] + } + } + } + }, + "indexes": [ + [ + "type", + "ip" + ] + ] + }, + "FDB": { + "columns": { + "dp_key": { + "type": { + "key": { + "type": "integer", + "minInteger": 1, + "maxInteger": 16777215 + } + } + }, + "mac": { + "type": "string" + }, + "port_key": { + "type": { + "key": { + "type": "integer", + "minInteger": 1, + "maxInteger": 16777215 + } + } + } + }, + "indexes": [ + [ + "mac", + "dp_key" + ] + ] + }, + "Gateway_Chassis": { + "columns": { + "chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "name": { + "type": "string" + }, + "options": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "priority": { + "type": { + "key": { + "type": "integer", + "minInteger": 0, + "maxInteger": 32767 + } + } + } + }, + "indexes": [ + [ + "name" + ] + ] + }, + "HA_Chassis": { + "columns": { + "chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "priority": { + "type": { + "key": { + "type": "integer", + "minInteger": 0, + "maxInteger": 32767 + } + } + } + } + }, + "HA_Chassis_Group": { + "columns": { + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "ha_chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "HA_Chassis", + "refType": "strong" + }, + "min": 0, + "max": "unlimited" + } + }, + "name": { + "type": "string" + }, + "ref_chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + } + }, + "indexes": [ + [ + "name" + ] + ] + }, + "IGMP_Group": { + "columns": { + "address": { + "type": "string" + }, + "chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "datapath": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "ports": { + "type": { + "key": { + "type": "uuid", + "refTable": "Port_Binding", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + } + }, + "indexes": [ + [ + "address", + "datapath", + "chassis" + ] + ] + }, + "IP_Multicast": { + "columns": { + "datapath": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding", + "refType": "weak" + } + } + }, + "enabled": { + "type": { + "key": { + "type": "boolean" + }, + "min": 0, + "max": 1 + } + }, + "eth_src": { + "type": "string" + }, + "idle_timeout": { + "type": { + "key": { + "type": "integer" + }, + "min": 0, + "max": 1 + } + }, + "ip4_src": { + "type": "string" + }, + "ip6_src": { + "type": "string" + }, + "querier": { + "type": { + "key": { + "type": "boolean" + }, + "min": 0, + "max": 1 + } + }, + "query_interval": { + "type": { + "key": { + "type": "integer" + }, + "min": 0, + "max": 1 + } + }, + "query_max_resp": { + "type": { + "key": { + "type": "integer" + }, + "min": 0, + "max": 1 + } + }, + "seq_no": { + "type": "integer" + }, + "table_size": { + "type": { + "key": { + "type": "integer" + }, + "min": 0, + "max": 1 + } + } + }, + "indexes": [ + [ + "datapath" + ] + ] + }, + "Load_Balancer": { + "columns": { + "datapath_group": { + "type": { + "key": { + "type": "uuid", + "refTable": "Logical_DP_Group" + }, + "min": 0, + "max": 1 + } + }, + "datapaths": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding" + }, + "min": 0, + "max": "unlimited" + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "name": { + "type": "string" + }, + "options": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "protocol": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "tcp", + "udp", + "sctp" + ] + ] + }, + "min": 0, + "max": 1 + } + }, + "vips": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + } + } + }, + "Logical_DP_Group": { + "columns": { + "datapaths": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + } + } + }, + "Logical_Flow": { + "columns": { + "actions": { + "type": "string" + }, + "controller_meter": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": 1 + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "logical_datapath": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding" + }, + "min": 0, + "max": 1 + } + }, + "logical_dp_group": { + "type": { + "key": { + "type": "uuid", + "refTable": "Logical_DP_Group" + }, + "min": 0, + "max": 1 + } + }, + "match": { + "type": "string" + }, + "pipeline": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "ingress", + "egress" + ] + ] + } + } + }, + "priority": { + "type": { + "key": { + "type": "integer", + "minInteger": 0, + "maxInteger": 65535 + } + } + }, + "table_id": { + "type": { + "key": { + "type": "integer", + "minInteger": 0, + "maxInteger": 32 + } + } + }, + "tags": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + } + } + }, + "MAC_Binding": { + "columns": { + "datapath": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding" + } + } + }, + "ip": { + "type": "string" + }, + "logical_port": { + "type": "string" + }, + "mac": { + "type": "string" + }, + "timestamp": { + "type": "integer" + } + }, + "indexes": [ + [ + "logical_port", + "ip" + ] + ] + }, + "Meter": { + "columns": { + "bands": { + "type": { + "key": { + "type": "uuid", + "refTable": "Meter_Band", + "refType": "strong" + }, + "min": 1, + "max": "unlimited" + } + }, + "name": { + "type": "string" + }, + "unit": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "kbps", + "pktps" + ] + ] + } + } + } + }, + "indexes": [ + [ + "name" + ] + ] + }, + "Meter_Band": { + "columns": { + "action": { + "type": { + "key": { + "type": "string", + "enum": "drop" + } + } + }, + "burst_size": { + "type": { + "key": { + "type": "integer", + "minInteger": 0, + "maxInteger": 4294967295 + } + } + }, + "rate": { + "type": { + "key": { + "type": "integer", + "minInteger": 1, + "maxInteger": 4294967295 + } + } + } + } + }, + "Mirror": { + "columns": { + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "filter": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "from-lport", + "to-lport" + ] + ] + } + } + }, + "index": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "sink": { + "type": "string" + }, + "type": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "gre", + "erspan" + ] + ] + } + } + } + }, + "indexes": [ + [ + "name" + ] + ] + }, + "Multicast_Group": { + "columns": { + "datapath": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding" + } + } + }, + "name": { + "type": "string" + }, + "ports": { + "type": { + "key": { + "type": "uuid", + "refTable": "Port_Binding", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + }, + "tunnel_key": { + "type": { + "key": { + "type": "integer", + "minInteger": 32768, + "maxInteger": 65535 + } + } + } + }, + "indexes": [ + [ + "datapath", + "tunnel_key" + ], + [ + "datapath", + "name" + ] + ] + }, + "Port_Binding": { + "columns": { + "additional_chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + }, + "additional_encap": { + "type": { + "key": { + "type": "uuid", + "refTable": "Encap", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + }, + "chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "datapath": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding" + } + } + }, + "encap": { + "type": { + "key": { + "type": "uuid", + "refTable": "Encap", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "gateway_chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Gateway_Chassis", + "refType": "strong" + }, + "min": 0, + "max": "unlimited" + } + }, + "ha_chassis_group": { + "type": { + "key": { + "type": "uuid", + "refTable": "HA_Chassis_Group", + "refType": "strong" + }, + "min": 0, + "max": 1 + } + }, + "logical_port": { + "type": "string" + }, + "mac": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "mirror_rules": { + "type": { + "key": { + "type": "uuid", + "refTable": "Mirror", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + }, + "nat_addresses": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "options": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "parent_port": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": 1 + } + }, + "port_security": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "requested_additional_chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + }, + "requested_chassis": { + "type": { + "key": { + "type": "uuid", + "refTable": "Chassis", + "refType": "weak" + }, + "min": 0, + "max": 1 + } + }, + "tag": { + "type": { + "key": { + "type": "integer", + "minInteger": 1, + "maxInteger": 4095 + }, + "min": 0, + "max": 1 + } + }, + "tunnel_key": { + "type": { + "key": { + "type": "integer", + "minInteger": 1, + "maxInteger": 32767 + } + } + }, + "type": { + "type": "string" + }, + "up": { + "type": { + "key": { + "type": "boolean" + }, + "min": 0, + "max": 1 + } + }, + "virtual_parent": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": 1 + } + } + }, + "indexes": [ + [ + "datapath", + "tunnel_key" + ], + [ + "logical_port" + ] + ] + }, + "Port_Group": { + "columns": { + "name": { + "type": "string" + }, + "ports": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + } + }, + "indexes": [ + [ + "name" + ] + ] + }, + "RBAC_Permission": { + "columns": { + "authorization": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "insert_delete": { + "type": "boolean" + }, + "table": { + "type": "string" + }, + "update": { + "type": { + "key": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + } + } + }, + "RBAC_Role": { + "columns": { + "name": { + "type": "string" + }, + "permissions": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "uuid", + "refTable": "RBAC_Permission", + "refType": "weak" + }, + "min": 0, + "max": "unlimited" + } + } + } + }, + "SB_Global": { + "columns": { + "connections": { + "type": { + "key": { + "type": "uuid", + "refTable": "Connection" + }, + "min": 0, + "max": "unlimited" + } + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "ipsec": { + "type": "boolean" + }, + "nb_cfg": { + "type": "integer" + }, + "options": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "ssl": { + "type": { + "key": { + "type": "uuid", + "refTable": "SSL" + }, + "min": 0, + "max": 1 + } + } + } + }, + "SSL": { + "columns": { + "bootstrap_ca_cert": { + "type": "boolean" + }, + "ca_cert": { + "type": "string" + }, + "certificate": { + "type": "string" + }, + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "private_key": { + "type": "string" + }, + "ssl_ciphers": { + "type": "string" + }, + "ssl_protocols": { + "type": "string" + } + } + }, + "Service_Monitor": { + "columns": { + "external_ids": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "ip": { + "type": "string" + }, + "logical_port": { + "type": "string" + }, + "options": { + "type": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "min": 0, + "max": "unlimited" + } + }, + "port": { + "type": { + "key": { + "type": "integer", + "minInteger": 0, + "maxInteger": 65535 + } + } + }, + "protocol": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "tcp", + "udp" + ] + ] + }, + "min": 0, + "max": 1 + } + }, + "src_ip": { + "type": "string" + }, + "src_mac": { + "type": "string" + }, + "status": { + "type": { + "key": { + "type": "string", + "enum": [ + "set", + [ + "online", + "offline", + "error" + ] + ] + }, + "min": 0, + "max": 1 + } + } + }, + "indexes": [ + [ + "logical_port", + "ip", + "port", + "protocol" + ] + ] + }, + "Static_MAC_Binding": { + "columns": { + "datapath": { + "type": { + "key": { + "type": "uuid", + "refTable": "Datapath_Binding" + } + } + }, + "ip": { + "type": "string" + }, + "logical_port": { + "type": "string" + }, + "mac": { + "type": "string" + }, + "override_dynamic_mac": { + "type": "boolean" + } + }, + "indexes": [ + [ + "logical_port", + "ip" + ] + ] + } + } +}` + +func Schema() ovsdb.DatabaseSchema { + var s ovsdb.DatabaseSchema + err := json.Unmarshal([]byte(schema), &s) + if err != nil { + panic(err) + } + return s +} diff --git a/pkg/ovsdb/ovnsb/multicast_group.go b/pkg/ovsdb/ovnsb/multicast_group.go new file mode 100644 index 00000000000..384ad8af751 --- /dev/null +++ b/pkg/ovsdb/ovnsb/multicast_group.go @@ -0,0 +1,15 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const MulticastGroupTable = "Multicast_Group" + +// MulticastGroup defines an object in Multicast_Group table +type MulticastGroup struct { + UUID string `ovsdb:"_uuid"` + Datapath string `ovsdb:"datapath"` + Name string `ovsdb:"name"` + Ports []string `ovsdb:"ports"` + TunnelKey int `ovsdb:"tunnel_key"` +} diff --git a/pkg/ovsdb/ovnsb/port_binding.go b/pkg/ovsdb/ovnsb/port_binding.go new file mode 100644 index 00000000000..94bbc36a87b --- /dev/null +++ b/pkg/ovsdb/ovnsb/port_binding.go @@ -0,0 +1,33 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const PortBindingTable = "Port_Binding" + +// PortBinding defines an object in Port_Binding table +type PortBinding struct { + UUID string `ovsdb:"_uuid"` + AdditionalChassis []string `ovsdb:"additional_chassis"` + AdditionalEncap []string `ovsdb:"additional_encap"` + Chassis *string `ovsdb:"chassis"` + Datapath string `ovsdb:"datapath"` + Encap *string `ovsdb:"encap"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + GatewayChassis []string `ovsdb:"gateway_chassis"` + HaChassisGroup *string `ovsdb:"ha_chassis_group"` + LogicalPort string `ovsdb:"logical_port"` + MAC []string `ovsdb:"mac"` + MirrorRules []string `ovsdb:"mirror_rules"` + NatAddresses []string `ovsdb:"nat_addresses"` + Options map[string]string `ovsdb:"options"` + ParentPort *string `ovsdb:"parent_port"` + PortSecurity []string `ovsdb:"port_security"` + RequestedAdditionalChassis []string `ovsdb:"requested_additional_chassis"` + RequestedChassis *string `ovsdb:"requested_chassis"` + Tag *int `ovsdb:"tag"` + TunnelKey int `ovsdb:"tunnel_key"` + Type string `ovsdb:"type"` + Up *bool `ovsdb:"up"` + VirtualParent *string `ovsdb:"virtual_parent"` +} diff --git a/pkg/ovsdb/ovnsb/port_group.go b/pkg/ovsdb/ovnsb/port_group.go new file mode 100644 index 00000000000..8da06275d96 --- /dev/null +++ b/pkg/ovsdb/ovnsb/port_group.go @@ -0,0 +1,13 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const PortGroupTable = "Port_Group" + +// PortGroup defines an object in Port_Group table +type PortGroup struct { + UUID string `ovsdb:"_uuid"` + Name string `ovsdb:"name"` + Ports []string `ovsdb:"ports"` +} diff --git a/pkg/ovsdb/ovnsb/rbac_permission.go b/pkg/ovsdb/ovnsb/rbac_permission.go new file mode 100644 index 00000000000..d140ae1f6c2 --- /dev/null +++ b/pkg/ovsdb/ovnsb/rbac_permission.go @@ -0,0 +1,15 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const RBACPermissionTable = "RBAC_Permission" + +// RBACPermission defines an object in RBAC_Permission table +type RBACPermission struct { + UUID string `ovsdb:"_uuid"` + Authorization []string `ovsdb:"authorization"` + InsertDelete bool `ovsdb:"insert_delete"` + Table string `ovsdb:"table"` + Update []string `ovsdb:"update"` +} diff --git a/pkg/ovsdb/ovnsb/rbac_role.go b/pkg/ovsdb/ovnsb/rbac_role.go new file mode 100644 index 00000000000..37114424187 --- /dev/null +++ b/pkg/ovsdb/ovnsb/rbac_role.go @@ -0,0 +1,13 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const RBACRoleTable = "RBAC_Role" + +// RBACRole defines an object in RBAC_Role table +type RBACRole struct { + UUID string `ovsdb:"_uuid"` + Name string `ovsdb:"name"` + Permissions map[string]string `ovsdb:"permissions"` +} diff --git a/pkg/ovsdb/ovnsb/sb_global.go b/pkg/ovsdb/ovnsb/sb_global.go new file mode 100644 index 00000000000..fd8585661de --- /dev/null +++ b/pkg/ovsdb/ovnsb/sb_global.go @@ -0,0 +1,17 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const SBGlobalTable = "SB_Global" + +// SBGlobal defines an object in SB_Global table +type SBGlobal struct { + UUID string `ovsdb:"_uuid"` + Connections []string `ovsdb:"connections"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + Ipsec bool `ovsdb:"ipsec"` + NbCfg int `ovsdb:"nb_cfg"` + Options map[string]string `ovsdb:"options"` + SSL *string `ovsdb:"ssl"` +} diff --git a/pkg/ovsdb/ovnsb/service_monitor.go b/pkg/ovsdb/ovnsb/service_monitor.go new file mode 100644 index 00000000000..1c46c7a1448 --- /dev/null +++ b/pkg/ovsdb/ovnsb/service_monitor.go @@ -0,0 +1,33 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const ServiceMonitorTable = "Service_Monitor" + +type ( + ServiceMonitorProtocol = string + ServiceMonitorStatus = string +) + +var ( + ServiceMonitorProtocolTCP ServiceMonitorProtocol = "tcp" + ServiceMonitorProtocolUDP ServiceMonitorProtocol = "udp" + ServiceMonitorStatusOnline ServiceMonitorStatus = "online" + ServiceMonitorStatusOffline ServiceMonitorStatus = "offline" + ServiceMonitorStatusError ServiceMonitorStatus = "error" +) + +// ServiceMonitor defines an object in Service_Monitor table +type ServiceMonitor struct { + UUID string `ovsdb:"_uuid"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + IP string `ovsdb:"ip"` + LogicalPort string `ovsdb:"logical_port"` + Options map[string]string `ovsdb:"options"` + Port int `ovsdb:"port"` + Protocol *ServiceMonitorProtocol `ovsdb:"protocol"` + SrcIP string `ovsdb:"src_ip"` + SrcMAC string `ovsdb:"src_mac"` + Status *ServiceMonitorStatus `ovsdb:"status"` +} diff --git a/pkg/ovsdb/ovnsb/ssl.go b/pkg/ovsdb/ovnsb/ssl.go new file mode 100644 index 00000000000..8f34642c97a --- /dev/null +++ b/pkg/ovsdb/ovnsb/ssl.go @@ -0,0 +1,18 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const SSLTable = "SSL" + +// SSL defines an object in SSL table +type SSL struct { + UUID string `ovsdb:"_uuid"` + BootstrapCaCert bool `ovsdb:"bootstrap_ca_cert"` + CaCert string `ovsdb:"ca_cert"` + Certificate string `ovsdb:"certificate"` + ExternalIDs map[string]string `ovsdb:"external_ids"` + PrivateKey string `ovsdb:"private_key"` + SSLCiphers string `ovsdb:"ssl_ciphers"` + SSLProtocols string `ovsdb:"ssl_protocols"` +} diff --git a/pkg/ovsdb/ovnsb/static_mac_binding.go b/pkg/ovsdb/ovnsb/static_mac_binding.go new file mode 100644 index 00000000000..95ac6621891 --- /dev/null +++ b/pkg/ovsdb/ovnsb/static_mac_binding.go @@ -0,0 +1,16 @@ +// Code generated by "libovsdb.modelgen" +// DO NOT EDIT. + +package ovnsb + +const StaticMACBindingTable = "Static_MAC_Binding" + +// StaticMACBinding defines an object in Static_MAC_Binding table +type StaticMACBinding struct { + UUID string `ovsdb:"_uuid"` + Datapath string `ovsdb:"datapath"` + IP string `ovsdb:"ip"` + LogicalPort string `ovsdb:"logical_port"` + MAC string `ovsdb:"mac"` + OverrideDynamicMAC bool `ovsdb:"override_dynamic_mac"` +}