首页 文章

获取在openstack网络中计算节点的IP地址

提问于
浏览
1

我计划创建一个服务,在openstack环境中休眠/唤醒未使用的计算节点,因为我需要计算节点的ip地址 . 是否有任何API或命令可用于获取openstack网络中存在的IP地址(而不是计算节点的名称)?

2 回答

  • 3

    OpenStack Cloud 环境设置中使用两种类型的IP地址 .

    • 修正:

    仅从openstack网络访问,即在VM之间 .

    • 浮动:

    可以从OpenStack Cloud 网络外部访问,基本上可以在不同的接口上工作,通常这个IP可供公众使用,从外部netwrok访问该VM .

    现在,您知道这一点,请遵循此处给出的API . http://api.openstack.org/api-ref.html#ext-os-ext-ips

    通过JSON响应获取IP地址时,首先必须检查它是固定的还是浮动的 .

    我希望,这应该回答你的问题 . 如果没有,请告知 .

  • 0

    您可以查询nova数据库并获取compute_node表中所有计算节点的ip . 我在python中编写了一个小函数来为我的一个测试做这个 .

    def get_compute_nodes(parameters):
        try:
            password = parameters['password']
            db=_mysql.connect(user="root",passwd=password, db="nova")
            query = """select host_ip from compute_nodes where deleted=0"""
            db.query(query)
            r=db.use_result()
            results =  r.fetch_row(maxrows=0)
            return results
        except Exception as exp:
            print "Error in accessing the Nova database"
            print exp
    

相关问题