Skip to content

Commit

Permalink
last synchro and copy from svn but not least
Browse files Browse the repository at this point in the history
  • Loading branch information
schevalier committed Mar 19, 2014
1 parent 83632f3 commit 1e29a68
Show file tree
Hide file tree
Showing 55 changed files with 10,078 additions and 17,996 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Section: 5xx-blueprint

cat <<EOF >> $ROOT_DIR/conpaas_install
cecho "===== install packages required by blueprint ====="

cecho "===== still TODO: set up all packages required by blueprint ====="
exit 1 # remove this line after setting up all packages required by blueprint

# remove cached .debs from /var/cache/apt/archives to save disk space
apt-get clean
EOF

6 changes: 3 additions & 3 deletions conpaas-client/cps/htcondor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ def info(self, service_id):
hub = nodes['hub'][0]
params = { 'serviceNodeId': hub }
details = self.callmanager(service['sid'], "get_node_info", False, params)
print "hub url: ", "http://%s:4444" % details['serviceNode']['ip']
print "node url:", "http://%s:3306" % details['serviceNode']['ip']
print "hub url: ", "http://%s:4444" % details['serviceNode']['ip'], "\tVMid: %s" % details['serviceNode']['id']
print "node url:", "http://%s:3306" % details['serviceNode']['ip'], "\tVMid: %s" % details['serviceNode']['id']

if 'node' in nodes:
# Multiple nodes
for node in nodes['node']:
params = { 'serviceNodeId': node }
details = self.callmanager(service['sid'], "get_node_info", False, params)
print "node url:", "http://%s:3306" % details['serviceNode']['ip']
print "node url:", "http://%s:3306" % details['serviceNode']['ip'], "\tVMid: %s" % details['serviceNode']['id']

def usage(self, cmdname):
BaseClient.usage(self, cmdname)
Expand Down
6 changes: 3 additions & 3 deletions conpaas-client/cps/selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def info(self, service_id):
hub = nodes['hub'][0]
params = { 'serviceNodeId': hub }
details = self.callmanager(service['sid'], "get_node_info", False, params)
print "hub url: ", "http://%s:4444" % details['serviceNode']['ip']
print "node url:", "http://%s:3306" % details['serviceNode']['ip']
print "hub url: ", "http://%s:4444" % details['serviceNode']['ip'], "\tVMid: %s" % details['serviceNode']['id']
print "node url:", "http://%s:3306" % details['serviceNode']['ip'], "\tVMid: %s" % details['serviceNode']['id']

if 'node' in nodes:
# Multiple nodes
for node in nodes['node']:
params = { 'serviceNodeId': node }
details = self.callmanager(service['sid'], "get_node_info", False, params)
print "node url:", "http://%s:3306" % details['serviceNode']['ip']
print "node url:", "http://%s:3306" % details['serviceNode']['ip'], "\tVMid: %s" % details['serviceNode']['id']

def usage(self, cmdname):
BaseClient.usage(self, cmdname)
Expand Down
41 changes: 39 additions & 2 deletions conpaas-client/cps/xtreemfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from cps.base import BaseClient

import base64

class Client(BaseClient):

def info(self, service_id):
Expand Down Expand Up @@ -45,6 +47,8 @@ def usage(self, cmdname):
print " list_volumes serviceid"
print " create_volume serviceid vol_name"
print " delete_volume serviceid vol_name"
print " get_client_cert serviceid passphrase adminflag filename"
print " get_user_cert serviceid user group passphrase adminflag filename"
print " list_policies serviceid policy_type # [ osd_sel | replica_sel | replication ]"
print " set_policy serviceid policy_type vol_name policy [factor]"
print " toggle_persistent serviceid"
Expand All @@ -57,8 +61,9 @@ def main(self, argv):
command = argv[1]

if command in ( 'add_nodes', 'remove_nodes', 'list_volumes',
'create_volume', 'delete_volume', 'list_policies',
'set_policy', 'toggle_persistent', 'set_osd_size' ):
'create_volume', 'delete_volume', 'get_client_cert',
'get_user_cert', 'list_policies', 'set_policy',
'toggle_persistent', 'set_osd_size' ):
try:
sid = int(argv[2])
except (IndexError, ValueError):
Expand Down Expand Up @@ -115,6 +120,38 @@ def main(self, argv):
else:
print "Volume", params['volumeName'], "deleted"

