def __init__(self): if not importutils.try_import('proliantutils'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import proliantutils library")) self.power = ilo_power.IloPower() self.deploy = fake.FakeDeploy()
def __init__(self): if not importutils.try_import('iboot'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import iboot library")) self.power = iboot.IBootPower() self.deploy = fake.FakeDeploy()
def __init__(self): if not importutils.try_import('pysnmp'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import pysnmp library")) self.power = snmp.SNMPPower() self.deploy = fake.FakeDeploy()
def __init__(self): if not importutils.try_import('scciclient'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import python-scciclient library")) self.power = irmc_power.IRMCPower() self.deploy = fake.FakeDeploy()
def __init__(self): if not importutils.try_import('pywsman'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_('Unable to import pywsman library')) self.power = drac_power.DracPower() self.deploy = fake.FakeDeploy()
def __init__(self, host, manager_module, manager_class): super(RPCService, self).__init__() self.host = host manager_module = importutils.try_import(manager_module) manager_class = getattr(manager_module, manager_class) self.manager = manager_class(host, manager_module.MANAGER_TOPIC) self.topic = self.manager.topic self.rpcserver = None
def __init__(self): if not importutils.try_import('iboot'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason="Unable to import iboot library") self.power = iboot.IBootPower() self.deploy = pxe.PXEDeploy() self.vendor = pxe.VendorPassthru()
def __init__(self): if not importutils.try_import('pyremotevbox'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import pyremotevbox library")) self.power = virtualbox.VirtualBoxPower() self.deploy = fake.FakeDeploy() self.management = virtualbox.VirtualBoxManagement()
def __init__(self): if not importutils.try_import('pyghmi'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import pyghmi library")) self.power = ipminative.NativeIPMIPower() self.deploy = pxe.PXEDeploy() self.management = ipminative.NativeIPMIManagement() self.vendor = pxe.VendorPassthru()
def __init__(self): if not importutils.try_import('pywsman'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_('Unable to import pywsman library')) self.power = power.DracPower() self.deploy = pxe.PXEDeploy() self.management = management.DracManagement()
def __init__(self): if not importutils.try_import('pyghmi'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import pyghmi IPMI library")) self.power = ipminative.NativeIPMIPower() self.console = ipminative.NativeIPMIShellinaboxConsole() self.deploy = fake.FakeDeploy() self.management = ipminative.NativeIPMIManagement()
def __init__(self): if not importutils.try_import('seamicroclient'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason="Unable to import seamicroclient library") self.power = seamicro.Power() self.deploy = fake.FakeDeploy() self.management = seamicro.Management() self.vendor = seamicro.VendorPassthru()
def __init__(self): if not importutils.try_import('scciclient'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import python-scciclient library")) self.power = irmc_power.IRMCPower() self.console = ipmitool.IPMIShellinaboxConsole() self.deploy = pxe.PXEDeploy() self.management = ipmitool.IPMIManagement() self.vendor = pxe.VendorPassthru()
def __init__(self): if not importutils.try_import('proliantutils'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import proliantutils library")) self.power = ilo_power.IloPower() self.deploy = ilo_deploy.IloPXEDeploy() self.vendor = ilo_deploy.IloPXEVendorPassthru() self.console = ipmitool.IPMIShellinaboxConsole() self.management = ipmitool.IPMIManagement()
def __init__(self): if not importutils.try_import('proliantutils'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import proliantutils library")) self.power = power.IloPower() self.deploy = deploy.IloVirtualMediaAgentDeploy() self.console = deploy.IloConsoleInterface() self.management = management.IloManagement() self.vendor = agent.AgentVendorInterface()
def _load_backend(self): with self._lock: if not self._backend: # Import the untranslated name if we don't have a mapping backend_path = self._backend_mapping.get(self._backend_name, self._backend_name) backend_mod = importutils.try_import(backend_path) if not backend_mod: raise ImportError("Unable to import backend '%s'" % self._backend_name) self._backend = backend_mod.get_backend()
def __init__(self): # Driver has a runtime dependency on PySNMP, abort load if it is absent if not importutils.try_import('pysnmp'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason=_("Unable to import pysnmp library")) self.power = snmp.SNMPPower() self.deploy = pxe.PXEDeploy() self.vendor = pxe.VendorPassthru() # PDUs have no boot device management capability. # Only PXE as a boot device is supported. self.management = None
def __init__(self): if not importutils.try_import('seamicroclient'): raise exception.DriverLoadError( driver=self.__class__.__name__, reason="Unable to import seamicroclient library") self.power = seamicro.Power() self.deploy = pxe.PXEDeploy() self.management = seamicro.Management() self.seamicro_vendor = seamicro.VendorPassthru() self.pxe_vendor = pxe.VendorPassthru() self.mapping = {'pass_deploy_info': self.pxe_vendor, 'attach_volume': self.seamicro_vendor, 'set_node_vlan_id': self.seamicro_vendor} self.vendor = utils.MixinVendorInterface(self.mapping)
import re import time from oslo.config import cfg from oslo.utils import importutils from cinder import exception from cinder.i18n import _, _LE, _LW, _LI from cinder.openstack.common import log as logging from cinder.openstack.common import loopingcall from cinder import utils LOG = logging.getLogger(__name__) vxg = importutils.try_import("vxg") if vxg: LOG.info(_LI("Running with xg-tools version: %s."), vxg.__version__) # version vmos versions V6.3.0.4 or newer VMOS_SUPPORTED_VERSION_PATTERNS = ['V6.3.0.[4-9]', 'V6.3.[1-9].?[0-9]?'] violin_opts = [ cfg.StrOpt('gateway_mga', default=None, help='IP address or hostname of mg-a'), cfg.StrOpt('gateway_mgb', default=None, help='IP address or hostname of mg-b'), cfg.BoolOpt('use_igroups', default=False,
def test_try_import(self): dt = importutils.try_import('datetime') self.assertEqual(sys.modules['datetime'], dt)
import tempfile from oslo.config import cfg from oslo.utils import importutils from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LE from ironic.common.i18n import _LI from ironic.common import images from ironic.common import swift from ironic.common import utils from ironic.drivers import utils as driver_utils from ironic.openstack.common import log as logging ilo_client = importutils.try_import('proliantutils.ilo.ribcl') STANDARD_LICENSE = 1 ESSENTIALS_LICENSE = 2 ADVANCED_LICENSE = 3 opts = [ cfg.IntOpt('client_timeout', default=60, help='Timeout (in seconds) for iLO operations'), cfg.IntOpt('client_port', default=443, help='Port to be used for iLO operations'), cfg.StrOpt('swift_ilo_container', default='ironic_ilo_container', help='The Swift iLO container to store data.'),
is_simplejson = True else: import json except ImportError: import json else: import json import six import six.moves.xmlrpc_client as xmlrpclib from oslo.utils import encodeutils from oslo.utils import importutils from oslo.utils import timeutils netaddr = importutils.try_import("netaddr") _nasty_type_tests = [inspect.ismodule, inspect.isclass, inspect.ismethod, inspect.isfunction, inspect.isgeneratorfunction, inspect.isgenerator, inspect.istraceback, inspect.isframe, inspect.iscode, inspect.isbuiltin, inspect.isroutine, inspect.isabstract] _simple_types = (six.string_types + six.integer_types + (type(None), bool, float)) def to_primitive(value, convert_instances=False, convert_datetime=True, level=0, max_depth=3): """Convert a complex object into primitives.
from oslo.utils import encodeutils from oslo.utils import importutils import six.moves.urllib.parse as urlparse import glanceclient from glanceclient.common import utils from glanceclient import exc from glanceclient.openstack.common.gettextutils import _ from keystoneclient.auth.identity import v2 as v2_auth from keystoneclient.auth.identity import v3 as v3_auth from keystoneclient import discover from keystoneclient.openstack.common.apiclient import exceptions as ks_exc from keystoneclient import session osprofiler_profiler = importutils.try_import("osprofiler.profiler") class OpenStackImagesShell(object): def _append_global_identity_args(self, parser): # FIXME(bobt): these are global identity (Keystone) arguments which # should be consistent and shared by all service clients. Therefore, # they should be provided by python-keystoneclient. We will need to # refactor this code once this functionality is avaible in # python-keystoneclient. See # # https://bugs.launchpad.net/python-keystoneclient/+bug/1332337 # parser.add_argument('-k', '--insecure', default=False,
from __future__ import absolute_import from oslo.config import cfg from oslo.utils import importutils from oslo.utils import units import six from cinder import exception from cinder.i18n import _, _LE from cinder.openstack.common import log as logging from cinder.volume import driver from cinder.volume import volume_types LOG = logging.getLogger(__name__) storpool = importutils.try_import('storpool') if storpool: from storpool import spapi from storpool import spopenstack from storpool import sptypes storpool_opts = [ cfg.StrOpt('storpool_template', default=None, help='The StorPool template for volumes with no type.'), cfg.IntOpt('storpool_replication', default=3, help='The default StorPool chain replication value. ' 'Used when creating a volume with no specified type if ' 'storpool_template is not set. Also used for calculating '
def test_try_import_returns_default(self): foo = importutils.try_import('foo.bar') self.assertIsNone(foo)
import shlex import signal import sys import time from oslo.utils import importutils from oslo.utils import strutils import six from oslo_concurrency._i18n import _ # NOTE(bnemec): eventlet doesn't monkey patch subprocess, so we need to # determine the proper subprocess module to use ourselves. I'm using the # time module as the check because that's a monkey patched module we use # in combination with subprocess below, so they need to match. eventlet = importutils.try_import('eventlet') if eventlet and eventlet.patcher.is_monkey_patched(time): from eventlet.green import subprocess else: import subprocess LOG = logging.getLogger(__name__) class InvalidArgumentError(Exception): def __init__(self, message=None): super(InvalidArgumentError, self).__init__(message) class UnknownArgumentError(Exception): def __init__(self, message=None):
def validate_service_installed(service): if not importutils.try_import('neutron_%s' % service): alembic_util.err(_('Package neutron-%s not installed') % service)
# 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 testtools from oslo.utils import importutils from tests import utils as test_utils # NOTE(jamespage) matchmaker tied directly to eventlet # which is not yet py3 compatible - skip if import fails matchmaker = (importutils.try_import('oslo.messaging._drivers.matchmaker')) @testtools.skipIf(not matchmaker, "matchmaker/eventlet unavailable") class MatchmakerTest(test_utils.BaseTestCase): def test_fanout_binding(self): matcher = matchmaker.MatchMakerBase() matcher.add_binding(matchmaker.FanoutBinding(), matchmaker.DirectExchange()) self.assertEqual(matcher.queues('hello.world'), []) self.assertEqual(matcher.queues('fanout~fantasy.unicorn'), [('fanout~fantasy.unicorn', 'unicorn')]) self.assertEqual(matcher.queues('fanout~fantasy.pony'), [('fanout~fantasy.pony', 'pony')]) def test_topic_binding(self):
""" from oslo.utils import excutils from oslo.utils import importutils from ironic.common import exception from ironic.common.i18n import _LE from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base from ironic.drivers.modules.drac import client as drac_client from ironic.drivers.modules.drac import common as drac_common from ironic.drivers.modules.drac import resource_uris from ironic.openstack.common import log as logging pywsman = importutils.try_import('pywsman') LOG = logging.getLogger(__name__) POWER_STATES = { '2': states.POWER_ON, '3': states.POWER_OFF, '11': states.REBOOT, } REVERSE_POWER_STATES = dict((v, k) for (k, v) in POWER_STATES.items()) def _get_power_state(node): """Returns the current power state of the node
import abc import six from oslo.config import cfg from oslo.utils import importutils from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base from ironic.openstack.common import log as logging from ironic.openstack.common import loopingcall pysnmp = importutils.try_import('pysnmp') if pysnmp: from pysnmp.entity.rfc3413.oneliner import cmdgen from pysnmp.proto import rfc1902 else: cmdgen = None rfc1902 = None opts = [ cfg.IntOpt('power_timeout', default=10, help='Seconds to wait for power action to be completed') ] LOG = logging.getLogger(__name__)
# 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 testtools from oslo.utils import importutils from oslo_messaging.tests import utils as test_utils redis = importutils.try_import('redis') matchmaker_redis = ( importutils.try_import('oslo.messaging._drivers.matchmaker_redis')) def redis_available(): '''Helper to see if local redis server is running''' if not redis: return False try: c = redis.StrictRedis(socket_timeout=1) c.ping() return True except redis.exceptions.ConnectionError: return False
import fixtures import testtools from six.moves import mock try: import zmq except ImportError: zmq = None from oslo import messaging from oslo.utils import importutils from oslo_messaging.tests import utils as test_utils # eventlet is not yet py3 compatible, so skip if not installed eventlet = importutils.try_import('eventlet') impl_zmq = importutils.try_import('oslo_messaging._drivers.impl_zmq') LOG = logging.getLogger(__name__) def get_unused_port(): """Returns an unused port on localhost.""" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 0)) port = s.getsockname()[1] s.close() return port
from oslo.utils import importutils from six.moves.urllib import parse as urlparse from ironic.common import boot_devices from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LE from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base from ironic.drivers.modules import console_utils from ironic.openstack.common import log as logging from ironic.openstack.common import loopingcall seamicroclient = importutils.try_import('seamicroclient') if seamicroclient: from seamicroclient import client as seamicro_client from seamicroclient import exceptions as seamicro_client_exception opts = [ cfg.IntOpt('max_retry', default=3, help='Maximum retries for SeaMicro operations'), cfg.IntOpt('action_timeout', default=10, help='Seconds to wait for power action to be completed') ] CONF = cfg.CONF opt_group = cfg.OptGroup(name='seamicro',
import random import time import six from oslo.config import cfg from oslo.messaging._drivers import amqp as rpc_amqp from oslo.messaging._drivers import amqpdriver from oslo.messaging._drivers import common as rpc_common from oslo.messaging import exceptions from oslo.messaging.openstack.common.gettextutils import _ from oslo.messaging.openstack.common import jsonutils from oslo.utils import importutils from oslo.utils import netutils qpid_codec = importutils.try_import("qpid.codec010") qpid_messaging = importutils.try_import("qpid.messaging") qpid_exceptions = importutils.try_import("qpid.messaging.exceptions") LOG = logging.getLogger(__name__) qpid_opts = [ cfg.StrOpt('qpid_hostname', default='localhost', help='Qpid broker hostname.'), cfg.IntOpt('qpid_port', default=5672, help='Qpid broker port.'), cfg.ListOpt('qpid_hosts', default=['$qpid_hostname:$qpid_port'], help='Qpid HA cluster host:port pairs.'), cfg.StrOpt('qpid_username', default='',
from oslo.utils import excutils from oslo.utils import importutils from ironic.common import boot_devices from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LE from ironic.common.i18n import _LW from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager from ironic.drivers import base from ironic.drivers.modules import console_utils from ironic.openstack.common import log as logging pyghmi = importutils.try_import('pyghmi') if pyghmi: from pyghmi import exceptions as pyghmi_exception from pyghmi.ipmi import command as ipmi_command opts = [ cfg.IntOpt('retry_timeout', default=60, help='Maximum time in seconds to retry IPMI operations.'), cfg.IntOpt('min_command_interval', default=5, help='Minimum time, in seconds, between IPMI operations ' 'sent to a server. There is a risk with some hardware ' 'that setting this too low may cause the BMC to crash. ' 'Recommended setting is 5 seconds.'), ]
# 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. from oslo.utils import importutils from heat.engine.clients import client_plugin mistral_base = importutils.try_import('mistralclient.api.base') mistral_client = importutils.try_import('mistralclient.api.client') class MistralClientPlugin(client_plugin.ClientPlugin): def _create(self): endpoint_type = self._get_client_option('mistral', 'endpoint_type') endpoint = self.url_for(service_type='workflowv2', endpoint_type=endpoint_type) args = { 'mistral_url': endpoint, 'auth_token': self.auth_token }
import os import socket import time from oslo.config import cfg from oslo.serialization import jsonutils from oslo.utils import importutils import requests import six from six.moves import urllib from keystoneclient import exceptions from keystoneclient.i18n import _, _LI, _LW from keystoneclient import utils osprofiler_web = importutils.try_import("osprofiler.web") USER_AGENT = 'python-keystoneclient' _logger = logging.getLogger(__name__) def _positive_non_zero_float(argument_value): if argument_value is None: return None try: value = float(argument_value) except ValueError: msg = _("%s must be a float") % argument_value raise argparse.ArgumentTypeError(msg) if value <= 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. """ The MatchMaker classes should accept a Topic or Fanout exchange key and return keys for direct exchanges, per (approximate) AMQP parlance. """ from oslo.config import cfg from oslo.messaging._drivers import matchmaker as mm_common from oslo.utils import importutils redis = importutils.try_import('redis') matchmaker_redis_opts = [ cfg.StrOpt('host', default='127.0.0.1', help='Host to locate redis.'), cfg.IntOpt('port', default=6379, help='Use this port to connect to redis host.'), cfg.StrOpt('password', help='Password for Redis server (optional).'), ] CONF = cfg.CONF opt_group = cfg.OptGroup(name='matchmaker_redis', title='Options for Redis-based MatchMaker') CONF.register_group(opt_group) CONF.register_opts(matchmaker_redis_opts, opt_group)
# 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. """ Common functionalities shared between different DRAC modules. """ from oslo.utils import importutils from ironic.common import exception from ironic.common.i18n import _ from ironic.drivers.modules.drac import client as drac_client pywsman = importutils.try_import('pywsman') REQUIRED_PROPERTIES = { 'drac_host': _('IP address or hostname of the DRAC card. Required.'), 'drac_username': _('username used for authentication. Required.'), 'drac_password': _('password used for authentication. Required.') } OPTIONAL_PROPERTIES = { 'drac_port': _('port used for WS-Man endpoint; default is 443. Optional.'), 'drac_path': _('path used for WS-Man endpoint; default is "/wsman". ' 'Optional.'), 'drac_protocol': _('protocol used for WS-Man endpoint; one of http, https;' ' default is "https". Optional.'), } COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy() COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES)
def __init__(self): self.db = importutils.try_import(CONF.db_driver)
iRMC Power Driver using the Base Server Profile """ from oslo.utils import importutils from oslo_config import cfg from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LE from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base from ironic.drivers.modules import ipmitool from ironic.drivers.modules.irmc import common as irmc_common from ironic.openstack.common import log as logging scci = importutils.try_import('scciclient.irmc.scci') CONF = cfg.CONF LOG = logging.getLogger(__name__) if scci: STATES_MAP = {states.POWER_OFF: scci.POWER_OFF, states.POWER_ON: scci.POWER_ON, states.REBOOT: scci.POWER_RESET} def _set_power_state(task, target_state): """Turns the server power on/off or do a reboot. :param task: a TaskManager instance containing the node to act on.
""" Ironic iBoot PDU power manager. """ from oslo.utils import importutils from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base from ironic.openstack.common import log as logging iboot = importutils.try_import('iboot') LOG = logging.getLogger(__name__) REQUIRED_PROPERTIES = { 'iboot_address': _("IP address of the node. Required."), 'iboot_username': _("username. Required."), 'iboot_password': _("password. Required."), } OPTIONAL_PROPERTIES = { 'iboot_relay_id': _("iBoot PDU relay id; default is 1. Optional."), 'iboot_port': _("iBoot PDU port; default is 9100. Optional."), } COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy() COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES)
import re import time from oslo.utils import importutils from oslo_config import cfg from cinder import exception from cinder.i18n import _, _LE, _LW, _LI from cinder.openstack.common import log as logging from cinder.openstack.common import loopingcall from cinder import utils LOG = logging.getLogger(__name__) vxg = importutils.try_import("vxg") if vxg: LOG.info(_LI("Running with xg-tools version: %s."), vxg.__version__) # version vmos versions V6.3.0.4 or newer VMOS_SUPPORTED_VERSION_PATTERNS = ['V6.3.0.[4-9]', 'V6.3.[1-9].?[0-9]?'] violin_opts = [ cfg.StrOpt('gateway_mga', default=None, help='IP address or hostname of mg-a'), cfg.StrOpt('gateway_mgb', default=None, help='IP address or hostname of mg-b'), cfg.BoolOpt('use_igroups', default=False,
from __future__ import with_statement from alembic import context from sqlalchemy import engine_from_config, pool from logging.config import fileConfig from oslo.utils import importutils from blog.db.sqlalchemy import model_base importutils.try_import('blog.db.v1.sqlalchemy.models') target_metadata = model_base.BlogSecureModelBase.metadata # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") # ... etc.
import fixtures import mock import testtools try: import zmq except ImportError: zmq = None from oslo import messaging from oslo.utils import importutils from oslo_messaging.tests import utils as test_utils # eventlet is not yet py3 compatible, so skip if not installed eventlet = importutils.try_import('eventlet') impl_zmq = importutils.try_import('oslo_messaging._drivers.impl_zmq') LOG = logging.getLogger(__name__) def get_unused_port(): """Returns an unused port on localhost.""" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 0)) port = s.getsockname()[1] s.close() return port
from oslo_config import cfg from six.moves.urllib import parse as urlparse from ironic.common import boot_devices from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LE from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base from ironic.drivers.modules import console_utils from ironic.openstack.common import log as logging from ironic.openstack.common import loopingcall seamicroclient = importutils.try_import('seamicroclient') if seamicroclient: from seamicroclient import client as seamicro_client from seamicroclient import exceptions as seamicro_client_exception opts = [ cfg.IntOpt('max_retry', default=3, help='Maximum retries for SeaMicro operations'), cfg.IntOpt('action_timeout', default=10, help='Seconds to wait for power action to be completed') ] CONF = cfg.CONF opt_group = cfg.OptGroup(name='seamicro',
import random import time import six from oslo.config import cfg from oslo.messaging._drivers import amqp as rpc_amqp from oslo.messaging._drivers import amqpdriver from oslo.messaging._drivers import common as rpc_common from oslo.messaging._i18n import _ from oslo.messaging import exceptions from oslo.serialization import jsonutils from oslo.utils import importutils from oslo.utils import netutils qpid_codec = importutils.try_import("qpid.codec010") qpid_messaging = importutils.try_import("qpid.messaging") qpid_exceptions = importutils.try_import("qpid.messaging.exceptions") LOG = logging.getLogger(__name__) qpid_opts = [ cfg.StrOpt('qpid_hostname', default='localhost', help='Qpid broker hostname.'), cfg.IntOpt('qpid_port', default=5672, help='Qpid broker port.'), cfg.ListOpt('qpid_hosts', default=['$qpid_hostname:$qpid_port'], help='Qpid HA cluster host:port pairs.'),
# See the License for the specific language governing permissions and # limitations under the License. import os import eventlet from oslo.config import cfg from oslo.utils import importutils from nova import exception from nova.i18n import _LE, _LW from nova.openstack.common import log as logging from nova.openstack.common import loopingcall from nova.servicegroup.drivers import base evzookeeper = importutils.try_import('evzookeeper') membership = importutils.try_import('evzookeeper.membership') zookeeper = importutils.try_import('zookeeper') zk_driver_opts = [ cfg.StrOpt('address', help='The ZooKeeper addresses for servicegroup service in the ' 'format of host1:port,host2:port,host3:port'), cfg.IntOpt('recv_timeout', default=4000, help='The recv_timeout parameter for the zk session'), cfg.StrOpt('sg_prefix', default="/servicegroups", help='The prefix used in ZooKeeper to store ephemeral nodes'), cfg.IntOpt('sg_retry_interval', default=5,
# under the License. """ Ironic iBoot PDU power manager. """ from oslo.utils import importutils from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base from ironic.openstack.common import log as logging iboot = importutils.try_import('iboot') LOG = logging.getLogger(__name__) REQUIRED_PROPERTIES = { 'iboot_address': _("IP address of the node. Required."), 'iboot_username': _("username. Required."), 'iboot_password': _("password. Required."), } OPTIONAL_PROPERTIES = { 'iboot_relay_id': _("iBoot PDU relay id; default is 1. Optional."), 'iboot_port': _("iBoot PDU port; default is 9100. Optional."), } COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy() COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES)
def import_versioned_module(version, submodule=None): module = 'ironic.common.glance_service.v%s' % version if submodule: module = '.'.join((module, submodule)) return importutils.try_import(module)
import eventlet import greenlet import six from six import moves from oslo.config import cfg from oslo.messaging._drivers import base from oslo.messaging._drivers import common as rpc_common from oslo.messaging._executors import impl_eventlet # FIXME(markmc) from oslo.messaging._i18n import _ from oslo.serialization import jsonutils from oslo.utils import excutils from oslo.utils import importutils zmq = importutils.try_import('eventlet.green.zmq') # for convenience, are not modified. pformat = pprint.pformat Timeout = eventlet.timeout.Timeout LOG = logging.getLogger(__name__) RPCException = rpc_common.RPCException zmq_opts = [ cfg.StrOpt('rpc_zmq_bind_address', default='*', help='ZeroMQ bind address. Should be a wildcard (*), ' 'an ethernet interface, or IP. ' 'The "host" option should point or resolve to this ' 'address.'),
import mock from oslo.utils import importutils from heat.common import exception from heat.common import template_format from heat.engine import resource from heat.engine import scheduler from heat.tests.common import HeatTestCase from heat.tests import utils from testtools import skipIf from ..resources import docker_container # noqa from .fake_docker_client import FakeDockerClient # noqa docker = importutils.try_import('docker') template = ''' { "AWSTemplateFormatVersion": "2010-09-09", "Description": "Test template", "Parameters": {}, "Resources": { "Blog": { "Type": "DockerInc::Docker::Container", "Properties": { "image": "samalba/wordpress", "env": [ "FOO=bar" ]
import hashlib import logging import os import time from oslo.config import cfg from oslo.serialization import jsonutils from oslo.utils import importutils import requests import six from six.moves import urllib from keystoneclient import exceptions from keystoneclient import utils osprofiler_web = importutils.try_import("osprofiler.web") USER_AGENT = 'python-keystoneclient' _logger = logging.getLogger(__name__) def _positive_non_zero_float(argument_value): if argument_value is None: return None try: value = float(argument_value) except ValueError: msg = "%s must be a float" % argument_value raise argparse.ArgumentTypeError(msg) if value <= 0:
- ipminative - proliantutils - pysnmp - scciclient """ import sys import mock from oslo.utils import importutils from ironic.drivers.modules import ipmitool # attempt to load the external 'seamicroclient' library, which is # required by the optional drivers.modules.seamicro module seamicroclient = importutils.try_import("seamicroclient") if not seamicroclient: smc = mock.Mock() smc.client = mock.Mock() smc.exceptions = mock.Mock() smc.exceptions.ClientException = Exception smc.exceptions.UnsupportedVersion = Exception sys.modules['seamicroclient'] = smc sys.modules['seamicroclient.client'] = smc.client sys.modules['seamicroclient.exceptions'] = smc.exceptions # if anything has loaded the seamicro driver yet, reload it now that # the external library has been mocked if 'ironic.drivers.modules.seamicro' in sys.modules: reload(sys.modules['ironic.drivers.modules.seamicro'])
import abc from oslo.config import cfg from oslo.utils import importutils import six from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base from ironic.openstack.common import log as logging from ironic.openstack.common import loopingcall pysnmp = importutils.try_import('pysnmp') if pysnmp: from pysnmp.entity.rfc3413.oneliner import cmdgen from pysnmp import error as snmp_error from pysnmp.proto import rfc1902 else: cmdgen = None snmp_error = None rfc1902 = None opts = [ cfg.IntOpt('power_timeout', default=10, help='Seconds to wait for power action to be completed') ]
import socket import threading import time import uuid from six import moves import testtools from oslo import messaging from oslo.utils import importutils from oslo_messaging.tests import utils as test_utils # TODO(kgiusti) Conditionally run these tests only if the necessary # dependencies are installed. This should be removed once the proton libraries # are available in the base repos for all supported platforms. pyngus = importutils.try_import("pyngus") if pyngus: from oslo.messaging._drivers.protocols.amqp import driver as amqp_driver LOG = logging.getLogger(__name__) class _ListenerThread(threading.Thread): """Run a blocking listener in a thread.""" def __init__(self, listener, msg_count): super(_ListenerThread, self).__init__() self.listener = listener self.msg_count = msg_count self.messages = moves.queue.Queue() self.daemon = True self.start()
from troveclient import client import troveclient.extension from troveclient.i18n import _ # noqa from troveclient.openstack.common.apiclient import exceptions as exc from troveclient import utils from troveclient.v1 import shell as shell_v1 DEFAULT_OS_DATABASE_API_VERSION = "1.0" DEFAULT_TROVE_ENDPOINT_TYPE = 'publicURL' DEFAULT_TROVE_SERVICE_TYPE = 'database' logger = logging.getLogger(__name__) osprofiler_profiler = importutils.try_import("osprofiler.profiler") class TroveClientArgumentParser(argparse.ArgumentParser): def __init__(self, *args, **kwargs): super(TroveClientArgumentParser, self).__init__(*args, **kwargs) def error(self, message): """error(message: string) Prints a usage message incorporating the message to stderr and exits. """ self.print_usage(sys.stderr) # FIXME(lzyeval): if changes occur in argparse.ArgParser._check_value
# License for the specific language governing permissions and limitations # under the License. """The bare-metal admin extension with Ironic Proxy.""" from oslo.config import cfg from oslo.utils import importutils import webob from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api.openstack import xmlutil from nova.i18n import _ from nova.openstack.common import log as logging ironic_client = importutils.try_import('ironicclient.client') authorize = extensions.extension_authorizer('compute', 'baremetal_nodes') node_fields = ['id', 'cpus', 'local_gb', 'memory_mb', 'pm_address', 'pm_user', 'service_host', 'terminal_port', 'instance_uuid'] node_ext_fields = ['uuid', 'task_state', 'updated_at', 'pxe_config_path'] interface_fields = ['id', 'address', 'datapath_id', 'port_no'] CONF = cfg.CONF CONF.import_opt('api_version', 'nova.virt.ironic.driver', group='ironic')