import getopt
import sys
+from authconn import AuthException
from auth import Authenticator
from engine import Engine, EngineException
from osm_common.dbbase import DbException
__version__ = "0.1.3"
version_date = "Apr 2018"
database_version = '1.0'
+auth_database_version = '1.0'
"""
North Bound Interface (O: OSM specific; 5,X: SOL005 not implemented yet; O5: SOL005 implemented)
/<vnfInstanceId> O
/subscriptions 5 5
/<subscriptionId> 5 X
+ /pdu/v1
+ /pdu_descriptor O O
+ /<id> O O O O
/admin/v1
/tokens O O
/<id> O O
def __init__(self):
self.instance += 1
self.engine = Engine()
- self.authenticator = Authenticator(self.engine)
+ self.authenticator = Authenticator()
self.valid_methods = { # contains allowed URL and methods
"admin": {
"v1": {
},
}
},
+ "pdu": {
+ "v1": {
+ "pdu_descriptors": {"METHODS": ("GET", "POST"),
+ "<ID>": {"METHODS": ("GET", "POST", "DELETE", "PATCH", "PUT")}
+ },
+ }
+ },
"nsd": {
"v1": {
"ns_descriptors_content": {"METHODS": ("GET", "POST"),
return self._format_out(outdata, session)
- except EngineException as e:
+ except (EngineException, AuthException) as e:
cherrypy.log("index Exception {}".format(e))
cherrypy.response.status = e.http_code.value
return self._format_out("Welcome to OSM!", session)
else:
raise NbiException("Method {} not allowed for token".format(method), HTTPStatus.METHOD_NOT_ALLOWED)
return self._format_out(outdata, session)
- except (NbiException, EngineException, DbException) as e:
+ except (NbiException, EngineException, DbException, AuthException) as e:
cherrypy.log("tokens Exception {}".format(e))
cherrypy.response.status = e.http_code.value
problem_details = {
engine_item = "nslcmops"
if item == "vnfrs" or item == "vnf_instances":
engine_item = "vnfrs"
+ elif topic == "pdu":
+ engine_item = "pdus"
if engine_item == "vims": # TODO this is for backward compatibility, it will remove in the future
engine_item = "vim_accounts"
else:
raise NbiException("Method {} not allowed".format(method), HTTPStatus.METHOD_NOT_ALLOWED)
return self._format_out(outdata, session, _format)
- except (NbiException, EngineException, DbException, FsException, MsgException) as e:
+ except (NbiException, EngineException, DbException, FsException, MsgException, AuthException) as e:
cherrypy.log("Exception {}".format(e))
cherrypy.response.status = e.http_code.value
if hasattr(outdata, "close"): # is an open file
update_dict['server.socket_host'] = v
elif k1 in ("server", "test", "auth", "log"):
update_dict[k1 + '.' + k2] = v
- elif k1 in ("message", "database", "storage"):
+ elif k1 in ("message", "database", "storage", "authentication"):
# k2 = k2.replace('_', '.')
- if k2 == "port":
+ if k2 in ("port", "db_port"):
engine_config[k1][k2] = int(v)
else:
engine_config[k1][k2] = v
+
except ValueError as e:
cherrypy.log.error("Ignoring environ '{}': " + str(e))
except Exception as e:
logger_module.setLevel(engine_config[k1]["loglevel"])
# TODO add more entries, e.g.: storage
cherrypy.tree.apps['/osm'].root.engine.start(engine_config)
+ cherrypy.tree.apps['/osm'].root.authenticator.start(engine_config)
try:
cherrypy.tree.apps['/osm'].root.engine.init_db(target_version=database_version)
- except EngineException:
+ cherrypy.tree.apps['/osm'].root.authenticator.init_db(target_version=auth_database_version)
+ except (EngineException, AuthException):
pass
# getenv('OSMOPENMANO_TENANT', None)