The next 3.6 release of CFEngine will offer some text manipulation functions. Their names are explicit enough, but the examples below will make their purposes crystal clear.
- strlen()
- upcase()
- downcase()
- head()
- tail()
The next 3.6 release of CFEngine will offer some text manipulation functions. Their names are explicit enough, but the examples below will make their purposes crystal clear.
Python-2.x offers 2 types of integers: plain integers and long integers.
While plain integers have a least a 32 bits precision, long integers have unlimited precision (Numeric types)
Plain integers are automatically promoted to long integers if an overflow happens:
Python 2.7.5 (default, May 12 2013, 12:00:47)
[GCC 4.8.0 20130502 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.maxint
9223372036854775807
>>> a = sys.maxint
>>> print type(a)
<type 'int'>
>>> a +=1
>>> print a
9223372036854775808
>>> print type(a)
<type 'long'>
In C language, integers overflow behavior is different regarding the integer signedness. 2 situations arise: (Basics of Integer Overflow)
Wondering which bundle takes the most time to execute? Here is an attempt to get a more precise idea, with a bundle granularity:
Recently (still in master branch, and certainly in CFEngine-3.5), great new functions have been added to make powerful manipulations on slists. You will find below for each function its documentation (extracted from master branch) and a downloadable example:
Extracts a sublist of elements matching arg1 as a regular expression (if arg3 is true) or as an exact string (if arg3 is false) from a list variable specified in arg2. In regular expression mode, the regex is anchored. If arg4 is true, the matches are inverted (you get elements that don’t match arg1). arg5 specifies a maximum number of elements to return.
Sometimes, crontab entries are preferable over CFEngine internal scheduling when jobs have special scheduling requirements. I have one example where a job must absolutely be started every 2 minutes. (03:20, 03:22, 03:24 and so on)
By default cf-execd is started every 5 minutes, it is ok for 03:20 with Min00, but Min22 and Min24 hard classes will never be defined while cf-execd is running, and some job occurrences never started. Cf-execd can be launched every minute, but by reducing this interval you may have to deal with lock issues. (long splaytime ?)
You can now get completion for cf-* commands if you are using Bash and bash-completion helper
Simply put contrib/cfengine-completion.bash into your bash_completion.d directory:
# wget https://raw.github.com/cfengine/core/master/contrib/cfengine-completion.bash -O -|sudo tee /etc/bash_completion.d/cfengine
Restart your shell, and enjoy:
$ cf-promises --<tab><tab>
--bundlesequence --diagnostic --full-check --negate --verbose
--debug --dry-run --help --policy-output-format --version
--define --file --inform --reports
$ ~/.cfagent/bin/cf-promises --bundl<tab>
$ ~/.cfagent/bin/cf-promises --bundlesequence
Because its meaning is unclear, outputs promises type has been removed from the current core/master tree, and will certainly be missing in the next 3.5 CFEngine community release.
It may reappear later as a control body setting.
Just merged into master branch, the new sys.interface_flags[interface_name] variable allows to get the device flags of a network interface by its name.
It is now possible to retrieve mac addresses under BSD operating systems. (merged into master branch, not yet released)
As far as I know, at least FreeBSD, NetBSD and OpenBSD don’t implement the SIOCGIFHWADDR ioctl, so a getifaddrs() fallback was needed.
Before, only mac_unknown hard class was reported:
# cf-promises -v|hcgrep mac
mac_unknown
Now:
# cf-promises -v|hcgrep mac
mac_08_00_d5_84_88_00
Of course, sys.hardware_addresses and [sys.hardware_macinterface_name] variables are populated.