We Discovered a Way of Using OpenShift PaaS Shell For Using the OpenStack Python Clients Including OpenStack Object Storage (Swift) Easily. Previously we have shown the running web shell on OpenShift. That is PHP cartridge. OpenStack Swift Python client is written in Python. Not exactly easy to run both PHP and Python on PaaS together and then execute command from front end. Without doubt, this is most complex App ever made on OpenShift PaaS. The setup is very easy on an IaaS – we have the full control of the server.
Using OpenShift PaaS Shell For OpenStack Python Clients : Installing Web Shell as PHP App
Using OpenShift PaaS Shell For OpenStack Python Clients : Activating Python on the Same Cartridge
SSH to that gear/application from your Mac or GNU/Linux computer. The ready to use command to do SSH looking like
ssh firstname.lastname@example.org will be found on OpenShift dashboard. The next commands are tricky :
virtualenv --no-site-packages $OPENSHIFT_DATA_DIR/env
Now you can install Python Swift Client with pip!
Using OpenShift PaaS Shell For OpenStack Python Clients : Installing Python Swift Client
Now run :
pip install python-swiftclient
from OpenShift client’s SSH screen. Swift Client will get activated and you can run swift command to check. Keep it mind – this is SSH. We need to run that swift command from frontend. Actually PHP will run the commands. The big difference between running command from SSH and our Web Shell is that – that
$OPENSHIFT_DATA_DIR will not work. So, to repeat the same commands at front end, you need to do a
pwd at SSH screen to get the real path of this –
$OPENSHIFT_DATA_DIR. You can understand, the commands will be very long due to bigger path.
Using OpenShift PaaS Shell For OpenStack Python Clients : Executing Commands
There is a bit cheating way to run the valid commands. These command syntax is valid for HP Cloud. Instead of running
swift list command, you have to run :
swift --os-auth-url https://api.example.com/v2.0 --os-tenant-name tenant --os-username user --os-password password list
We do not need the openstackrc file for this way. You are testing on OpenShift, you’ll use a real full server to use it. You do not need PHP bindings, Ruby Bindings for OpenStack Clients anymore. That official Python Clients will work fine. PHP bindings varies from providers to providers. It gives a huge pain.
We first tested on IaaS, obviously. It works and we can restrict the access to the web shell in various ways, limit the number of commands that can be executed etc. As you do not know what is the real path of
$OPENSHIFT_DATA_DIR for https://shell-abhishekghosh.rhcloud.com, it is not PUBLICLY usable.
Follow the Author of this article :