{"id":15981348,"url":"https://github.com/greg-hellings/cloud-cleaner","last_synced_at":"2025-03-17T20:31:01.253Z","repository":{"id":49559817,"uuid":"122278421","full_name":"greg-hellings/cloud-cleaner","owner":"greg-hellings","description":"A shade-based tool for cleaning up OpenStack resources","archived":false,"fork":false,"pushed_at":"2022-03-19T03:31:37.000Z","size":81,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T03:41:51.975Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/greg-hellings.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-21T01:14:19.000Z","updated_at":"2021-04-30T15:55:26.000Z","dependencies_parsed_at":"2022-08-20T23:31:03.900Z","dependency_job_id":null,"html_url":"https://github.com/greg-hellings/cloud-cleaner","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fcloud-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fcloud-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fcloud-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greg-hellings%2Fcloud-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greg-hellings","download_url":"https://codeload.github.com/greg-hellings/cloud-cleaner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243878488,"owners_count":20362433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T00:43:38.701Z","updated_at":"2025-03-17T20:31:00.928Z","avatar_url":"https://github.com/greg-hellings.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Travis CI status: [![Build Status](https://travis-ci.org/greg-hellings/cloud-cleaner.svg?branch=master)](https://travis-ci.org/greg-hellings/cloud-cleaner)\n\nCurrent code coverage: [![codecov](https://codecov.io/gh/greg-hellings/cloud-cleaner/branch/master/graph/badge.svg)](https://codecov.io/gh/greg-hellings/cloud-cleaner)\n\nCurrent PyPI Release: [![PyPI version](https://badge.fury.io/py/cloud-cleaner.svg)](https://badge.fury.io/py/cloud-cleaner)\n\n# Function\n\nCloud Cleaner is a utility designed to cleanup left over resources in an OpenStack environment. Often, when an\nOpenStack tenant is used for testing and ephemeral host provisioning, artifacts can be left over from previous runs\nfor a number of reasons. Perhaps a test run failed and did not include proper teardown procedures. Perhaps someone\nprovisioned a test resource but forgot about it or left the team and never tore it down.\n\nCloud Cleaner provides a way to specify that resources fitting certain criteria ought to be expunged from the\ntenant. This can help free up quota and limit the resources being utilized to only those that are actively necessary.\nThe primary component needing to be freed up are VMs, as these are resource intensive to maintain and are difficult\nto reuse properly. Other resource types can be added to Cloud Cleaner as the need arises.\n\n# Installation\n\nCloud Cleaner depends on several Python libraries, and supports Python versions 2.7 and 3.3+. The recommended way to\ninstall the application is through a Virtual Environment. To create a virtualenv do the following:\n\n#### Python 2\n`virtualenv cloud-cleaner`\n\n#### Python 3\n`pyvenv cloud-cleaner`\n\nOnce the virtualenv is created, you can install the application with the \"pip\" command, as follows:\n\n```bash\nsource cloud-cleaner/bin/activate\npip install -U cloud-cleaner\n```\n\nThis will install the latest version of Cloud Cleaner in your virtualenv. Likewise, if you already have it installed in\nthat virtualenv, this will update you to the latest installed version.\n\n# Configuration\n\nCloud Cleaner needs to know about your OpenStack endpoints. It uses the standard\n[openstack sdk](https://docs.openstack.org/openstacksdk/latest/user/config/configuration.html) mechanism to configure\nthe client for OpenStack access. This mechanism is in standard use across many OpenStack clients already, and by using\nthe same library, Cloud Cleaner should be accessible via the standard idioms OpenStack users are accustomed to using.\n\nThe three main mechanisms that openstack sdk uses are environment variables beginning with OS_, command line flags\nwhich can be seen by running the command `cloud-clean --help`, or through a yaml file documented as part of the standard\nopenstack sdk documentation. Check the docs linked above or elsewhere on the Internet to find more about how to\nproperly configure this app to connect to OpenStack.\n\n# Usage\n\nThe general structure of a call to Cloud Cleaner is\n\n`cloud-clean [global_options] {resource} [resource_options]`\n\nThe global options are things like verbosity, dry/wet run, OpenStack connection flags, email configurations, and the like. Calling the\nprogram with the \"--help\" or \"-h\" flag will give you the full list of those options. The resource is the type of object\nbeing cleaned up. The general \"--help\" option should also display all known resource types. These are such things as\n\"server\" - meaning exactly what it says on the tin or \"fip\" which is a floating IP address. Each resource type can\npossibly support options of its own to limit which items are actually deleted.\n\n## Global Options\n\nBy default the application runs very quietly. Adding a single -v flag should give enough output to make you comfortable\nthat the program is working as intended. If the details are of particular concern, then adding a second -v switch (or\nmaking the switch -vv) will give full debugging output. This amount of detail might be a bit \"over the top\", but can\nbe helpful if you really want to know what the program is doing\n\nBy default, the program only executes in dry-run mode. Thus, it will fetch a list of data from the OpenStack endpoint,\nprocess it, and output locally that it is working on the devices. However, it will not actually perform any alterations\nto your OpenStack environment unless run in force mode. This can be done by adding the global flag \"-f\" or \"--force\" to\nthe options. Doing so will result in the command performing the actual deletes after fetching and optionally filtering\nthe resources.\n\nCloud Cleaner also features email functionality, wherein the creator of a resource can be emailed if something\nhas or will be done to their resource. By default, the program will execute without sending any email. Email functionality\ncan be added by adding the global flag \"-e\" or \"--email\" to the options. If this is added, then the flags \"--sender\", \"--smtpN\",\nand \"--smtpP\" must be included with the email address to send from, the smtp server name to use, and the smtp port to use. Precisely\nwhat is emailed, or whether email functionality is included at all, will vary by resource.\n\n## Resource Specific Options\n\n### Servers\n\nSelect this type of resource by telling the cloud-clean script to operate on the \"server\" type. Servers currently\nsupport three options to filter them down from the full list.\n\nAge filtering, represented by the flag --age will search for any servers older than the specified age. If a server is half\nor more than half of the specified age, then its creator will be emailed a warning if email functionality is enabled. The age uses a\nbasic shorthand and can be measured in hours, days, weeks, months, or years. If you want to select all servers that are\nmore than 2 days old, add the option \"--age 2d\". If you wanted servers more than 2 weeks old, go with \"--age 2w\". In this example,\nany server older than 1 week and younger than 2 weeks would have the creator of the server emailed a warning message that their server\nmay be deleted at some point in the future. At the moment, there is no support for mixing and matching different time durations,\nso you can't say \"1d12h\", you would have to say \"36h\".\n\nName filtering, represented by the flag \"--name\" accepts a Python-compatible regular expression that will get matched\nagainst the name using Python's standard \"match\" function. Note that the \"match\" function defaults to matching against\nthe START of the name. So if you want to match \"any server that has the word 'test' anywhere in its name\" you need to\ninclude wildcard characters. An appropriate string would then be \".*test.*\". It is important to note that several of the\nspecial characters in a regular expression have special meanings in shells, as well. So you will need to escape those\ncharacters appropriately using quoting or slashes or whatever your shell environment uses. Details on the Python regex\nsyntax can be found [here](https://docs.python.org/3/howto/regex.html#regex-howto). The section titled \"The Backslash\nPlague\" can be safely ignored, as it applies only to people writing a regex inside of Python code. However, a similar\n\"plague\" could be experienced when writing out a complex regular expression in Bash.\n\nIn addition to selecting servers by name, it is possible to exclude them by name. Rather than crafting a complicated\nregular expression to select against such names, you can use the \"--skip-name\" option. It works exactly like the --name\noption, but inverts the selection by only taking servers that do not match.\n\nIt is possible to combine all three of these options. That is, if you want every server that is more than a week old,\nhas a name that begins with \"test-\" but does not contain the string \"keep\" anywhere in its name, you would construct the\ncommand like this:\n\n`cloud-clean server --age 1w --name \"test-.*\" --skip-name \".*keep.*\"`\n\n### Floating IPs\n\nSelect this type of resource by telling the cloud-clean script to operate on the \"fip\" type. Floating IP addresses\ncurrently allow for three different options.\n\nBy default, only floating IP addresses which are not in an attached state, according to the API, will be deleted. If\nall floating IPs should be considered, add the option \"--with-attached\" and the auto filtering will be skipped. This\noption is only a flag, and accepts no arguments.\n\nIf only floating IP addresses in a certain subnet should be considered, then the option \"--floating-subnet\" should be\nused. It takes as an argument a subnet mask definition. Arguments of this type are parsed using the Python library\ndocumented [here](https://docs.python.org/3/library/ipaddress.html) in both Python 2 (a backport of this code exists for\nPython 2.6+) and 3. In general, you can specify syntax such as \"10.0.0.0/8\" or \"10.0.0.0/255.0.0.0\".\n\nIf only floating IP addresses associated with a particular fixed IP subnet should be considered, then the option\n\"--static-subnet\" should be used. This uses the same syntax and parsing library as the --floating-subnet option above.\n\nAs of right now no email functionality is included for Floating IPs. Attempting to do so will incur an UnimplementedError.\nIt is recommended to not include any of the email flags when cleaning Floating IPs.\n\nAs one would expect, any combination of these options can be used. They will all be applied, and only floating IPs that\nmatch all conditions will be up for deletion.\n\nAlthough the library underlying IP address parsing can handle both IPv4 and IPv6, it may give issues when comparing a\nsubnet mask from one version against an IP address from the other version. If this raises a problem, the script can be\nenhanced with better handling of those cases. For now, it is a known and untested possibility that such mixing and\nmatching might result in the program crashing during filtering. If this happens, it will happen before any changes are\nmade to your OpenStack tenant.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreg-hellings%2Fcloud-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreg-hellings%2Fcloud-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreg-hellings%2Fcloud-cleaner/lists"}