summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/services/rgw_iam.py
blob: dbf00df25e0bbcc641ce4f8ca51080164507d977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from subprocess import SubprocessError
from typing import List

from .. import mgr
from ..exceptions import DashboardException


class RgwAccounts:
    def send_rgw_cmd(self, command: List[str]):
        try:
            exit_code, out, err = mgr.send_rgwadmin_command(command)

            if exit_code != 0:
                raise DashboardException(msg=err,
                                         http_status_code=500,
                                         component='rgw')
            return out

        except SubprocessError as e:
            raise DashboardException(e, component='rgw')

    def get_accounts(self):
        get_accounts_cmd = ['account', 'list']
        return self.send_rgw_cmd(get_accounts_cmd)