openstack(kilo) 使非admin用户看到虚拟机所在的宿主机

#修改horizon ubuntu下horizon安装在/usr/share/openstack-dashboard

# /usr/share/openstack-dashboard/openstack_dashboard/dashboards/project/instances/tables.py

[...]

class InstancesTable(tables.DataTable):
    TASK_STATUS_CHOICES = (
        (None, True),
        ("none", True)
    )
    STATUS_CHOICES = (
        ("active", True),
        ("shutoff", True),
        ("suspended", True),
        ("paused", True),
        ("error", False),
        ("rescue", True),
        ("shelved", True),
        ("shelved_offloaded", True),
    )
    name = tables.Column("name",
                         link="horizon:project:instances:detail",
                         verbose_name=_("Instance Name"))
    host = tables.Column("OS-EXT-SRV-ATTR:host",
                         verbose_name=_("Host"))
    image_name = tables.Column("image_name",
                               verbose_name=_("Image Name"))

[...]

nameimage_name之间加入host一行

重启apache

service apache2 restart

#配置nova-api 打开/etc/nova/policy.json文件

"compute_extension:extended_server_attributes": "rule:admin_api",

找到上面一行,将其中的rule:admin_api去掉

重启nova-api

service nova-api restart

#验证 使用非admin用户登录horizon。进入项目->Compute->实例查看。可以看到表格中多了一列主机字段 如果主机中的值显示的是-,则需确认nova-api那里的policy配置是否正确。

#debug 如果修改代码后没有生效,可尝试删除pyc文件: find /usr/share/openstack-dashboard -name "*.pyc" -exec rm -rf {} \;

转载于:https://my.oschina.net/fmnisme/blog/467936

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值