AhmedThabet / f5py-doc

3 stars 0 forks source link

When persist profile is present in VS data is not parsed / recorded #4

Closed samualblair closed 6 months ago

samualblair commented 7 months ago

I'm sure there are other edge cases but I have found when persist profile is present some data is not processed for a virtual server. (tested with the wasm module version)

Two virtual server configurations with the only significant difference being the persist profile, you can see the failure. Doesn't crash or throw any error, but fails to record much of the other relevant information.

I assume processing just halts for for variables related to that object, as the location of the 'persist' statement does affect the output.

When the persist statement is in the default location from the config file (middle of the config), as seen in EXAMPLE_VS_FAIL Here i see the following was lost:

When the persist statement is in the bottom of the config file as seen in EXAMPLE_VS_FAIL2 Here i see the only thing lost was the persist profile. Unfortunately this is only an example, in the normal config output this is not the location of the persistence profile.

Example:

ltm virtual /Common/EXAMPLE_VS_FAIL {
    creation-time 2022-06-27:14:02:36
    destination /Common/172.0.0.1:80
    ip-protocol tcp
    last-modified-time 2023-12-17:13:28:40
    mask 255.255.255.255
    pool /Common/EXAMPLE_POOL
    persist {
        /Common/EXAMPLE_PERSIST {
            default yes
        }
    }
    profiles {
        /Common/http { }
        /Common/tcp { }
    }
    source 0.0.0.0/0
    source-address-translation {
        pool /Common/EXAMPLE_SNAT_POOL
        type snat
    }
    translate-address enabled
    translate-port enabled
    vlans {
        /Common/EXAMPLE_VLAN
    }
    vlans-enabled
}
ltm virtual /Common/EXAMPLE_VS_GOOD {
    creation-time 2022-06-27:14:02:36
    destination /Common/172.0.0.1:81
    ip-protocol tcp
    last-modified-time 2023-12-17:13:28:40
    mask 255.255.255.255
    pool /Common/EXAMPLE_POOL
    profiles {
        /Common/http { }
        /Common/tcp { }
    }
    source 0.0.0.0/0
    source-address-translation {
        pool /Common/EXAMPLE_SNAT_POOL
        type snat
    }
    translate-address enabled
    translate-port enabled
    vlans {
        /Common/EXAMPLE_VLAN
    }
    vlans-enabled
}
ltm virtual /Common/EXAMPLE_VS_FAIL2 {
    creation-time 2022-06-27:14:02:36
    destination /Common/172.0.0.1:82
    ip-protocol tcp
    last-modified-time 2023-12-17:13:28:40
    mask 255.255.255.255
    pool /Common/EXAMPLE_POOL
    profiles {
        /Common/http { }
        /Common/tcp { }
    }
    source 0.0.0.0/0
    source-address-translation {
        pool /Common/EXAMPLE_SNAT_POOL
        type snat
    }
    translate-address enabled
    translate-port enabled
    vlans {
        /Common/EXAMPLE_VLAN
    }
    vlans-enabled
    persist {
        /Common/EXAMPLE_PERSIST {
            default yes
        }
    }
}

Which translates to this

{
  "partitions": [
    "Common"
  ],
  "virtual_servers": [
    {
      "name": "/Common/EXAMPLE_VS_FAIL",
      "destination": "/Common/172.0.0.1:80",
      "ip-protocol": "tcp",
      "creation-time": "2022-06-27:14:02:36",
      "last-modified-time": "2023-12-17:13:28:40",
      "mask": "255.255.255.255",
      "pool": "/Common/EXAMPLE_POOL",
      "translate_address": "",
      "translate_port": "",
      "source": ""
    },
    {
      "name": "/Common/EXAMPLE_VS_GOOD",
      "destination": "/Common/172.0.0.1:81",
      "ip-protocol": "tcp",
      "creation-time": "2022-06-27:14:02:36",
      "last-modified-time": "2023-12-17:13:28:40",
      "profiles": [
        {
          "name": "/Common/http"
        },
        {
          "name": "/Common/tcp"
        }
      ],
      "mask": "255.255.255.255",
      "pool": "/Common/EXAMPLE_POOL",
      "source-address-translation": {
        "type": "snat",
        "pool": "/Common/EXAMPLE_SNAT_POOL"
      },
      "translate_address": "enabled",
      "translate_port": "enabled",
      "vlans": [
        "/Common/EXAMPLE_VLAN"
      ],
      "vlans_enabled": true,
      "source": "0.0.0.0/0"
    },
    {
      "name": "/Common/EXAMPLE_VS_FAIL2",
      "destination": "/Common/172.0.0.1:82",
      "ip-protocol": "tcp",
      "creation-time": "2022-06-27:14:02:36",
      "last-modified-time": "2023-12-17:13:28:40",
      "profiles": [
        {
          "name": "/Common/http"
        },
        {
          "name": "/Common/tcp"
        }
      ],
      "mask": "255.255.255.255",
      "pool": "/Common/EXAMPLE_POOL",
      "source-address-translation": {
        "type": "snat",
        "pool": "/Common/EXAMPLE_SNAT_POOL"
      },
      "translate_address": "enabled",
      "translate_port": "enabled",
      "vlans": [
        "/Common/EXAMPLE_VLAN"
      ],
      "vlans_enabled": true,
      "source": "0.0.0.0/0"
    }
  ],
  "pools": [],
  "snat_pools": []
}
AhmedThabet commented 6 months ago

Thanks Michel, This a very detailed and helpful description for that bug, & I'll use the provided examples within the unit testing.

AhmedThabet commented 6 months ago

The fix is already in-place within the wasm portal https://ipvx.me/f5 The python lib requires a bit of work & will include the same fix as well.

samualblair commented 6 months ago

Thank you! I didn't expect such quick response or resolution, very much appreciated! Yes, I can confirm it looks to be working great in the wasm portal now!

AhmedThabet commented 6 months ago

The fix is now pushed to pypi with release v 0.3.0