以下内容均在libnetwork/driverapi目录下

Driver接口如下所示:

// Driver is an interface that every plugin driver needs to implement.

type Driver interface {
  discoverapi.Discover   // NetworkAllocate invokes the driver method to allocate network
  // specific resources passing network id and network specific config.
  // It returns a key, value pair of network specific driver allocations
  // to the caller.   NetworkAllocate(nid string, options map[string]string, ipV4Data, ipV6Data []IPAMData) (map[string]string, error)   // NetworkFree invokes the driver method to free network specific resources
  // associated with a given network id.
  NetworkFree(nid string) error   // CreateNetwork invokes the driver method to create a network
  // passing the network id and network specific config. The
  // config mechanism will eventually be replaced with labels
  // which are yet to be introduced. The driver can return a
  // list of table names for which it is interested in receiving
  // notification when a CRUD operation is performed on any
  // entry in that table. This will be ignored for local scope drivers.   CreateNetwork(nid string, options map[string]interface{}, nInfo NetworkInfo, ipV4Data, ipV6Data []IPAMData) error   // DeleteNetwork invokes the driver method to delete network passing
  // the network id.
  DeleteNetwork(nid string) error   // CreateEndpoint invokes the driver method to create an endpoint
  // passing the network id, endpoint id endpoint information and driver
  // specific config. The endpoint information can be either consumed by
  // the driver or populated by the driver. The config mechanism will
  // eventually be replaced with labels which are yet to be introducd.
  CreateEndpoint(nid, eid string, ifInfo InterfaceInfo, options map[string]interface{}) error   // DeleteEndpoint invokes the driver method to delete an endpoint
  // passing the network id and endpoint id.
  DeleteEndpoint(nid, eid string) error   // EndpointOperInfo retrieves from the driver the operational data related to the specific endpoint
  EndpointOperInfo(nid, eid string) (map[string]interface{}, error)   // Join method is invoked when a Sandbox is attached to an endpoint.
  Join(nid, eid string, sboxKey string, jinfo JoinInfo, options map[string]interface{}) error   // Leave method is invoked when a Sandbox detaches from an endpoint.
  Leave(nid, eid string) error   // ProgramExternalConnectivity invokes the driver method which does the necessary
  // programming to allow the external connectivity dictated by the passed options.
  ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error   // RevokeExternalConnectivity asks the driver to remove any external connectivity
  // programming that was done so far
  RevokeExternalConnectivity(nid, eid string) error   // EventNotify notifies the driver when a CRUD operation has
  // happended on a table of its interest as soon as this node
  // receives such an event in the gossip layer. This method is
  // only invoked for the global scope driver.
  EventNotify(event EventType, nid string, tableName string, key string, value []byte)   // Type returns the type of this driver, the network type this driver manages.
  Type() string   // IsBuiltIn returns true if it is a built-in driver
  IsBuiltIn() bool }

  

NetworkInfo接口如下所示:

// NetworkInfo provides a go interface for drivers to provide network
// specific information on libnetwork.
type NetworkInfo interface {
  // TableEventRegister registers driver interest in a given
  // table name.
  TableEventRegister(tableName string) error }

  

InterfaceInfo接口如下所示:

// InterfaceInfo provides a go interface for drivers to retrive
// network information to interface resources.
type InterfaceInfo interface {
  // SetMacAddress allows the driver to set the mac address to the endpoint interface
  // during the call to CreateEndpoint, if the mac address is not already set.
  SetMacAddress(mac net.HardwareAddr) error   // SetIPAddress allows the driver to set the ip address to the endpoint interface
  // during the call to CreateEndpoint, if the address is not already set.
  // The API is to be used to assign both the IPv4 and IPv6 address types.
  SetIPAddress(ip *net.IPNet) error   // MacAddress returns the MAC address.
  MacAddress() net.HardwareAddr   // Address returns the IPv4 address.
  Address() *net.IPNet   // AddressIPv6 returns the IPv4 address.
  AddressIPv6() *net.IPNet
}

  

InterfaceNameInfo接口如下所示:

// InterfaceNameInfo provides a go interface for the drivers to assign names
// to interfaces
type InterfaceNameInfo interface {
  // SetNames method assigns the srcName and dstPrefix for the interface.
  SetNames(srcName, dstPrefix string) error
}

  

JoinInfo接口如下所示:

// JoinInfo represents a set of resources that the driver has the ability to provide during
// join time.
type JoinInfo interface {
  // InterfaceName returns an InterfaceNameInfo go interface to facilitate
  // setting the names for the interface.
  InterfaceName() InterfaceNameInfo   // SetGateway sets the default IPv4 gateway when a container joins the endpoint.
  SetGateway(net.IP) error   // SetGatewayIPv6 sets the default IPv6 gateway when a container joins the endpoint
  SetGateway(net.IP) error   // AddStaticRoute adds a route to the sandbox.
  // It may be used in addition to or instead of a default gateway (as above)
  AddStaticRoute(destination *net.IPNet, routeType int, nextHop net.IP) error   // DisableGatewayService tells libnetwork not to provide Default GW for the container
  DisableGatewayService()   // AddTableEntry adds a table entry to the gossip layer
  // passing the table name, key and an opaque value.
  AddTableEntry(tableName string, key string, value []byte) error
}

  

