ceph dashboard set-rgw-api-ssl-verify False
+To set a custom hostname or address for an RGW gateway, set the value of ``RGW_HOSTNAME_PER_DAEMON``
+accordingly:
+
+.. promt:: bash $
+
+ ceph dashboard set-rgw-hostname <gateway_name> <hostname>
+
+The setting can be unset using:
+
+.. promt:: bash $
+
+ ceph dashboard unset-rgw-hostname <gateway_name>
+
If the Object Gateway takes too long to process requests and the dashboard runs
into timeouts, you can set the timeout value to your needs:
return 0, 'RGW credentials configured', ''
+ @CLIWriteCommand("dashboard set-rgw-hostname")
+ def set_rgw_hostname(self, daemon_name: str, hostname: str):
+ try:
+ rgw_service_manager = RgwServiceManager()
+ rgw_service_manager.set_rgw_hostname(daemon_name, hostname)
+ return 0, f'RGW hostname for daemon {daemon_name} configured', ''
+ except Exception as error:
+ return -errno.EINVAL, '', str(error)
+
+ @CLIWriteCommand("dashboard unset-rgw-hostname")
+ def unset_rgw_hostname(self, daemon_name: str):
+ try:
+ rgw_service_manager = RgwServiceManager()
+ rgw_service_manager.unset_rgw_hostname(daemon_name)
+ return 0, f'RGW hostname for daemon {daemon_name} resetted', ''
+ except Exception as error:
+ return -errno.EINVAL, '', str(error)
+
@CLIWriteCommand("dashboard set-login-banner")
def set_login_banner(self, inbuf: str):
'''
except ModuleNotFoundError:
logging.error("Module 'xmltodict' is not installed.")
-from mgr_util import build_url, name_to_config_section
+from mgr_util import build_url
from .. import mgr
from ..awsauth import S3Auth
Parse RGW daemon info to determine the configured host (IP address) and port.
"""
daemon = RgwDaemon()
- rgw_dns_name = CephService.send_command('mon', 'config get',
- who=name_to_config_section('rgw.' + daemon_info['metadata']['id']), # noqa E501 #pylint: disable=line-too-long
- key='rgw_dns_name').rstrip()
+ rgw_dns_name = ''
+ if (
+ Settings.RGW_HOSTNAME_PER_DAEMON
+ and daemon_info['metadata']['id'] in Settings.RGW_HOSTNAME_PER_DAEMON
+ ):
+ rgw_dns_name = Settings.RGW_HOSTNAME_PER_DAEMON[daemon_info['metadata']['id']]
daemon.port, daemon.ssl = _parse_frontend_config(daemon_info['metadata']['frontend_config#0'])
return (Settings.RGW_API_ACCESS_KEY,
Settings.RGW_API_SECRET_KEY,
Settings.RGW_API_ADMIN_RESOURCE,
- Settings.RGW_API_SSL_VERIFY)
+ Settings.RGW_API_SSL_VERIFY,
+ Settings.RGW_HOSTNAME_PER_DAEMON
+ )
@staticmethod
def instance(userid: Optional[str] = None,
except (AssertionError, SubprocessError) as error:
logger.exception(error)
raise NoCredentialsException
+
+ def set_rgw_hostname(self, daemon_name: str, hostname: str):
+ if not Settings.RGW_HOSTNAME_PER_DAEMON:
+ Settings.RGW_HOSTNAME_PER_DAEMON = {daemon_name: hostname}
+ return
+
+ rgw_hostname_setting = Settings.RGW_HOSTNAME_PER_DAEMON
+ rgw_hostname_setting[daemon_name] = hostname
+ Settings.RGW_HOSTNAME_PER_DAEMON = rgw_hostname_setting
+
+ def unset_rgw_hostname(self, daemon_name: str):
+ if not Settings.RGW_HOSTNAME_PER_DAEMON:
+ return
+
+ rgw_hostname_setting = Settings.RGW_HOSTNAME_PER_DAEMON
+ rgw_hostname_setting.pop(daemon_name, None)
+ Settings.RGW_HOSTNAME_PER_DAEMON = rgw_hostname_setting
RGW_API_SECRET_KEY = Setting('', [dict, str])
RGW_API_ADMIN_RESOURCE = Setting('admin', [str])
RGW_API_SSL_VERIFY = Setting(True, [bool])
+ RGW_HOSTNAME_PER_DAEMON = Setting('', [dict, str])
# Ceph Issue Tracker API Access Key
ISSUE_TRACKER_API_KEY = Setting('', [str])
from .. import mgr
from ..exceptions import DashboardException
-from ..services.rgw_client import NoRgwDaemonsException, RgwClient, _parse_frontend_config
+from ..services.rgw_client import NoRgwDaemonsException, RgwClient, \
+ _determine_rgw_addr, _parse_frontend_config
from ..services.service import NoCredentialsException
from ..settings import Settings
from ..tests import CLICommandTestMixin, RgwStub
retention_period_years=years
))
+ def test_set_rgw_hostname(self):
+ result = self.exec_cmd(
+ 'set-rgw-hostname',
+ daemon_name='test_daemon',
+ hostname='example.hostname.com'
+ )
+ self.assertEqual(
+ result,
+ 'RGW hostname for daemon test_daemon configured'
+ )
+ self.assertEqual(
+ Settings.RGW_HOSTNAME_PER_DAEMON,
+ {'test_daemon': 'example.hostname.com'}
+ )
+
+ @patch("dashboard.services.rgw_client.RgwDaemon")
+ def test_hostname_when_rgw_hostname_config_is_set(self, mock_daemons):
+ mock_instance = Mock()
+ mock_daemons.return_value = mock_instance
+
+ self.test_set_rgw_hostname()
+
+ daemon_info = {
+ 'metadata': {
+ 'id': 'test_daemon',
+ 'hostname': 'my-hostname.com',
+ 'frontend_config#0': 'beast port=8000'
+ },
+ 'addr': '192.0.2.1'
+ }
+
+ result = _determine_rgw_addr(daemon_info)
+ self.assertEqual(result.host, "example.hostname.com")
+
+ @patch("dashboard.services.rgw_client.RgwDaemon")
+ def test_hostname_when_rgw_hostname_config_is_not_set(self, mock_daemons):
+ mock_instance = Mock()
+ mock_daemons.return_value = mock_instance
+
+ daemon_info = {
+ 'metadata': {
+ 'id': 'test_daemon',
+ 'hostname': 'my.hostname.com',
+ 'frontend_config#0': 'beast port=8000'
+ },
+ 'addr': '192.168.178.3:49774/1534999298'
+ }
+
+ result = _determine_rgw_addr(daemon_info)
+ self.assertEqual(result.host, "192.168.178.3")
+
class RgwClientHelperTest(TestCase):
def test_parse_frontend_config_1(self):