Sunday, March 29, 2009

making a java application for the approval client

I will put here a link to a tar to the packages and source files that I found and am using to get the Approval Client running.

here's a link to the source and lib files that i'm using:

http://students.cs.byu.edu/~davidw/commons-codec-1.2.zip

In there, just link the .jar files in your project that you're using and make sure that you put the com and org files in the src directory.

The interface is a bit different than what I'm used to with boto. The AmazonSQS interface and the AmazonSQSClient classes are both classes that I used to communicate with sqs.

Sunday, February 15, 2009

programming the app server

I wish I had done this earlier. While doing the app server, I had to change where my web server was posting to. I would go into my code and just change the url in all of the six or so places every time I needed to change where it was posting to. I decided later that in my user-data script, I would create a python file that would basically return the app server url that the other files in the web server could call to get the url. I wish I had done this earlier rather than later.

Saturday, February 7, 2009

simpledb queries

here's a helpful page on how to do simpledb queries the right way.

http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide/index.html?UsingQuerySampleDataset.html

Thursday, February 5, 2009

some lab 3 stuff

OK.

Lab 3 is not documented very well. I'll try to correct some things here:

in forming your json, on the appserver page, it has SINGLE QUOTES around the keys in the json. in using simplejson, this is not correct. simplejson will not interpret it correctly if they're not DOUBLE QUOTES.

here are a line on how to get things from s3:
sdb = boto.connect_sdb(KEY, SECRET KEY)
imageDomain = sdb.get_domain('picture')

items = sdb.query('picture', "['ratesort' < '" + nextratesort + "'] sort 'ratesort' desc", 11)
for key in items:
item = imageDomain.get_item(key)

what the query returns back seems to be a list of the keys into the domain. you can use these keys to get individual items out as i've done above.

Edit: I'm not sure exactly which ones of the values of the json need to have quotes around them, but i got a few errors because at least a few didn't have quotes, so I put quotes around all of mine to avoid the error.

Wednesday, February 4, 2009

A couple of things about project three

I know that one of the domains to access simpledb is "pictures" (case matters).

Here's some code that

sdb = boto.connect_sdb(ACCESS KEY, SECRET ACCESS KEY) # these keys may or may not be necessary... i saw some examples iwth them and some without them.
imageDomain = sdb.get_domain('picture')

with this, you can loop over all the keys in the domain and get information out.

Tuesday, February 3, 2009

fix to the load balancer registration

I found out that my ami had to register itself automatically with the load balancer.

Basically, I found a web site that would tell me my public ip address, did a curl -s on this web site to get the response back, pipe that into grep and save that to a file. i do the same thing with ifconfig (the first the that comes back should be the private ip of the ami). i load these as strings into my program and do a wget on the address to register with the load balancer. my lines in my program look something like this:

os.system("curl -s http://www.ipaddress.org | egrep -m1 -o \'[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\' > /tmp/publicip.out")

then i load in the first line of /tmp/publicip.out into a variable in the program, concat that onto the end of a string and wget the loadbalancer url with that.

finding the public and private ip addresses

To find the public ip address, i took the number from the dns name, removed teh dashes adn inserted '.'s. ec2-75-101-229-61.compute-1.amazonaws.com became 75.101.229.61. to find the private ip address, i logged onto the box and typed ifconfig. the first address that looked like an ip address was my private ip address. mine started iwth a 10.

curl for the /submit file

I couldn't get the web server to work with urllib, and neither could I get it to work with pycurl. I kept on getting an invalid arguments error back from the server.

First, no matter what I did, I had to save my file to the server by using the following line of code:
open(randomimagename, 'wb').write(f['image'].file.read())

People that want to use pycurl should be able to send a response to teh server by using the following code. However, this code did not work on my server and will need to be changed in order to get it to work:

import pycurl
pf = [('submituser', f['submituser']), ('tags', f['tags']), ('description', f['description']), ('image', (pycurl.FORM_FILE, randomimagename)) ]
c = pycurl.Curl()
c.setopt(c.URL, "http://www.python.org/")
c.setopt(c.POST, 1)
c.setopt(c.HTTPPOST
c.perform()
c.close()

You can get the response from pycurl by using the following code:
import StringIO
b = StringIO.StringIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)
This code goes before you make the perform() call.


This line goes after you make the perform() call.
print b.getvalue()


However, this approach did not work for me. I ended up just making a system call to the curl command. This command works about the same way. Here's what I did:

import os;
os.system('curl -ivvv -X POST -F submituser=DavidW -F description=coolness -F
tags=foo -F image=@yellow_corvette.jpg
http://imaj-app.lddi.org:8010/submitimage')

Of course, things may need to be changed in this line to make it work for the actual server, but I was able to change the variables and customize them to get tehm to work for my specific case.

Monday, February 2, 2009

$('imagerater') is not a function

I got this error because I didn't include the .js files in the file. if you download these and make sure to include these, it'll work

another problem that i ran into was that my mod_python handler was not serving these with the default-handler. i needed to add the following lines in my http.conf file:

<Files *.js>
SetHandler default-handler
</Files>

second project

I've come up with a problem during the second project. whenever i try to use submitimage, it doesn't work. it gives me an invalidarguments error back whenever i try to use it. i have no clue why this happens. however, i consulted with a fellow class mate and he let me try his code on my server, but it doesn't help the problem even though he says that his code works. it's kind of a weird problem.

i had ap roblem that i fixed. i got it because i didn't copy over the .js files from the ta web site.

Friday, January 30, 2009

up till now

I just found out that I was supposed to have a blog about the class.

The first assignment went rather slowly. It took quite awhile to learn the different things necessary to do the project.

The project was to start an ami, put the things I needed to on the ami, install bootsrapping code on the ami so that this bootstrapping code will download a user-data script and use that to bootstrap the server on startup to customize the instance.

I started wtih elasticfox and found out how to get elasticfox working. Afterwards, I had to get my keys right. It was a bit tricky to get that right because I had to use puttygen to generate dthe right private key from the file that I received.

After this happened, I needed to install things on my ami and tehn bundle it and upload it and register it. I was stuck on hwo to bundle it because the tutorial tha tI was looking at said that I needed to have the certificate and private key associated with my aws account. Since this information is shared within our class, I didnt' watn to generate a new public/private key pair. I had to go to class and ask for the public and private key pairs. A few days later, Devlin posted the pairs on the blog.

I struggled with different things happening in my user-data script. One thing I struggled with was that I couldn't see the warning or error messages generated if things went wrong in the user-data script. What more, it took me awhile to find out that the user-data script is executed from the / directory while it's downloaded to the /tmp directory. Everything done is done from the / directory. I struggled with different things of this.

In the end, I got it to work and cgi working. I was done with the lab.