~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/api/metadata/base.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-07-06 10:18:33 UTC
  • mfrom: (1.1.58)
  • Revision ID: package-import@ubuntu.com-20120706101833-wp2nv392mpe9re8p
Tags: 2012.2~f2-0ubuntu1
[ Adam Gandelman ]
* Use new rootwrap configuration structure:
  - debian/nova-{compute, network, volume}.{pyinstall, pyremove}: Dropped.
  - debian/nova-common.dirs: Add /etc/nova/rootwrap.d/.
  - debian/nova-common.install: Install /etc/nova/rootwrap.conf.
  - debian/debian/nova.conf: Reference rootwrap.conf in calls to
    nova-rootwrap.
  - debian/nova-{compute, network, volume}.install: Install corresponding
    filter in /etc/nova/rootwrap.d/
* debian/rules: Install logging_sample.conf to /etc/nova/logging.conf
  as part of nova-common.
* debian/pydist-overrides: Add setuptools-git.
* debian/control: Add python-setuptools-git as a Build-Depends.
* debian/rules: Do not remove nova.egg-info during auto_clean.  Now that
  upstream has moved to setuptools-git, doing so results in missing files
  from built package.

[ Chuck Short ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from nova import db
29
29
from nova import exception
30
30
from nova import flags
31
 
from nova import log as logging
32
31
from nova import network
 
32
from nova.openstack.common import log as logging
33
33
from nova import volume
34
34
 
35
35
FLAGS = flags.FLAGS
81
81
 
82
82
        self.mappings = _format_instance_mapping(ctxt, instance)
83
83
 
84
 
        if instance.get('user_data', None) != None:
 
84
        if instance.get('user_data', None) is not None:
85
85
            self.userdata_b64 = base64.b64decode(instance['user_data'])
86
86
        else:
87
87
            self.userdata_b64 = None
88
88
 
89
89
        self.ec2_ids = {}
90
90
 
91
 
        self.ec2_ids['instance-id'] = ec2utils.id_to_ec2_id(instance['id'])
 
91
        self.ec2_ids['instance-id'] = ec2utils.id_to_ec2_inst_id(
 
92
                instance['id'])
92
93
        self.ec2_ids['ami-id'] = ec2utils.glance_id_to_ec2_id(ctxt,
93
94
            instance['image_ref'])
94
95
 
95
96
        for image_type in ['kernel', 'ramdisk']:
96
97
            if self.instance.get('%s_id' % image_type):
97
98
                image_id = self.instance['%s_id' % image_type]
98
 
                image_type = ec2utils.image_type(image_type)
 
99
                ec2_image_type = ec2utils.image_type(image_type)
99
100
                ec2_id = ec2utils.glance_id_to_ec2_id(ctxt, image_id,
100
 
                                                      image_type)
 
101
                                                      ec2_image_type)
101
102
                self.ec2_ids['%s-id' % image_type] = ec2_id
102
103
 
103
104
        self.address = address
133
134
        for key in self.ec2_ids:
134
135
            data['meta-data'][key] = self.ec2_ids[key]
135
136
 
136
 
        if self.userdata_b64 != None:
 
137
        if self.userdata_b64 is not None:
137
138
            data['user-data'] = self.userdata_b64
138
139
 
139
 
        # public-keys should be in meta-data only if user specified one
 
140
        # public keys are strangely rendered in ec2 metadata service
 
141
        #  meta-data/public-keys/ returns '0=keyname' (with no trailing /)
 
142
        # and only if there is a public key given.
 
143
        # '0=keyname' means there is a normally rendered dict at
 
144
        #  meta-data/public-keys/0
 
145
        #
 
146
        # meta-data/public-keys/ : '0=%s' % keyname
 
147
        # meta-data/public-keys/0/ : 'openssh-key'
 
148
        # meta-data/public-keys/0/openssh-key : '%s' % publickey
140
149
        if self.instance['key_name']:
141
150
            data['meta-data']['public-keys'] = {
142
 
                '0': {'_name': self.instance['key_name'],
 
151
                '0': {'_name': "0=" + self.instance['key_name'],
143
152
                      'openssh-key': self.instance['key_data']}}
144
153
 
145
154
        if False:  # TODO(vish): store ancestor ids
241
250
        for key in sorted(data.keys()):
242
251
            if key == '_name':
243
252
                continue
244
 
            output += key
245
253
            if isinstance(data[key], dict):
246
254
                if '_name' in data[key]:
247
 
                    output += '=' + str(data[key]['_name'])
 
255
                    output += str(data[key]['_name'])
248
256
                else:
249
 
                    output += '/'
 
257
                    output += key + '/'
 
258
            else:
 
259
                output += key
 
260
 
250
261
            output += '\n'
251
262
        return output[:-1]
252
263
    elif isinstance(data, list):