Commit 939d65b4 authored by Waleed Akbar's avatar Waleed Akbar
Browse files

Update connection hop validation and enhance logging in VlanIdPropagator and...

Update connection hop validation and enhance logging in VlanIdPropagator and added redeploy service component script
parent 104339b6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ class StaticRouteGenerator:

        num_connection_hops = len(connection_hop_list)
        if num_connection_hops % 2 != 0: raise Exception('Number of connection hops must be even')
        if num_connection_hops < 4: raise Exception('Number of connection hops must be >= 4')
        if num_connection_hops < 2: raise Exception('Number of connection hops must be >= 2')

        it_connection_hops = iter(connection_hop_list)
        return list(zip(it_connection_hops, it_connection_hops))
+3 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class VlanIdPropagator:

    def compose(self, connection_hop_list : List[Tuple[str, str, Optional[str]]]) -> None:
        link_endpoints = self._compute_link_endpoints(connection_hop_list)
        LOGGER.debug('link_endpoints = {:s}'.format(str(link_endpoints)))
        LOGGER.info('link_endpoints = {:s}'.format(str(link_endpoints)))

        self._propagate_vlan_id(link_endpoints)
        LOGGER.debug('config_rule_composer = {:s}'.format(json.dumps(self._config_rule_composer.dump())))
@@ -53,6 +53,7 @@ class VlanIdPropagator:
            filtered_connection_hop_list.append(connection_hop)
            added_connection_hops.add(connection_hop)
        connection_hop_list = filtered_connection_hop_list
        LOGGER.info('filtered connection_hop_list length = {:s}'.format(str(len(connection_hop_list))))

        # In some cases connection_hop_list first and last items might be internal endpoints of
        # devices instead of link endpoints. Filter those endpoints not reaching a new device.
@@ -65,7 +66,7 @@ class VlanIdPropagator:

        num_connection_hops = len(connection_hop_list)
        if num_connection_hops % 2 != 0: raise Exception('Number of connection hops must be even')
        if num_connection_hops < 4: raise Exception('Number of connection hops must be >= 4')
        if num_connection_hops < 2: raise Exception('Number of connection hops must be >= 2')

        it_connection_hops = iter(connection_hop_list)
        return list(zip(it_connection_hops, it_connection_hops))
+46 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# 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.

set -euo pipefail

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../../.." && pwd)"
cd "${REPO_ROOT}"

TFS_IMAGE_TAG="${TFS_IMAGE_TAG:-dev}"
TFS_K8S_NAMESPACE="${TFS_K8S_NAMESPACE:-tfs}"
TFS_REGISTRY_IMAGES="${TFS_REGISTRY_IMAGES:-http://localhost:32000/tfs/}"
TFS_ROLLOUT_TIMEOUT="${TFS_ROLLOUT_TIMEOUT:-300s}"

REGISTRY="${TFS_REGISTRY_IMAGES#http://}"
REGISTRY="${REGISTRY#https://}"
REGISTRY="${REGISTRY%/}"
LOCAL_IMAGE="service:${TFS_IMAGE_TAG}"
REMOTE_IMAGE="${REGISTRY}/${LOCAL_IMAGE}"
DEPLOYMENT="serviceservice"

kubectl --namespace "${TFS_K8S_NAMESPACE}" get deployment "${DEPLOYMENT}" >/dev/null

echo "Building ${LOCAL_IMAGE} without Docker cache..."
docker build --no-cache --tag "${LOCAL_IMAGE}" --file ./src/service/Dockerfile .

echo "Pushing ${REMOTE_IMAGE}..."
docker tag "${LOCAL_IMAGE}" "${REMOTE_IMAGE}"
docker push "${REMOTE_IMAGE}"

echo "Restarting deployment/${DEPLOYMENT} in namespace ${TFS_K8S_NAMESPACE}..."
kubectl --namespace "${TFS_K8S_NAMESPACE}" rollout restart "deployment/${DEPLOYMENT}"
kubectl --namespace "${TFS_K8S_NAMESPACE}" rollout status \
    "deployment/${DEPLOYMENT}" --timeout="${TFS_ROLLOUT_TIMEOUT}"