Current FaultAPIs (get_fault/get_faults/get_faults_by_id) cannot
distinguish error and no data case. None will be returned for both
case. To separate these two cases, and implement the code more as
pythonic way, FaultAPIsV2 is added, which will raise exception for
error case.
In order to separate the cases, the C functions called by API are
modified to return FALSE for error, and return None for no data.
Test:
Pass basic deploy test, and "fm alarm-*" cmd work as before.
Use fm_api_test.py/fm_api_v2_test.py to manual trigger API call,
confirm alarm could be created/get/deleted, and value is the same
as "fm alarm-list".
Modify fmManager to simulate error case, confirm exception is
generated for FaultAPIsV2, and behavior is not changed for
FaultAPIs.
Story: 2004859
Task: 29097
Change-Id: Ic1c0a15eb8dfec6c368099b096d6a158da0d3c77
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
It is due to out of range access violation. Fix it by checking length
before access.
Closes-Bug: 1807986
Change-Id: Iba2b445f50fd98a74d932c9b3f691fc7145274bb
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
This patch adds compiler flags to improve the security of STX code.
Flags added:
Format string vulnerabilities: CFLAGS="-Wformat -Wformat-security"
Compiler will treat string format warnings as errors,
so at compiling level, buffer overflow is avoided.
Story: 2004380
Task: 28806
Signed-off-by: Luis Botello <luis.botello.ortega@intel.com>
Reviewed-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
Victor Rodriguez <vm.rod25@gmail.com>
Sugested-by: Victor Rodriguez <vm.rod25@gmail.com>
Erich Cordoba <erich.cordoba.malibran@intel.com>
Change-Id: Ia1ffaf18e7050d9099b80f9023b2bf255b4750fa
The `install_non_bb` target was changed to `install`, also some
variable names in the Makefile and spec file were changed. There
was a hardcoded path in fmConstants.h and that was updated as well.
Story: 2004043
Task: 27543
Change-Id: I431b733030444185cc51a8b5352492926170a4c3
Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
in function fm_db_util_get_timestamp()
172: char *tstr = strdup(str);
memory obtained from strdup() is done dynamically using malloc().
it should be freed when tstr is no longer in use.
test case:
1. one controller + one compute deploy (virtual)
success to deploy and create an instance.
Closes-Bug: 1794705
Change-Id: I0d0c1e6e4386128d6cb38741d80af22a5f10b770
as for strncpy does not guarantee null terminated of dest string,
but snprintf does.
so change code from
strncpy(buffer, source, sizeof buffer);
to
int n = snprintf(buffer, sizeof buffer, "%s", source);
assert(n >= 0 && n < sizeof buffer);
test case:
1. a simple test about difference between strncpy and snprintf
2. use fmClientCli to create an alarm
mock the init_tables() function so there is no need to
connect to the server.
add code to dump SFmAlarmDataT to check datas return.
3. one controller + one compute deploy (virtual)
success deploy and create an instance.
Closes-Bug: 1794701
Change-Id: I04b4c5c85782ff571e2957e12c47f2f628d2b772
This update adds hooks to the spec files for the following packages
to generate wheels for the python modules:
- fm-api
- fm-common
- fm-rest-api
- python-fmclient
Change-Id: I0542650b52b9c5b0627023a2ce1996176135411d
Story: 2003907
Task: 27525
Signed-off-by: Don Penney <don.penney@windriver.com>
The macro STRCP_TO copies a c_str into a char buffer, it won't
copy more that sizeof(charb), however, the resulting string will
be truncated. Although this is expected, the resulting string
won't have a NULL terminator.
Story: 2003497
Task: 24774
Change-Id: I249c75af897ba02837ad6d3981d976c291e88aea
Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
Specifically get the psql include path from pg_config as libpq-fe.h
is in different places on RHEL-based and Debian-based systems.
Also add -f to symlink command in install because we can't assume
DEST_DIR is empty.
This is in support of Austin's DevStack wirk in stx-config started
in https://review.openstack.org/#/c/586443/, in my case because all of
my DevStack VMs run Ubuntu xenial.
Needed-by: https://review.openstack.org/595865
Change-Id: I8db0579225487e6b31fe8a5ed88a29820bda7d69
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
As C++ references cannot be NULL, new compilers optimizes the code
assuming this condition. Therefore, in new compilers, from GCC 6 to
8 the fn_snmp_util_gen_trap will segfault trying to deference
data.entity_instance_id as the if (&data != NULL) will be always
optimized to be true.
Turns out that the case where SFmAlarmDataT is expected to be NULL
(or empty) is when the alarm type is WARM_START. So changing the if
statement to look for WARM_START instead of checking the null reference
seems to be a feasible solution.
Story: 2003498
Task: 24775
Change-Id: Ica07ec8d7ad009e1048f014b0a6440c76de09eef
Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
Create fault management REST API service
Create fault management client and CLI shell
Add a python extension for fault management application APIs
Update fault management python APIs to use the python extension
Update fault manager to retrieve the SNMP configuration from the config file
Story: 2002828
Task: 22747
Depends-On: https://review.openstack.org/#/c/592176/
Change-Id: I888d8d23edf75d05d51594ccca55570ae366c848
Signed-off-by: Tao Liu <tao.liu@windriver.com>
Enable test for pep8 and use flake8 as check tool.
Story: 2003310
Task: 24446
Change-Id: Idf5cbde46dc1a2a579587438b83f2dcb7b9352bb
Signed-off-by: chenyan <yan.chen@intel.com>
In Python 3 print is a function.
Especially for multiple string print, need to import
print_function from __future__.
Story: 2003310
Task: 24265
Change-Id: I1e8f80527f9ba97093a8e753f3460110e160d1b9
Signed-off-by: chenyan <yan.chen@intel.com>
The built-in named 'file' has been removed since Python 3.0 [1]
This patch replaces it by 'open' which is the same under Python 2 and 3.
[1] https://docs.python.org/release/3.0/whatsnew/3.0.html#builtins
Change-Id: Ib2abbd0f6aea4423acae0c7dceccf1ef67c1caae
Doing filesystem resizes is blocked when a node is degraded and
going over 90% filesystem utilization degrades the node.
This prevents the user from clearing the alarm by resizing and
adding more space to a certain filesystem.
To fix this, we check add a new field to every alarm marking
which alarm causes a degrade.
In case of a filesystem resize, we poll all alarms and filter
them for those that are causing a degrade. If the only alarm
that causes a degrade is the filesystem usage alarm, then
it is safe to proceed with the resize.
Change-Id: I9b4a9c34f625ef2669725d489460b15e637c1efc
Signed-off-by: Jack Ding <jack.ding@windriver.com>