1.To remove the stale service instances:
Service intances must be associated with logical router or lbaas.
If service instance doesnt have the back referenec to logical router or lbaas, then its stale resource.
To clean this,
contrail-api-cli --ns contrail_api_cli.clean clean-stale-si --dry-run
contrail-api-cli --ns contrail_api_cli.clean clean-stale-si
2.To remove the stale route targets:
RTs that are not linked to a logical-router or a routing-instance are considered as staled and will be removed. If a ZK lock exists for the RT it will be removed.
contrail-api-cli --ns contrail_api_cli.clean clean-route-target --zk-server <ip> [route-target/uuid]
contrail-api-cli --ns contrail_api_cli.clean clean-route-target --exclude <RT_FQNAME> --exclude <RT_FQNAME>
Example dry-run
contrail-api-cli --ns contrail_api_cli.clean clean-route-target --dry-run --zk-server <zookeeper ip>
Example check
contrail-api-cli --ns contrail_api_cli.clean clean-route-target --check --zk-server <zookeeper ip>
Run(clear rt):
contrail-api-cli --ns contrail_api_cli.clean clean-route-target --zk-server <zookeeper ip>
ref: https://github.com/cloudwatt/contrail-api-cli-extra/blob/master/contrail_api_cli_extra/clean/rt.py
3. To remove stale subnets (clean subnet KV store)
Command to fix subnets KV store. This command works by first retrieving all the KV store, then it builds a dict which tends to reproduce a clean KV store based on the virtual-network back-refs objects present in the API. Finally
it compares the clean KV store with the current one and retrieves the keys of the stale entries to remove it in the current KV store.
contrail-api-cli --ns contrail_api_cli.clean clean-subnet --check
contrail-api-cli --ns contrail_api_cli.clean clean-subnet
4. To remove ACL(Security group rule which doesnt have parent or not associated with security group)
ACL is considered as stale if it has no parent
contrail-api-cli --ns contrail_api_cli.ns clean-orphaned-acl --cassandra-servers <ip1> <ip2>
Because of an API server limitation the ACLs are removed directly from the cassandra cluster. Thus, the cassandra cluster nodes IPs must be provided
contrail-api-cli --ns contrail_api_cli.clean clean-orphaned-acl --cassandra-servers <cassandra ip>
5. To find orphaned projects
Command to find projects that are still in contrail but no more in keystone
contrail-api-cli find-orphaned-projects