config/sysinv/sysinv/sysinv/sysinv/api/controllers/v1
Joao Victor Portal 9aee309999 Deprecate old policy engine and restrict access
This commit does two different changes: it changes the policy engine to
oslo_policy and restrict access to sysinv API to users of projects
'admin' or 'services'.

The policy engine deprecated is the one present in the file
"sysinv/sysinv/sysinv/sysinv/openstack/common/policy.py" (780 lines).
This file is no longer used by this repository and was not deleted
because it is used by other repositories, like starlingx/update. The
library oslo_policy is used in its place. In fact, the deprecated engine
seems to be an ancient version of oslo_policy. The library oslo_policy
changed the default format of configuration files from JSON to YAML, so
the configuration files named "policy.json" were changed to
"policy.yaml". The file that initializes and wraps oslo_policy
("sysinv/sysinv/sysinv/sysinv/common/policy.py") contains the minimal
implementation to use this library.

The access to sysinv API, before this commit, was restricted to users
with role "admin" or "administrator" from any project. This commit
restricts the access to users with role "admin" of projects "admin" or
"services". This change should not cause problems, because role
"administrator" doesn't exist and because all users from Starlingx are
from projects "admin" or "services". This change is needed to avoid
access from admin users of other projects.

To test custom policy rules set in the file "/etc/sysinv/policy.yaml",
it will be used the Service Parameter API actions create/apply/modify/
delete/get (commands "system service-parameter-[add/apply/modify/delete/
list]". To test default policy for sysinv API commands, it will be used
the command to change the system description (PATCH "/v1/isystems",
command "system modify --description='test'"). On test plan, these
commands will be reffered as "test commands". Any change in the file
"/etc/sysinv/policy.yaml" is detected by policy engine and rules are
updated.

Test Plan:

PASS: Successfully deploy an AIO-SX using an Debian image with this
commit present. Successfully create, through openstack CLI, the users:
'testreader' with role 'reader' in project 'admin',
'adminsvc' with role 'admin' in project 'services' and
'otheradmin' with role 'admin' in project 'notadminproject'.
Create openrc files for all new users. Note: the other user that will be
used is the already existing 'admin' with role 'admin' in project
'admin'.
PASS: In the deployed AIO-SX, check the behavior of test commands
through different users: for "admin" and "adminsvc" users, all commands
are successful; for user "testreader", only "service-parameter-list"
command is successful and for user "otheradmin" no command is
successful.
PASS: In the deployed AIO-SX, add the following lines in file
"/etc/sysinv/policy.yaml":
config_api:service_parameter:add: role:reader
config_api:service_parameter:apply: role:reader
config_api:service_parameter:delete: role:reader
config_api:service_parameter:get: role:reader
config_api:service_parameter:modify: role:reader
and check the behavior of test commands through different users:
for "admin" and "adminsvc" users, all commands are successful; for users
"testreader" and "otheradmin", all commands are successful except the
change in the system description ("system modify --description='test'").
PASS: In the deployed AIO-SX, to assert that public API works without
authentication, execute the commands:
"curl -v http://<MGMT_IP>:6385/v1/" and
"curl -v http://<MGMT_IP>:6385/v1/isystems/mgmtvlan" and
verify that they are accepted and that the HTTP response is 200,
and execute the commands:
"curl -v http://<MGMT_IP>:6385/v1/isystems/" and
"curl -v http://<MGMT_IP>:6385/v1/service_parameter" and
verify that they are rejected and that the HTTP response is 401.
PASS: Repeat all tests above changing the deploy to AIO-DX using an
CentOS image.
PASS: Successfully execute Debian AIO-SX daily regression and sanity
tests using an image containing this change.

Story: 2010149
Task: 45984

