10-17-2022 04:58 AM
Having several objects with "TEMP_" for example, tenant TEMP_tenant_A, vrf TEMP_vrf_A, TEMP_LIP_A etc.
was looking for a quick way to delete those objects. Postman is an option, but since the "TEMP_" objects are scattered all over the place, it's difficult to create and manage a collection.
The other option I came across is to via /mit/uni/infra. I attempted to delete a file or folder containing "TEMP_" but was unsuccessful using CLI or SCP. missed the opportunity to take a backup, so restoring is not an option for now.
for i in `find *TEMP_*`
do
echo "removing $i"
modelete $i
done
moconfig commit
sudo find -type d -name *TEMP_*| xargs sudo rm -rf
search and delete in winsCP
Solved! Go to Solution.
10-17-2022 06:33 PM - edited 10-17-2022 06:34 PM
Hi @Qwr! ,
I'm not sure if this is a question that you'd like answered, or a contribution to help others out - because you've (almost) given the answer to your comment ...
was looking for a quick way to delete those objects.
... when you listed the modelete
method - but unfortunately as written it won't necessarily get ALL objects starting with TEMP_
So if you are looking for an answer to get ALL objects, you'll need to do this (my additions in red) - it will throw a lot of errors which you can ignore (because it's trying to delete relationships that won't exist when the objects they link to are deleted) but it will (fingers crossed) work!
apic1# bash
admin@apic1:~> cd /mit/uni/infra/
admin@apic1:infra~> for i in `find . -name *TEMP_*`
> do
> echo "removing $i"
> modelete $i
> done
# POTENTIALLY LOTS OF OUTPUT #
admin@apic1:infra~> moconfig commit
You won't be able to use any sudo
commands on the APIC without TAC support
10-17-2022 06:33 PM - edited 10-17-2022 06:34 PM
Hi @Qwr! ,
I'm not sure if this is a question that you'd like answered, or a contribution to help others out - because you've (almost) given the answer to your comment ...
was looking for a quick way to delete those objects.
... when you listed the modelete
method - but unfortunately as written it won't necessarily get ALL objects starting with TEMP_
So if you are looking for an answer to get ALL objects, you'll need to do this (my additions in red) - it will throw a lot of errors which you can ignore (because it's trying to delete relationships that won't exist when the objects they link to are deleted) but it will (fingers crossed) work!
apic1# bash
admin@apic1:~> cd /mit/uni/infra/
admin@apic1:infra~> for i in `find . -name *TEMP_*`
> do
> echo "removing $i"
> modelete $i
> done
# POTENTIALLY LOTS OF OUTPUT #
admin@apic1:infra~> moconfig commit
You won't be able to use any sudo
commands on the APIC without TAC support
10-18-2022 05:25 AM - edited 10-18-2022 08:26 AM
@RedNectar For some reason, when i tried show run I do see lots of leftovers. Just wondering what could be the reason.
template policy-group TEMP_corporate_external
template policy-group TEMP_standard_access
tenant TEMP
leaf-interface-profile TEMP_server1
leaf-interface-profile TEMP_server2
leaf-interface-profile TEMP_phys_act_pass
leaf-interface-profile TEMP_corporate_external
switchport trunk allowed vlan 121 tenant TEMP application Evo epg Web
switchport trunk allowed vlan 123 tenant TEMP application Res epg Web
switchport trunk allowed vlan 125 tenant TEMP application Cha epg Web
10-18-2022 08:38 AM
also getting errors like ...find: paths must precede expression:
10-18-2022 01:54 PM - edited 10-19-2022 01:07 PM
Hi @Qwr! ,
[Edit 2022.10.20 - Scroll down to my later answer for a MUCH FASTER solution]
To remove Tenant TEMP
(and probably the switchport trunk ... TEMP application ...
run the same command without the _
(underscore) following TEMP
apic1# bash
admin@apic1:~> cd /mit/uni/infra/
admin@apic1:infra~> for i in `find . -name *TEMP*`
> do
> echo "removing $i"
> modelete $i
> done
# POTENTIALLY LOTS OF OUTPUT #
admin@apic1:infra~> moconfig commit
The error
...find: paths must precede expression:
can probably be avoided by putting single quotes around the search term - i.e. entering
for i in `find . -name '*TEMP*'`
rather than
for i in `find . -name *TEMP*`
From my testing, this also deletes the template policy-group
and leaf-interface-profile
statements from show running-config
too, but I actually think they should have been deleted anyway
In fact - I SUSPECT you left out the dot (period) between find and -name in
for i in `find . -name *TEMP*`
10-18-2022 11:48 PM - edited 10-18-2022 11:49 PM
@RedNectarThank you! - again. Indeed, it works now. but noticed the process is too slow. may be because of the following error? thinking about collecting DNs and simply POSTing them.
This command is being deprecated on APIC controller, please use NXOS-style equivalent command
10-19-2022 01:04 PM - edited 10-19-2022 01:16 PM
Hi @Qwr! ,
Yep. It is very slow. But I wasn't aiming for speed. The following would probably be quicker, because it limits the depth of the find
command (=big improvement) and limits it to finding just directories (=unknown improvement).
Note the following does NOT remove integrated Hypervisor objects - I did try adding uni/comp/prov-VMware
to the list of paths, and the script DID try to remove my VMware VMM domain, but it couldn't remove it for some reason.
apic1# bash
admin@apic1:~> for p in uni uni/infra uni/infra/funcprof
> do
> cd /mit/$p
> for i in `find . -maxdepth 1 -name "*TEMP*" -type d`
> do
> echo Removing $i
> modelete $i
> done
> moconfig commit
> done
I just tried the above on my system - but stuck a date
command before and after (i.e. I typed date ; for p in uni uni/infra uni/infra/funcprof ; do cd /mit/$p; for i in `find . -maxdepth 1 -type d -name "*T17:*"`; do echo Removing $i; modelete $i; done; moconfig commit; done ; date
) and got:
Thu Oct 20 06:46:31 AEDT 2022 Removing ./l3dom-T17:WAN_L3Dom This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./phys-T17:MappedVLANs_PhysDom This command is being deprecated on APIC controller, please use NXOS-style equivalent command This command is being deprecated on APIC controller, please use NXOS-style equivalent command Committing mo 'uni/phys-T17:MappedVLANs_PhysDom' Committing mo 'uni/l3dom-T17:WAN_L3Dom' All mos committed successfully. Removing ./vlanns-[T17:WAN_VLAN.Pool]-static This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./vlanns-[T17:vC_VLAN.Pool]-dynamic This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./vlanns-[T17:MappedVLANs_VLAN.Pool]-static This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./nprof-T17:L2201_LeafProf This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./accportprof-T17:L2202_IntProf This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./nprof-T17:L2202_LeafProf This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./nprof-T17:L2201..2202VPCs_LeafProf This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./accportprof-T17:L2201_IntProf This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./accportprof-T17:L2201..2202VPCs_IntProf This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./attentp-T17:HostLinks_AAEP This command is being deprecated on APIC controller, please use NXOS-style equivalent command This command is being deprecated on APIC controller, please use NXOS-style equivalent command Committing mo 'uni/infra/attentp-T17:HostLinks_AAEP' Committing mo 'uni/infra/accportprof-T17:L2201..2202VPCs_IntProf' Committing mo 'uni/infra/accportprof-T17:L2201_IntProf' Committing mo 'uni/infra/nprof-T17:L2201..2202VPCs_LeafProf' Committing mo 'uni/infra/nprof-T17:L2202_LeafProf' Committing mo 'uni/infra/accportprof-T17:L2202_IntProf' Committing mo 'uni/infra/nprof-T17:L2201_LeafProf' Committing mo 'uni/infra/vlanns-[T17:MappedVLANs_VLAN.Pool]-static' Committing mo 'uni/infra/vlanns-[T17:vC_VLAN.Pool]-dynamic' Committing mo 'uni/infra/vlanns-[T17:WAN_VLAN.Pool]-static' All mos committed successfully. Removing ./accportgrp-T17:SA.Host_APPG This command is being deprecated on APIC controller, please use NXOS-style equivalent command Removing ./accbundle-T17:L2201..2202:1:47_VPCIPG This command is being deprecated on APIC controller, please use NXOS-style equivalent command This command is being deprecated on APIC controller, please use NXOS-style equivalent command Committing mo 'uni/infra/funcprof/accbundle-T17:L2201..2202:1:47_VPCIPG' Committing mo 'uni/infra/funcprof/accportgrp-T17:SA.Host_APPG' All mos committed successfully. Thu Oct 20 06:48:07 AEDT 2022
So 06:48:07-06:46:31=00:01:36 which is not too shabby
I really don't think the This command is being deprecated on APIC controller, please use NXOS-style equivalent command
message makes any difference. That message has been around since approx v1.1 but still works
If you want more speed, better to use the APIs and write a python program - which is essentially the conclusion YOU came to when you said
thinking about collecting DNs and simply POSTing them.
10-20-2022 01:28 AM
>So 06:48:07-06:46:31=00:01:36 which is not too shabby
Agree, maybe there is some issue with our environment. It took more than 4 hours, but it was still going on. So it could be a different case.
>I really don't think the This command is being deprecated on APIC controller, please use NXOS-style equivalent command message makes any difference. That message has been around since approx v1.1 but still works
Noted. Good to know about this. Thank you.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide