~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« 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-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import base64
22
22
import json
23
23
import os
 
24
import posixpath
24
25
 
25
26
from nova.api.ec2 import ec2utils
26
27
from nova import block_device
27
28
from nova import context
28
29
from nova import db
29
 
from nova import flags
30
30
from nova import network
31
31
from nova.openstack.common import cfg
32
32
from nova.virt import netutils
40
40
                     'config drive')),
41
41
    ]
42
42
 
43
 
FLAGS = flags.FLAGS
44
 
flags.DECLARE('dhcp_domain', 'nova.network.manager')
45
 
FLAGS.register_opts(metadata_opts)
 
43
CONF = cfg.CONF
 
44
CONF.register_opts(metadata_opts)
 
45
CONF.import_opt('dhcp_domain', 'nova.network.manager')
46
46
 
47
47
 
48
48
VERSIONS = [
109
109
        self.ec2_ids = {}
110
110
 
111
111
        self.ec2_ids['instance-id'] = ec2utils.id_to_ec2_inst_id(
112
 
                instance['id'])
 
112
            instance['uuid'])
113
113
        self.ec2_ids['ami-id'] = ec2utils.glance_id_to_ec2_id(ctxt,
114
114
            instance['image_ref'])
115
115
 
163
163
        if version not in VERSIONS:
164
164
            raise InvalidMetadataVersion(version)
165
165
 
166
 
        hostname = "%s.%s" % (self.instance['hostname'], FLAGS.dhcp_domain)
 
166
        hostname = self._get_hostname()
 
167
 
167
168
        floating_ips = self.ip_info['floating_ips']
168
169
        floating_ip = floating_ips and floating_ips[0] or ''
169
170
 
290
291
                self.instance['key_name']: self.instance['key_data']
291
292
            }
292
293
 
293
 
        metadata['hostname'] = "%s.%s" % (self.instance['hostname'],
294
 
                                          FLAGS.dhcp_domain)
 
294
        metadata['hostname'] = self._get_hostname()
295
295
 
296
296
        metadata['name'] = self.instance['display_name']
297
297
        metadata['launch_index'] = self.instance['launch_index']
306
306
    def _check_version(self, required, requested):
307
307
        return VERSIONS.index(requested) >= VERSIONS.index(required)
308
308
 
 
309
    def _get_hostname(self):
 
310
        return "%s%s%s" % (self.instance['hostname'],
 
311
                           '.' if CONF.dhcp_domain else '',
 
312
                           CONF.dhcp_domain)
 
313
 
309
314
    def lookup(self, path):
310
315
        if path == "" or path[0] != "/":
311
 
            path = os.path.normpath("/" + path)
 
316
            path = posixpath.normpath("/" + path)
312
317
        else:
313
 
            path = os.path.normpath(path)
 
318
            path = posixpath.normpath(path)
314
319
 
315
320
        # fix up requests, prepending /ec2 to anything that does not match
316
321
        path_tokens = path.split('/')[1:]
346
351
        """Yields (path, value) tuples for metadata elements."""
347
352
        # EC2 style metadata
348
353
        for version in VERSIONS + ["latest"]:
349
 
            if version in FLAGS.config_drive_skip_versions.split(' '):
 
354
            if version in CONF.config_drive_skip_versions.split(' '):
350
355
                continue
351
356
 
352
357
            data = self.get_ec2_metadata(version)