Пример #1
0
    def _get_data(self):
        instance_id = self.kwargs['instance_id']
        user_name = self.kwargs['user_name']
        user_host = self.kwargs['user_host']
        try:
            databases = api.trove.database_list(self.request, instance_id)
        except Exception:
            redirect = reverse('horizon:project:databases:detail',
                               args=[instance_id])
            exceptions.handle(self.request,
                              _('Unable to retrieve databases.'),
                              redirect=redirect)
        try:
            instance = api.trove.instance_get(self.request, instance_id)
            username = db_capability.get_fully_qualified_username(
                instance.datastore['type'], user_name, user_host)
            granted = api.trove.user_show_access(
                self.request, instance_id, username)
        except Exception:
            redirect = reverse('horizon:project:databases:detail',
                               args=[instance_id])
            exceptions.handle(self.request,
                              _('Unable to retrieve accessible databases.'),
                              redirect=redirect)

        db_access_list = []
        for database in databases:
            if database in granted:
                access = True
            else:
                access = False

            db_access = DBAccess(database.name, access)
            db_access_list.append(db_access)
        return db_access_list
Пример #2
0
 def action(self, request, obj_id):
     instance_id = self.table.kwargs['instance_id']
     user_name = self.table.kwargs['user_name']
     user_host = self.table.kwargs['user_host']
     instance = api.trove.instance_get(request, instance_id)
     username = db_capability.get_fully_qualified_username(
         instance.datastore['type'], user_name, user_host)
     api.trove.user_revoke_access(
         request, instance_id, username, obj_id, None)
Пример #3
0
 def get_users_data(self):
     instance = self.tab_group.kwargs['instance']
     try:
         data = api.trove.users_list(self.request, instance.id)
         for user in data:
             user.instance = instance
             try:
                 username = db_capability.get_fully_qualified_username(
                     instance.datastore['type'], user.name, user.host)
                 user.access = api.trove.user_list_access(self.request,
                                                          instance.id,
                                                          username)
             except exceptions.NOT_FOUND:
                 pass
             except Exception:
                 msg = _('Unable to get user access data.')
                 exceptions.handle(self.request, msg)
     except Exception:
         msg = _('Unable to get user data.')
         exceptions.handle(self.request, msg)
         data = []
     return data
Пример #4
0
 def delete(self, request, obj_id):
     user = self.table.get_object_by_id(obj_id)
     username = db_capability.get_fully_qualified_username(
         user.instance.datastore['type'], user.name, user.host)
     api.trove.user_delete(request, user.instance.id, username)
Пример #5
0
 def _get_user_name(self, datastore, user_name, user_host):
     return db_capability.get_fully_qualified_username(
         datastore, user_name, user_host)