Monday, October 1, 2012

Renaming an OpenShift application

The OpenShift service from Red Hat lets you easily start and build web applications with common languages and frameworks such as Node.js, Ruby, Python, PHP, Perl, and Java.

For example, creating a new Django application is an easy 3 step procedure:

Create a python-2.6 application
rhc app create -a django -t python-2.6

Add this upstream repo
cd django
git remote add upstream -m master git://
git pull -s recursive -X theirs upstream master

Then push the repo to openshift
git push

So far so good.

Unfortunately, if you later decide to give your new application a more meaningful name you realize there is no command to do so directly. I've found this procedure quick and effective:

Create the new application with the correct name, using the -n option will not clone the new repo:
[giallu@novo django (master)]$ rhc-create-app -a newname -t python-2.6 -n

Note the git url it gives you in the output, then issue:
[giallu@novo django (master)]$ git remote set-url origin newurl

Push your repo to the new url
[giallu@novo django (master)]$ git push

Finally, remove the older repository:
[giallu@novo django (master)]$ rhc-ctl-app -a django -c destroy

Optionally, you can rename your top level directory to match the new application name.