Commit b2db666d authored by Stavros Sachtouris's avatar Stavros Sachtouris

Sanitize config

parent b92a025b
......@@ -18,8 +18,8 @@ import uuid
from snfOCCI.registry import snfRegistry
from snfOCCI.compute import ComputeBackend, SNFBackend
from snfOCCI.config import (
SERVER_CONFIG, KAMAKI_CONFIG, VOMS_CONFIG, KEYSTONE_URL)
from snfOCCI import config
from snfOCCI.config import VOMS_CONFIG, KEYSTONE_URL
from snfOCCI import snf_voms
from snfOCCI.network import (
NetworkBackend, IpNetworkBackend, IpNetworkInterfaceBackend,
......@@ -172,7 +172,7 @@ class MyAPP(wsgi.Application):
resource.attributes['occi.core.id'] = key
resource.attributes['occi.compute.state'] = 'inactive'
resource.attributes['occi.compute.architecture'] = (
SERVER_CONFIG['compute_arch'])
config.COMPUTE['arch'])
resource.attributes['occi.compute.cores'] = str(
flavor['vcpus'])
resource.attributes['occi.compute.memory'] = str(flavor['ram'])
......@@ -273,7 +273,7 @@ class MyAPP(wsgi.Application):
except KeyError:
print "No project provided, go to plan B"
astakosClient = astakos.AstakosClient(
KAMAKI_CONFIG['astakos_url'], environ['HTTP_AUTH_TOKEN'])
config.KAMAKI['astakos_url'], environ['HTTP_AUTH_TOKEN'])
projects = astakosClient.get_projects()
user_info = astakosClient.authenticate()
user_uuid = user_info['access']['user']['id']
......@@ -285,11 +285,11 @@ class MyAPP(wsgi.Application):
break
if ENABLE_VOMS:
compClient = ComputeClient(
KAMAKI_CONFIG['compute_url'], environ['HTTP_AUTH_TOKEN'])
config.KAMAKI['compute_url'], environ['HTTP_AUTH_TOKEN'])
cyclClient = CycladesClient(
KAMAKI_CONFIG['compute_url'], environ['HTTP_AUTH_TOKEN'])
config.KAMAKI['compute_url'], environ['HTTP_AUTH_TOKEN'])
netClient = CycladesNetworkClient(
KAMAKI_CONFIG['network_url'], environ['HTTP_AUTH_TOKEN'])
config.KAMAKI['network_url'], environ['HTTP_AUTH_TOKEN'])
try:
# Up-to-date flavors and images
self.refresh_images(compClient, cyclClient)
......@@ -316,11 +316,11 @@ class MyAPP(wsgi.Application):
else:
print 'I have a token and a project, we can proceed'
compClient = ComputeClient(
KAMAKI_CONFIG['compute_url'], environ['HTTP_AUTH_TOKEN'])
config.KAMAKI['compute_url'], environ['HTTP_AUTH_TOKEN'])
cyclClient = CycladesClient(
KAMAKI_CONFIG['compute_url'], environ['HTTP_AUTH_TOKEN'])
config.KAMAKI['compute_url'], environ['HTTP_AUTH_TOKEN'])
netClient = CycladesNetworkClient(
KAMAKI_CONFIG['network_url'], environ['HTTP_AUTH_TOKEN'])
config.KAMAKI['network_url'], environ['HTTP_AUTH_TOKEN'])
# Up-to-date flavors and images
self.refresh_images(compClient, cyclClient)
......@@ -351,7 +351,7 @@ def application(env, start_response):
print "@ refresh_user authentication details"
pool = False
astakosClient = astakos.AstakosClient(
KAMAKI_CONFIG['astakos_url'], env['HTTP_AUTH_TOKEN'], use_pool=pool)
config.KAMAKI['astakos_url'], env['HTTP_AUTH_TOKEN'], use_pool=pool)
user_details = astakosClient.authenticate()
response = {
......@@ -402,7 +402,7 @@ def tenant_application(env, start_response):
print "@ refresh_user authentication details"
pool = False
astakosClient = astakos.AstakosClient(
KAMAKI_CONFIG['astakos_url'], env['HTTP_AUTH_TOKEN'], use_pool=pool)
config.KAMAKI['astakos_url'], env['HTTP_AUTH_TOKEN'], use_pool=pool)
user_details = astakosClient.authenticate()
response = {
......
......@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from snfOCCI.config import SERVER_CONFIG
from snfOCCI import config
from kamaki.clients import ClientError
......@@ -101,7 +101,7 @@ class ComputeBackend(MyBackend):
entity.attributes.update((
('occi.compute.state', 'inactive'),
('occi.core.id', str(info['id'])),
('occi.compute.architecture', SERVER_CONFIG['compute_arch']),
('occi.compute.architecture', config.COMPUTE['arch']),
(
'occi.compute.cores',
flavor.attributes['occi.compute.cores']),
......
SERVER_CONFIG = {
'port': 9000,
'hostname': 'snf-136122.vm.okeanos.grnet.gr',
'compute_arch': 'x86',
}
# Copy this file as config.py and fill in the appropriate values
REGISTRY = {
'hostname': 'https://okeanos-occi2.hellasgrid.gr:9000'
COMPUTE = {
'arch': 'x86',
}
KAMAKI_CONFIG = {
'compute_url': 'https://cyclades.okeanos.grnet.gr/compute/v2.0/',
'astakos_url': 'https://accounts.okeanos.grnet.gr/identity/v2.0/',
'network_url': 'https://cyclades.okeanos.grnet.gr/network/v2.0'
KAMAKI = {
'compute_url': 'https://cyclades.example.com/compute/v2.0/',
'astakos_url': 'https://accounts.example.com/identity/v2.0/',
'network_url': 'https://cyclades.example.com/network/v2.0'
}
VOMS_CONFIG = {
......@@ -21,7 +17,8 @@ VOMS_CONFIG = {
'ca_path': '/etc/grid-security/certificates/',
'cert_dir': '/etc/ssl/certs/',
'key_dir': '/etc/ssl/private/',
'token': 'rCfDs3MHoh_h6ZgA7KofBfxWGOeSuXeVVJ4US21I9FM'
'token': 'synnefo token'
}
KEYSTONE_URL = 'https://okeanos-astavoms.hellasgrid.gr'
KEYSTONE_URL = 'https://okeanos-astavoms.example.com'
HOSTNAME = 'https://this-host.example.com'
......@@ -27,4 +27,4 @@ class snfRegistry(registry.NonePersistentRegistry):
super(snfRegistry, self).add_resource(key, resource, extras)
def set_hostname(self, hostname):
super(snfRegistry, self).set_hostname(config.REGISTRY.get('hostname'))
super(snfRegistry, self).set_hostname(config.HOSTNAME)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment