Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Uri_Bialik

Delete a host object

Overview

The purpose of this code it to show delete a host object while taking into consideration questions like: is the object a member of an existing group, is the object participating in a rulebase.

Description

If the host object is not a member of a group and is not used in a rule-base - delete the host object.

If the host is being used in a rulebase - remove the host from the rulebase.

If the host object was the last object-in its cell - disable thr rule.

if the host object was a member of a group - remove it from the group.

If the group is now an empty group - delete the group.

If the deleted group appeared in a rulebase - remove it from the rulebase.

if the deleted group was the last object in the cell - disable the rule.

Instructions

run delete_host.py (python 2.7 code).

Code Version

Code version 1.0.0

Tested on version

R80, API version 1.0

NOTICE: By using this sample code you agree to terms and conditions in this Terms and Conditions

...

0 Kudos
3 Replies
fwmeister
Contributor

Does this script actually work on R80.20? Specifically on MDS? I sort of got it to work on SC but never on MDS. I can never match the fingerprint. api fingerprint value never matches what the server returns. I eventually gave up and wrote a bash hack to do the same but I'd actually like to use python and the web api instead of mgmt_cli
0 Kudos
scripting_guru
Explorer

@fwmeister can you please share your code? 

0 Kudos
scripting_guru
Explorer

@Uri_Bialik please help how can I get the rulebasecsv?  I also tried to write another code to bypass the rulebase library requirement but I am having issues with pulling the UID. I am using Jupyter notebook through Anaconda for development environment. Error code 

"Error: Key 'uid' is missing in rule dictionary: {'rule': {'uid': '09bf0dea-5d3c-429d-890f-4bf9b5eb99b5', 'name': 'Sterling Access', 'type': 'access-rule', 'domain': {'uid': '41e821a0-3720-11e3-aa6e-0800200c9fde', 'name': 'SMC User', 'domain-type': 'domain'}}, 'rule-columns': ['source'], 'position': '13', 'layer': {'uid': 'e06bc425-1f8b-4487-a64f-661f85084a6d', 'name': 'Pennsylvania Security', 'type': 'access-layer', 'domain': {'uid': '41e821a0-3720-11e3-aa6e-0800200c9fde', 'name': 'SMC User', 'domain-type': 'domain'}}, 'layer-position': 1, 'package': {'uid': '93b650bc-8b28-4587-8641-73f25d7e3c8c', 'name': 'Pennsylvania', 'type': 'package', 'domain': {'uid': '41e821a0-3720-11e3-aa6e-0800200c9fde', 'name': 'SMC User', 'domain-type': 'domain'}}}" Error: 'object'


0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events