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

where-used and replace question

As Subject

where-used question

I had collected all the objects uid with a json file and run a command, the result show as below

11111.jpg

Is it possible execute each line (uid) of the file ?

then replace question

I know a method to replace the object to None (remove item) then delete it manually.

 object right click > where_used > press "replace" >    drop_down_menu select "None(remove item)" > then select objects or policy item

Is there a api command to do this ?

0 Kudos
6 Replies
Bob_Zimmerman
Authority
Authority

Each call to where-used only accepts one UUID. Check out xargs. It can ingest a stream of many lines or fields, carve them up into a series of grouped fields, then run a command separately for each group.

As for the replacement, I don't know of an API command to do that in one call.

PhoneBoy
Admin
Admin

I believe “none” is merely a specific object reference.
@Omer_Kleinstern would know for sure.

0 Kudos
Bob_Zimmerman
Authority
Authority

Yes, "None" is just a special object with the UUID 97aeb36a-9aea-11d5-bd16-0090272ccb30 and the type "CpmiAnyObject". It's like "Any" (97aeb369-9aea-11d5-bd16-0090272ccb30). Their UUIDs only differ in the 8th digit.

vavava
Contributor

That means it is impossible to replace the objects via api comments.

I also tried the "where-used",  it can read each line, but still not work. the command not found.

Any suggestion 😞?

11113.jpg

0 Kudos
Bob_Zimmerman
Authority
Authority

Like I said earlier, check out xargs. I don't know what your uid.json file contains, but if it's just a list of UUIDs, one per line, you could use it like this:

xargs <uid.json -L 1 mgmt_cli -r true where-used uid
PhoneBoy
Admin
Admin

What you're asking is fairly basic scripting.
Here's how to do this while minimizing the number of sessions created:

mgmt_cli -r true login > sid.txt
cat uid.json | while read X; do
  mgmt_cli -s sid.txt where-used uid $X
done
mgmt_cli -s sid.txt logout

Perhaps xargs can do this a bit more cleanly 🙂

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events