IPAMData结构如下所示

// IPAMData represents the per-network ip related
// operational information libnetwork will send
// to the network driver during CreateNetwork()
type IPAMData struct {
  AddressSpace   string
  Pool        *net.IPNet
  Gateway     *net.IPNet
  AuxAddresses   map[string]*net.IPNet
}

  

 DriverCallback数据结构如下所示

// DriverCallback provides a Callback interface for Drivers into LibNetwork
type DriverCallback interface{
  // GetPluginGetter returns the pluginv2 getter.
  GetPluginGetter() plugingetter.PluginGetter
  // RegisterDriver provides a way for remote drivers to dynamically register new NetworkType and associate with a driver instance
  RegisterDriver(name string, driver Driver, capability Capability) error
}

  

Docker Libnetwork driver API的更多相关文章

  1. Openshift 错误解决 "修改docker cgroup driver"

    一.Openshift 错误解决 "修改docker cgroup driver" 一.错误如下 failed to run Kubelet: failed to create k ...

  2. docker storage driver

    docker默认有2种方式用于持久化数据,volumes和bind mounts,也可以使用tmpfs,其中使用volume是持久化数据的最好方式,volume由docker控制管理,使用docker ...

  3. 玩转Docker之常用API(四)

    原文地址:http://accjiyun.cn/wan-zhuan-dockerzhi-chang-yong-api-si/ 任何一个开发的平台都会向开发者开发API,以供开发者更加自由地使用平台所提 ...

  4. 关于CUDA两种API:Runtime API 和 Driver API

                 CUDA 眼下有两种不同的 API:Runtime API 和 Driver API,两种 API 各有其适用的范围. 高级API(cuda_runtime.h)是一种C++ ...

  5. Docker storage driver(十四)

    目录 一.storage driver 作用 1.Images and layers 2.Container and layers Copy-on-Write 3.Data volumes and t ...

  6. Warning:detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd".

    执行kubeadm init集群初始化时遇到: [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker ...

  7. 【kubeadm初始化报错】failed to run Kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"

    复现场景 环境 系统:Centos7 kubernetes:1.18.5 docker:19.03.9 复现步骤 1.通过 yum 或 rpm 安装 kubelet kubectl kubeadm,并 ...

  8. 痞子衡嵌入式:其实i.MXRT1050,1020,1015系列ROM也提供了FlexSPI driver API

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是i.MXRT1050/1020/1015系列ROM中的FlexSPI驱动API使用. 今天痞子衡去4S店给爱车做保养了,保养一次要等两小 ...

  9. Docker libnetwork(CNM)设计简介

    The Container Network Model CNM由以下三个组件构成:Sandbox,Endpoint以及Network Sandbox 一个Sandbox包含了一个容器网络栈的配置.其中 ...

随机推荐

  1. Yii2数据库查询语法

    一: $con = Yii::$app->db; $rel = $con->createCommand("select * from user");//预处理对象 $r ...

  2. C++11 中function和bind以及lambda 表达式的用法

    关于std::function 的用法:  其实就可以理解成函数指针 1. 保存自由函数 void printA(int a) { cout<<a<<endl; } std:: ...

  3. hdu6006 Engineer Assignment 状态dp 定义dp[i][s]表示前i个工程状态为s可以执行的最大工程数。s表示前i个工人选走了s状态的工程师。

    /** 题目:hdu6006 Engineer Assignment 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6006 题意:已知n个工程,每个需要某 ...

  4. poj3020 Antenna Placement 匈牙利算法求最小覆盖=最大匹配数(自身对应自身情况下要对半) 小圈圈圈点

    /** 题目:poj3020 Antenna Placement 链接:http://poj.org/problem?id=3020 题意: 给一个由'*'或者'o'组成的n*m大小的图,你可以用一个 ...

  5. 企业Shell面试题5:解决DOS攻击生产案例

    企业Shell面试题5:解决DOS攻击生产案例 写一个Shell脚本解决DOS攻击生产案例. 请根据web日志或者或者网络连接数,监控当某个IP并发连接数或者短时内PV达到100(读者根据实际情况设定 ...

  6. Respond.js – 让不懂爱的 IE6-8 支持 CSS3 Media Query

    respond.min.js <script src="js/respond.min.js"></script> respond.min.js代码: /*! ...

  7. SQL语句大全2

    SQL 语句大全 --语 句 功 能 --数据操作 SELECT --从数据库表中检索数据行和列 INSERT --向数据库表添加新数据行 DELETE --从数据库表中删除数据行 UPDATE -- ...

  8. php 怎么查看是否开启了socket

    <?php if(extension_loaded('sockets')){ echo "已开启"; }else{ echo "未开启"; } ?>

  9. 简述基于Struts框架Web应用的工作流程

    简述基于Struts框架Web应用的工作流程 解答:在web应用启动时就会加载初始化ActionServlet,ActionServlet从struts-config.xml文件中读取配置信息,把它们 ...

  10. 数码相机常用CCD/CMOS尺寸对比

    数码相机的关键元件CCD或CMOS又称为“影像传感器”,其作用相当于感光胶片.CCD尺寸越大,采集光线的效果越好,画面记录的信息就越多,保留的细节也就越丰富,所以图像更完美漂亮. CCD尺寸的大小与像 ...