Ejemplo n.º 1
0
from orm.common.orm_common.injector import injector
from orm.common.orm_common.utils import api_error_utils as err_utils
from orm.services.flavor_manager.fms_rest.data.wsme.models import TenantWrapper
from orm.services.flavor_manager.fms_rest.logger import get_logger
from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus
from orm.services.flavor_manager.fms_rest.utils import authentication

from pecan import request, rest
from wsmeext.pecan import wsexpose

LOG = get_logger(__name__)

di = injector.get_di()


@di.dependsOn('flavor_logic')
@di.dependsOn('utils')
class TenantController(rest.RestController):
    @wsexpose(TenantWrapper,
              str,
              body=TenantWrapper,
              rest_content_types='json',
              status_code=201)
    def post(self, flavor_id, tenant_wrapper):
        flavor_logic, utils = di.resolver.unpack(TenantController)
        LOG.info("TenantController - add tenants: " + str(tenant_wrapper))
        authentication.authorize(request, 'flavor:add_flavor_tenants')

        try:
            result = flavor_logic.add_tenants(flavor_id, tenant_wrapper,
                                              request.transaction_id)
Ejemplo n.º 2
0
import os

from orm.common.orm_common.injector import injector
from orm.services.flavor_manager.fms_rest import di_providers
from orm.services.flavor_manager.fms_rest.logger import get_logger

logger = get_logger(__name__)

_current_dirname = os.path.dirname(os.path.realpath(di_providers.__file__))
injector.register_providers('FMS_ENV', _current_dirname, logger)