IT related stuff

Testing Environment & Command-line Utility & Editor – OPW Experience with OpenStack Part 2


This is a follow up of the last post with more things I learned.

Testing Environment

It turned out the best option to testing out the OpenStack API is to install my own using DevStack. It’s understandable that cloud providers do not want to give general user too much power.

I end up install DevStack on a small Nectar instance, with the following specs:

Flavor:m1.small
RAM:4GB
VCPUs:1 VCPU
Disk:10GB

Everything went smoothly, although it says

stack.sh completed in 5035 seconds

I felt it took more than 2 hours.

Command-line Utility

Command-line tools can often save some time/effort doing repetitive tasks.

I was given a task which involves:

Identify which code samples here:

http://git.openstack.org/cgit/openstack/api-site/tree/api-ref/src/wadls/compute-api/src/api_samples

Do not have a corresponding WADL file here:

http://git.openstack.org/cgit/openstack/api-site/tree/api-ref/src/wadls/compute-api/src/ext

It doesn’t have to be done using script, “Ctrl + F” search in the browser can do the job, but I don’t like the sound of “manually” search the name of the file every time. So I prepared the following bash script, it doesn’t really save me much time (compare to the alternative), but certainly provides a reusable solution.

#!/bin/bash
BASE_PATH="/home/ubuntu/api-site/api-ref/src/wadls/compute-api/"
SAMPLE_PATH="/home/ubuntu/api-site/api-ref/src/wadls/compute-api/src/api_samples"
WADL_PATH="/home/ubuntu/api-site/api-ref/src/wadls/compute-api/src/ext"
SAMPLE_FILE="/tmp/sample.tmp"
WADL_FILE="/tmp/wadl.tmp"
TEMP_FILE="/tmp/missing_wadl.tmp"
BRANCH="latest"
JSON=".json"
XML=".xml"
WADL=".wadl"
cd $BASE_PATH
git checkout $BRANCH
git pull
ls $SAMPLE_PATH > $SAMPLE_FILE
ls $WADL_PATH > $WADL_FILE

# option -i means in place
sed -i "s/$JSON//g" "$SAMPLE_FILE"
sed -i "s/$XML//g" "$SAMPLE_FILE"
sed -i "s/$WADL//g" "$WADL_FILE"
uniq < $SAMPLE_FILE > $TEMP_FILE && mv $TEMP_FILE $SAMPLE_FILE

#select Case Insensitive, non matching lines from $SAMPLE_FILE
grep -i -v -f $WADL_FILE $SAMPLE_FILE
rm $WADL_FILE
rm $SAMPLE_FILE

It can be run as:

ubuntu@openstack:~$ sh missing_wadl.sh

Output:

Already on 'latest'
Already up-to-date.
addresses
address
all_extensions
extension
flavor-get-resp
flavors-list-resp
image-get-resp
image-metadata-get-resp
image-metadata-post-req
image-metadata-post-resp
image-metadata-put-req
image-metadata-put-resp
image-metadata-resp
image-meta-key-get
image-meta-key-put-req
image-meta-key-put-resp
images-details-get-resp
images-details-resp
images-list-get-resp
images-list-resp
limit-get-resp
NMN
os-assisted-volume-snapshots
os-availability-zone
os-baremetal-nodes
os-cell-capacities
os-cells
os-config-drive
OS-DCF
os-evacuate
os-extended-floating-ips
os-extended-quotas
os-extended-volumes
OS-EXT-SRV-ATTR
OS-EXT-STS
OS-EXT-VIF-NET
os-flavor-manage
os-flavor-swap
OS-FLV-EXT-DATA
os-fping
os-hide-server-addresses
os-multiple-create
os-quota-class-sets
OS-SCH-HNT
os-server-diagnostics
os-shelve
OS-SRV-USG
os-tenant-networks
os-user-data
os-user-quotas
public
server-action-changepassword
server-action-confirmresize
server-action-createimage
server-action-reboot
server-action-rebuild
server-action-rebuild-resp
server-action-rebuild
server-action-resize
server-action-revertresize
server-get-resp
server-ips-network-resp
server-ips-resp
server-metadata-all-req
server-metadata-all-resp
server-metadata-req
server-metadata-resp
server-post-req
server-post-resp
server-put-req2
server-put-req-ad
server-put-req
server-put-resp-ad
server-put-resp
servers-details-resp
servers-list-resp
versions-get-resp

Editor

I know on the wiki the recommended editor is Oxygen, but because of the extra trouble I have to go through to obtain the license (although Oxygen company sponsor OpenStack with some 6-month licenses, it’s still a pain to have to worry about the license every half a year) and not to mention that I have to learn different short cut key combinations and UI. I have decided to use the editors I used before, hence already installed.

Sublime is the overall winner.

About the license:

Sublime Text 2 may be downloaded and evaluated for free, however a license must be purchased for continued use. There is currently no enforced time limit for the evaluation.

The only problem I have encountered with the other editors (Context, Notepad++) is tab/white space. Their automatic indentation, the number of white spaces inserted when hit “tab” is just not right. Jenkins (the auto code testing & niceness checking system) shows a difference indentation to my editor, as it complains.

Well, there may be a way to configure the editors to add space as Jenkins expected, but I’m too lazy to find out, since all the above mentioned editors just happen to be already installed on one of the computer available to me.

Nono is another editor I’d like to mention, I only use it for small editing over the terminal on the remote server. I have heard about the powerful Vi, but the insertion mode & all the commands have to learn makes me nervous, guess there is not enough reason to force me into using it. Like I can still remember there was a course I took teaching you Agda, the only editor support it is Emacs (at that time at least).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s