Exemplo n.º 1
0
from collections import namedtuple
from rest.app.util import memoize

from rest.logger import logger
log = logger()

CRUSH_RULE_TYPE_REPLICATED = 1
CRUSH_RULE_TYPE_ERASURE = 3

ServiceId = namedtuple('ServiceId', ['fsid', 'service_type', 'service_id'])

MON = 'mon'
OSD = 'osd'
MDS = 'mds'
POOL = 'pool'
OSD_MAP = 'osd_map'
CRUSH_RULE = 'crush_rule'
CLUSTER = 'cluster'
SERVER = 'server'


class SyncObject(object):
    """
    An object from a Ceph cluster that we are maintaining
    a copy of on the Calamari server.

    We wrap these JSON-serializable objects in a python object to:

    - Decorate them with things like id-to-entry dicts
    - Have a generic way of seeing the version of an object
Exemplo n.º 2
0
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 rest.app.types import OsdMap, SYNC_OBJECT_STR_TYPE, OSD, OSD_MAP, POOL, CLUSTER, CRUSH_RULE, ServiceId,\
    NotFound, SERVER

from rest.module import global_instance as rest_plugin

from rest.logger import logger
log = logger()


class DataObject(object):
    """
    A convenience for converting dicts from the backend into
    objects, because django_rest_framework expects objects
    """
    def __init__(self, data):
        self.__dict__.update(data)


class MgrClient(object):
    cluster_monitor = None

    def __init__(self):