简体   繁体   English

如何使用OHAI获取TestKitchen中指定的ipaddress的值?

[英]How to get value of the ipaddress specified in TestKitchen using OHAI?

I am providing the ipaddress of the machine within my kitchen.yml : 我在kitchen.yml提供了机器的ipaddress

  - name: node_abc
    driver:


      network:
      - ['private_network', {ip: '193.169.33.84'}]

When I try to retrieve the value of ipaddress using 当我尝试使用以下方法检索ipaddress的值时

ohai node[ipaddres]

I get 10.0.2.15 instead of 193.169.33.84 . 我得到10.0.2.15 ,而不是193.169.33.84

How can i get 193.169.33.84 ? 我如何获得193.169.33.84

Use 采用

node["network"]["interfaces"]["eth1"]["addresses"].first.

The reason, why ohai picks the first interface (even if it's only a non-globally routed IP) is because the default route uses this interface. ohai之所以选择第一个接口(即使它只是一个非全局路由的IP)也是因为默认路由使用了该接口。 This should be the place in the code. 应该在代码中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM