Monday, 2020-03-16

*** mattoliverau has joined #openstack-upstream-institute01:38
*** irclogbot_1 has quit IRC06:29
*** irclogbot_3 has joined #openstack-upstream-institute07:30
*** gbutnaru has joined #openstack-upstream-institute13:39
*** Andreas681 has joined #openstack-upstream-institute13:49
Andreas681Hello. I'm trying to make a horizon panel that will list all policies in keystone. I've found this `oslopolicy-policy-generator --namespace keystone --output-file policy.yaml` and it will generate all the default policies, but that is not my intention, since this will override all he existing policies. Is there a function or a module that i can use13:54
Andreas681to call and retrieve back policies as an object?13:54
Andreas681Ive tried this `$ source admin-openrc.sh`13:54
Andreas681`openstack access rule list --user=admin`13:54
Andreas681and it doesnt return anything, however, if I do like this13:54
Andreas681`openstack access rule list --user=demo`13:55
Andreas681Ill get this: `You are not authorized to perform the requested action: identity:list_access_rules. (HTTP 403) (Request-ID: req-77ce6190-2932-4f0c-b6f3-d8aebe43680b`13:55
ildikovAndreas681: it looks like the list you are trying to retrieve is empty14:37
gmannAndreas681: in case you missed the reply yesterday:14:53
gmannthis tool would overwrite the already defined policy. this tool fetch all the policies riles from policy file and merge them with the  defaults which are not in file.14:53
gmann12:04 PM this is where we take care of file rules - https://github.com/openstack/oslo.policy/blob/c3868371212597069e4614d9ae05fe7cd0358ca1/oslo_policy/generator.py#L294-L29914:53
gmannand 403 might be due to override rule. did you override list_access_rules rule ? default value is 'system reader or owner' in new policy or admin or owner depends on which openstack release you are using14:56
Andreas681Hm15:11
gmannyou are using openstack ussuri ?15:13
Andreas681So normally there is no `policy.yaml`file, instead all the policies are "baked" into code? Is there any function I can use to list the current policies that are put in place?15:13
Andreas681I'm using devstack15:13
Andreas681Never heard of ussuri, so I guess I don't use it15:14
gmannussuri is master branch. if you are using devstack master then it is master15:14
gmannlet me check if old default rules are still deprecated or removed. if removed then, you need system scope also15:15
Andreas681Ok I see. I'm working on a student project and my goal is to list all the policies in a nice manner in a horizon panel. But I can't really figure out how to extract the policies when there is no file that contains the policies.15:16
Andreas681And I've seen that there are two types, RuleDefault, and DocumentedRuleDefault. I guess it would be even better if the policy are listed as an object, with a detailed description.15:18
Andreas681Never worked with policies before, so I dont know how the traditional way to display them are15:19
Andreas681It would be a disaster if someone that would use my plugin would get their policies overwritten, so I'm really trying to figure out how to extract the configured policies, within that system, and then list them :]15:27
gmann DocumentedRuleDefault is one that has the description and all.15:30
Andreas681yes, that's the one I'm planning to list.15:31
Andreas681I'm just gonna list the policies in keystone, for starters15:32
gmannyou can use that tool to generate or there are documents also. let me check15:35
Andreas681cheers15:36
gmannAndreas681: here you go. these doc are generated from oslopolicy-policy-generator tool (it is modified at the same time any change in policy so you can rely on them as latest)15:38
gmannkeystone: https://docs.openstack.org/keystone/latest/configuration/policy.html15:38
gmannNova: https://docs.openstack.org/nova/latest/configuration/policy.html15:38
gmannyou can find the sample file also - https://docs.openstack.org/keystone/latest/configuration/samples/policy-yaml.html15:39
gmannsame you can find for all other projects15:39
Andreas681yes, I've been on those pages but I guess the answer flew past my head15:40
Andreas681So what's the syntax to generate DocumentedRuleDefault?15:40
Andreas681Ive only got this to work `oslopolicy-policy-generator --namespace keystone --output-file policy.yaml`15:40
gmannyes this is correct.15:41
Andreas681yes, but this one doesn't give me the documented version15:42
Andreas681It lists 200 policies looking like this15:42
Andreas681"identity:update_consumer": "role:admin and system_scope:all"15:42
Andreas681and so on15:43
gmannthis will give you the sample file (same as linked before)15:43
Andreas681yes, and it also overwrites the existing policies, right?15:44
gmannAndreas681: it should have document also. like this:15:44
gmann# DEPRECATED "identity:create_consumer":"rule:admin_required" has been15:44
gmann# deprecated since T in favor of15:44
gmann# "identity:create_consumer":"role:admin and system_scope:all". The15:44
gmann# OAUTH1 consumer API is now aware of system scope and default roles.15:44
gmann# Update OAUTH1 consumer.15:44
gmann# PATCH  /v3/OS-OAUTH1/consumers/{consumer_id}15:44
gmann# Intended scope(s): system15:44
gmann#"identity:update_consumer": "role:admin and system_scope:all"15:44
Andreas681It doesn't15:44
Andreas681It looks like this:15:45
Andreas681"identity:get_endpoint": "role:reader and system_scope:all"15:45
Andreas681All the way through15:45
gmannAndreas681: no, if there is policy file exist and policy rules present in that file will not be overwrite.15:45
gmannAndreas681: humm, let me try15:45
gmannexisting rules are not modified by this tool. it will just append the one not in file and present in code15:46
Andreas681Oohh15:46
gmannAndreas681: give me 5 min, booting VM15:47
Andreas681Cheers buddy15:47
Andreas681Does it matter where this `policy.yaml`-file is located? or are there any preferred locations such as `/etc/keystone/` or `/opt/stack/horizon/`15:50
*** matt_kosut has quit IRC16:00
*** matt_kosut has joined #openstack-upstream-institute16:00
Andreas681It could be that the description texts are omitted in the output-file, and only spitted out in the terminal16:05
Andreas681Looks like that part is left out in the terminal. I just remade the `policy.yam`-file16:16
Andreas681usr/local/lib/python3.6/dist-packages/oslo_policy/policy.py:706: UserWarning: Policy "identity:delete_user":"rule:admin_required" was deprecated in S in favor of "identity:delete_user":"(role:admin and system_scope:all) or (role:admin and token.domain.id:%(target.user.domain_id)s)". Reason: The user API is now aware of system scope and default16:16
Andreas681roles.. Either ensure your deployment is ready for the new default or copy/paste the deprecated policy into your policy file and maintain it manually.16:16
Andreas681  warnings.warn(deprecated_msg)16:16
Andreas681Andreascn@andreaspoliciesserver:/etc/keystone$16:16
Andreas681The terminal is flooded with this, instead of ending up in the output-file16:17
gmannAndreas681: ok, i got why you did not get documented rules. we have two tool actually, the one you are using is just outputting the rules without document and this one oslopolicy-sample-generator will generate sample file with document - https://docs.openstack.org/oslo.policy/latest/user/usage.html#sample-file-generation16:27
gmannoslopolicy-policy-generator tool will show what policies are used in your env which is nothing but existing policy in file + defaults in code16:28
Andreas681Oh wow, I've seen that tool before.. but the name "sample" made me think it was just a sample/example16:30
Andreas681Now I got it, thanks!16:30
gmannAndreas681: :) yeah name is like that.16:31
Andreas681gmann Does it matter where this `policy.yaml`-file is located? or are there any preferred locations such as `/etc/keystone/` or `/opt/stack/horizon/`16:32
Andreas681Also, there is something strange. With `oslopolicy-sample-generator --namespace keystone --output-file policy.yaml` it does generate policies, but there is only 8 lines that is active, the rest of the lines and commented out D:16:35
gmannAndreas681: not really. path is configurable CONF.policy_file16:36
Andreas681Got it!16:36
gmannthat you can configure this per service16:36
gmannAndreas681: yeah sample file is all commented and you can uncomment the one you want to override16:36
gmannusually, it helps operators to know what all policies are overridden and what all are default to what all users16:38
Andreas681I see I see, now I got something to chew into. Thanks a lot for your help and time <316:39
gmannnp!16:39
*** Andreas681 has quit IRC16:58
*** matt_kosut has quit IRC21:01

Generated by irclog2html.py 2.15.3 by Marius Gedminas - find it at mg.pov.lt!