From 01de7b6fea2ddcab72b64b570afbf087dddb0e20 Mon Sep 17 00:00:00 2001 From: Abdelilah Essiari Date: Fri, 15 Mar 2024 21:45:07 -0700 Subject: [PATCH] test fabric modify add + delete nodes --- .../ubuntu_22_and_test_modify_fabric_l2.yml | 89 +++++++++++++++++++ cicd/run-fabfed.sh | 8 ++ .../fabric_facility_port/config.fab | 7 +- fabfed/provider/fabric/fabric_network.py | 1 - fabfed/util/parser.py | 2 +- 5 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ubuntu_22_and_test_modify_fabric_l2.yml diff --git a/.github/workflows/ubuntu_22_and_test_modify_fabric_l2.yml b/.github/workflows/ubuntu_22_and_test_modify_fabric_l2.yml new file mode 100644 index 00000000..1ec28bac --- /dev/null +++ b/.github/workflows/ubuntu_22_and_test_modify_fabric_l2.yml @@ -0,0 +1,89 @@ +name: Ubuntu22.04 Test + +on: + push: + branches: + - knit8 + workflow_dispatch: + +env: + FABRIC_TOKEN: ${{ secrets.FABRIC_TOKEN }} + FABRIC_BASTION_KEY: ${{ secrets.FABRIC_BASTION_KEY }} + FABRIC_SLIVER_KEY: ${{ secrets.FABRIC_SLIVER_KEY }} + FABRIC_SLIVER_PUBKEY: ${{ secrets.FABRIC_SLIVER_PUBKEY }} + FABRIC_PROJECT: ${{ secrets.FABRIC_PROJECT }} + FABRIC_USER: ${{ secrets.FABRIC_USER }} + +jobs: + UbuntuTest: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Fabfed And Requirements + run: | + pip install --upgrade pip + pip install setuptools --upgrade + pip install --no-cache-dir --ignore-requires-python neo4j==5.18.0 + pip list -v | grep neo4j + pip install --no-cache-dir --ignore-requires-python -r requirements.txt + python3 -m pip install --no-cache-dir . + pip install --no-cache-dir git+https://gitlab.flux.utah.edu/stoller/portal-tools.git + + - name: Save Credentials + run: | + mkdir -p ${{ github.workspace }}/creds + echo ${{ env.FABRIC_TOKEN }} | base64 --decode > ${{ github.workspace }}/creds/token.json + echo ${{ env.FABRIC_BASTION_KEY }} | base64 --decode > ${{ github.workspace }}/creds/bastion + echo ${{ env.FABRIC_SLIVER_KEY }} | base64 --decode > ${{ github.workspace }}/creds/sliver + echo ${{ env.FABRIC_SLIVER_PUBKEY }} | base64 --decode > ${{ github.workspace }}/creds/sliver.pub + + - name: Test Fabric Modify with FacilityPort 0 nodes + run: | + export DO_NOT_DESTROY=1 + session=cicd-fabric-facility-port + echo "vlan: 3103" > $session-varfile.yml + echo "node_count: 0" >> $session-varfile.yml + ${{ github.workspace }}/cicd/run-fabfed.sh cicd/test_configs/fabric_facility_port $session $session-varfile.yml + + - name: Test Fabric Modify with FacilityPort Add One Node + run: | + export DO_NOT_DESTROY=1 + session=cicd-fabric-facility-port + echo "vlan: 3103" > $session-varfile.yml + echo "node_count: 1" >> $session-varfile.yml + ${{ github.workspace }}/cicd/run-fabfed.sh cicd/test_configs/fabric_facility_port $session $session-varfile.yml + + - name: Test Fabric Modify with FacilityPort Add Another Node + run: | + export DO_NOT_DESTROY=1 + session=cicd-fabric-facility-port + echo "vlan: 3103" > $session-varfile.yml + echo "node_count: 2" >> $session-varfile.yml + ${{ github.workspace }}/cicd/run-fabfed.sh cicd/test_configs/fabric_facility_port $session $session-varfile.yml + + - name: Test Fabric Modify with FacilityPort Remove One Node + run: | + export DO_NOT_DESTROY=1 + session=cicd-fabric-facility-port + echo "vlan: 3103" > $session-varfile.yml + echo "node_count: 1" >> $session-varfile.yml + ${{ github.workspace }}/cicd/run-fabfed.sh cicd/test_configs/fabric_facility_port $session $session-varfile.yml + + - name: Test Fabric Modify with FacilityPort Remove One Node + run: | + export DO_NOT_DESTROY=1 + session=cicd-fabric-facility-port + echo "vlan: 3103" > $session-varfile.yml + echo "node_count: 0" >> $session-varfile.yml + ${{ github.workspace }}/cicd/run-fabfed.sh cicd/test_configs/fabric_facility_port $session $session-varfile.yml + + - name: Test Fabric Modify with FacilityPort Destroy + run: | + export DO_NOT_DESTROY=0 + session=cicd-fabric-facility-port + echo "vlan: 3103" > $session-varfile.yml + echo "node_count: 0" >> $session-varfile.yml + ${{ github.workspace }}/cicd/run-fabfed.sh cicd/test_configs/fabric_facility_port $session $session-varfile.yml diff --git a/cicd/run-fabfed.sh b/cicd/run-fabfed.sh index 985f75e1..5dc01525 100755 --- a/cicd/run-fabfed.sh +++ b/cicd/run-fabfed.sh @@ -41,6 +41,14 @@ fabfed workflow -c $conf_dir $options -s $session -show -summary > $session-appl fabfed workflow -c $conf_dir $options -s $session -show -summary fabfed sessions -show +DO_NOT_DESTROY="${DO_NOT_DESTROY:=0}" + +if [ $DO_NOT_DESTROY -ne 0 ]; then + echo "NOT_DESTROYING:APPLY RESULTS:" + cat $session-apply-state.yaml + exit $ret1 +fi + echo "***************** DESTOYING ****************" echo fabfed workflow -c $conf_dir $options -s $session -destroy fabfed workflow -c $conf_dir $options -s $session -destroy diff --git a/cicd/test_configs/fabric_facility_port/config.fab b/cicd/test_configs/fabric_facility_port/config.fab index f94736f0..b10ef228 100644 --- a/cicd/test_configs/fabric_facility_port/config.fab +++ b/cicd/test_configs/fabric_facility_port/config.fab @@ -1,6 +1,9 @@ variable: - vlan: default: 3101 + - node_count: + default: 0 + provider: - fabric: - fabric_provider: @@ -20,12 +23,12 @@ resource: site: UTAH # CLEM # UTAH image: default_rocky_8 nic_model: NIC_Basic - count: 0 + network: '{{ network.fabric_network }}' + count: '{{ var.node_count }}' - network: - fabric_network: provider: '{{ fabric.fabric_provider }}' layer3: "{{ layer3.my_layer }}" - # interface: '{{ node.fabric_node }}' device_name: Utah-Cloudlab-Powder site: UTAH interface: diff --git a/fabfed/provider/fabric/fabric_network.py b/fabfed/provider/fabric/fabric_network.py index fc7abde3..8a70855d 100644 --- a/fabfed/provider/fabric/fabric_network.py +++ b/fabfed/provider/fabric/fabric_network.py @@ -92,7 +92,6 @@ def __init__(self, label, provider: FabricProvider, slice_object: Slice, name, r self.layer3 = resource.get(Constants.RES_LAYER3) self.peering = resource.get(Constants.RES_PEERING) self.peer_layer3 = resource.get(Constants.RES_PEER_LAYER3) - self.device = None self.stitching_net = None self.label = label self.net = None diff --git a/fabfed/util/parser.py b/fabfed/util/parser.py index cec01b13..4acb727d 100644 --- a/fabfed/util/parser.py +++ b/fabfed/util/parser.py @@ -115,7 +115,7 @@ def _validate_variables(variables: List[Variable]): raise ParseConfigException(f'detected duplicate variables') for variable in variables: - if not variable.value: + if variable.value is None: raise ParseConfigException(f'variable {variable .name} is not bound') @staticmethod