27
loading...
This website collects cookies to deliver better user experience
NOTE: Give me a little slack for the lack of anything important (documentation, testing frameworks, build structures, etc). This is for exercise purposes only.
metadata
for database work and object_store
for Swift operations). There is also a ui
directory which contains a Nuxt.js project for the user interface. This UI connects to the Flask Server via a REST API.openstacksdk
. This is the library that will give you the most consistent experience across services while also being widely supported by the OpenStack development team.import openstack
object_store
module in this project to outline the work done.username
, password
, project_id
, project_domain_id
, and auth_url
.cloud.yaml
file that lists the various clouds, projects, domains, credentials for many projects at once. You can then create different connections for each of the available credentials. More info here.clouds.yaml
file (if you have multiple identities in your project, the connection will error as you will need to specific which identity you want to use)_OS_CONNECTION = openstack.connect()
NOTE: Containers (or "buckets" in other cloud platforms) are a way to create segmentation within your data blocks. Swift also has the additional level of segmentation by creating "Folders" within your Containers.
__containers = [
cont.name
for cont in _OS_CONNECTION.object_store.containers(prefix=c.SWIFT_CONTAINER)
if cont.name == c.SWIFT_CONTAINER
]
if not __containers:
_OS_CONNECTION.object_store.create_container(name=c.SWIFT_CONTAINER)
NOTE: querying can be done to limit the number of data retrieved, but in most cases I can find, this is limited to the prefix
argument.
conn.upload_object(container, name, data)
object_store.py#L73
conn.delete_object(name, container)
object_store.py#L82
conn.objects(container, prefix=None)
object_store.py#L89 & object_store.py#L96
conn.download_object(name, container)
object_store.py#L104
git clone https://github.com/wsidl/openstack_swift_api.git
cd openstack_swift_api
# I do this almost everytime now... solves a lot of problems
pip install --upgrade pip
# If you don't have it installed yet, get Python Poetry
pip install poetry
# Setup a virtual environment, validate dependency versions,
# download and install those dependencies
poetry install
ssh app@<floating_ip> -L 0.0.0.0:5432:localhost:5432
.env
(the project uses python-dotenv
for looking up environment variables by file) and remove anything that doesn't assign a value and the "export " at the beginning of each line.grep -E "^export" openrc.sh | sed -E 's/^export (.*)="?([^"]*)"?$/\1=\2/g' > .env
OS_AUTH_URL=http://not.a.real.ip/identity
OS_PROJECT_ID=0123456789abcdef0123456789abcdef
OS_PROJECT_NAME=my_app
OS_USER_DOMAIN_NAME=Default
OS_PROJECT_DOMAIN_ID=default
OS_USERNAME=admin
OS_PASSWORD=$OS_PASSWORD_INPUT
OS_REGION_NAME=RegionOne
OS_INTERFACE=public
OS_IDENTITY_API_VERSION=3
$OS_PASSWORD_INPUT
with your admin
password. You'll also want to add some additional values for connecting to PostgreSQL:PG_HOST=<DevStack IP>
PG_PORT=<SSH Tunnel Port, defaults 5432>
PG_DBNAME=app
PG_USER=app
PG_PASSWORD=<DB Password>
poe dev
web_api
container is receiving files using unique hashes.