Esempio n. 1
0
#!/usr/bin/env python

from __future__ import with_statement
from __future__ import print_function
import redis
from json import dumps
import cgi
import cgitb
from common import authorize

cgitb.enable()
email = authorize()
form = cgi.FieldStorage()

d = {}

try:
    d['command'] = form.getfirst('command')
    d['username'] = email
    d['constellation'] = form.getfirst('constellation')
    d['machine'] = form.getfirst('machine')

    if d['command'] == 'update_tc':
        d['targetPacketLatency'] = form.getfirst('targetPacketLatency')
    else:
        print('tc_cmd.py Incorrect command (%s)' % (d['command']))
except Exception, e:
    print("Error processing traffic shaping commands [%s]" % d)

s = dumps(d)
Esempio n. 2
0
import collections

from common import UserDatabase


cgitb.enable()


def log(msg):
    red = redis.Redis()
    red.publish("cloudsim_log", msg)


from common import  authorize, ConfigsDb

email = authorize("officer")


print('Content-type: application/json')
print('\n')

cdb = ConfigsDb(email)

admin_configs = ['vpc_micro_trio', ]  # 'cloudsim', ]


configs = cdb.get_configs()
udb = UserDatabase()

if not udb.has_role(email, "admin"):
    for name in configs.keys():
Esempio n. 3
0
#!/usr/bin/env python

from __future__ import with_statement
from __future__ import print_function
import os
import cgi
import cgitb
import json

import redis
from common import authorize, UserDatabase

cgitb.enable()

email = authorize("admin")  # ("officer")
udb = UserDatabase()
role = udb.get_role(email)

form = cgi.FieldStorage()
method = os.environ['REQUEST_METHOD']
q_string = os.environ['QUERY_STRING']

red = redis.Redis()

user_name = None

red.publish("cloudsim_log", "query string %s" % q_string)
try:
    user_name = form.getfirst("user", None)
except Exception, e:
    # bug? cgi.FieldStorage() does not work for http delete
Esempio n. 4
0
#!/usr/bin/env python

from __future__ import with_statement
from __future__ import print_function

import cgitb
import os
import sys
cgitb.enable()

from common import authorize

TEAM_LOGIN_SSH_FNAME = '/var/www/cloudsim_ssh.zip'

email = authorize("admin")

#form = cgi.FieldStorage()
#filename = form.getfirst('file')

short_name = os.path.split(TEAM_LOGIN_SSH_FNAME)[1]
print("Content-Type: application/octet-stream")
print("Content-Disposition: attachment; filename=%s" % short_name)
print("")

f = open(TEAM_LOGIN_SSH_FNAME, 'rb')
while True:
    data = f.read(4096)
    sys.stdout.write(data)
    if not data:
        break