# pylint: disable=W0613
def create(self, realm_name, default, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.create_realm(realm_name, default)
return result
except NoRgwDaemonsException as e:
# pylint: disable=W0613
def list(self, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.list_realms()
return result
except NoRgwDaemonsException as e:
# pylint: disable=W0613
def get(self, realm_name, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.get_realm(realm_name)
return result
except NoRgwDaemonsException as e:
@allow_empty_body
# pylint: disable=W0613
- def set(self, realm_name, default, new_realm_name, daemon_name=None):
+ def set(self, realm_name: str, new_realm_name: str, default: str = None, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
- result = instance.edit_realm(realm_name, default, new_realm_name)
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
+ result = instance.edit_realm(realm_name, new_realm_name, default)
return result
except NoRgwDaemonsException as e:
raise DashboardException(e, http_status_code=404, component='rgw')
def create(self, realm_name, zonegroup_name, default=None, master=None,
zonegroup_endpoints=None, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.create_zonegroup(realm_name, zonegroup_name, default,
master, zonegroup_endpoints)
return result
# pylint: disable=W0613
def list(self, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.list_zonegroups()
return result
except NoRgwDaemonsException as e:
# pylint: disable=W0613
def get(self, zonegroup_name, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.get_zonegroup(zonegroup_name)
return result
except NoRgwDaemonsException as e:
def create(self, zone_name, zonegroup_name=None, default=False, master=False,
zone_endpoints=None, user=None, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.create_zone(zone_name, zonegroup_name, default,
master, zone_endpoints, user)
return result
# pylint: disable=W0613
def list(self, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.list_zones()
return result
except NoRgwDaemonsException as e:
# pylint: disable=W0613
def get(self, zone_name, daemon_name=None):
try:
- instance = RgwClient.admin_instance()
+ instance = RgwClient.admin_instance(daemon_name=daemon_name)
result = instance.get_zone(zone_name)
return result
except NoRgwDaemonsException as e:
except SubprocessError as error:
raise DashboardException(error, http_status_code=500, component='rgw')
- def edit_realm(self, realm_name: str, default: bool, new_realm_name: str):
+ def edit_realm(self, realm_name: str, new_realm_name: str, default: str = None):
rgw_realm_edit_cmd = []
- cmd_edit_realm_options = []
- if new_realm_name == realm_name:
- if str_to_bool(default):
- rgw_realm_edit_cmd = ['realm', 'default']
- cmd_edit_realm_options = ['--rgw-realm', realm_name]
- rgw_realm_edit_cmd += cmd_edit_realm_options
- try:
- exit_code, _, err = mgr.send_rgwadmin_command(rgw_realm_edit_cmd)
- if exit_code > 0:
- raise DashboardException(e=err, msg='Unable to set {} as default realm'.format(realm_name), # noqa E501 #pylint: disable=line-too-long
- http_status_code=500, component='rgw')
- except SubprocessError as error:
- raise DashboardException(error, http_status_code=500, component='rgw')
- else:
- raise DashboardException(msg='The realm already exists',
- http_status_code=400, component='rgw')
- else:
- rgw_realm_edit_cmd = ['realm', 'rename']
- cmd_edit_realm_options = ['--rgw-realm', realm_name, '--realm-new-name', new_realm_name]
- rgw_realm_edit_cmd += cmd_edit_realm_options
+ if new_realm_name != realm_name:
+ rgw_realm_edit_cmd = ['realm', 'rename', '--rgw-realm',
+ realm_name, '--realm-new-name', new_realm_name]
try:
exit_code, _, err = mgr.send_rgwadmin_command(rgw_realm_edit_cmd, False)
if exit_code > 0:
http_status_code=500, component='rgw')
except SubprocessError as error:
raise DashboardException(error, http_status_code=500, component='rgw')
- if str_to_bool(default):
- rgw_realm_edit_cmd = ['realm', 'default']
- cmd_edit_realm_options = ['--rgw-realm', new_realm_name]
- rgw_realm_edit_cmd += cmd_edit_realm_options
- try:
- exit_code, _, _ = mgr.send_rgwadmin_command(rgw_realm_edit_cmd, False)
- if exit_code > 0:
- raise DashboardException(msg='Unable to set {} as default realm'.format(new_realm_name), # noqa E501 #pylint: disable=line-too-long
- http_status_code=500, component='rgw')
- except SubprocessError as error:
- raise DashboardException(error, http_status_code=500, component='rgw')
+ if default and str_to_bool(default):
+ rgw_realm_edit_cmd = ['realm', 'default', '--rgw-realm', new_realm_name]
+ try:
+ exit_code, _, _ = mgr.send_rgwadmin_command(rgw_realm_edit_cmd, False)
+ if exit_code > 0:
+ raise DashboardException(msg='Unable to set {} as default realm'.format(new_realm_name), # noqa E501 #pylint: disable=line-too-long
+ http_status_code=500, component='rgw')
+ except SubprocessError as error:
+ raise DashboardException(error, http_status_code=500, component='rgw')
def create_zonegroup(self, realm_name: str, zonegroup_name: str,
default: bool, master: bool, endpoints: List[str]):