# 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
logger = logging.getLogger(__name__)
+
@app.task(bind=True)
def debug_task(self):
logger.debug("self.request")
FORWARDED_FOR_FIELDS = ["HTTP_X_FORWARDED_FOR", "HTTP_X_FORWARDED_HOST",
"HTTP_X_FORWARDED_SERVER"]
+
class LogContextMiddleware(object):
# the last IP behind multiple proxies, if no exist proxies
return ip
-
def process_request(self, request):
# fetch propageted Id from other component. if do not fetch id,
# generate one.
MDC.clear()
return response
-
# 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.
-
# 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.
-
# 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.
-
# limitations under the License.
import unittest
-import json
from django.test import Client
from rest_framework import status
MSB_SERVICE_ADDR = os.environ.get('MSB_ADDR', "127.0.0.1")
MSB_SERVICE_PORT = os.environ.get('MSB_PORT', "80")
-#[Multicloud]
+# [Multicloud]
MULTICLOUD_PREFIX = "http://%s:%s/api/multicloud-ocata/v0" % (
MSB_SERVICE_ADDR, MSB_SERVICE_PORT)
if 'test' in sys.argv:
- #LOGGING['handlers']['ocata_handler']['filename'] = 'logs/ocata.log'
+ # LOGGING['handlers']['ocata_handler']['filename'] = 'logs/ocata.log'
REST_FRAMEWORK = {}
import platform
# 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.
-
# limitations under the License.
import unittest
-import json
from django.test import Client
from rest_framework import status
# See the License for the specific language governing permissions and
# limitations under the License.
-from django.conf.urls import patterns, url
+from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from ocata.swagger.views import SwaggerJsonView
# See the License for the specific language governing permissions and
# limitations under the License.
-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 common.exceptions import VimDriverNewtonException
from newton_base.swagger import views as newton_json_view
logger = logging.getLogger(__name__)
:return:
'''
- resp = super(SwaggerJsonView,self).get(request)
+ 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"] = "Service NBI of MultiCloud plugin for OpenStack Ocata"
return Response(data=json_data, status=200)
else:
- return Response(data={'error':'internal error'}, status=500)
+ return Response(data={'error': 'internal error'}, status=500)
+
class APIv1SwaggerJsonView(newton_json_view.SwaggerJsonView):
:return:
'''
- resp = super(APIv1SwaggerJsonView,self).get(request)
+ resp = super(APIv1SwaggerJsonView, self).get(request)
json_data = resp.data if resp else None
if json_data:
json_data["basePath"] = "/api/multicloud-ocata/v1/"
json_data["info"]["title"] = "Service NBI v1 of MultiCloud plugin for Ocata"
return Response(data=json_data, status=200)
else:
- return Response(data={'error':'internal error'}, status=500)
+ return Response(data={'error': 'internal error'}, status=500)
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')),
+ include('ocata.proxy.urls')),
url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)/tenants$',
- tenants.Tenants.as_view()),
+ tenants.Tenants.as_view()),
url(r'^api/multicloud-ocata/v0/(?P<vimid>[0-9a-zA-Z_-]+)/'
'(?P<tenantid>[0-9a-zA-Z_-]{20,})/', include('ocata.requests.urls')),
# CapacityCheck
url(r'^api/multicloud-ocata/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/(?P<cloud_region_id>[0-9a-zA-Z_-]+)/infra_workload/(?P<requri>[0-9a-zA-Z_-]*)/?$',
infra_workload.APIv1InfraWorkload.as_view()),
]
-
-