Skip to content

Commit

Permalink
Merge pull request #1408 from kajinamit/netutils
Browse files Browse the repository at this point in the history
Use oslo.utils method to parse server format
  • Loading branch information
tobias-urdin authored Oct 7, 2024
2 parents 147dedd + a5c9a53 commit 3b509c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
16 changes: 5 additions & 11 deletions gnocchi/common/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.

import re

from oslo_config import cfg
from oslo_utils import netutils
from oslo_utils import strutils
from urllib import parse

Expand Down Expand Up @@ -119,15 +118,10 @@


def _parse_sentinel(sentinel):
# IPv6 (eg. [::1]:6379 )
match = re.search(r'^\[(\S+)\]:(\d+)$', sentinel)
if match:
return (match[1], int(match[2]))
# IPv4 or hostname (eg. 127.0.0.1:6379 or localhost:6379)
match = re.search(r'^(\S+):(\d+)$', sentinel)
if match:
return (match[1], int(match[2]))
raise ValueError('Malformed sentinel server format')
host, port = netutils.parse_host_port(sentinel)
if host is None or port is None:
raise ValueError('Malformed sentinel server format')
return (host, port)


def get_client(conf, scripts=None):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ install_requires =
oslo.config>=3.22.0
oslo.policy>=3.5.0
oslo.middleware>=3.22.0
oslo.utils>=1.1.1
pytimeparse
pecan>=0.9
jsonpatch
Expand Down

0 comments on commit 3b509c2

Please sign in to comment.