Skip to content
Snippets Groups Projects
Commit 5a73f405 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Update licence and remove snfServer

parent 81d8c4c5
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2012-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup
setup(
......
#!/usr/bin/env python
# Copyright (C) 2012-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
import uuid
......
# Copyright (C) 2012-2014 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
This it the entry point for paste deploy .
......@@ -24,7 +37,5 @@ from snfOCCI import APIserver
# noinspection PyUnusedLocal
def main(global_config, **settings):
"""
This is the entry point for paste into the OCCI OS world.
"""
"""This is the entry point for paste into the OCCI OS world."""
return APIserver.MyAPP()
# Copyright 2012-2013 GRNET S.A. All rights reserved.
# Copyright (C) 2012-2013 GRNET S.A.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from snfOCCI.config import SERVER_CONFIG
......@@ -46,6 +28,7 @@ import json, yaml
# Compute Backend for snf-occi-server
class MyBackend(KindBackend, ActionBackend):
# Updating and Replacing compute instances not supported by Cyclades
......@@ -68,9 +51,7 @@ class ComputeBackend(MyBackend):
'''
def create(self, entity, extras):
# Creating new compute instance
try:
snf_network = extras['snf_network']
......@@ -166,16 +147,14 @@ class ComputeBackend(MyBackend):
else:
raise ce
entity.attributes['occi.compute.state'] = 'inactive'
entity.attributes['occi.core.id'] = str(info['id'])
entity.attributes['occi.compute.architecture'] = SERVER_CONFIG['compute_arch']
entity.attributes['occi.compute.cores'] = flavor.attributes['occi.compute.cores']
entity.attributes['occi.compute.memory'] = flavor.attributes['occi.compute.memory']
entity.actions = [infrastructure.STOP,
entity.actions = [
infrastructure.STOP,
infrastructure.SUSPEND,
infrastructure.RESTART]
......@@ -296,5 +275,3 @@ class ComputeBackend(MyBackend):
elif action == infrastructure.SUSPEND:
raise HTTPError(501, "This actions is currently no applicable")
# Copyright (C) 2012-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
......@@ -12,7 +12,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# import os
from paste import deploy
from snfOCCI.config import CNF
......
......@@ -16,6 +16,7 @@
from occi.backend import ActionBackend, KindBackend, MixinBackend
from occi.exceptions import HTTPError
class NetworkBackend(KindBackend, ActionBackend):
"""Network Backend for snf-occi-server"""
def create(self, entity, extras):
......@@ -47,4 +48,3 @@ class NetworkInterfaceBackend(KindBackend):
def replace(self, old, new, extras):
raise HTTPError(501, "Currently not supported.")
# Copyright (C) 2012-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from kamaki.clients.compute import ComputeClient
from kamaki.clients.cyclades import CycladesClient
from kamaki.cli.config import Config
......@@ -7,6 +22,7 @@ from occi.core_model import Mixin
from occi.backend import MixinBackend
from occi.extensions.infrastructure import RESOURCE_TEMPLATE, OS_TEMPLATE
class snfRegistry(registry.NonePersistentRegistry):
def add_resource(self, key, resource, extras):
......@@ -17,4 +33,5 @@ class snfRegistry(registry.NonePersistentRegistry):
super(snfRegistry, self).add_resource(key, resource, extras)
def set_hostname(self, hostname):
super(snfRegistry, self).set_hostname("https://okeanos-occi2.hellasgrid.gr:9000")
super(snfRegistry, self).set_hostname(
"https://okeanos-occi2.hellasgrid.gr:9000")
import functools
import os
import logging
LOG = logging.getLogger(__name__)
__all__ = ['Server', 'httplib', 'subprocess']
_configured = False
Server = None
httplib = None
subprocess = None
def configure_once(name):
"""Ensure that environment configuration is only run once.
If environment is reconfigured in the same way then it is ignored.
It is an error to attempt to reconfigure environment in a different way.
"""
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
global _configured
if _configured:
if _configured == name:
return
else:
raise SystemError("Environment has already been "
"configured as %s" % _configured)
LOG.info(_("Environment configured as: %s"), name)
_configured = name
return func(*args, **kwargs)
return wrapper
return decorator
@configure_once('eventlet')
def use_eventlet(monkeypatch_thread=None):
global httplib, subprocess, Server
import eventlet
from eventlet.green import httplib as _httplib
from eventlet.green import subprocess as _subprocess
from snfOCCI.snfServer import ssl_server
if monkeypatch_thread is None:
monkeypatch_thread = not os.getenv('STANDARD_THREADS')
eventlet.patcher.monkey_patch(all=False, socket=True, time=True,
thread=monkeypatch_thread)
Server = ssl_server.Server
httplib = _httplib
subprocess = _subprocess
@configure_once('stdlib')
def use_stdlib():
global httplib, subprocess
import httplib as _httplib
import subprocess as _subprocess
httplib = _httplib
subprocess = _subprocess
'''
Created on Aug 22, 2013
@author: nassia
'''
import eventlet
from eventlet import wsgi
from logging import getLogger
import ssl
import sys
import socket
import greenlet
import logging
#LOG = getLogger(__name__)
class Server(object):
"""Server class to manage multiple WSGI sockets and applications."""
def __init__(self, application, host=None, port=None, threads=1000):
self.application = application
self.host = host or '0.0.0.0'
self.port = port or 0
self.pool = eventlet.GreenPool(threads)
self.socket_info = {}
self.greenthread = None
self.do_ssl = False
self.cert_required = False
def start(self, key=None, backlog=128):
"""Run a WSGI server with the given application."""
# LOG.debug(('Starting %(arg0)s on %(host)s:%(port)s') %
print (('Starting %(arg0)s on %(host)s:%(port)s') %
{'arg0': sys.argv[0],
'host': self.host,
'port': self.port})
# TODO(dims): eventlet's green dns/socket module does not actually
# support IPv6 in getaddrinfo(). We need to get around this in the
# future or monitor upstream for a fix
info = socket.getaddrinfo(self.host,
self.port,
socket.AF_UNSPEC,
socket.SOCK_STREAM)[0]
_socket = eventlet.listen(info[-1],
family=info[0],
backlog=backlog)
if key:
self.socket_info[key] = _socket.getsockname()
# SSL is enabled
if self.do_ssl:
if self.cert_required:
cert_reqs = ssl.CERT_REQUIRED
else:
cert_reqs = ssl.CERT_NONE
sslsocket = eventlet.wrap_ssl(_socket, certfile=self.certfile,
keyfile=self.keyfile,
server_side=True,
cert_reqs=cert_reqs,
ca_certs=self.ca_certs)
_socket = sslsocket
self.greenthread = self.pool.spawn(self._run,
self.application,
_socket)
def set_ssl(self, certfile, keyfile=None, ca_certs=None,
cert_required=True):
self.certfile = certfile
self.keyfile = keyfile
self.ca_certs = ca_certs
self.cert_required = cert_required
self.do_ssl = True
print certfile, keyfile, ca_certs, cert_required
def kill(self):
if self.greenthread:
self.greenthread.kill()
def wait(self):
"""Wait until all servers have completed running."""
try:
self.pool.waitall()
except KeyboardInterrupt:
pass
except greenlet.GreenletExit:
pass
def _run(self, application, socket):
"""Start a WSGI server in a new green thread."""
print "IN HERE!!!!"
log = getLogger('eventlet.wsgi.server')
try:
eventlet.wsgi.server(socket, application, custom_pool=self.pool,
log = logging.basicConfig())
except Exception:
#LOG.exception(('Server error'))
print "Server error"
raise
# Copyright (C) 2013-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
Created on Jul 31, 2013
......@@ -39,36 +54,6 @@ ASTAVOMS_URL = 'https://okeanos-astavoms.hellasgrid.gr'
ASTAVOMS_TOKEN = 'Nothing for now'
#saferun.logger.setLevel(DEBUG)
#@saferun.saferun
#def test_and_log_astavoms(ssl_certs):
# astavoms = AstavomsClient(ASTAVOMS_URL, ASTAVOMS_TOKEN)
# saferun.logger.info('LALA 1')
# astavoms.astacert = '/etc/grid-security/certificates/TERENA-eScience-SSL-CA-3.pem'
# saferun.logger.info('LALA 2')
# saferun.logger.info('Authenticate this: {certs}'.format(certs=ssl_certs))
# saferun.logger.info('LALA 3')
# # Not tryied that yet, do it next
# from kamaki.clients.utils import https
# #https.patch_with_certs(CA_PATH)
# https.patch_ignore_ssl()
# r = astavoms.authenticate(**ssl_certs)
# from kamaki.clients.utils import https
# saferun.logger.info('SAFERUN RESPONSE: {0}'.format(json.dumps(r, indent=2)))
# return r
#@saferun.saferun
#def compare_results(old, new):
# saferun.logger.info('OLD: {old}\nNEW:{new}'.format(old=old, new=new))
# keydiff = set(old).symmetric_difference(new)
# saferun.logger.info('KEY DIFF: %s', keydiff)
# for k in set(old).intersection(new):
# ov, nv = old[k], new[k]
# msg = ' OK' if ov == nv else ' diff: %s != %s' % (ov, nv)
# saferun.logger.info('Check key %s ... %s' % (k, msg))
class VomsError():
"""Voms credential management error"""
......@@ -113,6 +98,7 @@ class VomsError():
self.code = code
self.title = title
class VomsAuthN():
"""Filter that checks for the SSL data in the reqest.
......@@ -167,7 +153,6 @@ class VomsAuthN():
'SSL data not verified',
details=CONTEXT_ENV)
with voms_helper.VOMS(VOMSDIR_PATH,
CA_PATH, VOMSAPI_LIB) as v:
......@@ -243,7 +228,6 @@ class VomsAuthN():
continue
params[k] = v
environ[PARAMS_ENV] = params
# print environ[PARAMS_ENV]
......@@ -277,7 +261,6 @@ class VomsAuthN():
user_dn, user_vo, user_fqans, voms_info['snf:token'],
voms_info['snf:project'])
def process_request(self, environ):
print "Inside process_request!!!!"
if not self.is_applicable(environ):
......@@ -307,4 +290,3 @@ class VomsAuthN():
return (
user_dn, user_vo, user_fqans, voms_info['snf:token'],
voms_info['snf:project'])
'''
Created on Jul 30, 2013
@author: nassia
'''
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Spanish National Research Council
......@@ -21,8 +16,6 @@ Created on Jul 30, 2013
import ctypes
#import M2Crypto
class _voms(ctypes.Structure):
_fields_ = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment