ycoady / UVic-Distributed-Systems

Our extravaganza in building cool systems that involve multiple computational devices.
Creative Commons Zero v1.0 Universal
11 stars 3 forks source link

Lab 3: Hello GEE! #8

Open ycoady opened 9 years ago

ycoady commented 9 years ago

Post your results here!

Hoverbear commented 9 years ago

Dirty and simple.

def doAssignment():
    run('curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | gunzip > GeoLiteCity.dat')
    run('apt-get update && apt-get install -y geoip-bin wget')
    run("ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' > CONTAINER_IP")
    run("curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//' > HOST_IP")
    run("hostname > HOSTNAME")
    run("hostname | head -c 7 > SLICENAME")
    run("geoiplookup -f GeoLiteCity.dat $(cat HOST_IP) | awk -F '[, ]' '{print $(NF-6)}' > LAT")
    run("geoiplookup -f GeoLiteCity.dat $(cat HOST_IP) | awk -F '[, ]' '{print $(NF-4)}' > LNG")
    run("echo $(cat CONTAINER_IP) $(cat HOST_IP) $(cat HOSTNAME) $(cat SLICENAME) $(cat LAT) $(cat LNG)")
    run('curl "http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice=$(cat SLICENAME)&name=$(cat HOSTNAME)&ip=$(cat HOST_IP)&local=$(cat CONTAINER_IP)&lat=$(cat LAT)&lng=$(cat LNG)"')