
from oslo_policy import policy

from nova.policies import base


BASE_POLICY_NAME = 'os_compute_api:os-hosts'


hosts_policies = [
    policy.RuleDefault(
        name=BASE_POLICY_NAME,
        check_str=base.RULE_ADMIN_API),
]


def list_rules():
    return hosts_policies


from nova.policies import base


BASE_POLICY_NAME = 'os_compute_api:os-hosts'


hosts_policies = [
    base.create_rule_default(
        BASE_POLICY_NAME,
        base.RULE_ADMIN_API,
        """List, Show and Manage physical hosts.

These APIs are all deprecated in favor of os-hypervisors and os-services.""",
        [
            {
                'method': 'GET',
                'path': '/os-hosts'
            },
            {
                'method': 'GET',
                'path': '/os-hosts/{host_name}'
            },
            {
                'method': 'PUT',
                'path': '/os-hosts/{host_name}'
            },
            {
                'method': 'GET',
                'path': '/os-hosts/{host_name}/reboot'
            },
            {
                'method': 'GET',
                'path': '/os-hosts/{host_name}/shutdown'
            },
            {
                'method': 'GET',
                'path': '/os-hosts/{host_name}/startup'
            }
        ]),
]


def list_rules():
    return hosts_policies

Add policy description for os-host
Add policy description for os-host

This commit adds policy doc for os-host policies.

Partial implement blueprint policy-docs

Change-Id: Ie15125f025dbb4982ff27cfed12047e8fce3a3cf

- 
- from oslo_policy import policy
  
  from nova.policies import base
  
  
  BASE_POLICY_NAME = 'os_compute_api:os-hosts'
  
  
  hosts_policies = [
-     policy.RuleDefault(
+     base.create_rule_default(
-         name=BASE_POLICY_NAME,
+         BASE_POLICY_NAME,
-         check_str=base.RULE_ADMIN_API),
+         base.RULE_ADMIN_API,
+         """List, Show and Manage physical hosts.
+ 
+ These APIs are all deprecated in favor of os-hypervisors and os-services.""",
+         [
+             {
+                 'method': 'GET',
+                 'path': '/os-hosts'
+             },
+             {
+                 'method': 'GET',
+                 'path': '/os-hosts/{host_name}'
+             },
+             {
+                 'method': 'PUT',
+                 'path': '/os-hosts/{host_name}'
+             },
+             {
+                 'method': 'GET',
+                 'path': '/os-hosts/{host_name}/reboot'
+             },
+             {
+                 'method': 'GET',
+                 'path': '/os-hosts/{host_name}/shutdown'
+             },
+             {
+                 'method': 'GET',
+                 'path': '/os-hosts/{host_name}/startup'
+             }
+         ]),
  ]
  
  
  def list_rules():
      return hosts_policies
  
Add policy description for os-host
## Code Before:

from oslo_policy import policy

from nova.policies import base


BASE_POLICY_NAME = 'os_compute_api:os-hosts'


hosts_policies = [
    policy.RuleDefault(
        name=BASE_POLICY_NAME,
        check_str=base.RULE_ADMIN_API),
]


def list_rules():
    return hosts_policies

## Instruction:
Add policy description for os-host
## Code After:

from nova.policies import base


BASE_POLICY_NAME = 'os_compute_api:os-hosts'


hosts_policies = [
    base.create_rule_default(
        BASE_POLICY_NAME,
        base.RULE_ADMIN_API,
        """List, Show and Manage physical hosts.

These APIs are all deprecated in favor of os-hypervisors and os-services.""",
        [
            {
                'method': 'GET',
                'path': '/os-hosts'
            },
            {
                'method': 'GET',
                'path': '/os-hosts/{host_name}'
            },
            {
                'method': 'PUT',
                'path': '/os-hosts/{host_name}'
            },
            {
                'method': 'GET',
                'path': '/os-hosts/{host_name}/reboot'
            },
            {
                'method': 'GET',
                'path': '/os-hosts/{host_name}/shutdown'
            },
            {
                'method': 'GET',
                'path': '/os-hosts/{host_name}/startup'
            }
        ]),
]


def list_rules():
    return hosts_policies