Signed-off-by: Joao Victor Portal <Joao.VictorPortal@windriver.com>
Change-Id: Id7aa387e154afb1441a8484b076cdc97f2fc46cb
2022-08-10 11:18:38 -03:00
..
__init__.py Add runtime reconfiguration of kubelet 2022-06-09 17:59:35 -04:00
address.py Merge "Fixed address interface foreign key inconsistency" 2020-03-30 16:44:34 +00:00
address_pool.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
base.py Fix calls in sysinv to non-existent methods and constants 2019-08-30 14:54:58 -05:00
ceph_mon.py Enable ceph-mon resize on AIO-DX 2022-02-17 17:39:59 +00:00
certificate.py OpenLDAP certificate support in sysinv apis 2022-03-07 18:01:50 -05:00
cluster.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
collection.py Fix calls in sysinv to non-existent methods and constants 2019-08-30 14:54:58 -05:00
controller_fs.py Block filesystem resizes if waiting for agent to report 2022-04-27 12:29:08 -03:00
cpu.py Remove host hardware sysinv profile 2021-10-18 18:01:40 -03:00
cpu_utils.py Remove host hardware sysinv profile 2021-10-18 18:01:40 -03:00
datanetwork.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
device_image.py Device image upload with bmc type error 2022-07-06 20:13:18 +00:00
device_image_state.py Sysinv extensions for FPGA support 2020-05-13 16:20:37 -04:00
device_label.py Allow applying device image with non-device label 2020-07-28 11:27:28 -04:00
disk.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
dns.py Forbid IPv4 DNS in an IPv6 OAM config 2020-02-06 10:27:04 -05:00
drbdconfig.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
ethernet_port.py Re-enable important py3k checks for sysinv 2021-11-10 11:08:12 -03:00
fernet_repo.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
health.py Add kubernetes health checks 2019-12-20 10:50:33 -06:00
helm_charts.py Fix helm charts tests for DebianOS 2021-08-17 07:39:31 +00:00
host.py Align API types with database types 2022-07-14 18:27:31 -03:00
host_fs.py Block filesystem resizes if waiting for agent to report 2022-04-27 12:29:08 -03:00
hwmon_api.py move rest_api to common code 2021-03-02 15:36:03 -06:00
interface.py Disallow with sriov_numvfs is 0 or less when creating vf interface 2022-07-25 16:08:32 +09:00
interface_datanetwork.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
interface_network.py Remove host hardware sysinv profile 2021-10-18 18:01:40 -03:00
kube_app.py App Fmwk: Add support for FluxCDKustomizeOperator 2022-05-20 16:09:32 -04:00
kube_cluster.py Config API for Kubernetes cluster access information 2021-03-01 07:29:12 -06:00
kube_cmd_version.py Add new kube_cmd_versions table and API endpoint 2021-08-04 16:31:25 +03:00
kube_config_kubelet.py Add runtime reconfiguration of kubelet 2022-06-09 17:59:35 -04:00
kube_host_upgrade.py Provide infrastructure for kubernetes upgrades 2019-11-22 15:13:52 -06:00
kube_rootca_update.py Remove force option for k8s rootca update complete/abort 2021-11-24 12:07:53 -05:00
kube_upgrade.py Fix erroneous networking upgrade error message 2021-11-23 11:34:01 -05:00
kube_version.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
label.py Nohz_full configuration hieradata needs to be updated 2022-07-20 18:11:27 -03:00
license.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
link.py StarlingX open source release updates 2018-05-31 07:35:52 -07:00
lldp_agent.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
lldp_neighbour.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
lldp_tlv.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
load.py Populate more specific load import error messages 2022-07-05 21:03:02 +00:00
lvg.py Remove host hardware sysinv profile 2021-10-18 18:01:40 -03:00
memory.py Align API types with database types 2022-07-14 18:27:31 -03:00
mtce_api.py move rest_api to common code 2021-03-02 15:36:03 -06:00
network.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
network_oam.py Add support for AIO-SX to DX migration on subcloud 2021-03-29 14:00:52 -04:00
node.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
ntp.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
partition.py sysinv: Add support for mpath device 2022-05-24 08:25:18 -04:00
patch_api.py move rest_api to common code 2021-03-02 15:36:03 -06:00
pci_device.py Allow de-provisioning of FEC device 2022-04-06 06:02:42 -04:00
port.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
ptp.py [PTP dual NIC config] Patching PTP configuration 2022-02-10 11:51:08 -03:00
ptp_instance.py Fix PTP parameter deletion error messages 2022-02-22 07:04:01 -05:00
ptp_interface.py Fix PTP parameter deletion error messages 2022-02-22 07:04:01 -05:00
ptp_parameter.py [PTP dual NIC config] Changes from new data model 2021-12-23 15:59:02 -03:00
pv.py Remove host hardware sysinv profile 2021-10-18 18:01:40 -03:00
query.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
registry_image.py Verify docker registry certificate with system trusted CAs 2020-05-29 17:46:18 -04:00
remotelogging.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
restore.py Introduce CLI commands for system restore control 2020-10-09 16:54:04 +03:00
route.py Disallow route config during upgrade states 2022-05-05 10:39:45 -04:00
sdn_controller.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
sensor.py Align API types with database types 2022-07-14 18:27:31 -03:00
sensorgroup.py Align API types with database types 2022-07-14 18:27:31 -03:00
service.py python3: Refactor dict for python2/python3 compat 2021-08-10 12:58:36 -04:00
service_parameter.py Deprecate old policy engine and restrict access 2022-08-10 11:18:38 -03:00
servicegroup.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
servicenode.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
sm_api.py move rest_api to common code 2021-03-02 15:36:03 -06:00
state.py StarlingX open source release updates 2018-05-31 07:35:52 -07:00
storage.py sysinv: Add support for mpath device 2022-05-24 08:25:18 -04:00
storage_backend.py Expose ceph backend field over proxy endpoint 2021-05-24 11:00:19 +03:00
storage_ceph.py Clean unused ceph quota code 2022-02-15 14:12:19 -05:00
storage_ceph_external.py Allow configurable ceph storage backend network 2021-05-07 14:31:39 +03:00
storage_ceph_rook.py Allow configurable ceph storage backend network 2021-05-07 14:31:39 +03:00
storage_external.py Allow configurable ceph storage backend network 2021-05-07 14:31:39 +03:00
storage_file.py Allow configurable ceph storage backend network 2021-05-07 14:31:39 +03:00
storage_lvm.py Re-enable important py3k checks for sysinv 2021-11-10 11:08:12 -03:00
storage_tier.py Remove host hardware sysinv profile 2021-10-18 18:01:40 -03:00
system.py Add validation of special chars on system values 2022-01-26 11:06:37 -03:00
types.py Send the binary data instead of path 2021-05-08 05:52:48 -03:00
upgrade.py Add api to query an upgrade is in progress 2022-02-18 16:28:49 -05:00
user.py Deprecate sysinv.openstack.common.log 2019-11-05 15:29:20 -06:00
utils.py Ceph monitor host is able to lock when only 2 monitors are avilable 2022-06-14 11:38:01 +00:00
vim_api.py move rest_api to common code 2021-03-02 15:36:03 -06:00