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

Script to delete objects

Jump to solution

Hello everybody.

I'm doing a script to delete objects and rules. I'm having troubles to define if the object is the last in cell. In the SmartConsole, if I go to 'Where Used' in the object, I can see if it are the Last in Cell, but in the "mgmt_cli where used" there isn't a field with this information. Does anynone have this same problem? Is there another way to do this?

Thanks for while.

0 Kudos
3 Solutions

Accepted Solutions
Highlighted
Admin
Admin

Re: Script to delete objects

Jump to solution
The API does not return if a particular object is "last in cell" or not.
You would have to parse the individual results returned by the where-used API call to determine if it is "last in cell" or not.

View solution in original post

0 Kudos
Highlighted

Re: Script to delete objects

Jump to solution

Hi fwmeister.

 

I did a count in the source and destination colunms, to check if there is only one object. This is the only way I found to solve this problem.

mgmt_cli -r true -d "$DOMAIN" show access-rule uid "$(cat < ruleuid.json)" layer "$(cat < layer.json)" --format json > $ACCESS_RULE
cat access_rule.json | jq '.name' > $RULENAME
cat access_rule.json | jq '.source[] | .name' > $SOURCE_POSITION
cat access_rule.json | jq '.destination[] | .name' > $DESTINATION_POSITION
SOURCE_OBJECTS=$(cat source_p.json | wc -l)
DESTINATION_OBJECTS=$(cat destination_p.json | wc -l)

Please let me know if you need a help.

View solution in original post

0 Kudos
Highlighted
Admin
Admin

Re: Script to delete objects

Jump to solution
That's about the way to do it.
Where used will tell you what rules a particular object is used in.
You then have to evaluate each rule to determine whether it is "last in cell" or not.
Removing something "last in cell" can completely change the meaning of a rule, thus it can only be done by modifying the rule itself and not indirectly (e.g. by deleting a given object).

View solution in original post

0 Kudos
4 Replies
Highlighted
Admin
Admin

Re: Script to delete objects

Jump to solution
The API does not return if a particular object is "last in cell" or not.
You would have to parse the individual results returned by the where-used API call to determine if it is "last in cell" or not.

View solution in original post

0 Kudos
Highlighted
Ivory

Re: Script to delete objects

Jump to solution

Hi Dameon,

Will this be fixed in a future version?

If not, could you please elaborate on your answer? 

I don't see how to determine if the object is last-in-cell. 

Tnx in advance.

 

PS. Did anybody solve this?

 

0 Kudos
Highlighted

Re: Script to delete objects

Jump to solution

Hi fwmeister.

 

I did a count in the source and destination colunms, to check if there is only one object. This is the only way I found to solve this problem.

mgmt_cli -r true -d "$DOMAIN" show access-rule uid "$(cat < ruleuid.json)" layer "$(cat < layer.json)" --format json > $ACCESS_RULE
cat access_rule.json | jq '.name' > $RULENAME
cat access_rule.json | jq '.source[] | .name' > $SOURCE_POSITION
cat access_rule.json | jq '.destination[] | .name' > $DESTINATION_POSITION
SOURCE_OBJECTS=$(cat source_p.json | wc -l)
DESTINATION_OBJECTS=$(cat destination_p.json | wc -l)

Please let me know if you need a help.

View solution in original post

0 Kudos
Highlighted
Admin
Admin

Re: Script to delete objects

Jump to solution
That's about the way to do it.
Where used will tell you what rules a particular object is used in.
You then have to evaluate each rule to determine whether it is "last in cell" or not.
Removing something "last in cell" can completely change the meaning of a rule, thus it can only be done by modifying the rule itself and not indirectly (e.g. by deleting a given object).

View solution in original post

0 Kudos