mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
pybind/mgr: move rest into dir
Let's make each module its own directory. Signed-off-by: John Spray <john.spray@redhat.com>
This commit is contained in:
parent
7eb4572944
commit
5366980c38
3
src/pybind/mgr/rest/__init__.py
Normal file
3
src/pybind/mgr/rest/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
from module import *
|
||||
|
@ -3,7 +3,7 @@
|
||||
# the ceph source tree:
|
||||
#
|
||||
# PYTHONPATH=src/pybind/mgr \
|
||||
# DJANGO_SETTINGS_MODULE=calamari_rest.settings \
|
||||
# DJANGO_SETTINGS_MODULE=rest.app.settings \
|
||||
# CALAMARI_CONFIG=src/pybind/mgr/calamari.conf \
|
||||
# django-admin api_docs
|
||||
#
|
||||
@ -33,9 +33,9 @@ class ceph_state:
|
||||
sys.modules["ceph_state"] = ceph_state
|
||||
|
||||
# Needed to avoid weird import loops
|
||||
from rest import global_instance
|
||||
from rest.module import global_instance
|
||||
|
||||
from calamari_rest.serializers.v2 import ValidatingSerializer
|
||||
from rest.app.serializers.v2 import ValidatingSerializer
|
||||
|
||||
GENERATED_PREFIX = "."
|
||||
|
||||
@ -215,7 +215,7 @@ class ApiIntrospector(object):
|
||||
continue
|
||||
view_to_url_patterns[view_cls].append(url_pattern)
|
||||
|
||||
self.prefix = _find_prefix("calamari_rest.urls", url_module)
|
||||
self.prefix = _find_prefix("rest.app.urls", url_module)
|
||||
parse_urls(importlib.import_module(url_module).urlpatterns)
|
||||
|
||||
self.view_to_url_patterns = sorted(view_to_url_patterns.items(), cmp=lambda x, y: cmp(x[0].__name__, y[0].__name__))
|
||||
@ -388,7 +388,7 @@ class Command(NoArgsCommand):
|
||||
)
|
||||
|
||||
def handle_noargs(self, list_urls, **options):
|
||||
introspector = ApiIntrospector("calamari_rest.urls.v2")
|
||||
introspector = ApiIntrospector("rest.app.urls.v2")
|
||||
if list_urls:
|
||||
# TODO: this just prints an empty array (not sure why)
|
||||
print json.dumps(introspector.get_url_list())
|
@ -1,8 +1,8 @@
|
||||
from calamari_rest.manager.request_factory import RequestFactory
|
||||
from calamari_rest.types import OsdMap, OSD_IMPLEMENTED_COMMANDS, OSD_FLAGS
|
||||
from calamari_rest.manager.user_request import OsdMapModifyingRequest, RadosRequest
|
||||
from rest.app.manager.request_factory import RequestFactory
|
||||
from rest.app.types import OsdMap, OSD_IMPLEMENTED_COMMANDS, OSD_FLAGS
|
||||
from rest.app.manager.user_request import OsdMapModifyingRequest, RadosRequest
|
||||
|
||||
from rest import global_instance as rest_plugin
|
||||
from rest.module import global_instance as rest_plugin
|
||||
|
||||
class OsdRequestFactory(RequestFactory):
|
||||
"""
|
@ -1,12 +1,12 @@
|
||||
|
||||
from calamari_rest.manager.request_factory import RequestFactory
|
||||
from calamari_rest.types import OsdMap, Config
|
||||
from calamari_rest.manager.user_request import OsdMapModifyingRequest, \
|
||||
from rest.app.manager.request_factory import RequestFactory
|
||||
from rest.app.types import OsdMap, Config
|
||||
from rest.app.manager.user_request import OsdMapModifyingRequest, \
|
||||
PgCreatingRequest, PoolCreatingRequest
|
||||
|
||||
from rest import global_instance as rest_plugin
|
||||
from rest.module import global_instance as rest_plugin
|
||||
|
||||
from rest import logger
|
||||
from rest.logger import logger
|
||||
log = logger()
|
||||
|
||||
# Valid values for the 'var' argument to 'ceph osd pool set'
|
@ -1,10 +1,10 @@
|
||||
|
||||
from threading import RLock
|
||||
from calamari_rest.manager.user_request import UserRequest
|
||||
from rest import logger
|
||||
from rest.app.manager.user_request import UserRequest
|
||||
from rest.logger import logger
|
||||
log = logger()
|
||||
|
||||
from rest import global_instance as rest_plugin
|
||||
from rest.module import global_instance as rest_plugin
|
||||
|
||||
TICK_PERIOD = 20
|
||||
|
@ -2,13 +2,13 @@ import json
|
||||
import logging
|
||||
import uuid
|
||||
|
||||
from calamari_rest.types import OsdMap, PgSummary, USER_REQUEST_COMPLETE, USER_REQUEST_SUBMITTED
|
||||
from calamari_rest.util import now
|
||||
from rest.app.types import OsdMap, PgSummary, USER_REQUEST_COMPLETE, USER_REQUEST_SUBMITTED
|
||||
from rest.app.util import now
|
||||
from mgr_module import CommandResult
|
||||
|
||||
from rest import logger
|
||||
from rest.logger import logger
|
||||
log = logger()
|
||||
from rest import global_instance as rest_plugin
|
||||
from rest.module import global_instance as rest_plugin
|
||||
|
||||
|
||||
class UserRequestBase(object):
|
@ -1,6 +1,6 @@
|
||||
from rest_framework import serializers
|
||||
import calamari_rest.serializers.fields as fields
|
||||
from calamari_rest.types import CRUSH_RULE_TYPE_REPLICATED, \
|
||||
import rest.app.serializers.fields as fields
|
||||
from rest.app.types import CRUSH_RULE_TYPE_REPLICATED, \
|
||||
CRUSH_RULE_TYPE_ERASURE, USER_REQUEST_COMPLETE, \
|
||||
USER_REQUEST_SUBMITTED, OSD_FLAGS, severity_str, SEVERITIES
|
||||
|
@ -100,10 +100,10 @@ MIDDLEWARE_CLASSES = (
|
||||
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'calamari_rest.urls'
|
||||
ROOT_URLCONF = 'rest.app.urls'
|
||||
|
||||
# Python dotted path to the WSGI application used by Django's runserver.
|
||||
#WSGI_APPLICATION = 'calamari_rest.wsgi.application'
|
||||
#WSGI_APPLICATION = 'rest.app.wsgi.application'
|
||||
|
||||
INSTALLED_APPS = (
|
||||
#'django.contrib.auth',
|
||||
@ -113,7 +113,7 @@ INSTALLED_APPS = (
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
'calamari_rest'
|
||||
'rest.app'
|
||||
)
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
@ -1,7 +1,7 @@
|
||||
from collections import namedtuple
|
||||
from calamari_rest.util import memoize
|
||||
from rest.app.util import memoize
|
||||
|
||||
from rest import logger
|
||||
from rest.logger import logger
|
||||
log = logger()
|
||||
|
||||
|
@ -12,7 +12,7 @@ urlpatterns = patterns(
|
||||
# finds the views by name.
|
||||
url(r'^api/rest_framework/', include('rest_framework.urls', namespace='rest_framework')),
|
||||
|
||||
url(r'^api/v2/', include('calamari_rest.urls.v2')),
|
||||
url(r'^api/v2/', include('rest.app.urls.v2')),
|
||||
)
|
||||
|
||||
#handler500 = 'calamari_web.views.server_error'
|
@ -1,6 +1,6 @@
|
||||
from django.conf.urls import patterns, url, include
|
||||
from rest_framework import routers
|
||||
import calamari_rest.views.v2
|
||||
import rest.app.views.v2
|
||||
|
||||
router = routers.DefaultRouter(trailing_slash=False)
|
||||
|
||||
@ -10,110 +10,110 @@ urlpatterns = patterns(
|
||||
'',
|
||||
|
||||
# About the host calamari server is running on
|
||||
# url(r'^grains', calamari_rest.views.v2.grains),
|
||||
# url(r'^grains', rest.app.views.v2.grains),
|
||||
|
||||
# This has to come after /user/me to make sure that special case is handled
|
||||
url(r'^', include(router.urls)),
|
||||
|
||||
# About ongoing operations in cthulhu
|
||||
url(r'^request/(?P<request_id>[a-zA-Z0-9-]+)/cancel$',
|
||||
calamari_rest.views.v2.RequestViewSet.as_view({'post': 'cancel'}),
|
||||
rest.app.views.v2.RequestViewSet.as_view({'post': 'cancel'}),
|
||||
name='request-cancel'),
|
||||
url(r'^request/(?P<request_id>[a-zA-Z0-9-]+)$',
|
||||
calamari_rest.views.v2.RequestViewSet.as_view({'get': 'retrieve'}),
|
||||
rest.app.views.v2.RequestViewSet.as_view({'get': 'retrieve'}),
|
||||
name='request-detail'),
|
||||
url(r'^request$',
|
||||
calamari_rest.views.v2.RequestViewSet.as_view({'get': 'list'}),
|
||||
rest.app.views.v2.RequestViewSet.as_view({'get': 'list'}),
|
||||
name='request-list'),
|
||||
url(r'^cluster/request/(?P<request_id>[a-zA-Z0-9-]+)$',
|
||||
calamari_rest.views.v2.RequestViewSet.as_view({'get': 'retrieve'}),
|
||||
rest.app.views.v2.RequestViewSet.as_view({'get': 'retrieve'}),
|
||||
name='cluster-request-detail'),
|
||||
url(r'^cluster/request$',
|
||||
calamari_rest.views.v2.RequestViewSet.as_view({'get': 'list'}),
|
||||
rest.app.views.v2.RequestViewSet.as_view({'get': 'list'}),
|
||||
name='cluster-request-list'),
|
||||
|
||||
# OSDs, Pools, CRUSH
|
||||
url(r'^cluster/crush_rule_set$',
|
||||
calamari_rest.views.v2.CrushRuleSetViewSet.as_view({'get': 'list'}),
|
||||
rest.app.views.v2.CrushRuleSetViewSet.as_view({'get': 'list'}),
|
||||
name='cluster-crush_rule_set-list'),
|
||||
url(r'^cluster/crush_rule$',
|
||||
calamari_rest.views.v2.CrushRuleViewSet.as_view({'get': 'list'}),
|
||||
rest.app.views.v2.CrushRuleViewSet.as_view({'get': 'list'}),
|
||||
name='cluster-crush_rule-list'),
|
||||
url(r'^cluster/pool$', calamari_rest.views.v2.PoolViewSet.as_view(
|
||||
url(r'^cluster/pool$', rest.app.views.v2.PoolViewSet.as_view(
|
||||
{'get': 'list', 'post': 'create'}),
|
||||
name='cluster-pool-list'),
|
||||
url(r'^cluster/pool/(?P<pool_id>\d+)$',
|
||||
calamari_rest.views.v2.PoolViewSet.as_view({
|
||||
rest.app.views.v2.PoolViewSet.as_view({
|
||||
'get': 'retrieve',
|
||||
'patch': 'update',
|
||||
'delete': 'destroy'}),
|
||||
name='cluster-pool-detail'),
|
||||
|
||||
url(r'^cluster/osd$',
|
||||
calamari_rest.views.v2.OsdViewSet.as_view({'get': 'list'}),
|
||||
rest.app.views.v2.OsdViewSet.as_view({'get': 'list'}),
|
||||
name='cluster-osd-list'),
|
||||
url(r'^cluster/osd/(?P<osd_id>\d+)$',
|
||||
calamari_rest.views.v2.OsdViewSet.as_view(
|
||||
rest.app.views.v2.OsdViewSet.as_view(
|
||||
{'get': 'retrieve', 'patch': 'update'}),
|
||||
name='cluster-osd-detail'),
|
||||
url(r'^cluster/osd /command$', calamari_rest.views.v2.OsdViewSet.as_view(
|
||||
url(r'^cluster/osd /command$', rest.app.views.v2.OsdViewSet.as_view(
|
||||
{'get': 'get_implemented_commands'})),
|
||||
url(r'^cluster/osd/(?P<osd_id>\d+)/command$',
|
||||
calamari_rest.views.v2.OsdViewSet.as_view(
|
||||
rest.app.views.v2.OsdViewSet.as_view(
|
||||
{'get': 'get_valid_commands'})),
|
||||
|
||||
url(r'^cluster/osd/(?P<osd_id>\d+)/command/(?P<command>[a-zA-Z_]+)$',
|
||||
calamari_rest.views.v2.OsdViewSet.as_view(
|
||||
rest.app.views.v2.OsdViewSet.as_view(
|
||||
{'get': 'validate_command', 'post': 'apply'})),
|
||||
url(r'^cluster/osd_config$',
|
||||
calamari_rest.views.v2.OsdConfigViewSet.as_view(
|
||||
rest.app.views.v2.OsdConfigViewSet.as_view(
|
||||
{'get': 'osd_config', 'patch': 'update'})),
|
||||
|
||||
url(r'^cluster/mon$',
|
||||
calamari_rest.views.v2.MonViewSet.as_view({'get': 'list'}),
|
||||
rest.app.views.v2.MonViewSet.as_view({'get': 'list'}),
|
||||
name='cluster-mon-list'),
|
||||
url(r'^cluster/mon/(?P<mon_id>[a-zA-Z0-9-\.]+)$',
|
||||
calamari_rest.views.v2.MonViewSet.as_view(
|
||||
rest.app.views.v2.MonViewSet.as_view(
|
||||
{'get': 'retrieve'}), name='cluster-mon-detail'),
|
||||
|
||||
# Direct access to SyncObjects, mainly for debugging
|
||||
url(r'^cluster/sync_object$',
|
||||
calamari_rest.views.v2.SyncObject.as_view({'get': 'describe'}),
|
||||
rest.app.views.v2.SyncObject.as_view({'get': 'describe'}),
|
||||
name='cluster-sync-object-describe'),
|
||||
url(r'^cluster/sync_object/(?P<sync_type>[a-zA-Z0-9-_]+)$',
|
||||
calamari_rest.views.v2.SyncObject.as_view({'get': 'retrieve'}),
|
||||
rest.app.views.v2.SyncObject.as_view({'get': 'retrieve'}),
|
||||
name='cluster-sync-object'),
|
||||
url(r'^server/(?P<fqdn>[a-zA-Z0-9-\.]+)/debug_job',
|
||||
calamari_rest.views.v2.DebugJob.as_view({'post': 'create'}),
|
||||
rest.app.views.v2.DebugJob.as_view({'post': 'create'}),
|
||||
name='server-debug-job'),
|
||||
|
||||
url(r'^cluster/server$',
|
||||
calamari_rest.views.v2.ServerViewSet.as_view({'get': 'list'}),
|
||||
rest.app.views.v2.ServerViewSet.as_view({'get': 'list'}),
|
||||
name='cluster-server-list'),
|
||||
url(r'^cluster/server/(?P<fqdn>[a-zA-Z0-9-\.]+)$',
|
||||
calamari_rest.views.v2.ServerViewSet.as_view(
|
||||
rest.app.views.v2.ServerViewSet.as_view(
|
||||
{'get': 'retrieve'}), name='cluster-server-detail'),
|
||||
|
||||
# Ceph configuration settings
|
||||
url(r'^cluster/config$',
|
||||
calamari_rest.views.v2.ConfigViewSet.as_view({'get': 'list'})),
|
||||
rest.app.views.v2.ConfigViewSet.as_view({'get': 'list'})),
|
||||
url(r'^cluster/config/(?P<key>[a-zA-Z0-9_]+)$',
|
||||
calamari_rest.views.v2.ConfigViewSet.as_view({'get': 'retrieve'})),
|
||||
rest.app.views.v2.ConfigViewSet.as_view({'get': 'retrieve'})),
|
||||
|
||||
# Events
|
||||
# url(r'^event$', calamari_rest.views.v2.EventViewSet.as_view({'get': 'list'})),
|
||||
# url(r'^cluster/event$', calamari_rest.views.v2.EventViewSet.as_view({'get': 'list_cluster'})),
|
||||
# url(r'^server/(?P<fqdn>[a-zA-Z0-9-\.]+)/event$', calamari_rest.views.v2.EventViewSet.as_view({'get': 'list_server'})),
|
||||
# url(r'^event$', rest.app.views.v2.EventViewSet.as_view({'get': 'list'})),
|
||||
# url(r'^cluster/event$', rest.app.views.v2.EventViewSet.as_view({'get': 'list_cluster'})),
|
||||
# url(r'^server/(?P<fqdn>[a-zA-Z0-9-\.]+)/event$', rest.app.views.v2.EventViewSet.as_view({'get': 'list_server'})),
|
||||
|
||||
# Log tail
|
||||
# url(r'^cluster/log$',
|
||||
# calamari_rest.views.v2.LogTailViewSet.as_view({'get': 'get_cluster_log'})),
|
||||
# rest.app.views.v2.LogTailViewSet.as_view({'get': 'get_cluster_log'})),
|
||||
# url(r'^server/(?P<fqdn>[a-zA-Z0-9-\.]+)/log$',
|
||||
# calamari_rest.views.v2.LogTailViewSet.as_view({'get': 'list_server_logs'})),
|
||||
# rest.app.views.v2.LogTailViewSet.as_view({'get': 'list_server_logs'})),
|
||||
# url(r'^server/(?P<fqdn>[a-zA-Z0-9-\.]+)/log/(?P<log_path>.+)$',
|
||||
# calamari_rest.views.v2.LogTailViewSet.as_view({'get': 'get_server_log'})),
|
||||
# rest.app.views.v2.LogTailViewSet.as_view({'get': 'get_server_log'})),
|
||||
|
||||
# Ceph CLI access
|
||||
# url(r'^cluster/cli$',
|
||||
# calamari_rest.views.v2.CliViewSet.as_view({'post': 'create'}))
|
||||
# rest.app.views.v2.CliViewSet.as_view({'post': 'create'}))
|
||||
)
|
@ -6,20 +6,20 @@ their data from cthulhu with zeroRPC
|
||||
"""
|
||||
|
||||
|
||||
from calamari_rest.manager.osd_request_factory import OsdRequestFactory
|
||||
from calamari_rest.manager.pool_request_factory import PoolRequestFactory
|
||||
from rest.app.manager.osd_request_factory import OsdRequestFactory
|
||||
from rest.app.manager.pool_request_factory import PoolRequestFactory
|
||||
|
||||
from rest_framework import viewsets, status
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from rest_framework.response import Response
|
||||
|
||||
from calamari_rest.types import OsdMap, SYNC_OBJECT_STR_TYPE, OSD, OSD_MAP, POOL, CLUSTER, CRUSH_RULE, ServiceId,\
|
||||
from rest.app.types import OsdMap, SYNC_OBJECT_STR_TYPE, OSD, OSD_MAP, POOL, CLUSTER, CRUSH_RULE, ServiceId,\
|
||||
NotFound, SERVER
|
||||
|
||||
from rest import global_instance as rest_plugin
|
||||
from rest.module import global_instance as rest_plugin
|
||||
|
||||
from rest import logger
|
||||
from rest.logger import logger
|
||||
log = logger()
|
||||
|
||||
|
@ -11,16 +11,16 @@ from rest_framework import status
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
|
||||
from calamari_rest.serializers.v2 import PoolSerializer, CrushRuleSetSerializer, CrushRuleSerializer, \
|
||||
from rest.app.serializers.v2 import PoolSerializer, CrushRuleSetSerializer, CrushRuleSerializer, \
|
||||
ServerSerializer, SaltKeySerializer, RequestSerializer, \
|
||||
ClusterSerializer, EventSerializer, LogTailSerializer, OsdSerializer, ConfigSettingSerializer, MonSerializer, OsdConfigSerializer, \
|
||||
CliSerializer
|
||||
#from calamari_rest.views.database_view_set import DatabaseViewSet
|
||||
from calamari_rest.views.exceptions import ServiceUnavailable
|
||||
#from calamari_rest.views.paginated_mixin import PaginatedMixin
|
||||
#from calamari_rest.views.remote_view_set import RemoteViewSet
|
||||
from calamari_rest.views.rpc_view import RPCViewSet, DataObject
|
||||
from calamari_rest.types import CRUSH_RULE, POOL, OSD, USER_REQUEST_COMPLETE, USER_REQUEST_SUBMITTED, \
|
||||
#from rest.app.views.database_view_set import DatabaseViewSet
|
||||
from rest.app.views.exceptions import ServiceUnavailable
|
||||
#from rest.app.views.paginated_mixin import PaginatedMixin
|
||||
#from rest.app.views.remote_view_set import RemoteViewSet
|
||||
from rest.app.views.rpc_view import RPCViewSet, DataObject
|
||||
from rest.app.types import CRUSH_RULE, POOL, OSD, USER_REQUEST_COMPLETE, USER_REQUEST_SUBMITTED, \
|
||||
OSD_IMPLEMENTED_COMMANDS, MON, OSD_MAP, SYNC_OBJECT_TYPES, ServiceId, severity_from_str, SEVERITIES, \
|
||||
OsdMap, Config, MonMap, MonStatus
|
||||
|
||||
@ -28,7 +28,7 @@ from calamari_rest.types import CRUSH_RULE, POOL, OSD, USER_REQUEST_COMPLETE, US
|
||||
class Event(object):
|
||||
pass
|
||||
|
||||
from rest import logger
|
||||
from rest.logger import logger
|
||||
log = logger()
|
||||
|
||||
|
8
src/pybind/mgr/rest/logger.py
Normal file
8
src/pybind/mgr/rest/logger.py
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
def logger():
|
||||
# The logger name corresponds to the module name (courtesy of
|
||||
# MgrModule.__init__
|
||||
return logging.getLogger("rest")
|
@ -12,12 +12,6 @@ def global_instance():
|
||||
return _global_instance['plugin']
|
||||
|
||||
|
||||
def logger():
|
||||
# The logger name corresponds to the module name (courtesy of
|
||||
# MgrModule.__init__
|
||||
return logging.getLogger("rest")
|
||||
|
||||
|
||||
import os
|
||||
import logging
|
||||
import logging.config
|
||||
@ -31,11 +25,13 @@ from django.core.servers.basehttp import get_internal_wsgi_application
|
||||
|
||||
from mgr_module import MgrModule
|
||||
|
||||
from calamari_rest.manager.request_collection import RequestCollection
|
||||
from calamari_rest.types import OsdMap, NotFound, Config, FsMap, MonMap, \
|
||||
from rest.app.manager.request_collection import RequestCollection
|
||||
from rest.app.types import OsdMap, NotFound, Config, FsMap, MonMap, \
|
||||
PgSummary, Health, MonStatus
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "calamari_rest.settings")
|
||||
from logger import logger
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest.app.settings")
|
||||
|
||||
django_log = logging.getLogger("django.request")
|
||||
django_log.addHandler(logging.StreamHandler())
|
Loading…
Reference in New Issue
Block a user