示例#1
0
文件: service.py 项目: wffeige/trove
    def _validate_can_perform_action(self, tenant_id, instance_id, is_cluster,
                                     operation):
        if is_cluster:
            raise exception.ClusterOperationNotSupported(operation=operation)

        is_slave = self._is_slave(tenant_id, instance_id)
        if is_slave:
            raise exception.SlaveOperationNotSupported(operation=operation)
示例#2
0
 def root_index(self, req, tenant_id, instance_id, is_cluster):
     """Returns True if root is enabled; False otherwise."""
     if is_cluster:
         raise exception.ClusterOperationNotSupported(operation='show_root')
     LOG.info(_LI("Getting root enabled for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     is_root_enabled = models.Root.load(context, instance_id)
     return wsgi.Result(views.RootEnabledView(is_root_enabled).data(), 200)
示例#3
0
文件: service.py 项目: wffeige/trove
 def root_create(self, req, body, tenant_id, instance_id, is_cluster):
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='enable_root')
     LOG.info("Enabling root for instance '%s'.", instance_id)
     LOG.info("req : '%s'\n\n", req)
     context = req.environ[wsgi.CONTEXT_KEY]
     password = DefaultRootController._get_password_from_body(body)
     root = models.Root.create(context, instance_id, password)
     return wsgi.Result(views.RootCreatedView(root).data(), 200)
示例#4
0
文件: service.py 项目: wffeige/trove
 def root_delete(self, req, tenant_id, instance_id, is_cluster):
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='disable_root')
     LOG.info("Disabling root for instance '%s'.", instance_id)
     LOG.info("req : '%s'\n\n", req)
     context = req.environ[wsgi.CONTEXT_KEY]
     is_root_enabled = models.Root.load(context, instance_id)
     if not is_root_enabled:
         raise exception.RootHistoryNotFound()
     models.Root.delete(context, instance_id)
     return wsgi.Result(None, 204)
示例#5
0
 def root_create(self, req, body, tenant_id, instance_id, is_cluster):
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='enable_root')
     LOG.info(_LI("Enabling root for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     user_name = context.user
     if body:
         password = body['password'] if 'password' in body else None
     else:
         password = None
     root = models.Root.create(context, instance_id, user_name, password)
     return wsgi.Result(views.RootCreatedView(root).data(), 200)
示例#6
0
 def root_delete(self, req, tenant_id, instance_id, is_cluster):
     if is_cluster:
         raise exception.ClusterOperationNotSupported(
             operation='disable_root')
     LOG.info(_LI("Disabling root for instance '%s'.") % instance_id)
     LOG.info(_LI("req : '%s'\n\n") % req)
     context = req.environ[wsgi.CONTEXT_KEY]
     try:
         found_user = self._find_root_user(context, instance_id)
     except (ValueError, AttributeError) as e:
         raise exception.BadRequest(msg=str(e))
     if not found_user:
         raise exception.UserNotFound(uuid="root")
     models.Root.delete(context, instance_id)
     return wsgi.Result(None, 200)