diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2011-07-23 16:55:25 +0900 |
---|---|---|
committer | Isaku Yamahata <yamahata@valinux.co.jp> | 2011-07-23 16:55:25 +0900 |
commit | 1f55e116adbf00a0a5bd990f99a680e9d6b1618e (patch) | |
tree | d476bd802604d7addc997d350c361454bce0d3ea /nova/block_device.py | |
parent | 1a18ea6d738b513e03e3f0eddfb9f01dff9addca (diff) | |
download | nova-1f55e116adbf00a0a5bd990f99a680e9d6b1618e.tar.gz nova-1f55e116adbf00a0a5bd990f99a680e9d6b1618e.tar.xz nova-1f55e116adbf00a0a5bd990f99a680e9d6b1618e.zip |
ec2utils: factor generic helper function into generic place
This patch moves out a helper function, properties_root_device_name(),
into generic file nova/block_device.py.
Diffstat (limited to 'nova/block_device.py')
-rw-r--r-- | nova/block_device.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/nova/block_device.py b/nova/block_device.py new file mode 100644 index 000000000..963dffa37 --- /dev/null +++ b/nova/block_device.py @@ -0,0 +1,35 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 Isaku Yamahata <yamahata@valinux co jp> +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +def properties_root_device_name(properties): + """get root device name from image meta data. + If it isn't specified, return None. + """ + root_device_name = None + + # NOTE(yamahata): see image_service.s3.s3create() + for bdm in properties.get('mappings', []): + if bdm['virtual'] == 'root': + root_device_name = bdm['device'] + + # NOTE(yamahata): register_image's command line can override + # <machine>.manifest.xml + if 'root_device_name' in properties: + root_device_name = properties['root_device_name'] + + return root_device_name |