f5devcentral / f5-automation-config-converter

Convert BIG-IP configs to AS3 and DO declarations
https://clouddocs.f5.com/products/extensions/f5-automation-config-converter/latest/
Apache License 2.0
35 stars 14 forks source link

Missing 'type' for Policy_Condition #104

Open zongzw opened 9 months ago

zongzw commented 9 months ago

Environment

Summary

The generated AS3 declaration cannot be deployed to BIG-IP via AS3, reporting:

{
  "code": 422,
  "errors": [
    "/cis-c-tenant_1/application_1/mypolicy/rules/0/conditions/0: should have required property 'type'"
  ],
  "declarationFullId": "",
  "message": "declaration is invalid"
}

Is there any code update needed for ACC to compat Endpoint_Policy?

Steps To Reproduce

  1. Use the following command to convert .ucs to per-app AS3 declaration.

docker run --rm -v "$PWD":/app/data f5devcentral/f5-automation-config-converter:latest --ucs /app/data/vs-with-policy.ucs

vs-with-policy.ucs is a ucs file which contains a simple virtual and its depending policy:

the policy part looks like:

#TMSH-VERSION: 17.1.0.2

ltm node /cis-c-tenant/10.250.11.185 {
    address 10.250.11.185
}
ltm policy /cis-c-tenant/mypolicy {
    requires { http }
    rules {
        myrule {
            actions {
                0 {
                    http
                    enable
                }
            }
            conditions {
                0 {
                    http-host
                    starts-with
                    values { 1.1.1.1 }
                }
            }
        }
    }
    strategy /Common/first-match
}
ltm pool /cis-c-tenant/mypool {
    members {
        /cis-c-tenant/10.250.11.185:80 {
            address 10.250.11.185
        }
    }
    monitor /Common/http
}
ltm virtual /cis-c-tenant/myvs {
    creation-time 2024-02-01:02:34:42
    destination /cis-c-tenant/172.18.0.201:80
    ip-protocol tcp
    last-modified-time 2024-02-03:17:33:01
    mask 255.255.255.255
    policies {
        /cis-c-tenant/mypolicy { }
    }
    pool /cis-c-tenant/mypool
    profiles {
        /Common/http { }
        /Common/tcp { }
    }
    serverssl-use-sni disabled
    source 0.0.0.0/0
    source-address-translation {
        type automap
    }
    translate-address enabled
    translate-port enabled
}
ltm virtual-address /cis-c-tenant/172.18.0.201 {
    address 172.18.0.201
    arp enabled
    icmp-echo enabled
    mask 255.255.255.255
    traffic-group /Common/traffic-group-1
}
  1. The generated AS3 body is:
{
  "class": "ADC",
  "schemaVersion": "3.23.0",
  "id": "urn:uuid:55839454-8971-4a82-a09b-4570171c3d78",
  "label": "Converted Declaration",
  "remark": "Generated by JOURNEYS",
  "cis-c-tenant_1": {
    "class": "Tenant",
    "application_1": {
      "myvs": {
        "pool": "mypool",
        "snat": "auto",
        "class": "Service_HTTP",
        "layer4": "tcp",
        "profileTCP": {
          "bigip": "/Common/tcp"
        },
        "profileHTTP": {
          "bigip": "/Common/http"
        },
        "policyEndpoint": "/cis-c-tenant_1/application_1/mypolicy",
        "virtualAddresses": [
          "172.18.0.201"
        ],
        "translateServerPort": true,
        "translateServerAddress": true
      },
      "class": "Application",
      "mypool": {
        "class": "Pool",
        "members": [
          {
            "shareNodes": true,
            "servicePort": 80,
            "serverAddresses": [
              "10.250.11.185"
            ],
            "addressDiscovery": "static"
          }
        ],
        "monitors": [
          {
            "bigip": "/Common/http"
          }
        ]
      },
      "mypolicy": {
        "class": "Endpoint_Policy",
        "rules": [
          {
            "name": "myrule",
            "actions": [
              {
                "type": "http",
                "event": "request",
                "enabled": true
              }
            ],
            "conditions": [
              {                                                    # missing "type": "httpHost",
                "all": {
                  "values": [
                    "1.1.1.1"
                  ],
                  "operand": "starts-with"
                },
                "event": "request"
              }
            ]
          }
        ],
        "strategy": "first-match"
      },
      "template": "generic"
    }
  }
}

where, the conditions[0], should contain "type": "httpHost",, but no.

It cause the deployment fails, when I added it manually, it succeed for deployment.