Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWall89 committed Jun 17, 2020
2 parents cef6474 + e940354 commit 96c253d
Show file tree
Hide file tree
Showing 17 changed files with 1,491 additions and 348 deletions.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ cp nfvo_credentials_mock.json nfvo_credentials.json

### Environment with local database

Edit [docker-compose.yaml](docker-compose.yml) and disable site-inventory support.
Edit [docker-compose.yaml](docker-compose.yml) and disable iwf repository support.

```yaml
SITEINV: 'false'
IWFREPO: 'false'
```
Edit `adaptation-layer/seed/nfvo.json` and `adaptation-layer/seed/nfvo_credentials.json` (copied before)
Expand All @@ -50,16 +50,16 @@ docker-compose build
docker-compose up
```

### Environment with site-inventory (production)
### Environment with iwf repository

If [site-inventory](https://github.com/5GEVE/site-inventory) is available in your environment,
If [iwf-repository](https://github.com/5GEVE/iwf-repository) is available in your environment,
edit [docker-compose.yaml](docker-compose.yml) and change the environment variables for the `flask` service:

```yaml
SITEINV: 'true'
SITEINV_HOST: '192.168.17.20'
SITEINV_PORT: '8087'
SITEINV_INTERVAL: '300'
IWFREPO: 'true'
IWFREPO_HOST: '192.168.17.20'
IWFREPO_PORT: '8087'
IWFREPO_INTERVAL: '300'
```

Then, deploy with:
Expand All @@ -70,6 +70,16 @@ docker-compose build
docker-compose up
```

### Redis logical database mapping

In the following table we report all the Redis database indexes used in MSO-LO application and the relative purpose.

| Index | Purpose |
|- |- |
| 0 | Celery Background Task |
| 1 | NS last operationState |
| 2 | OSM token cache |

### Simple test

You can test the app with:
Expand Down
91 changes: 59 additions & 32 deletions adaptation_layer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@

import config
import driver.manager as manager
import siteinventory
import iwf_repository
import sqlite
import tasks
from error_handler import NfvoNotFound, NsNotFound, NsdNotFound, \
init_errorhandler, NfvoCredentialsNotFound, SubscriptionNotFound
from error_handler import Unauthorized, BadRequest, ServerError, NsOpNotFound
from error_handler import Unauthorized, BadRequest, ServerError, \
NsOpNotFound, Conflict, Unprocessable, Forbidden

SITEINV = os.getenv('SITEINV', 'false').lower()
IWFREPO = os.getenv('IWFREPO', 'false').lower()

logging.basicConfig(level=logging.INFO)
app = Flask(__name__)
app.config.from_object(config.Config)
init_errorhandler(app)

if SITEINV == 'true':
app.logger.info('using siteinventory')
database = siteinventory
if IWFREPO == 'true':
app.logger.info('using iwf repository')
database = iwf_repository
tasks.post_osm_vims.delay()
else:
app.logger.info('using sqlite')
Expand Down Expand Up @@ -77,10 +78,14 @@ def create_ns(nfvo_id):
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
abort(404, description=e.description)
except NsdNotFound as e:
except Forbidden as e:
abort(403, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound, NsdNotFound) as e:
abort(404, description=e.description)
except Conflict as e:
abort(409, description=e.description)
except Unprocessable as e:
abort(422, description=e.description)
except ServerError as e:
abort(500, description=e.description)

