Anonymous committed 54d2677

support for dyndns names

Comments (0)

Files changed (3)


 aws_key=<Amazon API key>
 aws_secret=<Amazon API secret>
-# instance names.  These names are local to this config and
-# don't have to match those used on AWS.
-instances=my_instance_one, my_instance_two
+# dyndns or similar url - will be hit via 
+# http, adding in public_hostname, ip_address,
+# if public_hostname exists for the instance
 # default instance name, optional,
 # used if no name is given with "startup" command
 # online
-# public hostname - if you have a public_ip_address,
+# public hostname - if you have a public_ip_address
+# or dyn dns account
 # this value can be used in the "success!" email


 class Config(object):
     def __init__(self, config_file_name):
-        self.config = ConfigParser.ConfigParser()
+        self.config = ConfigParser.RawConfigParser()[config_file_name])
     def _split_name(self, name):


 from boto.ec2.connection import EC2Connection
 import time
 import logging
+import urllib2
+import base64
 log = logging.getLogger(__name__)
 class CommandError(Exception):
             public_ip_address = self.config.get('public_ip_address', None)
             if public_ip_address is not None:
                 if self._conn.associate_address(instance_id, public_ip_address):
+          "Associated public ip address %s with instance", public_ip_address)
                     self.public_ip_address = public_ip_address
+            dyndns_url = self.config_file.get('dyndns_url', None)
+            public_hostname = self.config.get('public_hostname', None)
+            if dyndns_url and public_hostname:
+                username = self.config_file.get('dyndns_username')
+                password = self.config_file.get('dyndns_password')
+                url = dyndns_url % {'public_hostname':public_hostname, 'ip_address':self.instance.ip_address}
+      "Establishing dynamic dns: %s, userame %s, pw %s", url, username, password)               
+                req = urllib2.Request(url)
+                base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
+                req.add_header("Authorization", "Basic %s" % base64string)
+                result = urllib2.urlopen(req)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.