2013-05-10 84 views
4

我使用托盘获取ec2节点列表。我想获得这些的DNS名称。我发现在jcloud中有一个dnsName方法,但是我发现无法访问它以便在clojure中使用托盘。这可能吗?通过托盘获取ec2 dns名称

详细

我试图进行修改风暴部署项目,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

托盘0.8或0.7? – 2013-05-10 19:44:49

+0

0.7,虽然看文档似乎没有支持这个0.8 – 2013-05-12 18:20:40

+1

它只是没有在文档尚未。我的答案在0.8(我没有在0.7中测试过)运行,0.8测试版肯定可以用于日常使用。 – 2013-05-12 20:04:41

回答

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)) 
+0

谢谢。我最终用私人ips方法解决了这个问题。 – 2013-05-12 18:22:39