Expand Down Expand Up @@ -113,9 +118,7 @@ def get_ns(nfvo_id, ns_id):
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
abort(404, description=e.description)
except NsNotFound as e:
except (NfvoNotFound, NfvoCredentialsNotFound, NsNotFound) as e:
abort(404, description=e.description)
except ServerError as e:
abort(500, description=e.description)
Expand All @@ -132,9 +135,9 @@ def delete_ns(nfvo_id, ns_id):
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
abort(404, description=e.description)
except NsNotFound as e:
except Forbidden as e:
abort(403, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound, NsNotFound) as e:
abort(404, description=e.description)
except ServerError as e:
abort(500, description=e.description)
Expand All @@ -152,10 +155,14 @@ def instantiate_ns(nfvo_id, ns_id):
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
abort(404, description=e.description)
except NsNotFound as e:
except Forbidden as e:
abort(403, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound, NsNotFound) as e:
abort(404, description=e.description)
except Conflict as e:
abort(409, description=e.description)
except Unprocessable as e:
abort(422, description=e.description)
except ServerError as e:
abort(500, description=e.description)

Expand All @@ -172,10 +179,14 @@ def terminate_ns(nfvo_id, ns_id):
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
abort(404, description=e.description)
except NsNotFound as e:
except Forbidden as e:
abort(403, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound, NsNotFound) as e:
abort(404, description=e.description)
except Conflict as e:
abort(409, description=e.description)
except Unprocessable as e:
abort(422, description=e.description)
except ServerError as e:
abort(500, description=e.description)

Expand All @@ -192,10 +203,14 @@ def scale_ns(nfvo_id, ns_id):
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
abort(404, description=e.description)
except NsNotFound as e:
except Forbidden as e:
abort(403, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound, NsNotFound) as e:
abort(404, description=e.description)
except Conflict as e:
abort(409, description=e.description)
except Unprocessable as e:
abort(422, description=e.description)
except ServerError as e:
abort(500, description=e.description)

Expand All @@ -211,9 +226,7 @@ def get_op_list(nfvo_id):
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except NsNotFound as e:
abort(404, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
except (NfvoNotFound, NfvoCredentialsNotFound, NsNotFound) as e:
abort(404, description=e.description)
except ServerError as e:
abort(500, description=e.description)
Expand All @@ -230,9 +243,7 @@ def get_op(nfvo_id, nsLcmOpId):
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
abort(404, description=e.description)
except NsOpNotFound as e:
except (NfvoNotFound, NfvoCredentialsNotFound, NsNotFound, NsOpNotFound) as e:
abort(404, description=e.description)
except ServerError as e:
abort(500, description=e.description)
Expand All @@ -245,6 +256,8 @@ def get_subscription_list(nfvo_id):
200)
except Unauthorized as e:
abort(401, description=e.description)
except NfvoNotFound as e:
abort(404, description=e.description)
except ServerError as e:
abort(500, description=e.description)

Expand All @@ -256,6 +269,16 @@ def create_subscription(nfvo_id):
jsonify(database.create_subscription(nfvo_id, request.json)), 201)
except BadRequest as e:
abort(400, description=e.description)
except Unauthorized as e:
abort(401, description=e.description)
except Forbidden as e:
abort(403, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound) as e:
abort(404, description=e.description)
except Conflict as e:
abort(409, description=e.description)
except Unprocessable as e:
abort(422, description=e.description)
except ServerError as e:
abort(500, description=e.description)

Expand All @@ -265,7 +288,9 @@ def get_subscription(nfvo_id, subscriptionId):
try:
return make_response(
jsonify(database.get_subscription(nfvo_id, subscriptionId)), 200)
except SubscriptionNotFound as e:
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound, SubscriptionNotFound) as e:
abort(404, description=e.description)
except ServerError as e:
abort(500, description=e.description)
Expand All @@ -276,7 +301,9 @@ def delete_subscription(nfvo_id, subscriptionId):
try:
database.delete_subscription(subscriptionId)
return make_response('', 204)
except SubscriptionNotFound as e:
except Unauthorized as e:
abort(401, description=e.description)
except (NfvoNotFound, NfvoCredentialsNotFound, SubscriptionNotFound) as e:
abort(404, description=e.description)
except ServerError as e:
abort(500, description=e.description)
Expand Down
Loading

0 comments on commit 96c253d

Please sign in to comment.