libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject git commit: docs: Update examples.
Date Fri, 10 Jan 2014 00:56:01 GMT
Updated Branches:
  refs/heads/trunk 4aa7a27d1 -> b6ada523b


docs: Update examples.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b6ada523
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b6ada523
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b6ada523

Branch: refs/heads/trunk
Commit: b6ada523b3493c765b3e1cd164a889e1e22167f9
Parents: 4aa7a27
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Fri Jan 10 01:53:49 2014 +0100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Fri Jan 10 01:53:49 2014 +0100

----------------------------------------------------------------------
 .../create_a_record_for_all_rackspace_nodes.py  | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/b6ada523/docs/examples/dns/create_a_record_for_all_rackspace_nodes.py
----------------------------------------------------------------------
diff --git a/docs/examples/dns/create_a_record_for_all_rackspace_nodes.py b/docs/examples/dns/create_a_record_for_all_rackspace_nodes.py
index d7160ee..93147c1 100644
--- a/docs/examples/dns/create_a_record_for_all_rackspace_nodes.py
+++ b/docs/examples/dns/create_a_record_for_all_rackspace_nodes.py
@@ -3,16 +3,17 @@ from pprint import pprint
 from libcloud.compute.providers import get_driver as get_compute_driver
 from libcloud.compute.types import Provider as ComputeProvider
 from libcloud.dns.providers import get_driver as get_dns_driver
-from libcloud.dns.types import Provider as DNSProvider, RecordType
+from libcloud.dns.types import Provider as DNSProvider
+from libcloud.dns.types import RecordType
 
 CREDENTIALS_RACKSPACE = ('username', 'api key')
 CREDENTIALS_ZERIGO = ('email', 'api key')
 
-Cls = get_compute_driver(ComputeProvider.RACKSPACE)
-compute_driver = Cls(*CREDENTIALS_RACKSPACE)
+cls = get_compute_driver(ComputeProvider.RACKSPACE)
+compute_driver = cls(*CREDENTIALS_RACKSPACE)
 
-Cls = get_dns_driver(DNSProvider.ZERIGO)
-dns_driver = Cls(*CREDENTIALS_ZERIGO)
+cls = get_dns_driver(DNSProvider.ZERIGO)
+dns_driver = cls(*CREDENTIALS_ZERIGO)
 
 # Retrieve all the nodes
 nodes = compute_driver.list_nodes()
@@ -21,17 +22,16 @@ nodes = compute_driver.list_nodes()
 zone = dns_driver.create_zone(domain='mydomain2.com')
 
 created = []
+
 for node in nodes:
     name = node.name
 
-    ips = node.public_ip
+    ip = node.public_ips[0] if node.public_ips else None
 
-    if not ips:
+    if not ip:
         continue
 
-    ip = ips[0]
-
-    print 'Creating %s record (data=%s) for node %s' % ('A', ip, name)
+    print('Creating %s record (data=%s) for node %s' % ('A', ip, name))
     record = zone.create_record(name=name, type=RecordType.A, data=ip)
     created.append(record)
 


Mime
View raw message