Hi,
There is currently no API endpoint for adding, changing or deleting VS on a VSX. What we have is a vsx_provisioning_tool to perform these operations using the CLI, to achieve this over the RESTful Management API one could use a combination of the run-script api endpoint and vsx_provisioning_tool.
Here are two ansible playbook examples on how to create and delete VS on a VSX using a combination of run-script endpoint and the vsx_provisioning_tool. More information about the vsx_provisioning_tool can be found in the Check Point VSX R80.x Administration Guide
R80-AddVS.yml
---
# Example playbook to add Virtual System on a Check Point VSX
# Using management API run-script endpoint and the vsx_provisioning_tool binary
# Variables used in this playbook that are defined in vars.yml
# mgmt_user - Admin username for R80 Security Management API
# mgmt_password - Admin password for R80 Security Management API
# mgmt_domain - The Domain to make the changes in, set this to "SMC User" if this is a SMS
# mgmt_server - The MDS or SMS ip to connect to
# mgmt_fingerprint - The API server fingerprint on MDS or SMS
# dms_ip - Domain Management Server IP for the domain where the VSX object exists
# mgmt_user - Management API admin user name
# mgmt_password - Management API admin user password
# vsx_hostname - Name of the VSX object where the virtual system should be created
# script_targets - list, Should contain name of dms that managed the domain with the VSX object
- hosts: "localhost"
connection: local
gather_facts: no
vars_files:
- vars.yml
tasks:
- name: "login"
check_point_mgmt:
command: login
parameters:
username: "{{mgmt_user}}"
password: "{{mgmt_password}}"
domain: "{{mgmt_domain}}"
management: "{{mgmt_server}}"
fingerprint: "{{mgmt_fingerprint}}"
register: login_response
- name: "Create VS on VXS with run-script"
check_point_mgmt:
command: run-script
parameters:
script-name: "Create VS vs{{item}} on VXS {{vsx_hostname}} with run-script"
script: "$MDS_FWDIR/bin/vsx_provisioning_tool -s {{dms_ip}} -u {{mgmt_user}} -p {{mgmt_password}} -o add vd name vs{{item}} vsx {{vsx_hostname}} type vs, add interface name eth1.{{item}} ip 1.1.{{item}}.254 netmask 255.255.255.0, add interface name eth2.{{item}} ip 2.2.{{item}}.254 netmask 255.255.255.0"
targets:
"{{ script_targets }}"
session-data: "{{login_response}}"
with_sequence: start=10 end=12
- name: "logout"
check_point_mgmt:
command: logout
session-data: "{{login_response}}"
R80-RemoveVS.yml
---
# Example playbook to remove Virtual System on a Check Point VSX
# Using management API run-script endpoint and the vsx_provisioning_tool binary
# Variables used in this playbook that are defined in vars.yml
# mgmt_user - Admin username for R80 Security Management API
# mgmt_password - Admin password for R80 Security Management API
# mgmt_domain - The Domain to make the changes in, set this to "SMC User" if this is a SMS
# mgmt_server - The MDS or SMS ip to connect to
# mgmt_fingerprint - The API server fingerprint on MDS or SMS
# dms_ip - Domain Management Server IP for the domain where the VSX object exists
# mgmt_user - Management API admin user name
# mgmt_password - Management API admin user password
# vsx_hostname - Name of the VSX object where the virtual system should be created
# script_targets - list, Should contain name of dms that managed the domain with the VSX object
- hosts: "localhost"
connection: local
gather_facts: no
vars_files:
- vars.yml
tasks:
- name: "login"
check_point_mgmt:
command: login
parameters:
username: "{{mgmt_user}}"
password: "{{mgmt_password}}"
domain: "{{mgmt_domain}}"
management: "{{mgmt_server}}"
fingerprint: "{{mgmt_fingerprint}}"
register: login_response
- name: "Remove VS on VXS with run-script"
check_point_mgmt:
command: run-script
parameters:
script-name: "Remove VS vs{{item}} on VXS {{vsx_hostname}} with run-script"
script: "$MDS_FWDIR/bin/vsx_provisioning_tool -s {{dms_ip}} -u {{mgmt_user}} -p {{mgmt_password}} -o remove vd name vs{{item}}"
targets:
"{{ script_targets }}"
session-data: "{{login_response}}"
with_sequence: start=10 end=12
- name: "logout"
check_point_mgmt:
command: logout
session-data: "{{login_response}}"