0

在我的脚本文件 .sh 中使用:

ctx logger info $(ctx instance host_ip)

我在 AWS 上获得了我的实例的私有 IP。我如何获得公共IP?

4

2 回答 2

2

简短的回答是,目前您还不能,但该功能是计划好的。

更完整的答案 -

ctx.instance.host_ip 映射到计算节点实例的运行时属性 ctx.instance.runtime_properties[ip]。按照惯例,这是一个私有 IP 地址。

如果当前节点属于或派生自类型 cloudify.nodes.Compute,或者如果当前节点具有或派生自具有目标的类型 cloudify.relationships.contained_in,则设置此属性节点类型,或派生自 cloudify.nodes.Compute。

AWS 插件在节点类型 cloudify.aws.nodes.Instance ctx.instance.runtime_properties['public_ip_address'] 上设置运行时属性。

同时,最好的解决方案是给我们一个生命周期操作中的脚本,以在需要公共 IP 的所需节点上设置运行时属性,如您将在此处找到的。

于 2015-11-19T09:36:25.327 回答
0

您可以通过以下方式获取公共 IP 地址:

public_address=$(ctx instance public_ip_address)

ctx logger info "Public IP address is ${public_address}"
于 2016-01-06T08:48:31.353 回答