Skip to content
Snippets Groups Projects
Commit 199b12e6 authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Change quotes in function documentation string.

The documentation string for parse_host_mac_ip_list() used to be a
single-quoted string literal, and use double quotes (") around all
documented strings inside.  Change that, so it is a double-quoted
string literal and use single quotes (') for most documented strings
inside, in particular for those that are used as Ruby strings and
"symbols", and `` and '' for things that are quoted as text.  This
makes the text read better, in my opinion.  (Normal double quotes
would have been better for the latter case, but we would have to
quote them with backslashes, which makes it more difficult to read
in the source code, so `` and '' will have to do.)
parent a3d95ec7
Branches
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ require 'socket'
module Puppet::Parser::Functions
newfunction(:parse_host_mac_ip_list, :type => :rvalue, :doc => '
newfunction(:parse_host_mac_ip_list, :type => :rvalue, :doc => "
Parse lines of hostnames, MAC addresses and IP addresses.
This function parses lines containing hostname, MAC address, and IP
......@@ -35,43 +35,44 @@ module Puppet::Parser::Functions
i.e, a name, a MAC address, and zero, one or more IP addresses, all
separated by horizontal whitespace.
The special value "-" (a single minus sign/hyphen, ASCII 0x2d, and
The special value ``-'' (a single minus sign/hyphen, ASCII 0x2d, and
nothing else) in the MAC address column means there is no MAC address,
and the "mac" element will be the empty list. Likewise, a "-" instead
of IP address can be used to explicitly indicate that there are no IP
addresses; this is equivalent to simply not listing any IP addresses.
and the 'mac' element will be the empty list. Likewise, a ``-''
instead of IP address can be used to explicitly indicate that there
are no IP addresses; this is equivalent to simply not listing any IP
addresses, unless the 'default_self' flag is given.
An IP address can be a numeric IPv4 or IPv6 address, or a name within
square brackets ("[" and "]"). In the latter case, the name will be
returned with the brackets removed. Numeric IP addresses will be
square brackets (``['' and ``]''). In the latter case, the name will
be returned with the brackets removed. Numeric IP addresses will be
canonicalized.
If the "resolve" flag is specified, hostnames without square brackets
If the 'resolve' flag is specified, hostnames without square brackets
around them can also be listed. Such names will be resolved into
numeric IP addresses, and those will be added to the "ipv4" and
"ipv6" elements as appropriate; the name itself will not be added to
the "ip_Name" element.
The "default_self" flag causes the IP address list to default to the
hostname if no addresses are listed, and "-" is not explicitly given.
If the "resolve" flag is given, the name will be resolved, else it
will just be added to the "ip_Name" element, as if surrounded by
numeric IP addresses, and those will be added to the 'ipv4' and
'ipv6' elements as appropriate; the name itself will not be added to
the 'ip_Name' element.
The 'default_self' flag causes the IP address list to default to the
hostname if no addresses are listed, and ``-'' is not explicitly given.
If the 'resolve' flag is given, the name will be resolved, else it
will just be added to the 'ip_Name' element, as if surrounded by
square brackets.
The return value is a hash with the host names as keys, and the
value for each host being a hash with the following items:
- "mac" The MAC addresses (if any) for the host
- "ipv4" All IPv4 addresses for the host
- "ipv6" All IPv6 addresses for the host
- "ip_Name" All symbolic names in the IP address segment
- "ip" All addresses from the IP address segment; the
- 'mac' The MAC addresses (if any) for the host
- 'ipv4' All IPv4 addresses for the host
- 'ipv6' All IPv6 addresses for the host
- 'ip_Name' All symbolic names in the IP address segment
- 'ip' All addresses from the IP address segment; the
concatenation of the ipv4, ipv6 and ip_Name lists.
The "ip" element is mostly for backward compatibility with older
The 'ip' element is mostly for backward compatibility with older
versions of the function. Users are recommended to migrate away
from using it.
All item values are always lists, even the "mac" item (in the future
All item values are always lists, even the 'mac' item (in the future
there might be a way to specify multiple MAC addresses for a host).
Hostnames are not validated for correctness, and currently nor are MAC
......@@ -79,7 +80,7 @@ module Puppet::Parser::Functions
Each hostname must only be listed once.
Blank lines are ignored. Lines starting with a hash sign ("#") are
Blank lines are ignored. Lines starting with a hash sign (``#'') are
comments, and are also skipped
The intent is to have simple text files with one line per host,
......@@ -98,46 +99,46 @@ module Puppet::Parser::Functions
This will be parsed into the hash
{
"foo" => {
"mac" => [ "012345-6789ab" ],
"ipv4" => [ "192.0.2.6" ],
"ipv6" => [ ],
"ip_Name" => [ "xyzzy" ],
"ip" => [ "192.0.2.6", "xyzzy" ],
'foo' => {
'mac' => [ '012345-6789ab' ],
'ipv4' => [ '192.0.2.6' ],
'ipv6' => [ ],
'ip_Name' => [ 'xyzzy' ],
'ip' => [ '192.0.2.6', 'xyzzy' ],
},
"fie" => {
"mac" => [ ],
"ipv4" => [ "192.0.2.7" ],
"ipv6" => [ "2001:db8:1::7", "2001:db8:1::77" ],
"ip_Name" => [ ],
"ip" => [ "192.0.2.7", "2001:db8:1::7", "2001:db8:1::77" ],
'fie' => {
'mac' => [ ],
'ipv4' => [ '192.0.2.7' ],
'ipv6' => [ '2001:db8:1::7', '2001:db8:1::77' ],
'ip_Name' => [ ],
'ip' => [ '192.0.2.7', '2001:db8:1::7', '2001:db8:1::77' ],
},
"fum" => {
"mac" => [ "cdef-0123-4567" ],
"ipv4" => [ ],
"ipv6" => [ ],
"ip_Name" => [ "fum" ],
"ip" => [ "fum" ],
'fum' => {
'mac' => [ 'cdef-0123-4567' ],
'ipv4' => [ ],
'ipv6' => [ ],
'ip_Name' => [ 'fum' ],
'ip' => [ 'fum' ],
},
}
If the "resolve" flag is specified, then the line
If the 'resolve' flag is specified, then the line
web - www.example.com [dub-dub-dub]
will be parsed into the element
"web" => {
"mac" => [ ],
"ipv4" => [ "192.0.2.80" ],
"ipv6" => [ "2001:db8:1::80", "2001:db8:1::443" ],
"ip_Name" => [ "dub-dub-dub" ],
"ip" => [ "192.0.2.80", "2001:db8:1::80", "2001:db8:1::443", "dub-dub-dub" ],
'web' => {
'mac' => [ ],
'ipv4' => [ '192.0.2.80' ],
'ipv6' => [ '2001:db8:1::80', '2001:db8:1::443' ],
'ip_Name' => [ 'dub-dub-dub' ],
'ip' => [ '192.0.2.80', '2001:db8:1::80', '2001:db8:1::443', 'dub-dub-dub' ],
},
(assuming some specific entries in DNS for www.example.com).
') \
") \
do |args|
if args.length < 1 or args.length > 2
raise(Puppet::ParseError,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment