我使用托盘返回ec2节点列表。我想得到这些的DNS名称。我在jclouds中看到有一个dnsName方法,但我认为无法访问它以便在clojure中使用托盘。这可能吗?
详情
我正在尝试修改storm-deploy项目以使用dns名称,以便安全组正常工作。具体来说,我正在尝试编写类似这个函数的东西在代码中使用:
(defn zookeeper-dns-names [compute name]
(let [running-nodes (filter running?
(map (partial jclouds-node->node compute) (nodes-in-group compute (str "zookeeper-" name))))]
(map dns-name running-nodes)))
答案 0 :(得分:1)
我在我们的托盘部署中使用它,它通过公共IP获取dns名称:
(defn get-aws-name []
(let [ip (-> (target-node) bean :publicAddresses first)]
(str "ec2-" (apply str (replace {\. \-} ip)) ".compute-1.amazonaws.com")))
私有IP也可以通过安全组工作:
(defn ips-in-group [group-name public-or-private]
"Sequence of the first public IP from each node in the group"
(->> (nodes-in-group group-name)
(map bean)
(map public-or-private)
(map first))
(defn public-ips-in-group
"Sequence of the first public IP from each node in the group"
[group-name]
(ips-in-group group-name :publicAddresses))
(defn private-ips-in-group
"Sequence of the first public IP from each node in the group"
[group-name]
(ips-in-group group-name :privateAddresses))