How to use the nova.conf function in nova

To help you get started, we’ve selected a few nova examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / nova / nova / virt / zvm / utils.py View on Github external
import os
from oslo_log import log as logging
import six
import six.moves.urllib.parse as urlparse
from zvmconnector import connector

from oslo_utils import fileutils

from nova.api.metadata import base as instance_metadata
from nova import conf
from nova import exception
from nova.virt import configdrive


CONF = conf.CONF
LOG = logging.getLogger(__name__)


class ConnectorClient(object):
    """Request handler to zVM cloud connector"""

    def __init__(self, zcc_url, ca_file=None):
        _url = urlparse.urlparse(zcc_url)

        _ssl_enabled = False

        if _url.scheme == 'https':
            _ssl_enabled = True
        elif ca_file:
            LOG.warning("url is %(url) which is not https "
                        "but ca_file is configured to %(ca_file)s",
github openstack / nova / nova / crypto.py View on Github external
from oslo_utils import excutils
from oslo_utils import fileutils
import paramiko
import six

import nova.conf
from nova import context
from nova import db
from nova import exception
from nova.i18n import _, _LE
from nova import utils


LOG = logging.getLogger(__name__)

CONF = nova.conf.CONF


def ca_folder(project_id=None):
    if CONF.crypto.use_project_ca and project_id:
        return os.path.join(CONF.crypto.ca_path, 'projects', project_id)
    return CONF.crypto.ca_path


def ca_path(project_id=None):
    return os.path.join(ca_folder(project_id), CONF.crypto.ca_file)


def key_path(project_id=None):
    return os.path.join(ca_folder(project_id), CONF.crypto.key_file)
github openstack / nova / nova / virt / xenapi / agent.py View on Github external
from nova import exception
from nova.i18n import _
from nova import objects
from nova import utils


USE_AGENT_KEY = "xenapi_use_agent"
USE_AGENT_SM_KEY = utils.SM_IMAGE_PROP_PREFIX + USE_AGENT_KEY
SKIP_SSH_KEY = "xenapi_skip_agent_inject_ssh"
SKIP_SSH_SM_KEY = utils.SM_IMAGE_PROP_PREFIX + SKIP_SSH_KEY
SKIP_FILES_AT_BOOT_KEY = "xenapi_skip_agent_inject_files_at_boot"
SKIP_FILES_AT_BOOT_SM_KEY = utils.SM_IMAGE_PROP_PREFIX \
                                        + SKIP_FILES_AT_BOOT_KEY

LOG = logging.getLogger(__name__)
CONF = nova.conf.CONF


def _call_agent(session, instance, vm_ref, method, addl_args=None,
                timeout=None, success_codes=None):
    """Abstracts out the interaction with the agent xenapi plugin."""
    if addl_args is None:
        addl_args = {}
    if timeout is None:
        timeout = CONF.xenserver.agent_timeout
    if success_codes is None:
        success_codes = ['0']

    # always fetch domid because VM may have rebooted
    dom_id = session.VM.get_domid(vm_ref)
    uuid = uuidutils.generate_uuid()
    args = {
github openstack / nova / nova / volume / cinder.py View on Github external
def _load_session():
    global _SESSION

    if not _SESSION:
        _SESSION = ks_loading.load_session_from_conf_options(
            CONF, nova.conf.cinder.cinder_group.name)
github openstack / nova / nova / cmd / all.py View on Github external
"""

import sys

from oslo_log import log as logging

import nova.conf
from nova import config
from nova.i18n import _LE
from nova import objects
from nova import service
from nova import utils
from nova.vnc import xvp_proxy


CONF = nova.conf.CONF


def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "nova")
    LOG = logging.getLogger('nova.all')
    utils.monkey_patch()
    objects.register_all()
    launcher = service.process_launcher()

    # nova-api
    for api in CONF.enabled_apis:
        try:
            should_use_ssl = api in CONF.enabled_ssl_apis
            server = service.WSGIService(api, use_ssl=should_use_ssl)
            launcher.launch_service(server, workers=server.workers or 1)
github openstack / nova / nova / manager.py View on Github external
tasks to a wrapping service.

This module provides Manager, a base class for managers.

"""

from oslo_service import periodic_task
import six

import nova.conf
from nova.db import base
from nova import profiler
from nova import rpc


CONF = nova.conf.CONF


class PeriodicTasks(periodic_task.PeriodicTasks):
    def __init__(self):
        super(PeriodicTasks, self).__init__(CONF)


class ManagerMeta(profiler.get_traced_meta(), type(PeriodicTasks)):
    """Metaclass to trace all children of a specific class.

    This metaclass wraps every public method (not starting with _ or __)
    of the class using it. All children classes of the class using ManagerMeta
    will be profiled as well.

    Adding this metaclass requires that the __trace_args__ attribute be added
    to the class we want to modify. That attribute is a dictionary
github openstack / nova / nova / virt / xenapi / volume_utils.py View on Github external
import re
import uuid

from eventlet import greenthread
from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import strutils
from oslo_utils import versionutils
import six

import nova.conf
from nova import exception
from nova.i18n import _


CONF = nova.conf.CONF

LOG = logging.getLogger(__name__)

# Namespace for SRs so we can reliably generate a UUID
# Generated from uuid.uuid5(uuid.UUID(int=0), 'volume_utils-SR_UUID')
SR_NAMESPACE = uuid.UUID("3cca4135-a809-5bb3-af62-275fbfe87178")


def parse_sr_info(connection_data, description=''):
    params = {}
    if 'sr_uuid' not in connection_data:
        params = _parse_volume_info(connection_data)
        sr_identity = "%s/%s/%s" % (params['target'], params['port'],
                                    params['targetIQN'])
        # PY2 can only support taking an ascii string to uuid5
        if six.PY2 and isinstance(sr_identity, six.text_type):
github openstack / nova / nova / utils.py View on Github external
from oslo_utils import strutils
from oslo_utils import timeutils
from oslo_utils import units
import six
from six.moves import range

import nova.conf
from nova import exception
from nova.i18n import _, _LE, _LI, _LW
import nova.network
from nova import safe_utils

profiler = importutils.try_import('osprofiler.profiler')


CONF = nova.conf.CONF

LOG = logging.getLogger(__name__)

_IS_NEUTRON = None

synchronized = lockutils.synchronized_with_prefix('nova-')

SM_IMAGE_PROP_PREFIX = "image_"
SM_INHERITABLE_KEYS = (
    'min_ram', 'min_disk', 'disk_format', 'container_format',
)
# Keys which hold large structured data that won't fit in the
# size constraints of the system_metadata table, so we avoid
# storing and/or loading them.
SM_SKIP_KEYS = (
    # Legacy names
github openstack / nova / nova / cache_utils.py View on Github external
#
#    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.

"""Simple wrapper for oslo_cache."""

from oslo_cache import core as cache
from oslo_log import log as logging

import nova.conf
from nova.i18n import _

CONF = nova.conf.CONF

LOG = logging.getLogger(__name__)

WEEK = 604800


def _warn_if_null_backend():
    if CONF.cache.backend == 'dogpile.cache.null':
        LOG.warning("Cache enabled with backend dogpile.cache.null.")


def get_memcached_client(expiration_time=0):
    """Used ONLY when memcached is explicitly needed."""
    # If the operator has [cache]/enabled flag on then we let oslo_cache
    # configure the region from the configuration settings
    if CONF.cache.enabled and CONF.cache.memcache_servers:
github openstack / nova / nova / notifications / base.py View on Github external
from nova import exception
from nova import image as image_api
from nova import network
from nova.network import model as network_model
from nova.notifications.objects import base as notification_base
from nova.notifications.objects import instance as instance_notification
from nova import objects
from nova.objects import base as obj_base
from nova.objects import fields
from nova import rpc
from nova import utils


LOG = log.getLogger(__name__)

CONF = nova.conf.CONF


def send_update(context, old_instance, new_instance, service="compute",
                host=None):
    """Send compute.instance.update notification to report any changes occurred
    in that instance
    """

    if not CONF.notifications.notify_on_state_change:
        # skip all this if updates are disabled
        return

    update_with_state_change = False

    old_vm_state = old_instance["vm_state"]
    new_vm_state = new_instance["vm_state"]