# Copyright (c) 2016 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. export WS_ROOT=$(CURDIR) export BR=$(WS_ROOT)/build-root CCACHE_DIR?=$(BR)/.ccache GDB?=gdb PLATFORM?=vpp SAMPLE_PLUGIN?=no STARTUP_DIR?=$(PWD) MACHINE=$(shell uname -m) SUDO?=sudo ,:=, define disable_plugins $(if $(1), \ "plugins {" \ $(patsubst %,"plugin %_plugin.so { disable }",$(subst $(,), ,$(1))) \ " }" \ ,) endef MINIMAL_STARTUP_CONF=" \ unix { \ interactive \ cli-listen /run/vpp/cli.sock \ gid $(shell id -g) \ $(if $(wildcard startup.vpp),"exec startup.vpp",) \ } \ $(if $(DPDK_CONFIG), "dpdk { $(DPDK_CONFIG) }",) \ $(call disable_plugins,$(DISABLED_PLUGINS)) \ " GDB_ARGS= -ex "handle SIGUSR1 noprint nostop" # # OS Detection # # We allow Darwin (MacOS) for docs generation; VPP build will still fail. ifneq ($(shell uname),Darwin) OS_ID = $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') OS_VERSION_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') endif ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID)) PKG=deb else ifeq ($(filter rhel centos fedora opensuse opensuse-leap opensuse-tumbleweed,$(OS_ID)),$(OS_ID)) PKG=rpm endif # +libganglia1-dev if building the gmond plugin DEB_DEPENDS = curl build-essential autoconf automake ccache DEB_DEPENDS += debhelper dkms git libtool libapr1-dev dh-systemd DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope pkg-config DEB_DEPENDS += lcov chrpath autoconf indent clang-format libnuma-dev DEB_DEPENDS += python-all python3-all python3-setuptools python-dev DEB_DEPENDS += python-virtualenv python-pip libffi6 check DEB_DEPENDS += libboost-all-dev libffi-dev python3-ply libmbedtls-dev DEB_DEPENDS += cmake ninja-build uuid-dev ifeq ($(OS_VERSION_ID),14.04) DEB_DEPENDS += libssl-dev else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-8) DEB_DEPENDS += libssl-dev APT_ARGS = -t jessie-backports else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-9) DEB_DEPENDS += libssl1.0-dev else DEB_DEPENDS += libssl-dev endif RPM_DEPENDS = redhat-lsb glibc-static RPM_DEPENDS += apr-devel RPM_DEPENDS += numactl-devel RPM_DEPENDS += check check-devel RPM_DEPENDS += boost boost-devel RPM_DEPENDS += selinux-policy selinux-policy-devel RPM_DEPENDS += ninja-build RPM_DEPENDS += libuuid-devel RPM_DEPENDS += mbedtls-devel ifeq ($(OS_ID),fedora) RPM_DEPENDS += dnf-utils RPM_DEPENDS += subunit subunit-devel RPM_DEPENDS += compat-openssl10-devel RPM_DEPENDS += python3-devel python3-ply RPM_DEPENDS += python3-virtualenv RPM_DEPENDS += cmake RPM_DEPENDS_GROUPS = 'C Development Tools and Libraries' else RPM_DEPENDS += yum-utils RPM_DEPENDS += openssl-devel RPM_DEPENDS += python-devel python36-ply RPM_DEPENDS += python36-devel python36-pip RPM_DEPENDS += python-virtualenv RPM_DEPENDS += devtoolset-7 RPM_DEPENDS += cmake3 RPM_DEPENDS_GROUPS = 'Development Tools' endif # +ganglia-devel if building the ganglia plugin RPM_DEPENDS += chrpath libffi-devel rpm-build # lowercase- replace spaces with dashes. SUSE_NAME= $(shell grep '^NAME=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g' | sed -e 's/ /-/' | awk '{print tolower($$0)}') SUSE_ID= $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g' | cut -d' ' -f2) RPM_SUSE_BUILDTOOLS_DEPS = autoconf automake ccache check-devel chrpath RPM_SUSE_BUILDTOOLS_DEPS += clang cmake indent libtool make ninja python3-ply RPM_SUSE_DEVEL_DEPS = glibc-devel-static libnuma-devel RPM_SUSE_DEVEL_DEPS += libopenssl-devel openssl-devel mbedtls-devel libuuid-devel RPM_SUSE_PYTHON_DEPS = python-devel python3-devel python-pip python3-pip RPM_SUSE_PYTHON_DEPS += python-rpm-macros python3-rpm-macros RPM_SUSE_PLATFORM_DEPS = distribution-release shadow rpm-build ifeq ($(OS_ID),opensuse) ifeq ($(SUSE_NAME),tumbleweed) RPM_SUSE_DEVEL_DEPS = libboost_headers1_68_0-devel-1.68.0 libboost_thread1_68_0-devel-1.68.0 gcc RPM_SUSE_PYTHON_DEPS += python3-ply python2-virtualenv endif ifeq ($(SUSE_ID),15.0) RPM_SUSE_DEVEL_DEPS += libboost_headers-devel libboost_thread-devel gcc RPM_SUSE_PYTHON_DEPS += python3-ply python2-virtualenv else RPM_SUSE_DEVEL_DEPS += libboost_headers1_68_0-devel-1.68.0 gcc6 RPM_SUSE_PYTHON_DEPS += python-virtualenv endif endif ifeq ($(OS_ID),opensuse-leap) ifeq ($(SUSE_ID),15.0) RPM_SUSE_DEVEL_DEPS += libboost_headers-devel libboost_thread-devel gcc git curl RPM_SUSE_PYTHON_DEPS += python3-ply python2-virtualenv endif endif RPM_SUSE_DEPENDS += $(RPM_SUSE_BUILDTOOLS_DEPS) $(RPM_SUSE_DEVEL_DEPS) $(RPM_SUSE_PYTHON_DEPS) $(RPM_SUSE_PLATFORM_DEPS) ifneq ($(wildcard $(STARTUP_DIR)/startup.conf),) STARTUP_CONF ?= $(STARTUP_DIR)/startup.conf endif ifeq ($(findstring y,$(UNATTENDED)),y) CONFIRM=-y FORCE=--force-yes endif TARGETS = vpp ifneq ($(SAMPLE_PLUGIN),no) TARGETS += sample-plugin endif .PHONY: help wipe wipe-release build build-release rebuild rebuild-release .PHONY: run run-release debug debug-release build-vat run-vat pkg-deb pkg-rpm .PHONY: ctags cscope .PHONY: test test-debug retest retest-debug test-doc test-wipe-doc test-help test-wipe .PHONY: test-cov test-wipe-cov define banner @echo "========================================================================" @echo " $(1)" @echo "========================================================================" @echo " " endef help: @echo "Make Targets:" @echo " install-dep - install software dependencies" @echo " wipe - wipe all products of debug build " @echo " wipe-release - wipe all products of release build " @echo " build - build debug binaries" @echo " build-release - build release binaries" @echo " build-coverity - build coverity artifacts" @echo " rebuild - wipe and build debug binares" @echo " rebuild-release - wipe and build release binares" @echo " run - run debug binary" @echo " run-release - run release binary" @echo " debug - run debug binary with debugger" @echo " debug-release - run release binary with debugger" @echo " test - build and run (basic) functional tests" @echo " test-debug - build and run (basic) functional tests (debug build)" @echo " test-all - build and run (all) functional tests" @echo " test-all-debug - build and run (all) functional tests (debug build)" @echo " test-gcov
#  Copyright (c) 2019. Vinci Consulting Corp. All Rights Reserved.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

import vpp_object


class VppLbVip(vpp_object.VppObject):
    def __init__(self, test, pfx, sfx, port, protocol):
        self._test = test
        self.pfx = pfx
        self.sfx = sfx
        self.port = port
        self.protocol = protocol

    def add_vpp_config(self):
        self._test_vapi.lb_add_del_vip(
            pfx=self.pfx, sfx=self.pfx, port=self.port, protocol=self.protocol
        )

        self._test.registry.register(self, self._test.logger)

    def remove_vpp_config(self