Now we generate the console script using setuptools, and we don't
expect users may directly execute the *.py file.
Change-Id: I6ddeb659c641cf3af33518bb7bf4c24b101f87be
It's needed downstream when packaging. In RDO and Fedora,
we are hitting the issue "ERROR: ambiguous python shebang" during
the build.
Change-Id: I19d99f96d9687c27e04e8cc2ecbf61b42a4dcdf3
Bump hacking to resolve dependency problems and drop the lower
constraints job. Includes pep8 fixes.
Change-Id: If5473a753e774767abf60b9fcf9f57a9aa31b580
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.
Change-Id: Ia5a6219d6c4cc2cb10ddaeee22b957ca85064ab9
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
In a config file you never want the string "null" in place of a null
value. Just render an empty string instead.
Change-Id: Ibe145c4929d4944cd8d51c07a64aee6fd5f831f2
Closes-Bug: #1830967
Story: 2005797
If invalid json is included as the last element in
os_config_files.json it can silently break the file
customizations managed by os-apply-config.
More details:
https://bugzilla.redhat.com/show_bug.cgi?id=1493303
Closes-Bug: #1722321
Change-Id: I0ad89fcde101ba6f3723ab2fa5a348c40452bae5
In Python 3 __ne__ by default delegates to __eq__ and inverts the
result, but in Python 2 they urge you to define __ne__ when you
define __eq__ for it to work properly [1].There are no implied
relationships among the comparison operators. The truth of x==y
does not imply that x!=y is false. Accordingly, when defining __eq__(),
one should also define __ne__() so that the operators will behave as
expected.
[1]https://docs.python.org/2/reference/datamodel.html#object.__ne__
Change-Id: I3df4396495e3404e2c644c769693f89b7c01537a
There has been recent tripleo regressions caused by heat
setting empty config as '' rather than {} which cause os-apply-config
to error on merge_configs.
This change ignores any top-level config which evaluates to False,
ignoring possible empty data including '', {}, None, []
An os-apply-config release with this fix would likely allow the current
heat pin to be removed Id134664a5df7232da0fb5d9ed62b82e12b3d54a8
Change-Id: Ia5bd99d1550f43760c064b769be3be46b3417331
Closes-Bug: #1426116
Related-Bug: #1425238
Given os-apply-config takes a JSON file as input and prints JSON-style
strings not Python ones, Booleans present an anomaly.
These are printed using `str(config)`, resulting in "True" and "False"
rather than the lowercase and JSON-compatible "true" and "false". This
patch corrects this.
There is some risk of breaking users but it should be trivial for them
to fix their scripts. As I write this, o-a-c is at 0.1.28, so we're
allowed breaking changes and I believe this is the last change required
to make all output JSON-compatible.
Change-Id: Ib41d3b01656fc7afc4911fd78ba7c1116aa9b1c9
In the past if we wanted to have a boolean key we had to evaluate the
python string representation of the key which is not necessarily very
easy in shell. This allows us to replace this code:
if [ "$(os-apply-config --key x.foo --type raw)" = "True" ] ; then
...
fi
With a much more shell friendly version:
if os-apply-config --boolean-key x.foo; then
...
fi
Change-Id: Ie88663a0028596dbd2a9c25dfc4ce54a46a63e66
If you use os-apply-config to slice out a JSON blob on the command
line you'll get back a string formatted dump of a python
dictionary (or list). Ideally we would print out proper JSON text
so that other tooling (jq, etc) can post process things in a
useful manner.
This patch updates apply_config so that if an output key is
detected to be a dict or a list it is printed to stdout
in a JSON format.
Change-Id: Ibc8b21cd6922b8664ca71e9e6009c8573ea9d107
OAC can be used to get a key from metadata by supplying EG '--key A'.
You can also extract an item from a dict, EG '--key A.B'.
However, if A is a list, there's no way to get an item out of the list.
Extend the expression language (if that's not too grand a term) to
support this. EG '--key A.0' gets the first item out of the list A.
'--key A.1.B' gets B out of the second item of list A (which must be a
dict).
Change-Id: I406cbd2d974544ed5948e137359629184d8ee156
Add keys 'uid' and 'gid' to control file. The values may be UID/GIDs or
names. In either case, the value is checked against the passwd/group
database to ensure it exists.
Change-Id: I1730a126cf024755635043b1a0f70006ab22c046
The current method of serialization for keys containing null
values in JSON input files is that they become a part of the
metadata tree, with a value expressed as the string 'None' in
output (when invoked with --key) or when inserted into templates.
The use of 'None' creates awkward ambiguity (no way for downstream
code logic to tell if the request JSON key originally contained
the string "None" or if it was actually null), and also throws
conversion errors when requested in any type other than 'raw'.
This patch proposes that keys with null values be handled as
though they were absent from the metadata completely. (If
such a key is requested in command-line invokations using "--key"
and "--key-default", the provided default will be printed.)
Change-Id: I9288dffb13d781e0c4dd9e5be0b483c090ec2d7c
-- os-apply-config --
mode: 0644
-- end --
Mode must be an integer in [0, 0777]. Preferably this will be written as
three octal digits. The default is to use the mode of the target file if
it already exists, otherwise 0644.
Advances blueprint oac-header
Change-Id: I3abfee89d418474b3766a97cfc178c02252e2d02
Allow templates to provide a control file (EG foo => foo.oac). The
control file must be a single YAML mapping. Directory control files are
not supported yet.
Provide a single valid key, allow_empty, by way of example. If
allow_empty is false, either the target file will not be created or if
there's already a file in place, it will be deleted.
Add requirement on 'six' library for Python 3.3 compatibility.
Advances blueprint oac-header
See spec I8fe7126d7261c1f106d7413bd31aa379e9ae5c3e
Change-Id: Ic6952688e4f8273885192bcd5eda8cb657f5a940
OpenStack is making a push to move projects that had been tested on py33
to py34 because py34 will have a much larger install base (and is
consequently easier to test).
The python 3.4 json lib returns new and different error strings when
json decoding fails. Remove assertions from test_load_list_from_json
hat check these error strings, instead simply rely on assertRaises to
assert that the appropriate error is thrown.
Change-Id: Ia6603783014b0114de0f29664834d21196744774
Fix up various things to support Python 3. This also included removing
the pretty lines in README.rst, because tox with Python 3 just could
not cope.
Change-Id: I8e8a40ebc54ab781ccf0961a88fd1f8526aaeba0
/opt/stack is a very OpenStack-specific location to use as a
default for a project that is intended to be usable elsewhere.
This changes the default template directory to reside in
/usr/libexec and deprecates the /opt/stack location, but still
allows the use of /opt/stack so existing users won't be adversely
affected.
Change-Id: I3b7d356985a2c213303d52e36aec34e350f9b553
Os-collect-config will change its' default in this change:
I78b3851b35addfc16913e3cd53c9d0e7eb3d191a
We will need to also follow suit. We print a deprecation warning on
fall back to the old path so that users do not depend on the old path
working forever.
Change-Id: I4fe6e66716b83b202f4ddd5b6870eda448b4c6c8
Parsing usernames would be a fairly common thing todo from heat
metadata, this type allows what would be expected to cover most sane
usernames.
Change-Id: I3a5577d2c5bef1ce54629a0b99e2dc085d274f02
This test was intended to make sure netaddress does not pass through a
SQL injection, but is only testing the default value type.
Change-Id: I817b5d02fa08b6b021a76de9ef43d2a69bbb7b3f
While it is just a copy of the netaddress regexp, they may diverge later
and users should be able to continue using the appropriate one.
Change-Id: Ib6d96113f16fc5f4dc4b8918d2409d08e317a47d
Closes-Bug: #1262786
Or the usage will be displayed as `...OS_CONFIG_FILESis...'. It should
be `...OS_CONFIG_FILES is...'.
Change-Id: I2e5dc1cb565da327efcbba1e7b07ed442ff583fd
The variable is never used in loop, without `_' before the variable
name, pydev will mark a warning.
Change-Id: I3d63b0729c4ae9ec00ca97893c2ded65595235d1
Currently if an error is encountered in the template syntax one can only
see "could not render moustache template...". The error from pystache is
often quite helpful.
Change-Id: If79c3c07a5171d5ff58993066976f10cd9c2a1c7
Swift devices consist of a zone, region, host, port and device, if they
are passed into swift hosts via heat metadata we can now verify them as
native types.
Closes-Bug: #1252165
Change-Id: I8681e36a0b02f62e4856e42ef1900ce4888cb305
It's sometimes desirable to specify the permissions or ownership of the
generated config file instead of setting the default 644 root:root.
If the file is already present, os-apply-config will just update the
contents and leave everything else alone.
Closes-Bug: #1246266
Change-Id: Idd41ec276dd04f517760c1dbd97c75e376840b41