summaryrefslogtreecommitdiff
path: root/ec2init/DataSourceEc2.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2010-01-28 15:49:29 -0500
committerScott Moser <smoser@ubuntu.com>2010-01-28 15:49:29 -0500
commitf8eb4061196c8c2489ac7bf084e0fc0d3e6d27fc (patch)
treecf124cde80f291930a626874fb38b64661ee8315 /ec2init/DataSourceEc2.py
parenteb74cd6f36a2f4d2ebdee04d6b388834b1bc72d4 (diff)
downloadvyos-cloud-init-f8eb4061196c8c2489ac7bf084e0fc0d3e6d27fc.tar.gz
vyos-cloud-init-f8eb4061196c8c2489ac7bf084e0fc0d3e6d27fc.zip
Add support for user defined mount points
Also, move swap to use this format for specifying mounts. That way the user can turn off swap if they want with: | mounts: | - [ swap ] Other change wrapped in here is to have DataSourceEc2 read plain text (evalable) text for its metadata rather than pickl. This is really for debuging anyway, so any speed difference is not important.
Diffstat (limited to 'ec2init/DataSourceEc2.py')
-rw-r--r--ec2init/DataSourceEc2.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/ec2init/DataSourceEc2.py b/ec2init/DataSourceEc2.py
index 123ede67..1e81fddb 100644
--- a/ec2init/DataSourceEc2.py
+++ b/ec2init/DataSourceEc2.py
@@ -4,7 +4,6 @@ import ec2init
import socket
import urllib2
import time
-import cPickle
import boto_utils
class DataSourceEc2(DataSource.DataSource):
@@ -26,8 +25,9 @@ class DataSourceEc2(DataSource.DataSource):
self.userdata_raw = udf.read()
udf.close()
- mdf = open(self.cachedir + "/meta-data.pkl")
- self.metadata = cPickle.load(mdf)
+ mdf = open(self.cachedir + "/meta-data.raw")
+ data = mdf.read()
+ self.metadata = eval(data)
mdf.close()
return True
@@ -109,13 +109,17 @@ class DataSourceEc2(DataSource.DataSource):
return(keys)
- def getswap_devs(self):
+ def device_name_to_device(self, name):
+ # consult metadata service, that has
+ # ephemeral0: sdb
+ # and return 'sdb' for input 'ephemeral0'
if not self.metadata.has_key('block-device-mapping'):
- raise Exception("no block-device-mapping")
- list = []
- for use_t, device in self.metadata['block-device-mapping'].items():
- if not device.startswith("/dev"):
- device="/dev/%s" % device
- if use_t == "swap":
- list.append(device)
- return(list)
+ return(None)
+
+ for entname, device in self.metadata['block-device-mapping'].items():
+ if entname == name:
+ return(device)
+ # LP: #513842 mapping in Euca has 'ephemeral' not 'ephemeral0'
+ if entname == "ephemeral" and name == "ephemeral0":
+ return(device)
+ return None