diff --git a/README.rst b/README.rst index 9826c19..fd1a39d 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ why Need a reference application which is: - as minimal as possible re consumed resources -- touches as much of cloud services while created or used +- involves many cloud services while created or used - can be used in validation of user workloads surviving cloud LCM operations (update, upgrade) - allows for automation (has an API to work with from tests/scripts) @@ -17,11 +17,30 @@ Need a reference application which is: what ==== -Will consist of database backend (single node for now), actual data on Cinder -volume, multiple frontends with simple rest api behind Octavia -load balancer, possibly with custom TLS cert thru Barbican and domain name -via Designate. -Implemented as Heat template(s). +Current version consists of: + +- **Neutron** networks, subnets, routers and floating IPs for servers +- 3 **Nova** instances running MySQL Galera cluster as Database + + - Database files are kept on a separately attached **Cinder** volumes + +- 3 **Nova** instances running this app as API +- **Octavia** load balancer for Database instances +- **Octavia** load balancer for API instances +- DNS zones and records created for the instances in **Designate** + +**Keystone** and **Glance** are involved implicitly. + +Implemented two deployment scenarios: + +- as OpenStack Orchestration (**Heat**) template(s) +- as Terraform/OpenTofu configuration + +todo +---- + +- involve **Barbican** into the mix by using TLS-terminating + Octavia load balancer with user-supplied certificate. API ref ======= @@ -110,13 +129,22 @@ Show record by its id:: {"record": {"id": 2, "created_at": "2020-04-06T12:12:52.000", "host": "f1f66c9fb4b3", "data": null}} DELETE /records/{id} ------------------ +-------------------- -Delete record by its id:: +Delete single record by its id:: $ curl -X DELETE http:///records/2 +DELETE /records +--------------- + +Delete all records in one go, cleanup the database:: + + $ curl -X DELETE http:///records + + Used external components ======================== -`wait-for` script courtesy of https://github.com/Eficode/wait-for (MIT License) +`wait-for` script used in docker compose setup +courtesy of https://github.com/Eficode/wait-for (MIT License) diff --git a/docker-compose.yaml b/docker-compose.yaml index 570ec5d..3fb34dd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,14 +13,16 @@ services: build: . environment: OS_REFAPP_DB_URL: mysql+pymysql://refapp:supersecret@database:3306/refapp + volumes: + - ./wait-for:/wait-for:ro entrypoint: - - "./wait-for" + - "/wait-for" - "database:3306" - "--timeout=60" - "--" - "gunicorn" - "-c" - - "gunicorn.conf.py" + - "/opt/app/gunicorn.conf.py" - "openstack_refapp.app:create_app()" ports: - "8000:8000" diff --git a/openstack_refapp/records.py b/openstack_refapp/records.py index f11f88a..5c2c9ba 100644 --- a/openstack_refapp/records.py +++ b/openstack_refapp/records.py @@ -41,6 +41,12 @@ def on_post(self, req, resp): LOG.info(f"Created record {new_rec.id} with data {new_rec.data}") resp.media = new_rec.to_dict() + def on_delete(self, req, resp): + result = req.context.session.query(Record).delete() + if result: + req.context.session.commit() + LOG.warning("All record were deleted") + class RecordResource: def on_get(self, req, resp, id): diff --git a/pyproject.toml b/pyproject.toml index 889d327..dcac42c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,4 +3,4 @@ requires = ["setuptools>=30.3.0", "wheel", "pbr>=5.0.0"] [tool.black] line-length = 79 -target_version = ['py36'] +target_version = ['py38']