Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: pending deletion report #21

Open
Be-El opened this issue Oct 12, 2018 · 1 comment
Open

Enhancement: pending deletion report #21

Be-El opened this issue Oct 12, 2018 · 1 comment

Comments

@Be-El
Copy link
Contributor

Be-El commented Oct 12, 2018

The adapter currently does not delete project or user. This is good, and I do not want anything to be deleted automatically (yet).

Nonetheless I need a simple way to cleanup and release resources. My approach would be writing a simple script to be used in cron jobs....it just prints the project name/id for all project that can be deleted according to their state/tags, The site admins can trigger their site specific cleanup process afterwards (or just paste the output into 'xargs openstack project purge'...).

Comments on this? Time to dedust my python skills?

@jkrue
Copy link
Member

jkrue commented Nov 8, 2018

If a project is removed(deleted) from the Perun database, the adapter disable the project and set the scratched field to 'True'.

$ openstack project show XXXXXXXXX
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| domain_id   | 5718303825c1496290a10ad936552ada |
| enabled     | False                            |
| flag        | perun_propagation                |
| id          | ff0ea67d51044d75987021c42a4c34dc |
| is_domain   | False                            |
| name        | XXXXXXXXXX                       |
| parent_id   | 5718303825c1496290a10ad936552ada |
| perun_id    | XXXXX                            |
| scratched   | True                             |
| tags        | []                               |
+-------------+----------------------------------+

Unfortuneatly the openstack cmdline tool is very limited when filtering output, extra fields are not supported. However this python script will do the job ....

#!/usr/bin/env python3

import os
from keystoneauth1.identity import v3
from keystoneauth1 import session
from keystoneclient.v3 import client


auth = v3.Password(username=os.environ["OS_USERNAME"],
                   password=os.environ["OS_PASSWORD"],
                   auth_url=os.environ["OS_AUTH_URL"],
                   project_name=os.environ["OS_PROJECT_NAME"],
                   user_domain_name=os.environ["OS_USER_DOMAIN_NAME"],
                   project_domain_name=os.environ["OS_USER_DOMAIN_NAME"])

sess = session.Session(auth=auth)

# Create keystone client
keystone = client.Client(session=sess)

for p in keystone.projects.list():
    if hasattr(p,'scratched') and p.scratched:
        print(p.id)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants