summaryrefslogtreecommitdiffstats
path: root/ocata/ocata
diff options
context:
space:
mode:
Diffstat (limited to 'ocata/ocata')
-rw-r--r--ocata/ocata/__init__.py10
-rw-r--r--ocata/ocata/extensions/__init__.py10
-rw-r--r--ocata/ocata/extensions/urls.py28
-rw-r--r--ocata/ocata/proxy/__init__.py10
-rw-r--r--ocata/ocata/proxy/urls.py34
-rw-r--r--ocata/ocata/proxy/views/__init__.py10
-rw-r--r--ocata/ocata/proxy/views/identityV3.py33
-rw-r--r--ocata/ocata/proxy/views/services.py35
-rw-r--r--ocata/ocata/pub/__init__.py10
-rw-r--r--ocata/ocata/pub/config/__init__.py10
-rw-r--r--ocata/ocata/pub/config/config.py34
-rw-r--r--ocata/ocata/requests/__init__.py13
-rw-r--r--ocata/ocata/requests/urls.py47
-rw-r--r--ocata/ocata/samples/__init__.py10
-rw-r--r--ocata/ocata/samples/tests.py29
-rw-r--r--ocata/ocata/samples/urls.py16
-rw-r--r--ocata/ocata/samples/views.py26
-rw-r--r--ocata/ocata/settings.py122
-rw-r--r--ocata/ocata/swagger/__init__.py10
-rw-r--r--ocata/ocata/swagger/tests.py29
-rw-r--r--ocata/ocata/swagger/urls.py21
-rw-r--r--ocata/ocata/swagger/views.py45
-rw-r--r--ocata/ocata/urls.py34
-rw-r--r--ocata/ocata/wsgi.py19
24 files changed, 645 insertions, 0 deletions
diff --git a/ocata/ocata/__init__.py b/ocata/ocata/__init__.py
new file mode 100644
index 00000000..802f3fba
--- /dev/null
+++ b/ocata/ocata/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/ocata/ocata/extensions/__init__.py b/ocata/ocata/extensions/__init__.py
new file mode 100644
index 00000000..802f3fba
--- /dev/null
+++ b/ocata/ocata/extensions/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/ocata/ocata/extensions/urls.py b/ocata/ocata/extensions/urls.py
new file mode 100644
index 00000000..e87a02eb
--- /dev/null
+++ b/ocata/ocata/extensions/urls.py
@@ -0,0 +1,28 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from django.conf.urls import url
+from rest_framework.urlpatterns import format_suffix_patterns
+
+from newton.extensions.views import extensions
+from newton.extensions.views import epacaps
+
+urlpatterns = [
+ url(r'^sions$', extensions.Extensions.as_view()),
+ url(r'^sions/$', extensions.Extensions.as_view()),
+ url(r'^sions/epa-caps$', epacaps.EpaCaps.as_view()),
+ url(r'^sions/epa-caps/$', epacaps.EpaCaps.as_view()),
+]
+
+urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/ocata/ocata/proxy/__init__.py b/ocata/ocata/proxy/__init__.py
new file mode 100644
index 00000000..802f3fba
--- /dev/null
+++ b/ocata/ocata/proxy/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/ocata/ocata/proxy/urls.py b/ocata/ocata/proxy/urls.py
new file mode 100644
index 00000000..7d52a4ed
--- /dev/null
+++ b/ocata/ocata/proxy/urls.py
@@ -0,0 +1,34 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from django.conf.urls import url
+from rest_framework.urlpatterns import format_suffix_patterns
+
+from ocata.proxy.views import identityV3
+from ocata.proxy.views import services
+
+urlpatterns = [
+ # url(r'^identity/v2)$',
+ # identityV2.Tokens.as_view()),
+ url(r'^identity/v3/auth/tokens$',
+ identityV3.Tokens.as_view()),
+ url(r'^identity/v3/auth/catalog$',
+ identityV3.Catalog.as_view()),
+ url(r'^identity/(?:v2.0/|)tenants$',
+ services.GetTenants.as_view()),
+ url(r'^(?P<servicetype>[0-9a-zA-Z_-]+)/(?P<requri>[0-9a-zA-Z./_-]*)$',
+ services.Services.as_view()),
+]
+
+urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/ocata/ocata/proxy/views/__init__.py b/ocata/ocata/proxy/views/__init__.py
new file mode 100644
index 00000000..802f3fba
--- /dev/null
+++ b/ocata/ocata/proxy/views/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/ocata/ocata/proxy/views/identityV3.py b/ocata/ocata/proxy/views/identityV3.py
new file mode 100644
index 00000000..5e018e2a
--- /dev/null
+++ b/ocata/ocata/proxy/views/identityV3.py
@@ -0,0 +1,33 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import logging
+
+from newton.pub.config import config
+from newton.proxy.views import identityV3 as newton_identityV3
+
+logger = logging.getLogger(__name__)
+
+DEBUG=True
+
+class Tokens(newton_identityV3.Tokens):
+
+ def __init__(self):
+ self.proxy_prefix = config.MULTICLOUD_PREFIX
+ self._logger = logger
+
+class Catalog(newton_identityV3.Catalog):
+
+ def __init__(self):
+ self.proxy_prefix = config.MULTICLOUD_PREFIX
+ self._logger = logger
diff --git a/ocata/ocata/proxy/views/services.py b/ocata/ocata/proxy/views/services.py
new file mode 100644
index 00000000..5a022fe4
--- /dev/null
+++ b/ocata/ocata/proxy/views/services.py
@@ -0,0 +1,35 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import logging
+
+from newton.pub.config import config
+from newton.proxy.views import services as newton_services
+
+logger = logging.getLogger(__name__)
+
+DEBUG=True
+
+class Services(newton_services.Services):
+
+ def __init__(self):
+ self._logger = logger
+
+
+class GetTenants(newton_services.GetTenants):
+ '''
+ Backward compatible API for /v2.0/tenants
+ '''
+
+ def __init__(self):
+ self._logger = logger
diff --git a/ocata/ocata/pub/__init__.py b/ocata/ocata/pub/__init__.py
new file mode 100644
index 00000000..802f3fba
--- /dev/null
+++ b/ocata/ocata/pub/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/ocata/ocata/pub/config/__init__.py b/ocata/ocata/pub/config/__init__.py
new file mode 100644
index 00000000..802f3fba
--- /dev/null
+++ b/ocata/ocata/pub/config/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/ocata/ocata/pub/config/config.py b/ocata/ocata/pub/config/config.py
new file mode 100644
index 00000000..4de698f5
--- /dev/null
+++ b/ocata/ocata/pub/config/config.py
@@ -0,0 +1,34 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+import os
+
+# [MSB]
+MSB_SERVICE_IP = '127.0.0.1'
+MSB_SERVICE_PORT = '80'
+
+#[Multicloud]
+MULTICLOUD_PREFIX = "http://%s:%s/api/multicloud-ocata/v0" %(MSB_SERVICE_IP, MSB_SERVICE_PORT)
+
+# [A&AI]
+AAI_ADDR = "aai.api.simpledemo.openecomp.org"
+AAI_PORT = "8443"
+AAI_SERVICE_URL = 'https://%s:%s/aai' % (AAI_ADDR, AAI_PORT)
+AAI_SCHEMA_VERSION = "v11"
+AAI_USERNAME = 'AAI'
+AAI_PASSWORD = 'AAI'
+
+AAI_BASE_URL = "%s/%s" % (AAI_SERVICE_URL, AAI_SCHEMA_VERSION)
+
+MULTICLOUD_APP_ID = 'MultiCloud-Ocata'
+
+# [IMAGE LOCAL PATH]
+ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
diff --git a/ocata/ocata/requests/__init__.py b/ocata/ocata/requests/__init__.py
new file mode 100644
index 00000000..48b6e44b
--- /dev/null
+++ b/ocata/ocata/requests/__init__.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/ocata/ocata/requests/urls.py b/ocata/ocata/requests/urls.py
new file mode 100644
index 00000000..69f0e444
--- /dev/null
+++ b/ocata/ocata/requests/urls.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from django.conf.urls import url
+from rest_framework.urlpatterns import format_suffix_patterns
+
+from newton.requests.views import network
+from newton.requests.views import subnet
+from newton.requests.views import image
+from newton.requests.views import volume
+from newton.requests.views import server
+from newton.requests.views import vport
+from newton.requests.views import limits
+from newton.requests.views import hosts
+from newton.requests.views import flavor
+
+urlpatterns = [
+ url(r'^networks(/(?P<networkid>[0-9a-zA-Z_-]+))?',
+ network.Networks.as_view()),
+ url(r'^subnets(/(?P<subnetid>[0-9a-zA-Z_-]+))?',
+ subnet.Subnets.as_view()),
+ url(r'^images(/(?P<imageid>[0-9a-zA-Z_-]+))?',
+ image.Images.as_view()),
+ url(r'^volumes(/(?P<volumeid>[0-9a-zA-Z_-]+))?',
+ volume.Volumes.as_view()),
+ url(r'^servers(/(?P<serverid>[0-9a-zA-Z_-]+))?',
+ server.Servers.as_view()),
+ url(r'^ports(/(?P<portid>[0-9a-zA-Z_-]+))?',
+ vport.Vports.as_view()),
+ url(r'^flavors(/(?P<flavorid>[0-9a-zA-Z_-]+))?',
+ flavor.Flavors.as_view()),
+ url(r'^limits$', limits.Limits.as_view()),
+ url(r'^hosts(/(?P<hostname>[0-9a-zA-Z_-]+))?', hosts.Hosts.as_view()),
+]
+
+urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/ocata/ocata/samples/__init__.py b/ocata/ocata/samples/__init__.py
new file mode 100644
index 00000000..802f3fba
--- /dev/null
+++ b/ocata/ocata/samples/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/ocata/ocata/samples/tests.py b/ocata/ocata/samples/tests.py
new file mode 100644
index 00000000..d419efa5
--- /dev/null
+++ b/ocata/ocata/samples/tests.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+import unittest
+import json
+from django.test import Client
+from rest_framework import status
+
+
+class SampleViewTest(unittest.TestCase):
+ def setUp(self):
+ self.client = Client()
+
+ def tearDown(self):
+ pass
+
+ def test_sample(self):
+ response = self.client.get("/samples/")
+ self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
+ resp_data = response.json()
+ self.assertEqual({"status": "active"}, resp_data)
diff --git a/ocata/ocata/samples/urls.py b/ocata/ocata/samples/urls.py
new file mode 100644
index 00000000..c56bc627
--- /dev/null
+++ b/ocata/ocata/samples/urls.py
@@ -0,0 +1,16 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+from django.conf.urls import url
+from ocata.samples import views
+
+urlpatterns = [
+ url(r'^samples/$', views.SampleList.as_view()), ]
diff --git a/ocata/ocata/samples/views.py b/ocata/ocata/samples/views.py
new file mode 100644
index 00000000..e51044ad
--- /dev/null
+++ b/ocata/ocata/samples/views.py
@@ -0,0 +1,26 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+import logging
+
+from rest_framework.views import APIView
+from rest_framework.response import Response
+
+logger = logging.getLogger(__name__)
+
+
+class SampleList(APIView):
+ """
+ List all samples.
+ """
+ def get(self, request, format=None):
+ logger.debug("get")
+ return Response({"status": "active"})
diff --git a/ocata/ocata/settings.py b/ocata/ocata/settings.py
new file mode 100644
index 00000000..1e8473b7
--- /dev/null
+++ b/ocata/ocata/settings.py
@@ -0,0 +1,122 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+import os
+import sys
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = []
+
+# Application definition
+
+INSTALLED_APPS = [
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'rest_framework',
+]
+
+MIDDLEWARE_CLASSES = [
+ 'django.middleware.security.SecurityMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+ROOT_URLCONF = 'ocata.urls'
+
+WSGI_APPLICATION = 'ocata.wsgi.application'
+
+REST_FRAMEWORK = {
+ 'DEFAULT_RENDERER_CLASSES': (
+ 'rest_framework.renderers.JSONRenderer',
+ ),
+
+ 'DEFAULT_PARSER_CLASSES': (
+ 'rest_framework.parsers.JSONParser',
+ 'rest_framework.parsers.MultiPartParser',
+ # 'rest_framework.parsers.FormParser',
+ # 'rest_framework.parsers.FileUploadParser',
+ )
+}
+
+TIME_ZONE = 'UTC'
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/1.6/howto/static-files/
+
+STATIC_URL = '/static/'
+
+LOGGING = {
+ 'version': 1,
+ 'disable_existing_loggers': True,
+ 'formatters': {
+ 'standard': {
+ 'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s',
+ },
+ },
+ 'filters': {
+ },
+ 'handlers': {
+ 'ocata_handler': {
+ 'level': 'DEBUG',
+ 'class': 'logging.handlers.RotatingFileHandler',
+ 'filename': os.path.join(BASE_DIR, 'logs/runtime_ocata.log'),
+ 'formatter': 'standard',
+ 'maxBytes': 1024 * 1024 * 50,
+ 'backupCount': 5,
+ },
+ },
+
+ 'loggers': {
+ 'ocata': {
+ 'handlers': ['ocata_handler'],
+ 'level': 'DEBUG',
+ 'propagate': False
+ },
+ }
+}
+
+CACHES = {
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
+ 'LOCATION': '127.0.0.1:11211',
+ }
+}
+
+if 'test' in sys.argv:
+ from ocata.pub.config import config
+
+ REST_FRAMEWORK = {}
+ import platform
+
+ if platform.system() == 'Linux':
+ TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'
+ TEST_OUTPUT_VERBOSE = True
+ TEST_OUTPUT_DESCRIPTIONS = True
+ TEST_OUTPUT_DIR = 'test-reports'
diff --git a/ocata/ocata/swagger/__init__.py b/ocata/ocata/swagger/__init__.py
new file mode 100644
index 00000000..802f3fba
--- /dev/null
+++ b/ocata/ocata/swagger/__init__.py
@@ -0,0 +1,10 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/ocata/ocata/swagger/tests.py b/ocata/ocata/swagger/tests.py
new file mode 100644
index 00000000..8d4fa6a0
--- /dev/null
+++ b/ocata/ocata/swagger/tests.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+import unittest
+import json
+from django.test import Client
+from rest_framework import status
+
+
+class SampleViewTest(unittest.TestCase):
+ def setUp(self):
+ self.client = Client()
+
+ def tearDown(self):
+ pass
+
+ def test_sample(self):
+ response = self.client.get("/api/multicloud-ocata/v0/swagger.json")
+ self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
+# resp_data = response.json()
+# self.assertEqual({"status": "active"}, resp_data)
diff --git a/ocata/ocata/swagger/urls.py b/ocata/ocata/swagger/urls.py
new file mode 100644
index 00000000..b85d3cff
--- /dev/null
+++ b/ocata/ocata/swagger/urls.py
@@ -0,0 +1,21 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+from django.conf.urls import patterns, url
+from rest_framework.urlpatterns import format_suffix_patterns
+
+from ocata.swagger.views import SwaggerJsonView
+
+urlpatterns = [
+ url(r'^api/multicloud-ocata/v0/swagger.json$', SwaggerJsonView.as_view()),
+]
+
+urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/ocata/ocata/swagger/views.py b/ocata/ocata/swagger/views.py
new file mode 100644
index 00000000..0a90e1e6
--- /dev/null
+++ b/ocata/ocata/swagger/views.py
@@ -0,0 +1,45 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+import json
+import logging
+import os
+import traceback
+
+from rest_framework import status
+from rest_framework.response import Response
+from rest_framework.views import APIView
+
+from newton.pub.exceptions import VimDriverNewtonException
+from newton.swagger import views as newton_json_view
+
+logger = logging.getLogger(__name__)
+
+
+class SwaggerJsonView(newton_json_view.SwaggerJsonView):
+
+ def get(self, request):
+ '''
+ reuse newton code and update the basePath
+ :param request:
+ :return:
+ '''
+
+ resp = super(SwaggerJsonView,self).get(request)
+ json_data = resp.data if resp else None
+ if json_data:
+ json_data["basePath"] = "/api/multicloud-ocata/v0/"
+ json_data["info"]["title"] = "MultiVIM driver of OpenStack Ocata Service NBI"
+ return Response(data=json_data, status=200)
+ else:
+ return Response(data={'error':'internal error'}, status=500)
+
+
diff --git a/ocata/ocata/urls.py b/ocata/ocata/urls.py
new file mode 100644
index 00000000..db488bff
--- /dev/null
+++ b/ocata/ocata/urls.py
@@ -0,0 +1,34 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+from django.conf.urls import include, url
+
+from newton.registration.views import registration
+from newton.requests.views import tenants
+
+urlpatterns = [
+ url(r'^', include('ocata.swagger.urls')),
+ url(r'^', include('ocata.samples.urls')),
+ url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)/registry$',
+ registration.Registry.as_view()),
+ url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)$',
+ registration.Registry.as_view()),
+ url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)/exten',
+ include('ocata.extensions.urls')),
+ url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)/',
+ include('ocata.proxy.urls')),
+ url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)/tenants$',
+ tenants.Tenants.as_view()),
+ url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)/'
+ '(?P<tenantid>[0-9a-zA-Z_-]{8,})/', include('ocata.requests.urls')),
+]
+
+
diff --git a/ocata/ocata/wsgi.py b/ocata/ocata/wsgi.py
new file mode 100644
index 00000000..8471a58a
--- /dev/null
+++ b/ocata/ocata/wsgi.py
@@ -0,0 +1,19 @@
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ocata.settings")
+
+application = get_wsgi_application()