mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-05 11:36:56 +00:00
types: Replace agent/pkg/types with virtcontainers/pkg/types
This commit replaces every place where the "types" package from the Kata agent was used, with the new "types" package from virtcontainers. In order to do so, it introduces a few translation functions between the agent and virtcontainers types, since this is needed by the kata agent implementation. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
39b95cc365
commit
7bf84d05ad
@ -17,8 +17,8 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
|
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
|
"github.com/kata-containers/runtime/virtcontainers/pkg/types"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
"github.com/kata-containers/runtime/pkg/signals"
|
"github.com/kata-containers/runtime/pkg/signals"
|
||||||
|
"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"
|
||||||
@ -275,7 +275,7 @@ func convertInterface(linkAttrs *netlink.LinkAttrs, addrs []netlink.Addr) types.
|
|||||||
netMask, _ := addr.Mask.Size()
|
netMask, _ := addr.Mask.Size()
|
||||||
|
|
||||||
ipAddr := &types.IPAddress{
|
ipAddr := &types.IPAddress{
|
||||||
Family: types.IPFamily(netlinkFamily),
|
Family: netlinkFamily,
|
||||||
Address: addr.IP.String(),
|
Address: addr.IP.String(),
|
||||||
Mask: fmt.Sprintf("%d", netMask),
|
Mask: fmt.Sprintf("%d", netMask),
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
"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"
|
||||||
@ -181,7 +181,7 @@ func TestConvertInterface(t *testing.T) {
|
|||||||
HwAddr: testHwAddr,
|
HwAddr: testHwAddr,
|
||||||
IPAddresses: []*types.IPAddress{
|
IPAddresses: []*types.IPAddress{
|
||||||
{
|
{
|
||||||
Family: types.IPFamily(netlinkFamily),
|
Family: netlinkFamily,
|
||||||
Address: testIPAddress,
|
Address: testIPAddress,
|
||||||
Mask: "0",
|
Mask: "0",
|
||||||
},
|
},
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
"github.com/kata-containers/agent/protocols/grpc"
|
"github.com/kata-containers/agent/protocols/grpc"
|
||||||
|
"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"
|
||||||
|
@ -11,9 +11,9 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
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"
|
||||||
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"
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
||||||
|
"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"
|
||||||
)
|
)
|
||||||
|
@ -18,11 +18,11 @@ import (
|
|||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
|
|
||||||
proxyClient "github.com/clearcontainers/proxy/client"
|
proxyClient "github.com/clearcontainers/proxy/client"
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
"github.com/kata-containers/agent/protocols/grpc"
|
"github.com/kata-containers/agent/protocols/grpc"
|
||||||
"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"
|
||||||
"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"
|
||||||
|
@ -13,9 +13,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
"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"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -10,9 +10,9 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
"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"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -18,12 +18,13 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
aTypes "github.com/kata-containers/agent/pkg/types"
|
||||||
kataclient "github.com/kata-containers/agent/protocols/client"
|
kataclient "github.com/kata-containers/agent/protocols/client"
|
||||||
"github.com/kata-containers/agent/protocols/grpc"
|
"github.com/kata-containers/agent/protocols/grpc"
|
||||||
"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"
|
||||||
"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"
|
||||||
@ -31,6 +32,7 @@ import (
|
|||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/vishvananda/netlink"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
golangGrpc "google.golang.org/grpc"
|
golangGrpc "google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
@ -387,7 +389,7 @@ func (k *kataAgent) exec(sandbox *Sandbox, c Container, cmd Cmd) (*Process, erro
|
|||||||
func (k *kataAgent) updateInterface(ifc *types.Interface) (*types.Interface, error) {
|
func (k *kataAgent) updateInterface(ifc *types.Interface) (*types.Interface, error) {
|
||||||
// send update interface request
|
// send update interface request
|
||||||
ifcReq := &grpc.UpdateInterfaceRequest{
|
ifcReq := &grpc.UpdateInterfaceRequest{
|
||||||
Interface: ifc,
|
Interface: k.convertToKataAgentInterface(ifc),
|
||||||
}
|
}
|
||||||
resultingInterface, err := k.sendReq(ifcReq)
|
resultingInterface, err := k.sendReq(ifcReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -415,7 +417,7 @@ func (k *kataAgent) updateRoutes(routes []*types.Route) ([]*types.Route, error)
|
|||||||
if routes != nil {
|
if routes != nil {
|
||||||
routesReq := &grpc.UpdateRoutesRequest{
|
routesReq := &grpc.UpdateRoutesRequest{
|
||||||
Routes: &grpc.Routes{
|
Routes: &grpc.Routes{
|
||||||
Routes: routes,
|
Routes: k.convertToKataAgentRoutes(routes),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
resultingRoutes, err := k.sendReq(routesReq)
|
resultingRoutes, err := k.sendReq(routesReq)
|
||||||
@ -427,7 +429,7 @@ func (k *kataAgent) updateRoutes(routes []*types.Route) ([]*types.Route, error)
|
|||||||
}
|
}
|
||||||
resultRoutes, ok := resultingRoutes.(*grpc.Routes)
|
resultRoutes, ok := resultingRoutes.(*grpc.Routes)
|
||||||
if ok && resultRoutes != nil {
|
if ok && resultRoutes != nil {
|
||||||
return resultRoutes.Routes, err
|
return k.convertToRoutes(resultRoutes.Routes), err
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -442,7 +444,7 @@ func (k *kataAgent) listInterfaces() ([]*types.Interface, error) {
|
|||||||
}
|
}
|
||||||
resultInterfaces, ok := resultingInterfaces.(*grpc.Interfaces)
|
resultInterfaces, ok := resultingInterfaces.(*grpc.Interfaces)
|
||||||
if ok {
|
if ok {
|
||||||
return resultInterfaces.Interfaces, err
|
return k.convertToInterfaces(resultInterfaces.Interfaces), err
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -455,7 +457,7 @@ func (k *kataAgent) listRoutes() ([]*types.Route, error) {
|
|||||||
}
|
}
|
||||||
resultRoutes, ok := resultingRoutes.(*grpc.Routes)
|
resultRoutes, ok := resultingRoutes.(*grpc.Routes)
|
||||||
if ok {
|
if ok {
|
||||||
return resultRoutes.Routes, err
|
return k.convertToRoutes(resultRoutes.Routes), err
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1549,3 +1551,137 @@ func (k *kataAgent) getGuestDetails(req *grpc.GuestDetailsRequest) (*grpc.GuestD
|
|||||||
|
|
||||||
return resp.(*grpc.GuestDetailsResponse), nil
|
return resp.(*grpc.GuestDetailsResponse), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k *kataAgent) convertToKataAgentIPFamily(ipFamily int) aTypes.IPFamily {
|
||||||
|
switch ipFamily {
|
||||||
|
case netlink.FAMILY_V4:
|
||||||
|
return aTypes.IPFamily_v4
|
||||||
|
case netlink.FAMILY_V6:
|
||||||
|
return aTypes.IPFamily_v6
|
||||||
|
}
|
||||||
|
|
||||||
|
return aTypes.IPFamily_v4
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *kataAgent) convertToIPFamily(ipFamily aTypes.IPFamily) int {
|
||||||
|
switch ipFamily {
|
||||||
|
case aTypes.IPFamily_v4:
|
||||||
|
return netlink.FAMILY_V4
|
||||||
|
case aTypes.IPFamily_v6:
|
||||||
|
return netlink.FAMILY_V6
|
||||||
|
}
|
||||||
|
|
||||||
|
return netlink.FAMILY_V4
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *kataAgent) convertToKataAgentIPAddresses(ipAddrs []*types.IPAddress) (aIPAddrs []*aTypes.IPAddress) {
|
||||||
|
for _, ipAddr := range ipAddrs {
|
||||||
|
if ipAddr == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
aIPAddr := &aTypes.IPAddress{
|
||||||
|
Family: k.convertToKataAgentIPFamily(ipAddr.Family),
|
||||||
|
Address: ipAddr.Address,
|
||||||
|
Mask: ipAddr.Mask,
|
||||||
|
}
|
||||||
|
|
||||||
|
aIPAddrs = append(aIPAddrs, aIPAddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
return aIPAddrs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *kataAgent) convertToIPAddresses(aIPAddrs []*aTypes.IPAddress) (ipAddrs []*types.IPAddress) {
|
||||||
|
for _, aIPAddr := range aIPAddrs {
|
||||||
|
if aIPAddr == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
ipAddr := &types.IPAddress{
|
||||||
|
Family: k.convertToIPFamily(aIPAddr.Family),
|
||||||
|
Address: aIPAddr.Address,
|
||||||
|
Mask: aIPAddr.Mask,
|
||||||
|
}
|
||||||
|
|
||||||
|
ipAddrs = append(ipAddrs, ipAddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ipAddrs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *kataAgent) convertToKataAgentInterface(iface *types.Interface) *aTypes.Interface {
|
||||||
|
if iface == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &aTypes.Interface{
|
||||||
|
Device: iface.Device,
|
||||||
|
Name: iface.Name,
|
||||||
|
IPAddresses: k.convertToKataAgentIPAddresses(iface.IPAddresses),
|
||||||
|
Mtu: iface.Mtu,
|
||||||
|
HwAddr: iface.HwAddr,
|
||||||
|
PciAddr: iface.PciAddr,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) (ifaces []*types.Interface) {
|
||||||
|
for _, aIface := range aIfaces {
|
||||||
|
if aIface == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
iface := &types.Interface{
|
||||||
|
Device: aIface.Device,
|
||||||
|
Name: aIface.Name,
|
||||||
|
IPAddresses: k.convertToIPAddresses(aIface.IPAddresses),
|
||||||
|
Mtu: aIface.Mtu,
|
||||||
|
HwAddr: aIface.HwAddr,
|
||||||
|
PciAddr: aIface.PciAddr,
|
||||||
|
}
|
||||||
|
|
||||||
|
ifaces = append(ifaces, iface)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ifaces
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *kataAgent) convertToKataAgentRoutes(routes []*types.Route) (aRoutes []*aTypes.Route) {
|
||||||
|
for _, route := range routes {
|
||||||
|
if route == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
aRoute := &aTypes.Route{
|
||||||
|
Dest: route.Dest,
|
||||||
|
Gateway: route.Gateway,
|
||||||
|
Device: route.Device,
|
||||||
|
Source: route.Source,
|
||||||
|
Scope: route.Scope,
|
||||||
|
}
|
||||||
|
|
||||||
|
aRoutes = append(aRoutes, aRoute)
|
||||||
|
}
|
||||||
|
|
||||||
|
return aRoutes
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *kataAgent) convertToRoutes(aRoutes []*aTypes.Route) (routes []*types.Route) {
|
||||||
|
for _, aRoute := range aRoutes {
|
||||||
|
if aRoute == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
route := &types.Route{
|
||||||
|
Dest: aRoute.Dest,
|
||||||
|
Gateway: aRoute.Gateway,
|
||||||
|
Device: aRoute.Device,
|
||||||
|
Source: aRoute.Source,
|
||||||
|
Scope: aRoute.Scope,
|
||||||
|
}
|
||||||
|
|
||||||
|
routes = append(routes, route)
|
||||||
|
}
|
||||||
|
|
||||||
|
return routes
|
||||||
|
}
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
aTypes "github.com/kata-containers/agent/pkg/types"
|
||||||
pb "github.com/kata-containers/agent/protocols/grpc"
|
pb "github.com/kata-containers/agent/protocols/grpc"
|
||||||
"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"
|
||||||
@ -31,6 +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"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -185,16 +186,16 @@ func (p *gRPCProxy) DestroySandbox(ctx context.Context, req *pb.DestroySandboxRe
|
|||||||
return emptyResp, nil
|
return emptyResp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *gRPCProxy) AddInterface(ctx context.Context, req *pb.AddInterfaceRequest) (*types.Interface, error) {
|
func (p *gRPCProxy) AddInterface(ctx context.Context, req *pb.AddInterfaceRequest) (*aTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *gRPCProxy) RemoveInterface(ctx context.Context, req *pb.RemoveInterfaceRequest) (*types.Interface, error) {
|
func (p *gRPCProxy) RemoveInterface(ctx context.Context, req *pb.RemoveInterfaceRequest) (*aTypes.Interface, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *gRPCProxy) UpdateInterface(ctx context.Context, req *pb.UpdateInterfaceRequest) (*types.Interface, error) {
|
func (p *gRPCProxy) UpdateInterface(ctx context.Context, req *pb.UpdateInterfaceRequest) (*aTypes.Interface, error) {
|
||||||
return &types.Interface{}, nil
|
return &aTypes.Interface{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *gRPCProxy) UpdateRoutes(ctx context.Context, req *pb.UpdateRoutesRequest) (*pb.Routes, error) {
|
func (p *gRPCProxy) UpdateRoutes(ctx context.Context, req *pb.UpdateRoutesRequest) (*pb.Routes, error) {
|
||||||
|
@ -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/agent/pkg/types"
|
"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"
|
||||||
)
|
)
|
||||||
@ -1182,7 +1182,7 @@ func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*types.Interface
|
|||||||
}
|
}
|
||||||
netMask, _ := addr.Mask.Size()
|
netMask, _ := addr.Mask.Size()
|
||||||
ipAddress := types.IPAddress{
|
ipAddress := types.IPAddress{
|
||||||
Family: types.IPFamily_v4,
|
Family: netlink.FAMILY_V4,
|
||||||
Address: addr.IP.String(),
|
Address: addr.IP.String(),
|
||||||
Mask: fmt.Sprintf("%d", netMask),
|
Mask: fmt.Sprintf("%d", netMask),
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
"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"
|
||||||
)
|
)
|
||||||
@ -162,8 +162,8 @@ func TestGenerateInterfacesAndRoutes(t *testing.T) {
|
|||||||
// Build expected results:
|
// Build expected results:
|
||||||
//
|
//
|
||||||
expectedAddresses := []*types.IPAddress{
|
expectedAddresses := []*types.IPAddress{
|
||||||
{Family: 0, Address: "172.17.0.2", Mask: "16"},
|
{Family: netlink.FAMILY_V4, Address: "172.17.0.2", Mask: "16"},
|
||||||
{Family: 0, Address: "182.17.0.2", Mask: "16"},
|
{Family: netlink.FAMILY_V4, Address: "182.17.0.2", Mask: "16"},
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedInterfaces := []*types.Interface{
|
expectedInterfaces := []*types.Interface{
|
||||||
|
@ -8,8 +8,8 @@ package virtcontainers
|
|||||||
import (
|
import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
"github.com/kata-containers/agent/protocols/grpc"
|
"github.com/kata-containers/agent/protocols/grpc"
|
||||||
|
"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"
|
||||||
)
|
)
|
||||||
|
@ -20,10 +20,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
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"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -11,9 +11,9 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
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"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
@ -9,10 +9,10 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
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"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -9,10 +9,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
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"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -21,12 +21,12 @@ import (
|
|||||||
opentracing "github.com/opentracing/opentracing-go"
|
opentracing "github.com/opentracing/opentracing-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/kata-containers/agent/pkg/types"
|
|
||||||
"github.com/kata-containers/agent/protocols/grpc"
|
"github.com/kata-containers/agent/protocols/grpc"
|
||||||
"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/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"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user