if command == 'get_client_cert':
try:
params = { 'passphrase': argv[3],
'adminflag': str(argv[4]).lower() in ("yes", "y", "true", "t", "1") }
filename = argv[5]
except IndexError:
self.usage(argv[0])
sys.exit(0)

res = self.callmanager(sid, 'get_client_cert', True, params)
if 'error' in res:
print res['error']
else:
open(filename, 'wb').write(base64.b64decode(res['cert']))

if command == 'get_user_cert':
try:
params = { 'user': argv[3],
'group': argv[4],
'passphrase': argv[5],
'adminflag': str(argv[6]).lower() in ("yes", "y", "true", "t", "1") }
filename = argv[7]
except IndexError:
self.usage(argv[0])
sys.exit(0)

res = self.callmanager(sid, 'get_user_cert', True, params)
if 'error' in res:
print res['error']
else:
open(filename, 'wb').write(base64.b64decode(res['cert']))

if command == 'list_volumes':
res = self.callmanager(sid, 'listVolumes', False, {})
if 'error' in res:
Expand Down
13 changes: 9 additions & 4 deletions conpaas-director/cpsdirector/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import socket
import urllib2
import simplejson
import uuid

from cpsdirector.common import log
from cpsdirector.common import build_response
Expand Down Expand Up @@ -597,9 +598,10 @@ def get_service_manifest(self, service):
if 'StartupInstances' not in tmp:
tmp['StartupInstances'] = {}

tmp['StartupInstances']['resume'] = []
tmp['StartupInstances']['resume'] = {}
tmp['StartupInstances']['resume']['nodes'] = []

for node in snapshot:
for node in snapshot['nodes']:
node_filename = self.__get_node_archive_filename(node)
data = base64.b64decode(node.pop('data'))
open(node_filename, 'wb').write(data)
Expand All @@ -608,7 +610,9 @@ def get_service_manifest(self, service):
node['archive'] = '%s/download_data/%s' % (get_director_url(),
basename(node_filename))

tmp['StartupInstances']['resume'].append(node)
tmp['StartupInstances']['resume']['nodes'].append(node)

tmp['StartupInstances']['resume']['manager'] = snapshot['manager']

return tmp

Expand All @@ -632,7 +636,8 @@ def startup(self, service_id, cloud='default'):

def start(self, json, appid):
try:
to_resume = { 'nodes': json['StartupInstances']['resume'] }
to_resume = { 'nodes': json['StartupInstances']['resume']['nodes'],
'manager' : json['StartupInstances']['resume']['manager'] }
except KeyError:
to_resume = {}

Expand Down
43 changes: 34 additions & 9 deletions conpaas-director/cpsdirector/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class User(db.Model):
password = db.Column(db.String(256))
created = db.Column(db.DateTime)
credit = db.Column(db.Integer)
uuid = db.Column(db.String(80))

def __init__(self, **kwargs):
# Default values
Expand All @@ -115,15 +116,22 @@ def to_dict(self):
'email': self.email, 'affiliation': self.affiliation,
'password': self.password, 'credit': self.credit,
'created': self.created.isoformat(),
'uuid': self.uuid,
}


def get_user(username, password):
"""Return a User object if the specified (username, password) combination
is valid."""
log('user login attempt with username %s' % username)
return User.query.filter_by(username=username,
password=hashlib.md5(password).hexdigest()).first()

def get_user_by_uuid(uuid):
"""Return a User object if the specified uuid is found."""
log('uuid login attempt with uuid %s' % uuid)
return User.query.filter_by(uuid=uuid).first()

from cpsdirector.application import Application


