#修改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"))
[...]
在name
与image_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 {} \;