nova service-list 显示 zone 问题

新部署了一个 nova-compute 节点,使用nova service-list 显示 zone  的问题。

[root@compute-0-46 ~(keystone_admin)]# nova service-list
/usr/lib/python2.7/site-packages/novaclient/client.py:278: UserWarning: The 'tenant_id' argument is deprecated in Ocata and its use may result in errors in future releases. As 'project_id' is provided, the 'tenant_id' argument will be ignored.
  warnings.warn(msg)
+----+------------------+------------------+----------+----------+-------+----------------------------+-----------------+
| Id | Binary           | Host             | Zone     | Status   | State | Updated_at                 | Disabled Reason |
+----+------------------+------------------+----------+----------+-------+----------------------------+-----------------+
| 1  | nova-conductor   | compute-0-3.com | internal | enabled  | up    | 2017-12-04T02:45:00.000000 | -               |
| 3  | nova-consoleauth | compute-0-3.com | internal | enabled  | up    | 2017-12-04T02:45:01.000000 | -               |
| 4  | nova-scheduler   | compute-0-3.com | internal | enabled  | up    | 2017-12-04T02:45:01.000000 | -               |
| 7  | nova-compute     | compute-0-4.com | nova     | disabled | up    | 2017-12-04T02:45:07.000000 | -               |
| 8  | nova-compute     | compute-0-5.com | nova     | disabled | up    | 2017-12-04T02:45:05.000000 | -               |
| 9  | nova-compute     | compute-0-6.com | nova     | disabled | up    | 2017-12-04T02:45:02.000000 | -               |
+----+------------------+-----------------+----------+----------+-------+----------------------------+-----------------+


为什么我新加进去的zone默认名都显示为nova呢,这很奇怪了,因为我在nova-compute里的nova.conf设置了  default_availability_zone=ram_zone。竟然没有到起作用, 

这就是说我在nova-compute里默认设置的zone名字没有用了。 这个很以前老版就不一样了,以前老版这个zone名是在计算节点的配置文件里设置的,我们当时就觉的这个很不合理,看来新版越来越完善了。


还是要分析下代码,这个zone是从哪里来的,怎么设置他呢?

于是跟代码,发现这样一段代码

def _build_metadata_by_host(aggregates, hosts=None):
    if hosts and not isinstance(hosts, set):
        hosts = set(hosts)
    metadata = collections.defaultdict(set)
    for aggregate in aggregates:
        for host in aggregate.hosts:
            if hosts and host not in hosts:
                continue
            metadata[host].add(list(aggregate.metadata.values())[0])
    return metadata


def set_availability_zones(context, services):
    # Makes sure services isn't a sqlalchemy object
    services = [dict(service) for service in services]
    hosts = set([service['host'] for service in services])
    aggregates = objects.AggregateList.get_by_metadata_key(context,
            'availability_zone', hosts=hosts)
    metadata = _build_metadata_by_host(aggregates, hosts=hosts)
    # gather all of the availability zones associated with a service host
    for service in services:
        az = CONF.internal_service_availability_zone
        if service['topic'] == "compute":
            if metadata.get(service['host']):     #如果有metadata就从 metadata里取, 这个metadata就是从
                az = u','.join(list(metadata[service['host']]))
            else:
                az = CONF.default_availability_zone   #没有就直接用nova_api里的 conf配置了,都不从计算节点里读取并存储了
                # update the cache
                update_host_availability_zone_cache(context,
                                                    service['host'], az)
        service['availability_zone'] = az
    return services


从以上代码可以看出,如果不设置zone就默认是 nova_api 里的 conf.default_availability_zone 配置

所以最好在aggregate里设置下

nova aggregate-add-host ceph compute-0-48.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值