def _mounted_processing(device, key, net):
    """Callback which runs with the image VDI attached"""

    dev_path = "/dev/" + device + "1"  # NB: Partition 1 hardcoded
    tmpdir = tempfile.mkdtemp()
    try:
        # Mount only Linux filesystems, to avoid disturbing NTFS images
        err = _mount_filesystem(dev_path, tmpdir)
        if not err:
            try:
                # This try block ensures that the umount occurs
                if not _find_guest_agent(tmpdir, FLAGS.xenapi_agent_path):
                    LOG.info(_("Manipulating interface files " "directly"))
                    disk.inject_data_into_fs(tmpdir, key, net, utils.execute)
            finally:
                utils.execute("sudo", "umount", dev_path)
        else:
            LOG.info(_("Failed to mount filesystem (expected for " "non-linux instances): %s") % err)
    finally:
        # remove temporary directory
        os.rmdir(tmpdir)
Exemple #2
0
def _mounted_processing(device, key, net):
    """Callback which runs with the image VDI attached"""

    dev_path = '/dev/' + device + '1'  # NB: Partition 1 hardcoded
    tmpdir = tempfile.mkdtemp()
    try:
        # Mount only Linux filesystems, to avoid disturbing NTFS images
        err = _mount_filesystem(dev_path, tmpdir)
        if not err:
            try:
                # This try block ensures that the umount occurs
                if not _find_guest_agent(tmpdir, FLAGS.xenapi_agent_path):
                    LOG.info(_('Manipulating interface files ' 'directly'))
                    disk.inject_data_into_fs(tmpdir, key, net, utils.execute)
            finally:
                utils.execute('umount', dev_path, run_as_root=True)
        else:
            LOG.info(
                _('Failed to mount filesystem (expected for '
                  'non-linux instances): %s') % err)
    finally:
        # remove temporary directory
        os.rmdir(tmpdir)
Exemple #3
0
def _mounted_processing(device, key, nets, metadata):
    """Callback which runs with the image VDI attached"""

    dev_path = '/dev/' + device + '1'  # NB: Partition 1 hardcoded
    tmpdir = tempfile.mkdtemp()
    try:
        # Mount only Linux filesystems, to avoid disturbing NTFS images
        err = _mount_filesystem(dev_path, tmpdir)
        if not err:
            try:
                # This try block ensures that the umount occurs
                if not _find_guest_agent(tmpdir, FLAGS.xenapi_agent_path):
                    LOG.info(_('Manipulating interface files '
                            'directly'))
                    disk.inject_data_into_fs(FileInjector(tmpdir), key, nets, metadata)
            finally:
                utils.execute('umount', dev_path, run_as_root=True)
        else:
            LOG.info(_('Failed to mount filesystem (expected for '
                'non-linux instances): %s') % err)
    finally:
        # remove temporary directory
        os.rmdir(tmpdir)