~citrix-openstack/nova/d4-addons

« back to all changes in this revision

Viewing changes to nova/virt/xenapi/vm_utils.py

  • Committer: Tarmac
  • Author(s): Christopher MacGown
  • Date: 2011-08-23 06:00:12 UTC
  • mfrom: (1476.1.2 trunk_merge)
  • Revision ID: tarmac-20110823060012-od44a3emqh6he9ud
Implements first-pass of config-drive that adds a vfat format drive to a vm when config_drive is True (or an image id).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
2
 
3
3
# Copyright (c) 2010 Citrix Systems, Inc.
 
4
# Copyright 2011 Piston Cloud Computing, Inc.
4
5
#
5
6
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
6
7
#    not use this file except in compliance with the License. You may obtain
740
741
        # if at all, so determine whether it's required first, and then do
741
742
        # everything
742
743
        mount_required = False
743
 
        key, net = _prepare_injectables(instance, network_info)
744
 
        mount_required = key or net
 
744
        key, net, metadata = _prepare_injectables(instance, network_info)
 
745
        mount_required = key or net or metadata
745
746
        if not mount_required:
746
747
            return
747
748
 
748
749
        with_vdi_attached_here(session, vdi_ref, False,
749
 
                               lambda dev: _mounted_processing(dev, key, net))
 
750
                               lambda dev: _mounted_processing(dev, key, net,
 
751
                                                               metadata))
750
752
 
751
753
    @classmethod
752
754
    def lookup_kernel_ramdisk(cls, session, vm):
1198
1200
    return False
1199
1201
 
1200
1202
 
1201
 
def _mounted_processing(device, key, net):
 
1203
def _mounted_processing(device, key, net, metadata):
1202
1204
    """Callback which runs with the image VDI attached"""
1203
1205
 
1204
1206
    dev_path = '/dev/' + device + '1'  # NB: Partition 1 hardcoded
1212
1214
                if not _find_guest_agent(tmpdir, FLAGS.xenapi_agent_path):
1213
1215
                    LOG.info(_('Manipulating interface files '
1214
1216
                            'directly'))
1215
 
                    disk.inject_data_into_fs(tmpdir, key, net,
 
1217
                    disk.inject_data_into_fs(tmpdir, key, net, metadata,
1216
1218
                        utils.execute)
1217
1219
            finally:
1218
1220
                utils.execute('umount', dev_path, run_as_root=True)
1235
1237
    template = t.Template
1236
1238
    template_data = open(FLAGS.injected_network_template).read()
1237
1239
 
 
1240
    metadata = inst['metadata']
1238
1241
    key = str(inst['key_data'])
1239
1242
    net = None
1240
1243
    if networks_info:
1272
1275
            net = str(template(template_data,
1273
1276
                                searchList=[{'interfaces': interfaces_info,
1274
1277
                                            'use_ipv6': FLAGS.use_ipv6}]))
1275
 
    return key, net
 
1278
    return key, net, metadata