# Copyright (c) 2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


policy_data = """
{
    "admin_api": "is_admin:True",

    "cells_scheduler_filter:TargetCellFilter": "is_admin:True",

    "context_is_admin": "role:admin or role:administrator",
    "compute:create": "",
    "compute:create:attach_network": "",
    "compute:create:attach_volume": "",

    "compute:get": "",
    "compute:get_all": "",
    "compute:get_all_tenants": "",

    "compute:update": "",

    "compute:get_instance_metadata": "",
    "compute:get_all_instance_metadata": "",
    "compute:get_all_instance_system_metadata": "",
    "compute:update_instance_metadata": "",
    "compute:delete_instance_metadata": "",

    "compute:get_instance_faults": "",
    "compute:get_diagnostics": "",
    "compute:get_instance_diagnostics": "",

    "compute:get_lock": "",
    "compute:lock": "",
    "compute:unlock": "",
    "compute:unlock_override": "is_admin:True",

    "compute:get_vnc_console": "",
    "compute:get_spice_console": "",
    "compute:get_rdp_console": "",
    "compute:get_serial_console": "",
    "compute:get_console_output": "",

    "compute:associate_floating_ip": "",
    "compute:reset_network": "",
    "compute:inject_network_info": "",
    "compute:add_fixed_ip": "",
    "compute:remove_fixed_ip": "",

    "compute:attach_volume": "",
    "compute:detach_volume": "",

    "compute:attach_interface": "",
    "compute:detach_interface": "",

    "compute:set_admin_password": "",

    "compute:rescue": "",
    "compute:unrescue": "",

    "compute:suspend": "",
    "compute:resume": "",

    "compute:pause": "",
    "compute:unpause": "",

    "compute:start": "",
    "compute:stop": "",

    "compute:resize": "",
    "compute:confirm_resize": "",
    "compute:revert_resize": "",

    "compute:rebuild": "",

    "compute:reboot": "",

    "compute:snapshot": "",
    "compute:backup": "",

    "compute:shelve": "",
    "compute:shelve_offload": "",
    "compute:unshelve": "",

    "compute:security_groups:add_to_instance": "",
    "compute:security_groups:remove_from_instance": "",

    "compute:delete": "",
    "compute:soft_delete": "",
    "compute:force_delete": "",
    "compute:restore": "",
    "compute:swap_volume": "",

    "compute:volume_snapshot_create": "",
    "compute:volume_snapshot_delete": "",

    "compute:v3:servers:start": "",
    "compute:v3:servers:stop": "",
    "compute_extension:v3:os-access-ips": "",
    "compute_extension:accounts": "",
    "compute_extension:admin_actions:pause": "",
    "compute_extension:admin_actions:unpause": "",
    "compute_extension:admin_actions:suspend": "",
    "compute_extension:admin_actions:resume": "",
    "compute_extension:admin_actions:lock": "",
    "compute_extension:admin_actions:unlock": "",
    "compute_extension:admin_actions:resetNetwork": "",
    "compute_extension:admin_actions:injectNetworkInfo": "",
    "compute_extension:admin_actions:createBackup": "",
    "compute_extension:admin_actions:migrateLive": "",
    "compute_extension:admin_actions:resetState": "",
    "compute_extension:admin_actions:migrate": "",
    "compute_extension:v3:os-admin-actions:reset_network": "",
    "compute_extension:v3:os-admin-actions:inject_network_info": "",
    "compute_extension:v3:os-admin-actions:reset_state": "",
    "compute_extension:v3:os-admin-password": "",
    "compute_extension:aggregates": "rule:admin_api",
    "compute_extension:v3:os-aggregates:index": "rule:admin_api",
    "compute_extension:v3:os-aggregates:create": "rule:admin_api",
    "compute_extension:v3:os-aggregates:show": "rule:admin_api",
    "compute_extension:v3:os-aggregates:update": "rule:admin_api",
    "compute_extension:v3:os-aggregates:delete": "rule:admin_api",
    "compute_extension:v3:os-aggregates:add_host": "rule:admin_api",
    "compute_extension:v3:os-aggregates:remove_host": "rule:admin_api",
    "compute_extension:v3:os-aggregates:set_metadata": "rule:admin_api",
    "compute_extension:agents": "",
    "compute_extension:v3:os-agents": "",
    "compute_extension:attach_interfaces": "",
    "compute_extension:v3:os-attach-interfaces": "",
    "compute_extension:baremetal_nodes": "",
    "compute_extension:v3:os-baremetal-nodes": "",
    "compute_extension:cells": "",
    "compute_extension:cells:create": "rule:admin_api",
    "compute_extension:cells:delete": "rule:admin_api",
    "compute_extension:cells:update": "rule:admin_api",
    "compute_extension:cells:sync_instances": "rule:admin_api",
    "compute_extension:v3:os-cells": "",
    "compute_extension:v3:os-cells:create": "rule:admin_api",
    "compute_extension:v3:os-cells:delete": "rule:admin_api",
    "compute_extension:v3:os-cells:update": "rule:admin_api",
    "compute_extension:v3:os-cells:sync_instances": "rule:admin_api",
    "compute_extension:certificates": "",
    "compute_extension:v3:os-certificates:create": "",
    "compute_extension:v3:os-certificates:show": "",
    "compute_extension:cloudpipe": "",
    "compute_extension:v3:os-cloudpipe": "",
    "compute_extension:cloudpipe_update": "",
    "compute_extension:config_drive": "",
    "compute_extension:v3:os-config-drive": "",
    "compute_extension:console_output": "",
    "compute_extension:v3:os-console-output": "",
    "compute_extension:consoles": "",
    "compute_extension:v3:os-remote-consoles": "",
    "compute_extension:createserverext": "",
    "compute_extension:v3:os-create-backup": "",
    "compute_extension:deferred_delete": "",
    "compute_extension:v3:os-deferred-delete": "",
    "compute_extension:disk_config": "",
    "compute_extension:v3:os-disk-config": "",
    "compute_extension:evacuate": "is_admin:True",
    "compute_extension:v3:os-evacuate": "is_admin:True",
    "compute_extension:extended_server_attributes": "",
    "compute_extension:v3:os-extended-server-attributes": "",
    "compute_extension:extended_status": "",
    "compute_extension:v3:os-extended-status": "",
    "compute_extension:extended_availability_zone": "",
    "compute_extension:v3:os-extended-availability-zone": "",
    "compute_extension:extended_ips": "",
    "compute_extension:extended_ips_mac": "",
    "compute_extension:extended_vif_net": "",
    "compute_extension:extended_volumes": "",
    "compute_extension:v3:os-extended-volumes": "",
    "compute_extension:v3:os-extended-volumes:swap": "",
    "compute_extension:v3:os-extended-volumes:attach": "",
    "compute_extension:v3:os-extended-volumes:detach": "",
    "compute_extension:v3:extensions:discoverable": "",
    "compute_extension:fixed_ips": "",
    "compute_extension:v3:os-fixed-ips": "",
    "compute_extension:flavor_access": "",
    "compute_extension:flavor_access:addTenantAccess": "rule:admin_api",
    "compute_extension:flavor_access:removeTenantAccess": "rule:admin_api",
    "compute_extension:v3:os-flavor-access": "",
    "compute_extension:v3:os-flavor-access:remove_tenant_access":
    "rule:admin_api",
    "compute_extension:v3:os-flavor-access:add_tenant_access":
    "rule:admin_api",
    "compute_extension:flavor_disabled": "",
    "compute_extension:v3:os-flavor-disabled": "",
    "compute_extension:flavor_rxtx": "",
    "compute_extension:v3:os-flavor-rxtx": "",
    "compute_extension:flavor_swap": "",
    "compute_extension:flavorextradata": "",
    "compute_extension:flavorextraspecs:index": "",
    "compute_extension:flavorextraspecs:show": "",
    "compute_extension:flavorextraspecs:create": "is_admin:True",
    "compute_extension:flavorextraspecs:update": "is_admin:True",
    "compute_extension:flavorextraspecs:delete": "is_admin:True",
    "compute_extension:v3:flavor-extra-specs:index": "",
    "compute_extension:v3:flavor-extra-specs:show": "",
    "compute_extension:v3:flavor-extra-specs:create": "is_admin:True",
    "compute_extension:v3:flavor-extra-specs:update": "is_admin:True",
    "compute_extension:v3:flavor-extra-specs:delete": "is_admin:True",
    "compute_extension:flavormanage": "",
    "compute_extension:v3:flavor-manage": "",
    "compute_extension:v3:flavors:discoverable": "",
    "compute_extension:floating_ip_dns": "",
    "compute_extension:floating_ip_pools": "",
    "compute_extension:v3:os-floating-ip-pools": "",
    "compute_extension:floating_ips": "",
    "compute_extension:floating_ips_bulk": "",
    "compute_extension:v3:os-floating-ips-bulk": "",
    "compute_extension:fping": "",
    "compute_extension:fping:all_tenants": "is_admin:True",
    "compute_extension:v3:os-fping": "",
    "compute_extension:v3:os-fping:all_tenants": "is_admin:True",
    "compute_extension:hide_server_addresses": "",
    "compute_extension:v3:os-hide-server-addresses": "",
    "compute_extension:hosts": "rule:admin_api",
    "compute_extension:v3:os-hosts": "rule:admin_api",
    "compute_extension:hypervisors": "rule:admin_api",
    "compute_extension:v3:os-hypervisors": "rule:admin_api",
    "compute_extension:image_size": "",
    "compute_extension:v3:image-size": "",
    "compute_extension:instance_actions": "",
    "compute_extension:v3:os-instance-actions": "",
    "compute_extension:instance_actions:events": "is_admin:True",
    "compute_extension:v3:os-instance-actions:events": "is_admin:True",
    "compute_extension:instance_usage_audit_log": "",
    "compute_extension:keypairs": "",
    "compute_extension:keypairs:index": "",
    "compute_extension:keypairs:show": "",
    "compute_extension:keypairs:create": "",
    "compute_extension:keypairs:delete": "",

    "compute_extension:v3:os-keypairs": "",
    "compute_extension:v3:os-keypairs:index": "",
    "compute_extension:v3:os-keypairs:show": "",
    "compute_extension:v3:os-keypairs:create": "",
    "compute_extension:v3:os-keypairs:delete": "",
    "compute_extension:v3:os-lock-server:lock": "",
    "compute_extension:v3:os-lock-server:unlock": "",
    "compute_extension:v3:os-migrate-server:migrate": "",
    "compute_extension:v3:os-migrate-server:migrate_live": "",
    "compute_extension:multinic": "",
    "compute_extension:v3:os-multinic": "",
    "compute_extension:networks": "",
    "compute_extension:networks:view": "",
    "compute_extension:v3:os-networks": "",
    "compute_extension:v3:os-networks:view": "",
    "compute_extension:networks_associate": "",
    "compute_extension:v3:os-networks-associate": "",
    "compute_extension:os-tenant-networks": "",
    "compute_extension:v3:os-tenant-networks": "",
    "compute_extension:v3:os-pause-server:pause": "",
    "compute_extension:v3:os-pause-server:unpause": "",
    "compute_extension:v3:os-pci:pci_servers": "",
    "compute_extension:v3:os-pci:index": "",
    "compute_extension:v3:os-pci:detail": "",
    "compute_extension:v3:os-pci:show": "",
    "compute_extension:quotas:show": "",
    "compute_extension:quotas:update": "",
    "compute_extension:quotas:delete": "",
    "compute_extension:v3:os-quota-sets:show": "",
    "compute_extension:v3:os-quota-sets:update": "",
    "compute_extension:v3:os-quota-sets:delete": "",
    "compute_extension:v3:os-quota-sets:detail": "",
    "compute_extension:quota_classes": "",
    "compute_extension:rescue": "",
    "compute_extension:v3:os-rescue": "",
    "compute_extension:security_group_default_rules": "",
    "compute_extension:security_groups": "",
    "compute_extension:v3:os-security-groups": "",
    "compute_extension:server_diagnostics": "",
    "compute_extension:v3:os-server-diagnostics": "",
    "compute_extension:server_groups": "",
    "compute_extension:server_password": "",
    "compute_extension:v3:os-server-password": "",
    "compute_extension:server_usage": "",
    "compute_extension:v3:os-server-usage": "",
    "compute_extension:v3:os-server-groups": "",
    "compute_extension:services": "",
    "compute_extension:v3:os-services": "",
    "compute_extension:shelve": "",
    "compute_extension:shelveOffload": "",
    "compute_extension:v3:os-shelve:shelve": "",
    "compute_extension:v3:os-shelve:shelve_offload": "",
    "compute_extension:simple_tenant_usage:show": "",
    "compute_extension:simple_tenant_usage:list": "",
    "compute_extension:v3:os-simple-tenant-usage:show": "",
    "compute_extension:v3:os-simple-tenant-usage:list": "",
    "compute_extension:unshelve": "",
    "compute_extension:v3:os-shelve:unshelve": "",
    "compute_extension:v3:os-suspend-server:suspend": "",
    "compute_extension:v3:os-suspend-server:resume": "",
    "compute_extension:users": "",
    "compute_extension:virtual_interfaces": "",
    "compute_extension:virtual_storage_arrays": "",
    "compute_extension:volumes": "",
    "compute_extension:volume_attachments:index": "",
    "compute_extension:volume_attachments:show": "",
    "compute_extension:volume_attachments:create": "",
    "compute_extension:volume_attachments:update": "",
    "compute_extension:volume_attachments:delete": "",
    "compute_extension:v3:os-volumes": "",
    "compute_extension:volumetypes": "",
    "compute_extension:zones": "",
    "compute_extension:availability_zone:list": "",
    "compute_extension:v3:os-availability-zone:list": "",
    "compute_extension:availability_zone:detail": "is_admin:True",
    "compute_extension:v3:os-availability-zone:detail": "is_admin:True",
    "compute_extension:used_limits_for_admin": "is_admin:True",
    "compute_extension:v3:os-used-limits": "is_admin:True",
    "compute_extension:migrations:index": "is_admin:True",
    "compute_extension:v3:os-migrations:index": "is_admin:True",
    "compute_extension:os-assisted-volume-snapshots:create": "",
    "compute_extension:os-assisted-volume-snapshots:delete": "",
    "compute_extension:console_auth_tokens": "is_admin:True",
    "compute_extension:v3:os-console-auth-tokens": "is_admin:True",
    "compute_extension:os-server-external-events:create": "rule:admin_api",
    "compute_extension:v3:os-server-external-events:create": "rule:admin_api",

    "volume:create": "",
    "volume:get": "",
    "volume:get_all": "",
    "volume:get_volume_metadata": "",
    "volume:delete": "",
    "volume:update": "",
    "volume:delete_volume_metadata": "",
    "volume:update_volume_metadata": "",
    "volume:attach": "",
    "volume:detach": "",
    "volume:reserve_volume": "",
    "volume:unreserve_volume": "",
    "volume:begin_detaching": "",
    "volume:roll_detaching": "",
    "volume:check_attach": "",
    "volume:check_detach": "",
    "volume:initialize_connection": "",
    "volume:terminate_connection": "",
    "volume:create_snapshot": "",
    "volume:delete_snapshot": "",
    "volume:get_snapshot": "",
    "volume:get_all_snapshots": "",


    "volume_extension:volume_admin_actions:reset_status": "rule:admin_api",
    "volume_extension:snapshot_admin_actions:reset_status": "rule:admin_api",
    "volume_extension:volume_admin_actions:force_delete": "rule:admin_api",
    "volume_extension:volume_actions:upload_image": "",
    "volume_extension:types_manage": "",
    "volume_extension:types_extra_specs": "",


    "network:get_all": "",
    "network:get": "",
    "network:create": "",
    "network:delete": "",
    "network:associate": "",
    "network:disassociate": "",
    "network:get_vifs_by_instance": "",
    "network:get_vif_by_mac_address": "",
    "network:allocate_for_instance": "",
    "network:deallocate_for_instance": "",
    "network:validate_networks": "",
    "network:get_instance_uuids_by_ip_filter": "",
    "network:get_instance_id_by_floating_address": "",
    "network:setup_networks_on_host": "",

    "network:get_floating_ip": "",
    "network:get_floating_ip_pools": "",
    "network:get_floating_ip_by_address": "",
    "network:get_floating_ips_by_project": "",
    "network:get_floating_ips_by_fixed_address": "",
    "network:allocate_floating_ip": "",
    "network:deallocate_floating_ip": "",
    "network:associate_floating_ip": "",
    "network:disassociate_floating_ip": "",
    "network:release_floating_ip": "",
    "network:migrate_instance_start": "",
    "network:migrate_instance_finish": "",

    "network:get_fixed_ip": "",
    "network:get_fixed_ip_by_address": "",
    "network:add_fixed_ip_to_instance": "",
    "network:remove_fixed_ip_from_instance": "",
    "network:add_network_to_project": "",
    "network:get_instance_nw_info": "",

    "network:get_dns_domains": "",
    "network:add_dns_entry": "",
    "network:modify_dns_entry": "",
    "network:delete_dns_entry": "",
    "network:get_dns_entries_by_address": "",
    "network:get_dns_entries_by_name": "",
    "network:create_private_dns_domain": "",
    "network:create_public_dns_domain": "",
    "network:delete_dns_domain": "",
    "network:attach_external_network": "rule:admin_api"
}
"""
