Skip to content

Commit

Permalink
EOS SDK v2.23.1 (EOS 4.32.2F)
Browse files Browse the repository at this point in the history
  • Loading branch information
prufer committed Aug 21, 2024
1 parent d96aad1 commit d10a17b
Show file tree
Hide file tree
Showing 112 changed files with 3,968 additions and 145 deletions.
97 changes: 47 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
# Copyright (c) 2020 Arista Networks, Inc. All rights reserved.
# Copyright (c) 2024 Arista Networks, Inc. All rights reserved.
# Arista Networks, Inc. Confidential and Proprietary.

#-----------------------------------------------------------------------------------
# This Dockerfile can be used to build a docker image.
# Docker containers of this image can be used to build EosSdk applications.
# The following build options are provided:
# arch : Use 'm32' to build a 32-bit EosSdk application otherwise use 'm64'
# to build a 64-bit EosSdk application.
# Default value is set to 'm32'.
# Example:
# Steps to build an application using EosSdk docker container.
# 1) Build Docker image with tag as arista-eossdk:latest:
# a) Docker image with a 32-bit libeos.so
# "docker build -t arista-eossdk --build-arg arch=m32 ."
# or "docker build -t arista-eossdk ."
#
# OR
# b) Docker image with a 64-bit libeos.so
# "docker build -t arista-eossdk --build-arg arch=m64 ."
# This Dockerfile can be used to build a docker image that can then be used to create
# a docker container that will be able to compile EosSdk applications in exactly the
# same way as EOS native applications are compiled (and thus binary compatible with
# EOS libraries).
#
# 2) Run Docker container:
# docker run -v /home/sdk-app:/sdk-app --name <name> -it arista-eossdk bash
# This will mount /home/sdk-app as sdk-app inside the container.
# Place the application code and necessary dependencies in /home/sdk-app
# 1) Build Docker image (we will call it 'arista-eossdk')
# docker build . -f <this Dockerfile> -t arista-eossdk
#
# 3) Compile application binary:
# Run the following command from /sdk-app.
# For 32-bit binary: "g++ -m32 --std=gnu++0x -o <target> <source file> -leos"
# For 64-bit binary: "g++ -m64 --std=gnu++0x -o <target> <source file> -leos"
# The generated binary will also be available in /home/sdk-app on the host
# machine.
# 2) Create container: (assuming application code to be compiled is at /code on the
# host machine that starts the container)
# docker run -v /code:/code -itd --name arista-eossdk-c1 arista-eossdk
#
#4) Load the application on Arista switch:
# 3) Go into the container and build the application
# docker exec -it arista-eossdk-c1 /bin/bash
# cd /code
# g++ -std=gnu++20 -o /code/build/HelloWorld.o -c /code/HelloWorld.cpp
# g++ -std=gnu++20 -o /code/build/HelloWorld /code/HelloWorld.o -leos -lrt
# g++ -m32 -std=gnu++20 -o /code/build/HelloWorld.o -c /code/HelloWorld.cpp
# g++ -m32 -std=gnu++20 -o /code/build/HelloWorld32 /code/HelloWorld.o -leos -lrt
#
# 4) Load the application (in /code/build on your host) onto an Arista switch
# Further instructions to run the application on Arista switch can be found here:
# https://github.com/aristanetworks/EosSdk/wiki/Quickstart%3A-Hello-World
#
# 5) Cleanup
# docker rm arista-eossdk-c1
# docker rmi arista-eossdk
#
# To learn more about EosSdk visit the following link.
# https://github.com/aristanetworks/EosSdk/wiki
#-----------------------------------------------------------------------------------

FROM centos:7
ARG version=2.23.0
ARG arch="m32"
FROM almalinux:9
ARG version=2.23.1

# Set eossdk version as label and environ variable.
LABEL version=$version
Expand All @@ -57,29 +51,32 @@ RUN \
&& yum -y install wget \
&& yum -y install patch \
&& yum -y install libtool \
&& yum -y install diffutils \
&& yum -y install swig3 \
&& yum -y install python-devel \
&& yum -y install python3-devel

