Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
IPAllocator Class Reference

Public Member Functions

 IPAllocator (const std::shared_ptr< DobbyRdkPluginUtils > &utils)
 
in_addr_t allocateIpAddress (const std::string &vethName)
 Allocated an IP address for the currently running container with the specified veth.
 
in_addr_t allocateIpAddress (const std::string &containerId, const std::string &vethName)
 Allocated an IP address with the specified veth.
 
bool deallocateIpAddress (const std::string &containerId)
 Releases a previously allocated IP address back to the pool so it can be re-used by other containers.
 
bool getContainerNetworkInfo (const std::string &containerId, ContainerNetworkInfo &networkInfo) const
 Retrieves the networking information (veth, ip) for a given container.
 

Static Public Member Functions

static in_addr_t stringToIpAddress (const std::string &ipAddressStr)
 Convert an string to an IP address. Note - doesn't do any byte-order modifications.
 
static std::string ipAddressToString (const in_addr_t &ipAddress)
 Convert an IP address to string. Note - doesn't do any byte-order modifications.
 

Private Member Functions

bool getContainerIpsFromDisk ()
 Synchronise the in-memory pool of allocated IPs with the disk store.
 
bool getNetworkInfo (const std::string &filePath, ContainerNetworkInfo &networkInfo) const
 Retrieves the networking information (veth, ip) from a file from the store.
 

Private Attributes

const std::shared_ptr< DobbyRdkPluginUtilsmUtils
 
const in_addr_t mBeginAddress
 
const in_addr_t mEndAddress
 
std::vector< ContainerNetworkInfomAllocatedIps
 

Member Function Documentation

◆ allocateIpAddress() [1/2]

in_addr_t IPAllocator::allocateIpAddress ( const std::string &  containerId,
const std::string &  vethName 
)

Allocated an IP address with the specified veth.

Parameters
[in]containerIdName of the container to associate the IP with
[in]vethNameName of the veth interface used by the container
Returns
Allocated IP address. -1 on error

◆ allocateIpAddress() [2/2]

in_addr_t IPAllocator::allocateIpAddress ( const std::string &  vethName)

Allocated an IP address for the currently running container with the specified veth.

Parameters
[in]vethNameName of the veth interface used by the container
Returns
Allocated IP address. -1 on error

◆ deallocateIpAddress()

bool IPAllocator::deallocateIpAddress ( const std::string &  containerId)

Releases a previously allocated IP address back to the pool so it can be re-used by other containers.

Parameters
[in]containerIdName of the container to deallocate the IP for
Returns
True on success, false on error

◆ getContainerIpsFromDisk()

bool IPAllocator::getContainerIpsFromDisk ( )
private

Synchronise the in-memory pool of allocated IPs with the disk store.

Returns
True on success

◆ getContainerNetworkInfo()

bool IPAllocator::getContainerNetworkInfo ( const std::string &  containerId,
ContainerNetworkInfo networkInfo 
) const

Retrieves the networking information (veth, ip) for a given container.

Parameters
[in]containerIdName of the container to retrieve the information about
[out]networkInfoStruct to store the container network info in
Returns
True on success, false on failure

◆ getNetworkInfo()

bool IPAllocator::getNetworkInfo ( const std::string &  filePath,
ContainerNetworkInfo networkInfo 
) const
private

Retrieves the networking information (veth, ip) from a file from the store.

Parameters
[in]filePathPath to the file to parse for information about the container network
[out]networkInfoStruct to store the container network info in
Returns
True on success, false on failure

◆ ipAddressToString()

std::string IPAllocator::ipAddressToString ( const in_addr_t &  ipAddress)
static

Convert an IP address to string. Note - doesn't do any byte-order modifications.

Parameters
[in]ipAddressIP Address to convert
Returns
IP address string

◆ stringToIpAddress()

in_addr_t IPAllocator::stringToIpAddress ( const std::string &  ipAddr)
static

Convert an string to an IP address. Note - doesn't do any byte-order modifications.

Parameters
[in]ipAddrIP Address to convert
Returns
IP address integer

The documentation for this class was generated from the following files: