
from oslo_policy import policy

from nova.policies import base


POLICY_ROOT = 'os_compute_api:ips:%s'


ips_policies = [
    policy.RuleDefault(
        name=POLICY_ROOT % 'show',
        check_str=base.RULE_ADMIN_OR_OWNER),
    policy.RuleDefault(
        name=POLICY_ROOT % 'index',
        check_str=base.RULE_ADMIN_OR_OWNER),
]


def list_rules():
    return ips_policies


from nova.policies import base


POLICY_ROOT = 'os_compute_api:ips:%s'


ips_policies = [
    base.create_rule_default(
        POLICY_ROOT % 'show',
        base.RULE_ADMIN_OR_OWNER,
        """Shows IP addresses details for a network label of a server.""",
        [
            {
                'method': 'GET',
                'path': '/servers/{server_id}/ips/{network_label}'
            }
        ]),
    base.create_rule_default(
        POLICY_ROOT % 'index',
        base.RULE_ADMIN_OR_OWNER,
        """Lists IP addresses that are assigned to a server.""",
        [
            {
                'method': 'GET',
                'path': '/servers/{server_id}/ips'
            }
        ]),
]


def list_rules():
    return ips_policies

Add policy description for Servers IPs
Add policy description for Servers IPs

This commit adds policy doc for Servers IPs policies.

Partial implement blueprint policy-docs

Change-Id: I94a7c023dd97413d30f5be9edc313caeb47cb633

- 
- from oslo_policy import policy
  
  from nova.policies import base
  
  
  POLICY_ROOT = 'os_compute_api:ips:%s'
  
  
  ips_policies = [
-     policy.RuleDefault(
+     base.create_rule_default(
-         name=POLICY_ROOT % 'show',
+         POLICY_ROOT % 'show',
-         check_str=base.RULE_ADMIN_OR_OWNER),
+         base.RULE_ADMIN_OR_OWNER,
-     policy.RuleDefault(
+         """Shows IP addresses details for a network label of a server.""",
+         [
+             {
+                 'method': 'GET',
+                 'path': '/servers/{server_id}/ips/{network_label}'
+             }
+         ]),
+     base.create_rule_default(
-         name=POLICY_ROOT % 'index',
+         POLICY_ROOT % 'index',
-         check_str=base.RULE_ADMIN_OR_OWNER),
+         base.RULE_ADMIN_OR_OWNER,
+         """Lists IP addresses that are assigned to a server.""",
+         [
+             {
+                 'method': 'GET',
+                 'path': '/servers/{server_id}/ips'
+             }
+         ]),
  ]
  
  
  def list_rules():
      return ips_policies
  
Add policy description for Servers IPs
## Code Before:

from oslo_policy import policy

from nova.policies import base


POLICY_ROOT = 'os_compute_api:ips:%s'


ips_policies = [
    policy.RuleDefault(
        name=POLICY_ROOT % 'show',
        check_str=base.RULE_ADMIN_OR_OWNER),
    policy.RuleDefault(
        name=POLICY_ROOT % 'index',
        check_str=base.RULE_ADMIN_OR_OWNER),
]


def list_rules():
    return ips_policies

## Instruction:
Add policy description for Servers IPs
## Code After:

from nova.policies import base


POLICY_ROOT = 'os_compute_api:ips:%s'


ips_policies = [
    base.create_rule_default(
        POLICY_ROOT % 'show',
        base.RULE_ADMIN_OR_OWNER,
        """Shows IP addresses details for a network label of a server.""",
        [
            {
                'method': 'GET',
                'path': '/servers/{server_id}/ips/{network_label}'
            }
        ]),
    base.create_rule_default(
        POLICY_ROOT % 'index',
        base.RULE_ADMIN_OR_OWNER,
        """Lists IP addresses that are assigned to a server.""",
        [
            {
                'method': 'GET',
                'path': '/servers/{server_id}/ips'
            }
        ]),
]


def list_rules():
    return ips_policies
