VMware Networking Community
rajkumar49
Contributor
Contributor

create redirection policy in NSX-T 3.0 using API

hi,

i want to create a redirection policy using the API.

But POST method is not available in the API guide.

tried below API call :

PUT https://10.204.x.x/policy/api/v1/infra/domains/default/redirection-policies

payload:

{

      "redirect_to": [],

      "north_south": true,

      "resource_type": "RedirectionPolicy",

      "id": "DEFAULT-NS-TEST100-REDIRECTION-POLICY",

      "display_name": "DEFAULT-NS-TEST100-REDIRECTION-POLICY",

      "path": "/infra/domains/default/redirection-policies/DEFAULT-NS-TEST100-REDIRECTION-POLICY",

      "relative_path": "DEFAULT-NS-TEST100-REDIRECTION-POLICY",

      "parent_path": "/infra/domains/default",

      "marked_for_delete": false,

      "overridden": false,

      "category": "Application",

      "stateful": true,

      "locked": false,

      "lock_modified_time": 0,

      "scope": [

        "ANY"

      ]

}

response :

    "module_name": "common-services",

    "error_message": "Method is not allowed",

    "error_code": 282

}

so ,How to create Redirection policy  using API ?

Tags (1)
0 Kudos
4 Replies
rajkumar49
Contributor
Contributor

additional info:

i want to find the NSX-T equivalent for the below NSX-V API :

POST /api/2.0/services/policy/securitypolicy
Description:
Create a security policy

0 Kudos
p0wertje
Hot Shot
Hot Shot

/policy/api/v1/infra/domains/default/security-policies

api guide (nsx 3.0) 3.4.7.1.1.2

NSX-T Data Center REST API - VMware API Explorer - VMware {code}

Cheers,
p0wertje | VCIX6-NV | JNCIS-ENT | vExpert
Please kudo helpful posts and mark the thread as solved if solved
0 Kudos
rajkumar49
Contributor
Contributor

hi chris,

this API is not using POST method to create a policy. only PUT method is used to create or update policy, but I am not able to use that.

0 Kudos
p0wertje
Hot Shot
Hot Shot

I am able to create a redirect-policy.

You need to create a Service Segment and a Service chain first (under Security, Network introspection Settings)

After that i created a new rule (New_Policy2)

Mind the "/infra/service-chains/c82101d3-e62c-4710-925b-2664083170da" which points to you service-chain

put https://x.y.z.z/policy/api/v1//infra/domains/default/redirection-policies/New_Policy2

Body:

{

  "rules": [],

  "redirect_to": [

    "/infra/service-chains/c82101d3-e62c-4710-925b-2664083170da"

  ],

  "north_south": true,

  "resource_type": "RedirectionPolicy",

  "id": "New_Policy",

  "display_name": "New Policy",

  "relative_path": "New_Policy",

  "parent_path": "/infra/domains/default",

  "marked_for_delete": false,

  "overridden": false,

  "sequence_number": 10,

  "internal_sequence_number": 13000010,

  "category": "Application",

  "stateful": false,

  "tcp_strict": false,

  "locked": false,

  "lock_modified_time": 0,

  "scope": [

    "/infra/tier-0s/test2"

  ]

 

}

Which returns:

{

  "rules": [],

  "redirect_to": [

    "/infra/service-chains/c82101d3-e62c-4710-925b-2664083170da"

  ],

  "north_south": true,

  "resource_type": "RedirectionPolicy",

  "id": "New_Policy2",

  "display_name": "New Policy",

  "path": "/infra/domains/default/redirection-policies/New_Policy2",

  "relative_path": "New_Policy2",

  "parent_path": "/infra/domains/default",

  "unique_id": "4c9b61f4-415f-40b9-92f4-eebb6be0c490",

  "marked_for_delete": false,

  "overridden": false,

  "sequence_number": 10,

  "internal_sequence_number": 13000010,

  "category": "Application",

  "stateful": false,

  "tcp_strict": false,

  "locked": false,

  "lock_modified_time": 0,

  "scope": [

    "/infra/tier-0s/test2"

  ],

  "rule_count": 0,

  "is_default": false,

  "_create_user": "admin",

  "_create_time": 1597777185679,

  "_last_modified_user": "admin",

  "_last_modified_time": 1597777185682,

  "_system_owned": false,

  "_protection": "NOT_PROTECTED",

  "_revision": 0

}

Cheers,
p0wertje | VCIX6-NV | JNCIS-ENT | vExpert
Please kudo helpful posts and mark the thread as solved if solved
0 Kudos