contrail_api_cli_extra.clean package

Module containing commands to clean bad resources.

Since these commands are sensitive as they will probably remove resources the contrail_api_cli.clean namespace must be loaded explicitely to be able to run the commands:

contrail-api-cli --ns contrail_api_cli.clean <command>

contrail_api_cli_extra.clean.orphaned_acl module

class contrail_api_cli_extra.clean.orphaned_acl.OrphanedACL(name)

Bases: contrail_api_cli.command.Command

Removes stale ACLs.

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>

Note

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_extra.clean.project module

class contrail_api_cli_extra.clean.project.FindOrphanedProjects(name)

Bases: contrail_api_cli.command.Command

Command to find projects that are still in contrail but no more in keystone.

Run:

contrail-api-cli find-orphaned-projects
class contrail_api_cli_extra.clean.project.PurgeProject(name)

Bases: contrail_api_cli_extra.utils.ConfirmCommand

Command to purge a project. All related resources are deleted.

Warning

This command is experimental and not fully tested.

This command works recursively by first trying to remove the project. If other resources are linked to the project the API will return a 409 response with all linked resources. The command will then try to delete these resources and so on until the project resource can be deleted.

Because of this no dry-run mode is possible.

To run the command:

contrail-api-cli --ns contrail_api_cli.clean purge-project project/uuid

contrail_api_cli_extra.clean.refs module

class contrail_api_cli_extra.clean.refs.CleanRefs(name)

Bases: contrail_api_cli_extra.utils.CheckCommand

Clean references in Contrail DB.

Broken refs can be found with gremlin.

The command expects a list of ids where the first ID is a valid resource while the second is a missing resource still referenced.

For example:

> g.V().hasLabel('routing_instance').not(has('_missing')).in().hasLabel('virtual_machine_interface').has('_missing').path().by(id).unfold().fold()
[ri_id, vmi_id, ri_id, vmi_id, ...]

This return a list of broken refs between RIs and VMIs where VMIs don’t exists or are incomplete.

We can clean then by running:

contrail-api-cli --ns contrail_api_cli.clean clean-refs --ref-type backref --target-type virtual_machine_interface ri_id vmi_id ri_id vmi_id ...

Or directly from a file:

contrail-api-cli --ns contrail_api_cli.clean clean-refs --ref-type backref --target-type virtual_machine_interface --resources-file file

Other examples:

# RIs without any parent VN
> g.V().hasLabel('routing_instance').not(has('_missing')).out('parent').hasLabel('virtual_network').has('_missing').path().by(id).unfold().fold()
> contrail-api-cli clean-refs --ref-type parent --target-type virtual_network ...

# ACLs without any SG
> g.V().hasLabel('access_control_list').not(has('_missing')).out('parent').hasLabel('security_group').has('_missing').path().by(id).unfold().fold()
> contrail-api-cli clean-refs --ref-type parent --target-type security_group ...

contrail_api_cli_extra.clean.rt module

class contrail_api_cli_extra.clean.rt.CleanRT(name)

Bases: contrail_api_cli_extra.utils.CheckCommand, contrail_api_cli_extra.utils.ZKCommand, contrail_api_cli_extra.utils.PathCommand

Removes 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]

If no route-target path is provided all RTs are considered. --check and --dry-run options are available.

You can exclude RT from the cleaning process:

contrail-api-cli --ns contrail_api_cli.clean clean-route-target --exclude <RT_FQNAME> --exclude <RT_FQNAME> [...]

contrail_api_cli_extra.clean.si module

class contrail_api_cli_extra.clean.si.CleanSIScheduling(name)

Bases: contrail_api_cli_extra.utils.CheckCommand, contrail_api_cli_extra.utils.PathCommand

On some occasion a SI VM can be scheduled on multiple virtual-routers.

In such case the command will remove extraenous VR links on the SI VM:

contrail-api-cli --ns contrail_api_cli.clean clean-si-scheduling [service-instance/uuid]

--check and --dry-run options are available.

class contrail_api_cli_extra.clean.si.CleanStaleSI(name)

Bases: contrail_api_cli_extra.utils.CheckCommand, contrail_api_cli_extra.utils.PathCommand

Clean stale service instances.

SIs are considered stale when:

  • LBaaS SI has no pool
  • LBaaS SI pool has no VIP
  • LBaas SI VIP has no instance-ip
  • SNAT SI has no logical-router

To run the command:

contrail-api-cli --ns contrail_api_cli.ns clean-stale-si [service-instance/uuid]

--check and --dry-run options are available.

contrail_api_cli_extra.clean.subnet module

class contrail_api_cli_extra.clean.subnet.CleanSubnet(name)

Bases: contrail_api_cli_extra.utils.CheckCommand

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.

To run the command:

contrail-api-cli --ns contrail_api_cli.clean clean-subnet