Commit b2db666d authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Sanitize config

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