diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-01-17 12:42:44 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-01-17 12:42:44 -0500 |
commit | 2f7227c7092ad873757167f62c2a82fb4ee69472 (patch) | |
tree | acc620e1f0423910a4d0ea0d79ee231290e4a393 /cloudinit/DataSourceEc2.py | |
parent | 1d00c0936bfc63117493d89268da8c81611b3c40 (diff) | |
parent | ec070cdf8746651d6dea011bd3ea9a445223028c (diff) | |
download | vyos-cloud-init-2f7227c7092ad873757167f62c2a82fb4ee69472.tar.gz vyos-cloud-init-2f7227c7092ad873757167f62c2a82fb4ee69472.zip |
fix pylint warnings (LP: #914739) [Juerg Haefliger]
This merge pulls in Jeurg's 'fix-pylint-warnings.tgz' patchset from
LP: #914739.
Diffstat (limited to 'cloudinit/DataSourceEc2.py')
-rw-r--r-- | cloudinit/DataSourceEc2.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/cloudinit/DataSourceEc2.py b/cloudinit/DataSourceEc2.py index 9191e647..14484bdd 100644 --- a/cloudinit/DataSourceEc2.py +++ b/cloudinit/DataSourceEc2.py @@ -35,8 +35,8 @@ class DataSourceEc2(DataSource.DataSource): return("DataSourceEc2") def get_data(self): - seedret={ } - if util.read_optional_seed(seedret,base=self.seeddir+ "/"): + seedret = { } + if util.read_optional_seed(seedret, base=self.seeddir+"/"): self.userdata_raw = seedret['user-data'] self.metadata = seedret['meta-data'] log.debug("using seeded ec2 data in %s" % self.seeddir) @@ -46,9 +46,12 @@ class DataSourceEc2(DataSource.DataSource): if not self.wait_for_metadata_service(): return False start = time.time() - self.userdata_raw = boto_utils.get_instance_userdata(self.api_ver, None, self.metadata_address) - self.metadata = boto_utils.get_instance_metadata(self.api_ver, self.metadata_address) - log.debug("crawl of metadata service took %ds" % (time.time()-start)) + self.userdata_raw = boto_utils.get_instance_userdata(self.api_ver, + None, self.metadata_address) + self.metadata = boto_utils.get_instance_metadata(self.api_ver, + self.metadata_address) + log.debug("crawl of metadata service took %ds" % (time.time() - + start)) return True except Exception as e: print e @@ -74,7 +77,7 @@ class DataSourceEc2(DataSource.DataSource): return fallback try: - host="%s.ec2.archive.ubuntu.com" % availability_zone[:-1] + host = "%s.ec2.archive.ubuntu.com" % availability_zone[:-1] socket.getaddrinfo(host, None, 0, socket.SOCK_STREAM) return 'http://%s/ubuntu/' % host except: @@ -88,7 +91,7 @@ class DataSourceEc2(DataSource.DataSource): max_wait = 120 try: - max_wait = int(mcfg.get("max_wait",max_wait)) + max_wait = int(mcfg.get("max_wait", max_wait)) except Exception: util.logexc(log) log.warn("Failed to get max wait. using %s" % max_wait) @@ -98,7 +101,7 @@ class DataSourceEc2(DataSource.DataSource): timeout = 50 try: - timeout = int(mcfg.get("timeout",timeout)) + timeout = int(mcfg.get("timeout", timeout)) except Exception: util.logexc(log) log.warn("Failed to get timeout, using %s" % timeout) @@ -168,17 +171,18 @@ class DataSourceEc2(DataSource.DataSource): short = os.path.basename(found) if not found.startswith("/"): - found="/dev/%s" % found + found = "/dev/%s" % found if os.path.exists(found): return(found) for nfrom, tlist in mappings.items(): - if not short.startswith(nfrom): continue + if not short.startswith(nfrom): + continue for nto in tlist: cand = "/dev/%s%s" % (nto, short[len(nfrom):]) if os.path.exists(cand): - log.debug("remapped device name %s => %s" % (found,cand)) + log.debug("remapped device name %s => %s" % (found, cand)) return(cand) # on t1.micro, ephemeral0 will appear in block-device-mapping from @@ -192,14 +196,16 @@ class DataSourceEc2(DataSource.DataSource): def is_vpc(self): # per comment in LP: #615545 - ph="public-hostname"; p4="public-ipv4" + ph = "public-hostname" + p4 = "public-ipv4" if ((ph not in self.metadata or self.metadata[ph] == "") and (p4 not in self.metadata or self.metadata[p4] == "")): return True return False -def wait_for_metadata_service(urls, max_wait=None, timeout=None, status_cb=None): +def wait_for_metadata_service(urls, max_wait=None, timeout=None, + status_cb=None): """ urls: a list of urls to try max_wait: roughly the maximum time to wait before giving up @@ -236,7 +242,7 @@ def wait_for_metadata_service(urls, max_wait=None, timeout=None, status_cb=None) loop_n = 0 while True: - sleeptime=int(loop_n/5)+1 + sleeptime = int(loop_n/5)+1 for url in urls: now = time.time() if loop_n != 0: |