Issue #1830 has been updated by [email protected].

Motivation for having this function:

The general problem is that I get some value, for example from a fact
or from a parameter to a definition, that needs to be formatted in some
way for the specific use it is being put to.  regsubst() can also be
used for extracting parts of such values.

As a concrete problem I will be solving, I have a large number of
machines that are connected with Ethernet and Infiniband.  They
should have IP addresses on both networks, for example the machine
named n23 should have 10.17.0.23 on the Ethernet net, and 10.18.0.23
on the Infiniband net.  On the ethernet network, they get their IP
addresses using DHCP (and the dhcpd.conf file is generated with an
ERB template).  However, none of the DHCP clients I have seen, and
few of the DHCP servers, can handle Infiniband.  Thus, I want Puppet
to derive the node's Infiniband IP address from its Ethernet IP
address.  With regsubst() and sprintf() I can do that like this:

     $ipre = '^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$'
     $i1 = regsubst($ipaddress_eth0, $ipre, '\1')
     $i2 = regsubst($ipaddress_eth0, $ipre, '\2')
     $i3 = regsubst($ipaddress_eth0, $ipre, '\3')
     $i4 = regsubst($ipaddress_eth0, $ipre, '\4')
     $ibip = sprintf("%d.%d.%d.%d", $i1, $i2 + 1, $i3, $i4)

(This uses the sprintf() function requested in #1831.)
----------------------------------------
Feature #1830: regsubst() function
http://projects.reductivelabs.com/issues/1830

Author: [email protected]
Status: Accepted
Priority: Low
Assigned to: [email protected]
Category: functions
Target version: unplanned
Complexity: Easy
Affected version: 0.24.6
Keywords: 


A function for performing regular expression substitutions on text strings 
would be nice.

A draft implementation has been posted to the puppet-devel list by me, and I 
will work on completing it.


----------------------------------------
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://reductivelabs.com/redmine/my/account

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to