mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 11:06:21 +00:00
virtcontainers: Alias for pkg/types
Since we're going to have both external and internal types packages, we alias the external one as vcTypes. And the internal one will be usable through the types namespace. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
36c267a1d2
commit
3ab7d077d1
@ -12,7 +12,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -152,7 +152,7 @@ func networkModifyCommand(ctx context.Context, containerID, input string, opType
|
|||||||
}
|
}
|
||||||
switch opType {
|
switch opType {
|
||||||
case interfaceType:
|
case interfaceType:
|
||||||
var inf, resultingInf *types.Interface
|
var inf, resultingInf *vcTypes.Interface
|
||||||
if err = json.NewDecoder(f).Decode(&inf); err != nil {
|
if err = json.NewDecoder(f).Decode(&inf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ func networkModifyCommand(ctx context.Context, containerID, input string, opType
|
|||||||
}
|
}
|
||||||
json.NewEncoder(output).Encode(resultingInf)
|
json.NewEncoder(output).Encode(resultingInf)
|
||||||
case routeType:
|
case routeType:
|
||||||
var routes, resultingRoutes []*types.Route
|
var routes, resultingRoutes []*vcTypes.Route
|
||||||
if err = json.NewDecoder(f).Decode(&routes); err != nil {
|
if err = json.NewDecoder(f).Decode(&routes); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ func networkListCommand(ctx context.Context, containerID string, opType networkT
|
|||||||
|
|
||||||
switch opType {
|
switch opType {
|
||||||
case interfaceType:
|
case interfaceType:
|
||||||
var interfaces []*types.Interface
|
var interfaces []*vcTypes.Interface
|
||||||
interfaces, err = vci.ListInterfaces(ctx, sandboxID)
|
interfaces, err = vci.ListInterfaces(ctx, sandboxID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
kataLog.WithField("existing-interfaces", fmt.Sprintf("%+v", interfaces)).
|
kataLog.WithField("existing-interfaces", fmt.Sprintf("%+v", interfaces)).
|
||||||
@ -217,7 +217,7 @@ func networkListCommand(ctx context.Context, containerID string, opType networkT
|
|||||||
}
|
}
|
||||||
json.NewEncoder(file).Encode(interfaces)
|
json.NewEncoder(file).Encode(interfaces)
|
||||||
case routeType:
|
case routeType:
|
||||||
var routes []*types.Route
|
var routes []*vcTypes.Route
|
||||||
routes, err = vci.ListRoutes(ctx, sandboxID)
|
routes, err = vci.ListRoutes(ctx, sandboxID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
kataLog.WithField("resulting-routes", fmt.Sprintf("%+v", routes)).
|
kataLog.WithField("resulting-routes", fmt.Sprintf("%+v", routes)).
|
||||||
|
@ -13,24 +13,24 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testAddInterfaceFuncReturnNil = func(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
testAddInterfaceFuncReturnNil = func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
testRemoveInterfaceFuncReturnNil = func(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
testRemoveInterfaceFuncReturnNil = func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
testListInterfacesFuncReturnNil = func(ctx context.Context, sandboxID string) ([]*types.Interface, error) {
|
testListInterfacesFuncReturnNil = func(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
testUpdateRoutsFuncReturnNil = func(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error) {
|
testUpdateRoutsFuncReturnNil = func(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
testListRoutesFuncReturnNil = func(ctx context.Context, sandboxID string) ([]*types.Route, error) {
|
testListRoutesFuncReturnNil = func(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kata-containers/runtime/pkg/signals"
|
"github.com/kata-containers/runtime/pkg/signals"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
lSyslog "github.com/sirupsen/logrus/hooks/syslog"
|
lSyslog "github.com/sirupsen/logrus/hooks/syslog"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
@ -70,7 +70,7 @@ type netmon struct {
|
|||||||
storagePath string
|
storagePath string
|
||||||
sharedFile string
|
sharedFile string
|
||||||
|
|
||||||
netIfaces map[int]types.Interface
|
netIfaces map[int]vcTypes.Interface
|
||||||
|
|
||||||
linkUpdateCh chan netlink.LinkUpdate
|
linkUpdateCh chan netlink.LinkUpdate
|
||||||
linkDoneCh chan struct{}
|
linkDoneCh chan struct{}
|
||||||
@ -151,7 +151,7 @@ func newNetmon(params netmonParams) (*netmon, error) {
|
|||||||
netmonParams: params,
|
netmonParams: params,
|
||||||
storagePath: filepath.Join(storageParentPath, params.sandboxID),
|
storagePath: filepath.Join(storageParentPath, params.sandboxID),
|
||||||
sharedFile: filepath.Join(storageParentPath, params.sandboxID, sharedFile),
|
sharedFile: filepath.Join(storageParentPath, params.sandboxID, sharedFile),
|
||||||
netIfaces: make(map[int]types.Interface),
|
netIfaces: make(map[int]vcTypes.Interface),
|
||||||
linkUpdateCh: make(chan netlink.LinkUpdate),
|
linkUpdateCh: make(chan netlink.LinkUpdate),
|
||||||
linkDoneCh: make(chan struct{}),
|
linkDoneCh: make(chan struct{}),
|
||||||
rtUpdateCh: make(chan netlink.RouteUpdate),
|
rtUpdateCh: make(chan netlink.RouteUpdate),
|
||||||
@ -259,13 +259,13 @@ func (n *netmon) listenNetlinkEvents() error {
|
|||||||
// convertInterface converts a link and its IP addresses as defined by netlink
|
// convertInterface converts a link and its IP addresses as defined by netlink
|
||||||
// package, into the Interface structure format expected by kata-runtime to
|
// package, into the Interface structure format expected by kata-runtime to
|
||||||
// describe an interface and its associated IP addresses.
|
// describe an interface and its associated IP addresses.
|
||||||
func convertInterface(linkAttrs *netlink.LinkAttrs, linkType string, addrs []netlink.Addr) types.Interface {
|
func convertInterface(linkAttrs *netlink.LinkAttrs, linkType string, addrs []netlink.Addr) vcTypes.Interface {
|
||||||
if linkAttrs == nil {
|
if linkAttrs == nil {
|
||||||
netmonLog.Warn("Link attributes are nil")
|
netmonLog.Warn("Link attributes are nil")
|
||||||
return types.Interface{}
|
return vcTypes.Interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ipAddrs []*types.IPAddress
|
var ipAddrs []*vcTypes.IPAddress
|
||||||
|
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
if addr.IPNet == nil {
|
if addr.IPNet == nil {
|
||||||
@ -274,7 +274,7 @@ func convertInterface(linkAttrs *netlink.LinkAttrs, linkType string, addrs []net
|
|||||||
|
|
||||||
netMask, _ := addr.Mask.Size()
|
netMask, _ := addr.Mask.Size()
|
||||||
|
|
||||||
ipAddr := &types.IPAddress{
|
ipAddr := &vcTypes.IPAddress{
|
||||||
Family: netlinkFamily,
|
Family: netlinkFamily,
|
||||||
Address: addr.IP.String(),
|
Address: addr.IP.String(),
|
||||||
Mask: fmt.Sprintf("%d", netMask),
|
Mask: fmt.Sprintf("%d", netMask),
|
||||||
@ -283,7 +283,7 @@ func convertInterface(linkAttrs *netlink.LinkAttrs, linkType string, addrs []net
|
|||||||
ipAddrs = append(ipAddrs, ipAddr)
|
ipAddrs = append(ipAddrs, ipAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
iface := types.Interface{
|
iface := vcTypes.Interface{
|
||||||
Device: linkAttrs.Name,
|
Device: linkAttrs.Name,
|
||||||
Name: linkAttrs.Name,
|
Name: linkAttrs.Name,
|
||||||
IPAddresses: ipAddrs,
|
IPAddresses: ipAddrs,
|
||||||
@ -300,8 +300,8 @@ func convertInterface(linkAttrs *netlink.LinkAttrs, linkType string, addrs []net
|
|||||||
// convertRoutes converts a list of routes as defined by netlink package,
|
// convertRoutes converts a list of routes as defined by netlink package,
|
||||||
// into a list of Route structure format expected by kata-runtime to
|
// into a list of Route structure format expected by kata-runtime to
|
||||||
// describe a set of routes.
|
// describe a set of routes.
|
||||||
func convertRoutes(netRoutes []netlink.Route) []types.Route {
|
func convertRoutes(netRoutes []netlink.Route) []vcTypes.Route {
|
||||||
var routes []types.Route
|
var routes []vcTypes.Route
|
||||||
|
|
||||||
// Ignore routes with IPv6 addresses as this is not supported
|
// Ignore routes with IPv6 addresses as this is not supported
|
||||||
// by Kata yet.
|
// by Kata yet.
|
||||||
@ -335,7 +335,7 @@ func convertRoutes(netRoutes []netlink.Route) []types.Route {
|
|||||||
dev = iface.Name
|
dev = iface.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
route := types.Route{
|
route := vcTypes.Route{
|
||||||
Dest: dst,
|
Dest: dst,
|
||||||
Gateway: gw,
|
Gateway: gw,
|
||||||
Device: dev,
|
Device: dev,
|
||||||
@ -407,7 +407,7 @@ func (n *netmon) execKataCmd(subCmd string) error {
|
|||||||
return os.Remove(n.sharedFile)
|
return os.Remove(n.sharedFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *netmon) addInterfaceCLI(iface types.Interface) error {
|
func (n *netmon) addInterfaceCLI(iface vcTypes.Interface) error {
|
||||||
if err := n.storeDataToSend(iface); err != nil {
|
if err := n.storeDataToSend(iface); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ func (n *netmon) addInterfaceCLI(iface types.Interface) error {
|
|||||||
return n.execKataCmd(kataCLIAddIfaceCmd)
|
return n.execKataCmd(kataCLIAddIfaceCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *netmon) delInterfaceCLI(iface types.Interface) error {
|
func (n *netmon) delInterfaceCLI(iface vcTypes.Interface) error {
|
||||||
if err := n.storeDataToSend(iface); err != nil {
|
if err := n.storeDataToSend(iface); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -423,7 +423,7 @@ func (n *netmon) delInterfaceCLI(iface types.Interface) error {
|
|||||||
return n.execKataCmd(kataCLIDelIfaceCmd)
|
return n.execKataCmd(kataCLIDelIfaceCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *netmon) updateRoutesCLI(routes []types.Route) error {
|
func (n *netmon) updateRoutesCLI(routes []vcTypes.Route) error {
|
||||||
if err := n.storeDataToSend(routes); err != nil {
|
if err := n.storeDataToSend(routes); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
@ -176,12 +176,12 @@ func TestConvertInterface(t *testing.T) {
|
|||||||
|
|
||||||
linkType := "link_type_test"
|
linkType := "link_type_test"
|
||||||
|
|
||||||
expected := types.Interface{
|
expected := vcTypes.Interface{
|
||||||
Device: testIfaceName,
|
Device: testIfaceName,
|
||||||
Name: testIfaceName,
|
Name: testIfaceName,
|
||||||
Mtu: uint64(testMTU),
|
Mtu: uint64(testMTU),
|
||||||
HwAddr: testHwAddr,
|
HwAddr: testHwAddr,
|
||||||
IPAddresses: []*types.IPAddress{
|
IPAddresses: []*vcTypes.IPAddress{
|
||||||
{
|
{
|
||||||
Family: netlinkFamily,
|
Family: netlinkFamily,
|
||||||
Address: testIPAddress,
|
Address: testIPAddress,
|
||||||
@ -211,7 +211,7 @@ func TestConvertRoutes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := []types.Route{
|
expected := []vcTypes.Route{
|
||||||
{
|
{
|
||||||
Dest: testIPAddress,
|
Dest: testIPAddress,
|
||||||
Gateway: testIPAddress,
|
Gateway: testIPAddress,
|
||||||
@ -245,7 +245,7 @@ func testSetupNetwork(t *testing.T) testTeardownNetwork {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCreateDummyNetwork(t *testing.T, handler *netlink.Handle) (int, types.Interface) {
|
func testCreateDummyNetwork(t *testing.T, handler *netlink.Handle) (int, vcTypes.Interface) {
|
||||||
hwAddr, err := net.ParseMAC(testHwAddr)
|
hwAddr, err := net.ParseMAC(testHwAddr)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ func testCreateDummyNetwork(t *testing.T, handler *netlink.Handle) (int, types.I
|
|||||||
attrs := link.Attrs()
|
attrs := link.Attrs()
|
||||||
assert.NotNil(t, attrs)
|
assert.NotNil(t, attrs)
|
||||||
|
|
||||||
iface := types.Interface{
|
iface := vcTypes.Interface{
|
||||||
Device: testIfaceName,
|
Device: testIfaceName,
|
||||||
Name: testIfaceName,
|
Name: testIfaceName,
|
||||||
Mtu: uint64(testMTU),
|
Mtu: uint64(testMTU),
|
||||||
@ -289,7 +289,7 @@ func TestScanNetwork(t *testing.T) {
|
|||||||
idx, expected := testCreateDummyNetwork(t, handler)
|
idx, expected := testCreateDummyNetwork(t, handler)
|
||||||
|
|
||||||
n := &netmon{
|
n := &netmon{
|
||||||
netIfaces: make(map[int]types.Interface),
|
netIfaces: make(map[int]vcTypes.Interface),
|
||||||
netHandler: handler,
|
netHandler: handler,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,9 +300,9 @@ func TestScanNetwork(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStoreDataToSend(t *testing.T) {
|
func TestStoreDataToSend(t *testing.T) {
|
||||||
var got types.Interface
|
var got vcTypes.Interface
|
||||||
|
|
||||||
expected := types.Interface{
|
expected := vcTypes.Interface{
|
||||||
Device: testIfaceName,
|
Device: testIfaceName,
|
||||||
Name: testIfaceName,
|
Name: testIfaceName,
|
||||||
Mtu: uint64(testMTU),
|
Mtu: uint64(testMTU),
|
||||||
@ -399,15 +399,15 @@ func TestActionsCLI(t *testing.T) {
|
|||||||
defer os.RemoveAll(testStorageParentPath)
|
defer os.RemoveAll(testStorageParentPath)
|
||||||
|
|
||||||
// Test addInterfaceCLI
|
// Test addInterfaceCLI
|
||||||
err = n.addInterfaceCLI(types.Interface{})
|
err = n.addInterfaceCLI(vcTypes.Interface{})
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// Test delInterfaceCLI
|
// Test delInterfaceCLI
|
||||||
err = n.delInterfaceCLI(types.Interface{})
|
err = n.delInterfaceCLI(vcTypes.Interface{})
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// Test updateRoutesCLI
|
// Test updateRoutesCLI
|
||||||
err = n.updateRoutesCLI([]types.Route{})
|
err = n.updateRoutesCLI([]vcTypes.Route{})
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
tearDownNetworkCb := testSetupNetwork(t)
|
tearDownNetworkCb := testSetupNetwork(t)
|
||||||
@ -465,8 +465,8 @@ func TestHandleRTMNewLink(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// Interface already exist in list
|
// Interface already exist in list
|
||||||
n.netIfaces = make(map[int]types.Interface)
|
n.netIfaces = make(map[int]vcTypes.Interface)
|
||||||
n.netIfaces[testIfaceIndex] = types.Interface{}
|
n.netIfaces[testIfaceIndex] = vcTypes.Interface{}
|
||||||
ev = netlink.LinkUpdate{
|
ev = netlink.LinkUpdate{
|
||||||
Link: &netlink.Dummy{
|
Link: &netlink.Dummy{
|
||||||
LinkAttrs: netlink.LinkAttrs{
|
LinkAttrs: netlink.LinkAttrs{
|
||||||
@ -479,7 +479,7 @@ func TestHandleRTMNewLink(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// Flags are not up and running
|
// Flags are not up and running
|
||||||
n.netIfaces = make(map[int]types.Interface)
|
n.netIfaces = make(map[int]vcTypes.Interface)
|
||||||
ev = netlink.LinkUpdate{
|
ev = netlink.LinkUpdate{
|
||||||
Link: &netlink.Dummy{
|
Link: &netlink.Dummy{
|
||||||
LinkAttrs: netlink.LinkAttrs{
|
LinkAttrs: netlink.LinkAttrs{
|
||||||
@ -492,7 +492,7 @@ func TestHandleRTMNewLink(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// Invalid link
|
// Invalid link
|
||||||
n.netIfaces = make(map[int]types.Interface)
|
n.netIfaces = make(map[int]vcTypes.Interface)
|
||||||
ev = netlink.LinkUpdate{
|
ev = netlink.LinkUpdate{
|
||||||
Link: &netlink.Dummy{
|
Link: &netlink.Dummy{
|
||||||
LinkAttrs: netlink.LinkAttrs{
|
LinkAttrs: netlink.LinkAttrs{
|
||||||
@ -533,7 +533,7 @@ func TestHandleRTMDelLink(t *testing.T) {
|
|||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
// Interface does not exist in list
|
// Interface does not exist in list
|
||||||
n.netIfaces = make(map[int]types.Interface)
|
n.netIfaces = make(map[int]vcTypes.Interface)
|
||||||
ev = netlink.LinkUpdate{
|
ev = netlink.LinkUpdate{
|
||||||
Link: &netlink.Dummy{
|
Link: &netlink.Dummy{
|
||||||
LinkAttrs: netlink.LinkAttrs{
|
LinkAttrs: netlink.LinkAttrs{
|
||||||
@ -548,7 +548,7 @@ func TestHandleRTMDelLink(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleRTMNewRouteIfaceNotFound(t *testing.T) {
|
func TestHandleRTMNewRouteIfaceNotFound(t *testing.T) {
|
||||||
n := &netmon{
|
n := &netmon{
|
||||||
netIfaces: make(map[int]types.Interface),
|
netIfaces: make(map[int]vcTypes.Interface),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := n.handleRTMNewRoute(netlink.RouteUpdate{})
|
err := n.handleRTMNewRoute(netlink.RouteUpdate{})
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/protocols/grpc"
|
"github.com/kata-containers/agent/protocols/grpc"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
@ -234,16 +234,16 @@ type agent interface {
|
|||||||
reseedRNG(data []byte) error
|
reseedRNG(data []byte) error
|
||||||
|
|
||||||
// updateInterface will tell the agent to update a nic for an existed Sandbox.
|
// updateInterface will tell the agent to update a nic for an existed Sandbox.
|
||||||
updateInterface(inf *types.Interface) (*types.Interface, error)
|
updateInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||||
|
|
||||||
// listInterfaces will tell the agent to list interfaces of an existed Sandbox
|
// listInterfaces will tell the agent to list interfaces of an existed Sandbox
|
||||||
listInterfaces() ([]*types.Interface, error)
|
listInterfaces() ([]*vcTypes.Interface, error)
|
||||||
|
|
||||||
// updateRoutes will tell the agent to update route table for an existed Sandbox.
|
// updateRoutes will tell the agent to update route table for an existed Sandbox.
|
||||||
updateRoutes(routes []*types.Route) ([]*types.Route, error)
|
updateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error)
|
||||||
|
|
||||||
// listRoutes will tell the agent to list routes of an existed Sandbox
|
// listRoutes will tell the agent to list routes of an existed Sandbox
|
||||||
listRoutes() ([]*types.Route, error)
|
listRoutes() ([]*vcTypes.Route, error)
|
||||||
|
|
||||||
// getGuestDetails will tell the agent to get some information of guest
|
// getGuestDetails will tell the agent to get some information of guest
|
||||||
getGuestDetails(*grpc.GuestDetailsRequest) (*grpc.GuestDetailsResponse, error)
|
getGuestDetails(*grpc.GuestDetailsRequest) (*grpc.GuestDetailsResponse, error)
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
deviceApi "github.com/kata-containers/runtime/virtcontainers/device/api"
|
deviceApi "github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||||
deviceConfig "github.com/kata-containers/runtime/virtcontainers/device/config"
|
deviceConfig "github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
opentracing "github.com/opentracing/opentracing-go"
|
opentracing "github.com/opentracing/opentracing-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -804,7 +804,7 @@ func AddDevice(ctx context.Context, sandboxID string, info deviceConfig.DeviceIn
|
|||||||
return s.AddDevice(info)
|
return s.AddDevice(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleInterface(ctx context.Context, sandboxID string, inf *types.Interface, add bool) (*types.Interface, error) {
|
func toggleInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface, add bool) (*vcTypes.Interface, error) {
|
||||||
if sandboxID == "" {
|
if sandboxID == "" {
|
||||||
return nil, errNeedSandboxID
|
return nil, errNeedSandboxID
|
||||||
}
|
}
|
||||||
@ -829,7 +829,7 @@ func toggleInterface(ctx context.Context, sandboxID string, inf *types.Interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddInterface is the virtcontainers add interface entry point.
|
// AddInterface is the virtcontainers add interface entry point.
|
||||||
func AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
func AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
span, ctx := trace(ctx, "AddInterface")
|
span, ctx := trace(ctx, "AddInterface")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
@ -837,7 +837,7 @@ func AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveInterface is the virtcontainers remove interface entry point.
|
// RemoveInterface is the virtcontainers remove interface entry point.
|
||||||
func RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
func RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
span, ctx := trace(ctx, "RemoveInterface")
|
span, ctx := trace(ctx, "RemoveInterface")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
@ -845,7 +845,7 @@ func RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListInterfaces is the virtcontainers list interfaces entry point.
|
// ListInterfaces is the virtcontainers list interfaces entry point.
|
||||||
func ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface, error) {
|
func ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) {
|
||||||
span, ctx := trace(ctx, "ListInterfaces")
|
span, ctx := trace(ctx, "ListInterfaces")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
@ -869,7 +869,7 @@ func ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRoutes is the virtcontainers update routes entry point.
|
// UpdateRoutes is the virtcontainers update routes entry point.
|
||||||
func UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error) {
|
func UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
span, ctx := trace(ctx, "UpdateRoutes")
|
span, ctx := trace(ctx, "UpdateRoutes")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
@ -893,7 +893,7 @@ func UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListRoutes is the virtcontainers list routes entry point.
|
// ListRoutes is the virtcontainers list routes entry point.
|
||||||
func ListRoutes(ctx context.Context, sandboxID string) ([]*types.Route, error) {
|
func ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) {
|
||||||
span, ctx := trace(ctx, "ListRoutes")
|
span, ctx := trace(ctx, "ListRoutes")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -2422,12 +2422,12 @@ func TestNetworkOperation(t *testing.T) {
|
|||||||
cleanUp()
|
cleanUp()
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
inf := &types.Interface{
|
inf := &vcTypes.Interface{
|
||||||
Name: "eno1",
|
Name: "eno1",
|
||||||
Mtu: 1500,
|
Mtu: 1500,
|
||||||
HwAddr: "02:00:ca:fe:00:48",
|
HwAddr: "02:00:ca:fe:00:48",
|
||||||
}
|
}
|
||||||
ip := types.IPAddress{
|
ip := vcTypes.IPAddress{
|
||||||
Family: 0,
|
Family: 0,
|
||||||
Address: "192.168.0.101",
|
Address: "192.168.0.101",
|
||||||
Mask: "24",
|
Mask: "24",
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/hyperstart"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/hyperstart"
|
||||||
ns "github.com/kata-containers/runtime/virtcontainers/pkg/nsenter"
|
ns "github.com/kata-containers/runtime/virtcontainers/pkg/nsenter"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/utils"
|
"github.com/kata-containers/runtime/virtcontainers/utils"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
@ -890,22 +890,22 @@ func (h *hyper) onlineCPUMem(cpus uint32, cpuOnly bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *hyper) updateInterface(inf *types.Interface) (*types.Interface, error) {
|
func (h *hyper) updateInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
// hyperstart-agent does not support update interface
|
// hyperstart-agent does not support update interface
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *hyper) listInterfaces() ([]*types.Interface, error) {
|
func (h *hyper) listInterfaces() ([]*vcTypes.Interface, error) {
|
||||||
// hyperstart-agent does not support list interfaces
|
// hyperstart-agent does not support list interfaces
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *hyper) updateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
func (h *hyper) updateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
// hyperstart-agent does not support update routes
|
// hyperstart-agent does not support update routes
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *hyper) listRoutes() ([]*types.Route, error) {
|
func (h *hyper) listRoutes() ([]*vcTypes.Route, error) {
|
||||||
// hyperstart-agent does not support list routes
|
// hyperstart-agent does not support list routes
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
|
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -152,26 +152,26 @@ func (impl *VCImpl) AddDevice(ctx context.Context, sandboxID string, info config
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddInterface implements the VC function of the same name.
|
// AddInterface implements the VC function of the same name.
|
||||||
func (impl *VCImpl) AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
func (impl *VCImpl) AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return AddInterface(ctx, sandboxID, inf)
|
return AddInterface(ctx, sandboxID, inf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveInterface implements the VC function of the same name.
|
// RemoveInterface implements the VC function of the same name.
|
||||||
func (impl *VCImpl) RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
func (impl *VCImpl) RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return RemoveInterface(ctx, sandboxID, inf)
|
return RemoveInterface(ctx, sandboxID, inf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListInterfaces implements the VC function of the same name.
|
// ListInterfaces implements the VC function of the same name.
|
||||||
func (impl *VCImpl) ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface, error) {
|
func (impl *VCImpl) ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) {
|
||||||
return ListInterfaces(ctx, sandboxID)
|
return ListInterfaces(ctx, sandboxID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRoutes implements the VC function of the same name.
|
// UpdateRoutes implements the VC function of the same name.
|
||||||
func (impl *VCImpl) UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error) {
|
func (impl *VCImpl) UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
return UpdateRoutes(ctx, sandboxID, routes)
|
return UpdateRoutes(ctx, sandboxID, routes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRoutes implements the VC function of the same name.
|
// ListRoutes implements the VC function of the same name.
|
||||||
func (impl *VCImpl) ListRoutes(ctx context.Context, sandboxID string) ([]*types.Route, error) {
|
func (impl *VCImpl) ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) {
|
||||||
return ListRoutes(ctx, sandboxID)
|
return ListRoutes(ctx, sandboxID)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -48,11 +48,11 @@ type VC interface {
|
|||||||
|
|
||||||
AddDevice(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)
|
AddDevice(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)
|
||||||
|
|
||||||
AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error)
|
AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||||
RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error)
|
RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||||
ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface, error)
|
ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error)
|
||||||
UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error)
|
UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error)
|
||||||
ListRoutes(ctx context.Context, sandboxID string) ([]*types.Route, error)
|
ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VCSandbox is the Sandbox interface
|
// VCSandbox is the Sandbox interface
|
||||||
@ -93,11 +93,11 @@ type VCSandbox interface {
|
|||||||
|
|
||||||
AddDevice(info config.DeviceInfo) (api.Device, error)
|
AddDevice(info config.DeviceInfo) (api.Device, error)
|
||||||
|
|
||||||
AddInterface(inf *types.Interface) (*types.Interface, error)
|
AddInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||||
RemoveInterface(inf *types.Interface) (*types.Interface, error)
|
RemoveInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||||
ListInterfaces() ([]*types.Interface, error)
|
ListInterfaces() ([]*vcTypes.Interface, error)
|
||||||
UpdateRoutes(routes []*types.Route) ([]*types.Route, error)
|
UpdateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error)
|
||||||
ListRoutes() ([]*types.Route, error)
|
ListRoutes() ([]*vcTypes.Route, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VCContainer is the Container interface
|
// VCContainer is the Container interface
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
ns "github.com/kata-containers/runtime/virtcontainers/pkg/nsenter"
|
ns "github.com/kata-containers/runtime/virtcontainers/pkg/nsenter"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/uuid"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/uuid"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/utils"
|
"github.com/kata-containers/runtime/virtcontainers/utils"
|
||||||
opentracing "github.com/opentracing/opentracing-go"
|
opentracing "github.com/opentracing/opentracing-go"
|
||||||
@ -398,7 +398,7 @@ func (k *kataAgent) exec(sandbox *Sandbox, c Container, cmd Cmd) (*Process, erro
|
|||||||
k.state.URL, cmd, []ns.NSType{}, enterNSList)
|
k.state.URL, cmd, []ns.NSType{}, enterNSList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) updateInterface(ifc *types.Interface) (*types.Interface, error) {
|
func (k *kataAgent) updateInterface(ifc *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
// send update interface request
|
// send update interface request
|
||||||
ifcReq := &grpc.UpdateInterfaceRequest{
|
ifcReq := &grpc.UpdateInterfaceRequest{
|
||||||
Interface: k.convertToKataAgentInterface(ifc),
|
Interface: k.convertToKataAgentInterface(ifc),
|
||||||
@ -410,13 +410,13 @@ func (k *kataAgent) updateInterface(ifc *types.Interface) (*types.Interface, err
|
|||||||
"resulting-interface": fmt.Sprintf("%+v", resultingInterface),
|
"resulting-interface": fmt.Sprintf("%+v", resultingInterface),
|
||||||
}).WithError(err).Error("update interface request failed")
|
}).WithError(err).Error("update interface request failed")
|
||||||
}
|
}
|
||||||
if resultInterface, ok := resultingInterface.(*types.Interface); ok {
|
if resultInterface, ok := resultingInterface.(*vcTypes.Interface); ok {
|
||||||
return resultInterface, err
|
return resultInterface, err
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) updateInterfaces(interfaces []*types.Interface) error {
|
func (k *kataAgent) updateInterfaces(interfaces []*vcTypes.Interface) error {
|
||||||
for _, ifc := range interfaces {
|
for _, ifc := range interfaces {
|
||||||
if _, err := k.updateInterface(ifc); err != nil {
|
if _, err := k.updateInterface(ifc); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -425,7 +425,7 @@ func (k *kataAgent) updateInterfaces(interfaces []*types.Interface) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) updateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
func (k *kataAgent) updateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
if routes != nil {
|
if routes != nil {
|
||||||
routesReq := &grpc.UpdateRoutesRequest{
|
routesReq := &grpc.UpdateRoutesRequest{
|
||||||
Routes: &grpc.Routes{
|
Routes: &grpc.Routes{
|
||||||
@ -448,7 +448,7 @@ func (k *kataAgent) updateRoutes(routes []*types.Route) ([]*types.Route, error)
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) listInterfaces() ([]*types.Interface, error) {
|
func (k *kataAgent) listInterfaces() ([]*vcTypes.Interface, error) {
|
||||||
req := &grpc.ListInterfacesRequest{}
|
req := &grpc.ListInterfacesRequest{}
|
||||||
resultingInterfaces, err := k.sendReq(req)
|
resultingInterfaces, err := k.sendReq(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -461,7 +461,7 @@ func (k *kataAgent) listInterfaces() ([]*types.Interface, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) listRoutes() ([]*types.Route, error) {
|
func (k *kataAgent) listRoutes() ([]*vcTypes.Route, error) {
|
||||||
req := &grpc.ListRoutesRequest{}
|
req := &grpc.ListRoutesRequest{}
|
||||||
resultingRoutes, err := k.sendReq(req)
|
resultingRoutes, err := k.sendReq(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1664,7 +1664,7 @@ func (k *kataAgent) convertToIPFamily(ipFamily aTypes.IPFamily) int {
|
|||||||
return netlink.FAMILY_V4
|
return netlink.FAMILY_V4
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) convertToKataAgentIPAddresses(ipAddrs []*types.IPAddress) (aIPAddrs []*aTypes.IPAddress) {
|
func (k *kataAgent) convertToKataAgentIPAddresses(ipAddrs []*vcTypes.IPAddress) (aIPAddrs []*aTypes.IPAddress) {
|
||||||
for _, ipAddr := range ipAddrs {
|
for _, ipAddr := range ipAddrs {
|
||||||
if ipAddr == nil {
|
if ipAddr == nil {
|
||||||
continue
|
continue
|
||||||
@ -1682,13 +1682,13 @@ func (k *kataAgent) convertToKataAgentIPAddresses(ipAddrs []*types.IPAddress) (a
|
|||||||
return aIPAddrs
|
return aIPAddrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) convertToIPAddresses(aIPAddrs []*aTypes.IPAddress) (ipAddrs []*types.IPAddress) {
|
func (k *kataAgent) convertToIPAddresses(aIPAddrs []*aTypes.IPAddress) (ipAddrs []*vcTypes.IPAddress) {
|
||||||
for _, aIPAddr := range aIPAddrs {
|
for _, aIPAddr := range aIPAddrs {
|
||||||
if aIPAddr == nil {
|
if aIPAddr == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ipAddr := &types.IPAddress{
|
ipAddr := &vcTypes.IPAddress{
|
||||||
Family: k.convertToIPFamily(aIPAddr.Family),
|
Family: k.convertToIPFamily(aIPAddr.Family),
|
||||||
Address: aIPAddr.Address,
|
Address: aIPAddr.Address,
|
||||||
Mask: aIPAddr.Mask,
|
Mask: aIPAddr.Mask,
|
||||||
@ -1700,7 +1700,7 @@ func (k *kataAgent) convertToIPAddresses(aIPAddrs []*aTypes.IPAddress) (ipAddrs
|
|||||||
return ipAddrs
|
return ipAddrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) convertToKataAgentInterface(iface *types.Interface) *aTypes.Interface {
|
func (k *kataAgent) convertToKataAgentInterface(iface *vcTypes.Interface) *aTypes.Interface {
|
||||||
if iface == nil {
|
if iface == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1715,13 +1715,13 @@ func (k *kataAgent) convertToKataAgentInterface(iface *types.Interface) *aTypes.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) (ifaces []*types.Interface) {
|
func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) (ifaces []*vcTypes.Interface) {
|
||||||
for _, aIface := range aIfaces {
|
for _, aIface := range aIfaces {
|
||||||
if aIface == nil {
|
if aIface == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
iface := &types.Interface{
|
iface := &vcTypes.Interface{
|
||||||
Device: aIface.Device,
|
Device: aIface.Device,
|
||||||
Name: aIface.Name,
|
Name: aIface.Name,
|
||||||
IPAddresses: k.convertToIPAddresses(aIface.IPAddresses),
|
IPAddresses: k.convertToIPAddresses(aIface.IPAddresses),
|
||||||
@ -1736,7 +1736,7 @@ func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) (ifaces []*
|
|||||||
return ifaces
|
return ifaces
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) convertToKataAgentRoutes(routes []*types.Route) (aRoutes []*aTypes.Route) {
|
func (k *kataAgent) convertToKataAgentRoutes(routes []*vcTypes.Route) (aRoutes []*aTypes.Route) {
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
if route == nil {
|
if route == nil {
|
||||||
continue
|
continue
|
||||||
@ -1756,13 +1756,13 @@ func (k *kataAgent) convertToKataAgentRoutes(routes []*types.Route) (aRoutes []*
|
|||||||
return aRoutes
|
return aRoutes
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) convertToRoutes(aRoutes []*aTypes.Route) (routes []*types.Route) {
|
func (k *kataAgent) convertToRoutes(aRoutes []*aTypes.Route) (routes []*vcTypes.Route) {
|
||||||
for _, aRoute := range aRoutes {
|
for _, aRoute := range aRoutes {
|
||||||
if aRoute == nil {
|
if aRoute == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
route := &types.Route{
|
route := &vcTypes.Route{
|
||||||
Dest: aRoute.Dest,
|
Dest: aRoute.Dest,
|
||||||
Gateway: aRoute.Gateway,
|
Gateway: aRoute.Gateway,
|
||||||
Device: aRoute.Device,
|
Device: aRoute.Device,
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
"github.com/kata-containers/runtime/virtcontainers/device/manager"
|
"github.com/kata-containers/runtime/virtcontainers/device/manager"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -817,7 +817,7 @@ func TestAgentNetworkOperation(t *testing.T) {
|
|||||||
_, err = k.listInterfaces()
|
_, err = k.listInterfaces()
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
|
||||||
_, err = k.updateRoutes([]*types.Route{})
|
_, err = k.updateRoutes([]*vcTypes.Route{})
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
|
||||||
_, err = k.listRoutes()
|
_, err = k.listRoutes()
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"github.com/vishvananda/netns"
|
"github.com/vishvananda/netns"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/uuid"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/uuid"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/utils"
|
"github.com/kata-containers/runtime/virtcontainers/utils"
|
||||||
)
|
)
|
||||||
@ -1196,18 +1196,18 @@ func deleteNetNS(netNSPath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*types.Interface, []*types.Route, error) {
|
func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*vcTypes.Interface, []*vcTypes.Route, error) {
|
||||||
|
|
||||||
if networkNS.NetNsPath == "" {
|
if networkNS.NetNsPath == "" {
|
||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var routes []*types.Route
|
var routes []*vcTypes.Route
|
||||||
var ifaces []*types.Interface
|
var ifaces []*vcTypes.Interface
|
||||||
|
|
||||||
for _, endpoint := range networkNS.Endpoints {
|
for _, endpoint := range networkNS.Endpoints {
|
||||||
|
|
||||||
var ipAddresses []*types.IPAddress
|
var ipAddresses []*vcTypes.IPAddress
|
||||||
for _, addr := range endpoint.Properties().Addrs {
|
for _, addr := range endpoint.Properties().Addrs {
|
||||||
// Skip IPv6 because not supported
|
// Skip IPv6 because not supported
|
||||||
if addr.IP.To4() == nil {
|
if addr.IP.To4() == nil {
|
||||||
@ -1223,14 +1223,14 @@ func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*types.Interface
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
netMask, _ := addr.Mask.Size()
|
netMask, _ := addr.Mask.Size()
|
||||||
ipAddress := types.IPAddress{
|
ipAddress := vcTypes.IPAddress{
|
||||||
Family: netlink.FAMILY_V4,
|
Family: netlink.FAMILY_V4,
|
||||||
Address: addr.IP.String(),
|
Address: addr.IP.String(),
|
||||||
Mask: fmt.Sprintf("%d", netMask),
|
Mask: fmt.Sprintf("%d", netMask),
|
||||||
}
|
}
|
||||||
ipAddresses = append(ipAddresses, &ipAddress)
|
ipAddresses = append(ipAddresses, &ipAddress)
|
||||||
}
|
}
|
||||||
ifc := types.Interface{
|
ifc := vcTypes.Interface{
|
||||||
IPAddresses: ipAddresses,
|
IPAddresses: ipAddresses,
|
||||||
Device: endpoint.Name(),
|
Device: endpoint.Name(),
|
||||||
Name: endpoint.Name(),
|
Name: endpoint.Name(),
|
||||||
@ -1242,7 +1242,7 @@ func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*types.Interface
|
|||||||
ifaces = append(ifaces, &ifc)
|
ifaces = append(ifaces, &ifc)
|
||||||
|
|
||||||
for _, route := range endpoint.Properties().Routes {
|
for _, route := range endpoint.Properties().Routes {
|
||||||
var r types.Route
|
var r vcTypes.Route
|
||||||
|
|
||||||
if route.Dst != nil {
|
if route.Dst != nil {
|
||||||
r.Dest = route.Dst.String()
|
r.Dest = route.Dst.String()
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
@ -161,16 +161,16 @@ func TestGenerateInterfacesAndRoutes(t *testing.T) {
|
|||||||
//
|
//
|
||||||
// Build expected results:
|
// Build expected results:
|
||||||
//
|
//
|
||||||
expectedAddresses := []*types.IPAddress{
|
expectedAddresses := []*vcTypes.IPAddress{
|
||||||
{Family: netlink.FAMILY_V4, Address: "172.17.0.2", Mask: "16"},
|
{Family: netlink.FAMILY_V4, Address: "172.17.0.2", Mask: "16"},
|
||||||
{Family: netlink.FAMILY_V4, Address: "182.17.0.2", Mask: "16"},
|
{Family: netlink.FAMILY_V4, Address: "182.17.0.2", Mask: "16"},
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedInterfaces := []*types.Interface{
|
expectedInterfaces := []*vcTypes.Interface{
|
||||||
{Device: "eth0", Name: "eth0", IPAddresses: expectedAddresses, Mtu: 1500, HwAddr: "02:00:ca:fe:00:04"},
|
{Device: "eth0", Name: "eth0", IPAddresses: expectedAddresses, Mtu: 1500, HwAddr: "02:00:ca:fe:00:04"},
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedRoutes := []*types.Route{
|
expectedRoutes := []*vcTypes.Route{
|
||||||
{Dest: "", Gateway: "172.17.0.1", Device: "eth0", Source: "", Scope: uint32(254)},
|
{Dest: "", Gateway: "172.17.0.1", Device: "eth0", Source: "", Scope: uint32(254)},
|
||||||
{Dest: "172.17.0.0/16", Gateway: "172.17.0.1", Device: "eth0", Source: "172.17.0.2"},
|
{Dest: "172.17.0.0/16", Gateway: "172.17.0.1", Device: "eth0", Source: "172.17.0.2"},
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/protocols/grpc"
|
"github.com/kata-containers/agent/protocols/grpc"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
@ -96,22 +96,22 @@ func (n *noopAgent) onlineCPUMem(cpus uint32, cpuOnly bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// updateInterface is the Noop agent Interface update implementation. It does nothing.
|
// updateInterface is the Noop agent Interface update implementation. It does nothing.
|
||||||
func (n *noopAgent) updateInterface(inf *types.Interface) (*types.Interface, error) {
|
func (n *noopAgent) updateInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// listInterfaces is the Noop agent Interfaces list implementation. It does nothing.
|
// listInterfaces is the Noop agent Interfaces list implementation. It does nothing.
|
||||||
func (n *noopAgent) listInterfaces() ([]*types.Interface, error) {
|
func (n *noopAgent) listInterfaces() ([]*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateRoutes is the Noop agent Routes update implementation. It does nothing.
|
// updateRoutes is the Noop agent Routes update implementation. It does nothing.
|
||||||
func (n *noopAgent) updateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
func (n *noopAgent) updateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// listRoutes is the Noop agent Routes list implementation. It does nothing.
|
// listRoutes is the Noop agent Routes list implementation. It does nothing.
|
||||||
func (n *noopAgent) listRoutes() ([]*types.Route, error) {
|
func (n *noopAgent) listRoutes() ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -254,7 +254,7 @@ func (m *VCMock) AddDevice(ctx context.Context, sandboxID string, info config.De
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddInterface implements the VC function of the same name.
|
// AddInterface implements the VC function of the same name.
|
||||||
func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
if m.AddInterfaceFunc != nil {
|
if m.AddInterfaceFunc != nil {
|
||||||
return m.AddInterfaceFunc(ctx, sandboxID, inf)
|
return m.AddInterfaceFunc(ctx, sandboxID, inf)
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *types.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveInterface implements the VC function of the same name.
|
// RemoveInterface implements the VC function of the same name.
|
||||||
func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error) {
|
func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
if m.RemoveInterfaceFunc != nil {
|
if m.RemoveInterfaceFunc != nil {
|
||||||
return m.RemoveInterfaceFunc(ctx, sandboxID, inf)
|
return m.RemoveInterfaceFunc(ctx, sandboxID, inf)
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *typ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListInterfaces implements the VC function of the same name.
|
// ListInterfaces implements the VC function of the same name.
|
||||||
func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*types.Interface, error) {
|
func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) {
|
||||||
if m.ListInterfacesFunc != nil {
|
if m.ListInterfacesFunc != nil {
|
||||||
return m.ListInterfacesFunc(ctx, sandboxID)
|
return m.ListInterfacesFunc(ctx, sandboxID)
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*types
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRoutes implements the VC function of the same name.
|
// UpdateRoutes implements the VC function of the same name.
|
||||||
func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error) {
|
func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
if m.UpdateRoutesFunc != nil {
|
if m.UpdateRoutesFunc != nil {
|
||||||
return m.UpdateRoutesFunc(ctx, sandboxID, routes)
|
return m.UpdateRoutesFunc(ctx, sandboxID, routes)
|
||||||
}
|
}
|
||||||
@ -290,7 +290,7 @@ func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListRoutes implements the VC function of the same name.
|
// ListRoutes implements the VC function of the same name.
|
||||||
func (m *VCMock) ListRoutes(ctx context.Context, sandboxID string) ([]*types.Route, error) {
|
func (m *VCMock) ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) {
|
||||||
if m.ListRoutesFunc != nil {
|
if m.ListRoutesFunc != nil {
|
||||||
return m.ListRoutesFunc(ctx, sandboxID)
|
return m.ListRoutesFunc(ctx, sandboxID)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/factory"
|
"github.com/kata-containers/runtime/virtcontainers/factory"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -748,7 +748,7 @@ func TestVCMockAddInterface(t *testing.T) {
|
|||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(IsMockError(err))
|
assert.True(IsMockError(err))
|
||||||
|
|
||||||
m.AddInterfaceFunc = func(ctx context.Context, sid string, inf *types.Interface) (*types.Interface, error) {
|
m.AddInterfaceFunc = func(ctx context.Context, sid string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -775,7 +775,7 @@ func TestVCMockRemoveInterface(t *testing.T) {
|
|||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(IsMockError(err))
|
assert.True(IsMockError(err))
|
||||||
|
|
||||||
m.RemoveInterfaceFunc = func(ctx context.Context, sid string, inf *types.Interface) (*types.Interface, error) {
|
m.RemoveInterfaceFunc = func(ctx context.Context, sid string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,7 +802,7 @@ func TestVCMockListInterfaces(t *testing.T) {
|
|||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(IsMockError(err))
|
assert.True(IsMockError(err))
|
||||||
|
|
||||||
m.ListInterfacesFunc = func(ctx context.Context, sid string) ([]*types.Interface, error) {
|
m.ListInterfacesFunc = func(ctx context.Context, sid string) ([]*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,7 +829,7 @@ func TestVCMockUpdateRoutes(t *testing.T) {
|
|||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(IsMockError(err))
|
assert.True(IsMockError(err))
|
||||||
|
|
||||||
m.UpdateRoutesFunc = func(ctx context.Context, sid string, routes []*types.Route) ([]*types.Route, error) {
|
m.UpdateRoutesFunc = func(ctx context.Context, sid string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,7 +856,7 @@ func TestVCMockListRoutes(t *testing.T) {
|
|||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(IsMockError(err))
|
assert.True(IsMockError(err))
|
||||||
|
|
||||||
m.ListRoutesFunc = func(ctx context.Context, sid string) ([]*types.Route, error) {
|
m.ListRoutesFunc = func(ctx context.Context, sid string) ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -188,26 +188,26 @@ func (s *Sandbox) AddDevice(info config.DeviceInfo) (api.Device, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddInterface implements the VCSandbox function of the same name.
|
// AddInterface implements the VCSandbox function of the same name.
|
||||||
func (s *Sandbox) AddInterface(inf *types.Interface) (*types.Interface, error) {
|
func (s *Sandbox) AddInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveInterface implements the VCSandbox function of the same name.
|
// RemoveInterface implements the VCSandbox function of the same name.
|
||||||
func (s *Sandbox) RemoveInterface(inf *types.Interface) (*types.Interface, error) {
|
func (s *Sandbox) RemoveInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListInterfaces implements the VCSandbox function of the same name.
|
// ListInterfaces implements the VCSandbox function of the same name.
|
||||||
func (s *Sandbox) ListInterfaces() ([]*types.Interface, error) {
|
func (s *Sandbox) ListInterfaces() ([]*vcTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRoutes implements the VCSandbox function of the same name.
|
// UpdateRoutes implements the VCSandbox function of the same name.
|
||||||
func (s *Sandbox) UpdateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
func (s *Sandbox) UpdateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRoutes implements the VCSandbox function of the same name.
|
// ListRoutes implements the VCSandbox function of the same name.
|
||||||
func (s *Sandbox) ListRoutes() ([]*types.Route, error) {
|
func (s *Sandbox) ListRoutes() ([]*vcTypes.Route, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
"github.com/kata-containers/runtime/virtcontainers/device/api"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -69,9 +69,9 @@ type VCMock struct {
|
|||||||
|
|
||||||
AddDeviceFunc func(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)
|
AddDeviceFunc func(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)
|
||||||
|
|
||||||
AddInterfaceFunc func(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error)
|
AddInterfaceFunc func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||||
RemoveInterfaceFunc func(ctx context.Context, sandboxID string, inf *types.Interface) (*types.Interface, error)
|
RemoveInterfaceFunc func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||||
ListInterfacesFunc func(ctx context.Context, sandboxID string) ([]*types.Interface, error)
|
ListInterfacesFunc func(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error)
|
||||||
UpdateRoutesFunc func(ctx context.Context, sandboxID string, routes []*types.Route) ([]*types.Route, error)
|
UpdateRoutesFunc func(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error)
|
||||||
ListRoutesFunc func(ctx context.Context, sandboxID string) ([]*types.Route, error)
|
ListRoutesFunc func(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
"github.com/kata-containers/runtime/virtcontainers/device/config"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/device/drivers"
|
"github.com/kata-containers/runtime/virtcontainers/device/drivers"
|
||||||
deviceManager "github.com/kata-containers/runtime/virtcontainers/device/manager"
|
deviceManager "github.com/kata-containers/runtime/virtcontainers/device/manager"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/utils"
|
"github.com/kata-containers/runtime/virtcontainers/utils"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
@ -1094,7 +1094,7 @@ func (s *Sandbox) removeNetwork() error {
|
|||||||
return s.network.remove(s, s.factory != nil)
|
return s.network.remove(s, s.factory != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sandbox) generateNetInfo(inf *types.Interface) (NetworkInfo, error) {
|
func (s *Sandbox) generateNetInfo(inf *vcTypes.Interface) (NetworkInfo, error) {
|
||||||
hw, err := net.ParseMAC(inf.HwAddr)
|
hw, err := net.ParseMAC(inf.HwAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return NetworkInfo{}, err
|
return NetworkInfo{}, err
|
||||||
@ -1125,7 +1125,7 @@ func (s *Sandbox) generateNetInfo(inf *types.Interface) (NetworkInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddInterface adds new nic to the sandbox.
|
// AddInterface adds new nic to the sandbox.
|
||||||
func (s *Sandbox) AddInterface(inf *types.Interface) (*types.Interface, error) {
|
func (s *Sandbox) AddInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
netInfo, err := s.generateNetInfo(inf)
|
netInfo, err := s.generateNetInfo(inf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1156,7 +1156,7 @@ func (s *Sandbox) AddInterface(inf *types.Interface) (*types.Interface, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveInterface removes a nic of the sandbox.
|
// RemoveInterface removes a nic of the sandbox.
|
||||||
func (s *Sandbox) RemoveInterface(inf *types.Interface) (*types.Interface, error) {
|
func (s *Sandbox) RemoveInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||||
for i, endpoint := range s.networkNS.Endpoints {
|
for i, endpoint := range s.networkNS.Endpoints {
|
||||||
if endpoint.HardwareAddr() == inf.HwAddr {
|
if endpoint.HardwareAddr() == inf.HwAddr {
|
||||||
s.Logger().WithField("endpoint-type", endpoint.Type()).Info("Hot detaching endpoint")
|
s.Logger().WithField("endpoint-type", endpoint.Type()).Info("Hot detaching endpoint")
|
||||||
@ -1174,17 +1174,17 @@ func (s *Sandbox) RemoveInterface(inf *types.Interface) (*types.Interface, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListInterfaces lists all nics and their configurations in the sandbox.
|
// ListInterfaces lists all nics and their configurations in the sandbox.
|
||||||
func (s *Sandbox) ListInterfaces() ([]*types.Interface, error) {
|
func (s *Sandbox) ListInterfaces() ([]*vcTypes.Interface, error) {
|
||||||
return s.agent.listInterfaces()
|
return s.agent.listInterfaces()
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRoutes updates the sandbox route table (e.g. for portmapping support).
|
// UpdateRoutes updates the sandbox route table (e.g. for portmapping support).
|
||||||
func (s *Sandbox) UpdateRoutes(routes []*types.Route) ([]*types.Route, error) {
|
func (s *Sandbox) UpdateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||||
return s.agent.updateRoutes(routes)
|
return s.agent.updateRoutes(routes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListRoutes lists all routes and their configurations in the sandbox.
|
// ListRoutes lists all routes and their configurations in the sandbox.
|
||||||
func (s *Sandbox) ListRoutes() ([]*types.Route, error) {
|
func (s *Sandbox) ListRoutes() ([]*vcTypes.Route, error) {
|
||||||
return s.agent.listRoutes()
|
return s.agent.listRoutes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user