
from oslo_policy import policy

from nova.policies import base


BASE_POLICY_NAME = 'os_compute_api:os-instance-actions'
POLICY_ROOT = 'os_compute_api:os-instance-actions:%s'


instance_actions_policies = [
    policy.RuleDefault(
        name=POLICY_ROOT % 'events',
        check_str=base.RULE_ADMIN_API),
    policy.RuleDefault(
        name=BASE_POLICY_NAME,
        check_str=base.RULE_ADMIN_OR_OWNER),
]


def list_rules():
    return instance_actions_policies


from nova.policies import base


BASE_POLICY_NAME = 'os_compute_api:os-instance-actions'
POLICY_ROOT = 'os_compute_api:os-instance-actions:%s'


instance_actions_policies = [
    base.create_rule_default(
        POLICY_ROOT % 'events',
        base.RULE_ADMIN_API,
        """Add events details in action details for a server.

This check is performed only after the check
os_compute_api:os-instance-actions passes""",
        [
            {
                'method': 'GET',
                'path': '/servers/{server_id}/os-instance-actions/{request_id}'
            }
        ]),
    base.create_rule_default(
        BASE_POLICY_NAME,
        base.RULE_ADMIN_OR_OWNER,
        """List actions and show action details for a server.""",
        [
            {
                'method': 'GET',
                'path': '/servers/{server_id}/os-instance-actions'
            },
            {
                'method': 'GET',
                'path': '/servers/{server_id}/os-instance-actions/{request_id}'
            }
        ]),
]


def list_rules():
    return instance_actions_policies

Add policy description for instance actions
Add policy description for instance actions

This commit adds policy doc for instance actions policies.

Partial implement blueprint policy-docs

Change-Id: Id336b660fb687d096cd55bf8758dc408c45f9382

- 
- from oslo_policy import policy
  
  from nova.policies import base
  
  
  BASE_POLICY_NAME = 'os_compute_api:os-instance-actions'
  POLICY_ROOT = 'os_compute_api:os-instance-actions:%s'
  
  
  instance_actions_policies = [
-     policy.RuleDefault(
+     base.create_rule_default(
-         name=POLICY_ROOT % 'events',
+         POLICY_ROOT % 'events',
-         check_str=base.RULE_ADMIN_API),
+         base.RULE_ADMIN_API,
-     policy.RuleDefault(
+         """Add events details in action details for a server.
+ 
+ This check is performed only after the check
+ os_compute_api:os-instance-actions passes""",
+         [
+             {
+                 'method': 'GET',
+                 'path': '/servers/{server_id}/os-instance-actions/{request_id}'
+             }
+         ]),
+     base.create_rule_default(
-         name=BASE_POLICY_NAME,
+         BASE_POLICY_NAME,
-         check_str=base.RULE_ADMIN_OR_OWNER),
+         base.RULE_ADMIN_OR_OWNER,
+         """List actions and show action details for a server.""",
+         [
+             {
+                 'method': 'GET',
+                 'path': '/servers/{server_id}/os-instance-actions'
+             },
+             {
+                 'method': 'GET',
+                 'path': '/servers/{server_id}/os-instance-actions/{request_id}'
+             }
+         ]),
  ]
  
  
  def list_rules():
      return instance_actions_policies
  
Add policy description for instance actions
## Code Before:

from oslo_policy import policy

from nova.policies import base


BASE_POLICY_NAME = 'os_compute_api:os-instance-actions'
POLICY_ROOT = 'os_compute_api:os-instance-actions:%s'


instance_actions_policies = [
    policy.RuleDefault(
        name=POLICY_ROOT % 'events',
        check_str=base.RULE_ADMIN_API),
    policy.RuleDefault(
        name=BASE_POLICY_NAME,
        check_str=base.RULE_ADMIN_OR_OWNER),
]


def list_rules():
    return instance_actions_policies

## Instruction:
Add policy description for instance actions
## Code After:

from nova.policies import base


BASE_POLICY_NAME = 'os_compute_api:os-instance-actions'
POLICY_ROOT = 'os_compute_api:os-instance-actions:%s'


instance_actions_policies = [
    base.create_rule_default(
        POLICY_ROOT % 'events',
        base.RULE_ADMIN_API,
        """Add events details in action details for a server.

This check is performed only after the check
os_compute_api:os-instance-actions passes""",
        [
            {
                'method': 'GET',
                'path': '/servers/{server_id}/os-instance-actions/{request_id}'
            }
        ]),
    base.create_rule_default(
        BASE_POLICY_NAME,
        base.RULE_ADMIN_OR_OWNER,
        """List actions and show action details for a server.""",
        [
            {
                'method': 'GET',
                'path': '/servers/{server_id}/os-instance-actions'
            },
            {
                'method': 'GET',
                'path': '/servers/{server_id}/os-instance-actions/{request_id}'
            }
        ]),
]


def list_rules():
    return instance_actions_policies