WORKDIR /usr/src/EosSdk-stubs-$version
ADD ./ ./
&& yum -y install diffutils

# Download cross-compiler.
RUN \
wget -O /tmp/arista-cross-compiler.rpm \
https://github.com/aristanetworks/EosSdk-cross-compiler/releases/download/v4.25.0/arista-centos7.5-gcc8.4.0-glibc2.17-1.0-0.i686.rpm
RUN wget -O /tmp/arista-cross-compiler.rpm \
https://github.com/aristanetworks/EosSdk-cross-compiler/releases/download/v4.32.0/arista-gcc-11.i686.rpm

# Install the cross compiler.
RUN yum -y install /tmp/arista-cross-compiler.rpm

ENV PATH=/opt/arista/centos7.5-gcc8.4.0-glibc2.17/bin:$PATH

RUN test -f Makefile && rm -f Makefile
RUN test -f configure && rm -f configure
# Build EosSdk stubs.
RUN ./build.sh --$arch
RUN make install
RUN rpm --force --nodeps -Uvh /tmp/arista-cross-compiler.rpm

# Delete the cross compiler rpm.
RUN rm -f /tmp/arista-cross-compiler.rpm

ENV PATH=/opt/arista/gcc11/bin:$PATH

# Download the EosSdk stubs
RUN wget -O /tmp/stubs.tar.gz \
https://github.com/aristanetworks/EosSdk/archive/refs/tags/v$version.tar.gz

# Build EosSdk stubs and install libeos and headerfiles for both m32 and m64
RUN cd /tmp; tar -xzf stubs.tar.gz; cd EosSdk-* ;\
./build.sh -m32 >& ../build32.log ;\
make install >& ../install32.log ;\
rm -rf /tmp/EosSdk-* ;\
cd /tmp; tar -xzf stubs.tar.gz; cd EosSdk-* ;\
./build.sh -m64 >& ../build64.log ;\
make install >& ../install64.log ;\
cd .. ;\
rm -rf /tmp/EosSdk-* ;\
rm stubs.tar.gz
3 changes: 3 additions & 0 deletions EosSdk.i
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ void throw_py_error(error const& err) {
%template() std::vector<eos::mpls_label_t>;
%template() std::set<eos::policy_map_action_t>;

STD_FORWARD_LIST(fib_via_t)
STD_FORWARD_LIST(mpls_label_t)


// For vlan_set_t
%template(_BitSet4096) std::bitset<4096>;
Expand Down
20 changes: 15 additions & 5 deletions SwigUtils.i
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ namespace std {
};
}

%define STD_FORWARD_LIST(data_type)
%define STD_FORWARD_LIST_IN(data_type, cvref)

