13 Commits

Author SHA1 Message Date
Harald Jensås
7d0f1b785d inet6_prefix() - add test with prefix in input
Extend the unit tests of the inet6_prefix() function to
test input including the prefix ('inet6:[2001::01]:80').

Change-Id: I68ead773868bd418f10a480f2b7b7fc08084374e
2019-05-24 16:43:06 +02:00
Harald Jensås
1f13d87fdf inet6 prefix utility
Utility to handle prefixing IPv6 address with `inet6:`.

This is useful for services relying on python-memcached
which require the inet6:[<ip_address]:<port> format.

Change-Id: Ibd280929f62bae61f34b2984af7710fbd422264b
2019-05-24 01:53:02 +02:00
Carlos Camacho
b3d0590022 Allow integer port in os_transport_url
Currently we only allow to use strings
as the data type for ports.

Due to this we need to cast the data type
in the puppet modules because from THT
this is configured as a Number.

This submission allow to use either string
or numbers for the port parameter in the
os_transport_url function.

Change-Id: I9e56f8e2de542b20fe9e6995506cff5bb435e220
Closes-Bug: #1664561
2017-02-22 10:40:31 +01:00
Andrew Smith
f9672b062f Enable alternative transport in os_transport_url
Change-Id: Ie6965dc5f7896587b5625e38cc758b5564e59bd4
Closes-Bug: 1651215
2016-12-20 10:00:55 -05:00
Alex Schultz
cbeb29e69b Improve os_transport_url ssl support
The ssl paramter of the os_transport_url should be 0/1 but we do not
ensure that this is the value being used in the creation of the
transport_url. This change leverages the stdlib str2bool and bool2num to
ensure that when provided the ssl paramter ends up being 0/1 which is
the correct format for the transport url.  Additionally this also allows
for string booleans to be passed into the ssl parameter and it should
still work correctly.

Change-Id: I278559ba98ba48974ae590dc1e0bb99b6ab961d7
2016-12-19 11:43:07 -07:00
Alex Schultz
8d37c059d2 Fix os_transport_url with single hosts array
If an array with a single host is passed into the hosts param, the
function was erroring because the host was getting converted to a string
when it was checking for bracketing for ipv6. This change checks the
type and fixes the case where a single host is being passed so it
continues to function.

Change-Id: I91b9959a6f71b4e6885e55a568116cc28cf16ddd
Closes-Bug: #1650042
2016-12-14 15:21:03 -07:00
Alex Schultz
7ef2f7b0d7 os_transport_url parser function
This change adds a os_transport_url function that can be used to
generate correct URIs for the transport_url setting used by
oslo.messaging.

Change-Id: If83c0f0e61a08061334536399a42767a305966b7
2016-11-10 16:17:30 -07:00
Emilien Macchi
435c50fe88 normalize_ip_for_uri: allow to give an array of IP addresses
Allow to give an array of IP addresses to normalize_ip_for_url function.
Each IP in the list will be normalized like it would be for a string.

Change-Id: I8d361ce9cfcfe6a3f8592b2b7991971a3c748c75
Co-Authored-By: Athlan-Guyot sofer <sathlang@redhat.com>
2016-09-20 12:55:11 +02:00
Sofer Athlan-Guyot
af2aefbd74 Utility to handle IPv6 address brackets.
This add the function normalize_ip_for_uri to the parser.  It encloses
into brackets any valid IPv6 address thrown at it.

Change-Id: I093dd5a4e6294e20761cb3d33373652eeadeac36
Closes-bug: 1531960
2016-02-11 13:41:14 +01:00
Michael Polenchuk
bad1c6514a Update os_database_connection with extra param
Add support for providing additional parameters to be used when
constructing the database uri. This change adds an 'extra' parameter
which is a hash that will be joined together when constructing the
database uri. It should be noted that the charset option, which can be
provided as a standalone option, will override charset when passed in
the 'extra' parameter. This is to maintain backwards compatibility.

Usage Example:
  os_database_connection({
    ...
    extra => { 'charset' => 'utf-8', 'read_timeout' => 60 }
  })

Change-Id: I7ef078b76ac6cd7bea42a0ac92b383cefd47167a
Co-Authored-By: Alex Schultz <aschultz@mirantis.com>
2015-12-28 15:05:33 -07:00
Alex Schultz
74de9e1d34 Create is_service_default function
This change creates a parser function that can be used to check if a
value is set to the '<SERVICE DEFAULT>' string. The is_service_default
function will return true if the parameter passed in is '<SERVICE
DEFAULT>' otherwise it returns false.

Checks like:
  if ($our_param == '<SERVICE DEFAULT>') { ... }

Should be replaced with:
  if is_service_default($our_param) { ... }

This change will also be useful if we ever refactor the default value
string or have different values as this function could be updated to
support multiple values without having to adjust the calling code.

Change-Id: I07b8b9b54ed1e88891f74da9b930e4f39876a607
2015-09-15 12:23:08 -05:00
Gael Chamoulaud
3fa6399cad spec: updates for rspec-puppet 2.x and rspec 3.x
This patch aim to update our specs test in order to work with the rspec-puppet
release 2.0.0, in the mean time, we update rspec syntax order to be prepared
for rspec 3.x move.

In details:
* Upgrade and pin rspec-puppet from 1.0.1 to 2.0.0
* Convert 'should' keyword to 'is_expected.to' (prepare rspec 3.x)
* Fix spec tests for rspec-puppet 2.0.0
* Clean Gemfile (remove over-specificication of runtime deps of
  puppetlabs_spec_helper)

Change-Id: Ice356e35a65204a62e47f49dd4f5816208a6dace
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2015-03-31 12:13:33 +02:00
Mathieu Gagné
0536a214f4 Add os_database_connection function
The os_database_connection function is an helper used to build
database connection URI from various parameters.

Example:

  os_database_connection({
    dialect  => 'mysql',
    host     => '127.0.0.1',
    port     => '3306',
    username => 'guest',
    password => 's3cr3t',
    database => 'test',
    charset  => 'utf-8'
  })

Result:

  mysql://guest:s3cr3t@127.0.0.1:3306/test?charset=utf-8

Change-Id: Id0bde33891112e36f13d3f8fdf0ff89820c09c01
2014-07-09 14:20:34 -04:00