nova-lxd/nova/virt/lxd/utils.py
Chuck Short b03c33ce64 Add support for ephemeral storage
Add previously missing ephemeral storage support for nova-lxd.
This patch provides the infrastructure  to translate
the configuration of the instance to something
that LXD can understand and act upon.

The way that the ephemeral storage works is that block_device_info
dict and instance object. If an empeheral storage device
is needed then the storage deivce is created on the compute host
and bind mounted into the container when the container is started.
This is due to the contanier is running unprivileged and restricted
mount(8)

To come is restricting the ephemeral storage based on the LXD storage
backend on the compute host.

Update exist unit tests and adds unit new tests.

Change-Id: I38d48708b3c6fb450258e03a6106f47be3aeb998
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2016-07-05 14:23:46 -04:00

59 lines
1.7 KiB
Python

# Copyright 2015 Canonical Ltd
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import nova.conf
CONF = nova.conf.CONF
BASE_DIR = os.path.join(
CONF.instances_path, CONF.image_cache_subdirectory_name)
def get_instance_dir(instance):
return os.path.join(CONF.instances_path, instance)
def get_container_rootfs_image(image_meta):
return os.path.join(BASE_DIR, '%s-rootfs.tar.gz' % image_meta.id)
def get_container_manifest_image(image_meta):
return os.path.join(BASE_DIR, '%s-manifest.tar' % image_meta.id)
def get_container_storage(ephemeral, instance):
return os.path.join(CONF.instances_path, instance, 'storage', ephemeral)
def get_container_configdrive(instance):
return os.path.join(CONF.instances_path, instance, 'configdrive')
def get_console_path(instance):
return os.path.join('/var/log/lxd/', instance, 'console.log')
def get_container_dir(instance):
return os.path.join(CONF.lxd.root_dir, 'containers')
def get_container_rootfs(instance):
return os.path.join(CONF.lxd.root_dir, 'containers', instance, 'rootfs')
def get_container_rescue(instance):
return os.path.join(CONF.lxd.root_dir, 'containers', instance, 'rootfs')