~ubuntu-branches/ubuntu/precise/euca2ools/precise-proposed

« back to all changes in this revision

Viewing changes to .pc/debian-changes-2.0.0~bzr464-0ubuntu1/euca2ools/metadata.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Moser
  • Date: 2011-08-15 11:16:29 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110815111629-3u49jvtwabwozpb7
Tags: 2.0.0~bzr464-0ubuntu1
* new upstream snapshot of bzr revno 464. (LP: #826022)
* Note, previous upload was incorrectly named 'bzr451'.  It should have
  been named bzr461 as it was a snapshot of revision 461.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Software License Agreement (BSD License)
 
2
#
 
3
# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
 
4
# All rights reserved.
 
5
#
 
6
# Redistribution and use of this software in source and binary forms, with or
 
7
# without modification, are permitted provided that the following conditions
 
8
# are met:
 
9
#
 
10
#   Redistributions of source code must retain the above
 
11
#   copyright notice, this list of conditions and the
 
12
#   following disclaimer.
 
13
#
 
14
#   Redistributions in binary form must reproduce the above
 
15
#   copyright notice, this list of conditions and the
 
16
#   following disclaimer in the documentation and/or other
 
17
#   materials provided with the distribution.
 
18
#
 
19
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
20
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
21
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
22
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
23
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
24
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
25
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
26
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
27
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
28
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
29
# POSSIBILITY OF SUCH DAMAGE.
 
30
#
 
31
# Author: Neil Soman neil@eucalyptus.com
 
32
#         Mitch Garnaat mgarnaat@eucalyptus.com
 
33
 
 
34
from boto.utils import get_instance_metadata
 
35
from exceptions import MetadataReadError
 
36
 
 
37
class MetaData(object):
 
38
 
 
39
    def __init__(self):
 
40
        self.md = get_instance_metadata()
 
41
        
 
42
    def get_instance_metadata(self, key):
 
43
        try:
 
44
            value = self.md[key]
 
45
        except KeyError:
 
46
            raise MetadataReadError
 
47
        return value
 
48
 
 
49
    def get_instance_ramdisk(self):
 
50
        return self.get_instance_metadata('ramdisk-id')
 
51
 
 
52
    def get_instance_kernel(self):
 
53
        return self.get_instance_metadata('kernel-id')
 
54
 
 
55
    def get_instance_product_codes(self):
 
56
        return self.get_instance_metadata('product-codes')
 
57
 
 
58
    def get_ancestor_ami_ids(self):
 
59
        return self.get_instance_metadata('ancestor-ami-ids')
 
60
 
 
61
    def get_instance_block_device_mappings(self):
 
62
        return self.get_instance_metadata('block-device-mapping')
 
63