Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cfggen] Add tool to translate openconfig acl into sonic format #388

Merged
merged 7 commits into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions dockers/docker-config-engine/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,42 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update

# Dependencies for sonic-cfggen
RUN apt-get install -y python-lxml python-jinja2 python-netaddr python-ipaddr python-yaml
RUN apt-get install -y python-lxml python-yaml python-bitarray python-pip python-dev

RUN pip install --upgrade pip

RUN pip install netaddr ipaddr jinja2 pyangbind

{% if docker_config_engine_debs != '' %}
COPY \
{% for deb in docker_config_engine_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor -%}
debs/
{%- endif -%}

{% if docker_config_engine_debs != '' %}
Copy link
Collaborator

@lguohan lguohan Mar 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> {% if docker_config_engine_debs.strip() -%} #Resolved

RUN dpkg -i \
{% for deb in docker_config_engine_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor %}
{%- endif -%}

{% if docker_config_engine_whls != '' %}
Copy link
Collaborator

@lguohan lguohan Mar 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above #Resolved

COPY \
{% for whl in docker_config_engine_whls.split(' ') -%}
python-wheels/{{ whl }}{{' '}}
{%- endfor -%}
python-wheels/
{%- endif -%}

{% if docker_config_engine_whls != '' %}
RUN pip install \
{% for whl in docker_config_engine_whls.split(' ') -%}
python-wheels/{{ whl }}{{' '}}
{%- endfor %}
{%- endif -%}

## Clean up
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs
RUN apt-get remove -y python-pip python-dev; apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs /python-wheels
14 changes: 7 additions & 7 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ sudo cp $IMAGE_CONFIGS/environment/motd $FILESYSTEM_ROOT/etc/
sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic/
sudo mkdir -p $FILESYSTEM_ROOT/usr/share/sonic/templates/

# Install dependencies for SONiC config engine
# TODO: pip-install instead of apt-get after config engine wrapped into a wheel, even better use pip implicitly installing dependencies
# Install dependencies for SONiC config engine
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install \
python-dev \
Copy link
Collaborator

@lguohan lguohan Mar 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also need to remove python-dev later? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in base image. Do we also care a lot about size here? I prefer we keep it for easier usage of pip.


In reply to: 105694773 [](ancestors = 105694773)

Copy link
Collaborator

@lguohan lguohan Mar 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we care about size since some switch only have 2G disk, what's the size we are talking about? #Resolved

python-lxml \
python-jinja2 \
python-netaddr \
python-ipaddr \
python-yaml
python-yaml \
python-bitarray

# Install SONiC config engine
sudo dpkg --root=$FILESYSTEM_ROOT -i {{config_engine}}
CONFIG_ENGINE_WHL_NAME=`basename {{config_engine}}`
sudo cp {{config_engine}} $FILESYSTEM_ROOT/$CONFIG_ENGINE_WHL_NAME
sudo chroot $FILESYSTEM_ROOT pip install $CONFIG_ENGINE_WHL_NAME

# Install SONiC Utilities (and its dependencies via 'apt-get -y install -f')
sudo dpkg --root=$FILESYSTEM_ROOT -i target/debs/python-sonic-utilities_*.deb || \
Expand Down
2 changes: 1 addition & 1 deletion rules/docker-config-engine.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

DOCKER_CONFIG_ENGINE = docker-config-engine.gz
$(DOCKER_CONFIG_ENGINE)_PATH = $(DOCKERS_PATH)/docker-config-engine
$(DOCKER_CONFIG_ENGINE)_DEPENDS += $(SONIC_CONFIG_ENGINE)
$(DOCKER_CONFIG_ENGINE)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE)
$(DOCKER_CONFIG_ENGINE)_LOAD_DOCKERS += $(DOCKER_BASE)
SONIC_DOCKER_IMAGES += $(DOCKER_CONFIG_ENGINE)
5 changes: 3 additions & 2 deletions rules/sonic-config.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# sonic-config-engine package

SONIC_CONFIG_ENGINE = python-sonic-config-engine_1.0-1_all.deb
SONIC_CONFIG_ENGINE = sonic_config_engine-1.0-py2-none-any.whl
$(SONIC_CONFIG_ENGINE)_SRC_PATH = $(SRC_PATH)/sonic-config-engine
SONIC_PYTHON_STDEB_DEBS += $(SONIC_CONFIG_ENGINE)
$(SONIC_CONFIG_ENGINE)_PYTHON_VERSION = 2
SONIC_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE)
5 changes: 3 additions & 2 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .pl
sudo mount --bind $(PYTHON_WHEELS_PATH) $($*.gz_PATH)/python-wheels $(LOG)
# Export variables for j2. Use path for unique variable names, e.g. docker_orchagent_debs
$(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_debs=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_DEPENDS),RDEPENDS))\n" | awk '!a[$$0]++'))
$(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_whls=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_PYTHON_WHEELS)))\n" | awk '!a[$$0]++'))
$(eval export $(subst -,_,$(notdir $($*.gz_PATH)))_dbgs=$(shell printf "$(subst $(SPACE),\n,$(call expand,$($*.gz_DBG_PACKAGES)))\n" | awk '!a[$$0]++'))
j2 $($*.gz_PATH)/Dockerfile.j2 > $($*.gz_PATH)/Dockerfile
docker build --squash --no-cache -t $* $($*.gz_PATH) $(LOG)
Expand All @@ -291,7 +292,7 @@ $(DOCKER_LOAD_TARGETS) : $(TARGET_PATH)/%.gz-load : .platform docker-start $$(TA
###############################################################################

# targets for building installers with base image
$(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform onie-image.conf $$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)) $$(addprefix $(DEBS_PATH)/,$$($$*_INSTALLS)) $(addprefix $(DEBS_PATH)/,$(INITRAMFS_TOOLS) $(LINUX_KERNEL) $(IGB_DRIVER) $(SONIC_CONFIG_ENGINE) $(SONIC_DEVICE_DATA) $(SONIC_UTILS)) $$(addprefix $(TARGET_PATH)/,$$($$*_DOCKERS))
$(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform onie-image.conf $$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)) $$(addprefix $(DEBS_PATH)/,$$($$*_INSTALLS)) $(addprefix $(DEBS_PATH)/,$(INITRAMFS_TOOLS) $(LINUX_KERNEL) $(IGB_DRIVER) $(SONIC_DEVICE_DATA) $(SONIC_UTILS)) $$(addprefix $(TARGET_PATH)/,$$($$*_DOCKERS)) $$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CONFIG_ENGINE))
$(HEADER)
## Pass initramfs and linux kernel explicitly. They are used for all platforms
export initramfs_tools="$(DEBS_PATH)/$(INITRAMFS_TOOLS)"
Expand All @@ -300,7 +301,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform
export installer_debs="$(addprefix $(DEBS_PATH)/,$($*_DEPENDS))"
export lazy_installer_debs="$(foreach deb, $($*_INSTALLS),$(addprefix $($(deb)_PLATFORM)@, $(DEBS_PATH)/$(deb)))"
export installer_images="$(addprefix $(TARGET_PATH)/,$($*_DOCKERS))"
export config_engine="$(addprefix $(DEBS_PATH)/,$(SONIC_CONFIG_ENGINE))"
export config_engine="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CONFIG_ENGINE))"
export image_type="$($*_IMAGE_TYPE)"
export sonicadmin_user="$(USERNAME)"
export sonic_asic_platform="$(CONFIGURED_PLATFORM)"
Expand Down
Loading