// Python --> C
%typemap(in) std::forward_list<eos::##data_type> const & {
%typemap(in) std::forward_list<eos::##data_type> cvref {
PyObject *t = $input;
if (PyTuple_Check(t) != true) {
PyErr_SetString(PyExc_TypeError, "argument must be a tuple");
Expand Down Expand Up @@ -92,8 +92,12 @@ namespace std {
$1 = a;
}

%enddef

%define STD_FORWARD_LIST_OUT(data_type, cvref)

// C --> Python
%typemap(out) std::forward_list<eos::##data_type> const & {
%typemap(out) std::forward_list<eos::##data_type> cvref {
std::forward_list<eos::##data_type> *a = $1;
std::forward_list<eos::##data_type>::const_iterator it;
int count = 0;
Expand All @@ -113,8 +117,14 @@ namespace std {
}
%enddef

STD_FORWARD_LIST(fib_via_t)
STD_FORWARD_LIST(mpls_label_t)
%define STD_FORWARD_LIST( data_type )

STD_FORWARD_LIST_IN( data_type, const & );
STD_FORWARD_LIST_OUT( data_type, const & );
STD_FORWARD_LIST_IN( data_type, && );
STD_FORWARD_LIST_OUT( data_type, && );

%enddef

// policy_map_hw_status_t::intf_statuses_is() conversion from Python to C++
%typemap(in) std::map<eos::policy_map_hw_status_key_t, eos::policy_map_status_t> const & {
Expand Down
69 changes: 69 additions & 0 deletions acl_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ acl_ttl_spec_t::operator=(
return *this;
}

EOS_SDK_PUBLIC acl_ttl_spec_t::acl_ttl_spec_t(
acl_ttl_spec_t && other) noexcept :
pimpl(std::move(other.pimpl)) {}
EOS_SDK_PUBLIC acl_ttl_spec_t&
acl_ttl_spec_t::operator=(
acl_ttl_spec_t && other) noexcept
{
if(this != &other) {
std::swap(pimpl, other.pimpl);
}
return *this;
}

EOS_SDK_PUBLIC void *
acl_ttl_spec_t::operator new( std::size_t size ) {
return ::operator new( size );
Expand Down Expand Up @@ -66,6 +79,19 @@ acl_port_spec_t::operator=(
return *this;
}

EOS_SDK_PUBLIC acl_port_spec_t::acl_port_spec_t(
acl_port_spec_t && other) noexcept :
pimpl(std::move(other.pimpl)) {}
EOS_SDK_PUBLIC acl_port_spec_t&
acl_port_spec_t::operator=(
acl_port_spec_t && other) noexcept
{
if(this != &other) {
std::swap(pimpl, other.pimpl);
}
return *this;
}

EOS_SDK_PUBLIC void *
acl_port_spec_t::operator new( std::size_t size ) {
return ::operator new( size );
Expand Down Expand Up @@ -94,6 +120,19 @@ acl_rule_base_t::operator=(
return *this;
}

EOS_SDK_PUBLIC acl_rule_base_t::acl_rule_base_t(
acl_rule_base_t && other) noexcept :
pimpl(std::move(other.pimpl)) {}
EOS_SDK_PUBLIC acl_rule_base_t&
acl_rule_base_t::operator=(
acl_rule_base_t && other) noexcept
{
if(this != &other) {
std::swap(pimpl, other.pimpl);
}
return *this;
}

EOS_SDK_PUBLIC void *
acl_rule_base_t::operator new( std::size_t size ) {
return ::operator new( size );
Expand Down Expand Up @@ -125,6 +164,21 @@ acl_rule_ip_t::operator=(
return *this;
}

EOS_SDK_PUBLIC acl_rule_ip_t::acl_rule_ip_t(
acl_rule_ip_t && other) noexcept :
acl_rule_base_t(std::move(other)),
pimpl(std::move(other.pimpl)) {}
EOS_SDK_PUBLIC acl_rule_ip_t&
acl_rule_ip_t::operator=(
acl_rule_ip_t && other) noexcept
{
if(this != &other) {
acl_rule_base_t::operator=(std::move(other));
std::swap(pimpl, other.pimpl);
}
return *this;
}

EOS_SDK_PUBLIC void *
acl_rule_ip_t::operator new( std::size_t size ) {
return ::operator new( size );
Expand Down Expand Up @@ -155,6 +209,21 @@ acl_rule_eth_t::operator=(
return *this;
}

EOS_SDK_PUBLIC acl_rule_eth_t::acl_rule_eth_t(
acl_rule_eth_t && other) noexcept :
acl_rule_base_t(std::move(other)),
pimpl(std::move(other.pimpl)) {}
EOS_SDK_PUBLIC acl_rule_eth_t&
acl_rule_eth_t::operator=(
acl_rule_eth_t && other) noexcept
{
if(this != &other) {
acl_rule_base_t::operator=(std::move(other));
std::swap(pimpl, other.pimpl);
}
return *this;
}

EOS_SDK_PUBLIC void *
acl_rule_eth_t::operator new( std::size_t size ) {
return ::operator new( size );
Expand Down
Loading

0 comments on commit d10a17b

Please sign in to comment.