Expand All @@ -133,8 +141,7 @@ def list_users():
"""
return User.query.all()


def create_user(username, fname, lname, email, affiliation, password, credit):
def create_user(username, fname, lname, email, affiliation, password, credit, uuid):
"""Create a new user with the given attributes. Return a new User object
in case of successful creation. None otherwise."""
new_user = User(username=username,
Expand All @@ -143,7 +150,8 @@ def create_user(username, fname, lname, email, affiliation, password, credit):
email=email,
affiliation=affiliation,
password=hashlib.md5(password).hexdigest(),
credit=credit)
credit=credit,
uuid=uuid)

app = Application(user=new_user)

Expand All @@ -163,13 +171,28 @@ def login_required(fn):
def decorated_view(*args, **kwargs):
username = request.values.get('username', '')
password = request.values.get('password', '')
uuid = request.values.get('uuid', '')
if uuid == '<none>':
uuid = ''

# Getting user data from DB
g.user = get_user(username, password)
# Getting user data from DB through username and password
if len(username.strip()):
log('authentication attempt for <%s, %s> ' % (username, password) )
g.user = get_user(username, password)

if g.user:
# user authenticated
return fn(*args, **kwargs)
if g.user:
# user authenticated through username and passwword
return fn(*args, **kwargs)

# authentication failed, try uuid
# Getting user data from DB through uuid
if len(uuid.strip()):
log('authentication attempt for <%s> ' % (uuid) )
g.user = get_user_by_uuid(uuid)

if g.user:
# user authenticated through uuid
return fn(*args, **kwargs)

# authentication failed
return build_response(simplejson.dumps(False))
Expand All @@ -181,7 +204,7 @@ def decorated_view(*args, **kwargs):
def new_user():
values = {}
required_fields = ('username', 'fname', 'lname', 'email',
'affiliation', 'password', 'credit')
'affiliation', 'password', 'credit', 'uuid')

log('New user "%s <%s>" creation attempt' % (
request.values.get('username'), request.values.get('email')))
Expand All @@ -196,6 +219,8 @@ def new_user():
return build_response(jsonify({
'error': True, 'msg': '%s is a required field' % field,
}))
if field == 'uuid' and values[field] == '<none>':
values[field] = ''

# check if the provided username already exists
if User.query.filter_by(username=values['username']).first():
Expand Down
6 changes: 6 additions & 0 deletions conpaas-director/director.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ CERT_DIR = /etc/cpsdirector/certs

# OPENNEBULA_VERSION = 3.8

# specify COST_PER_TIME as currency amount / ATU (in seconds)
# so $ 6.00 / 3600 is 6 dollar per hour (or part thereof)
# and $ 1.00 / 600 is 1 dollar per 10 minutes (or part thereof)
COST_PER_TIME = $ 6.00/3600
MAX_VMS = 9

[director]
DEBUG = true
DATABASE_URI = sqlite:////etc/cpsdirector/director.db
Expand Down
15 changes: 15 additions & 0 deletions conpaas-director/director.cfg.multicloud-example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ OS_ARCH = x86_64
OS_ROOT = hda
DISK_TARGET = hda
CONTEXT_TARGET = hdc
# specify COST_PER_TIME as currency amount / ATU (in seconds)
# so $ 6.00 / 3600 is 6 dollar per hour (or part thereof)
# and $ 1.00 / 600 is 1 dollar per 10 minutes (or part thereof)
COST_PER_TIME = $ 1.00/600
MAX_VMS = 9

# Here we specify the names of our additional clouds
OTHER_CLOUDS = ec2virginia, amsterdam
Expand All @@ -36,6 +41,11 @@ KEY_NAME = my_keyname
REGION = ec2.us-east-1.amazonaws.com
IMAGE_ID = ami-bb780cd2
SIZE_ID = t1.micro
# specify COST_PER_TIME as currency amount / ATU (in seconds)
# so $ 6.00 / 3600 is 6 dollar per hour (or part thereof)
# and $ 1.00 / 600 is 1 dollar per 10 minutes (or part thereof)
COST_PER_TIME = $ 12.00/3600
MAX_VMS = 9

[amsterdam]
# We also have a data center in Amsterdam with a running OpenNebula installation
Expand All @@ -54,6 +64,11 @@ OS_ARCH = x86_64
OS_ROOT = hda
DISK_TARGET = hda
CONTEXT_TARGET = hdc
# specify COST_PER_TIME as currency amount / ATU (in seconds)
# so $ 6.00 / 3600 is 6 dollar per hour (or part thereof)
# and $ 1.00 / 600 is 1 dollar per 10 minutes (or part thereof)
COST_PER_TIME = $ 6.00/3600
MAX_VMS = 9


[director]
Expand Down
Loading

0 comments on commit 1e29a68

Please sign in to comment.