当前位置: 首页>>代码示例>>Python>>正文


Python cfg.RequiredOptError方法代码示例

本文整理汇总了Python中oslo_config.cfg.RequiredOptError方法的典型用法代码示例。如果您正苦于以下问题:Python cfg.RequiredOptError方法的具体用法?Python cfg.RequiredOptError怎么用?Python cfg.RequiredOptError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_config.cfg的用法示例。


在下文中一共展示了cfg.RequiredOptError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_parent_port_by_host_ip

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def _get_parent_port_by_host_ip(self, node_fixed_ip):
        os_net = clients.get_network_client()
        node_subnet_id = oslo_cfg.CONF.pod_vif_nested.worker_nodes_subnet
        if not node_subnet_id:
            raise oslo_cfg.RequiredOptError(
                'worker_nodes_subnet', oslo_cfg.OptGroup('pod_vif_nested'))

        try:
            fixed_ips = ['subnet_id=%s' % str(node_subnet_id),
                         'ip_address=%s' % str(node_fixed_ip)]
            ports = os_net.ports(fixed_ips=fixed_ips)
        except os_exc.SDKException:
            LOG.error("Parent vm port with fixed ips %s not found!",
                      fixed_ips)
            raise

        try:
            return next(ports)
        except StopIteration:
            LOG.error("Neutron port for vm port with fixed ips %s not found!",
                      fixed_ips)
            raise kl_exc.NoResourceException 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:24,代码来源:nested_vif.py

示例2: handle_config_exception

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def handle_config_exception(exc):
    msg = ""

    if not any(LOG.handlers):
        logging.basicConfig(level=logging.DEBUG)

    if isinstance(exc, cfg.RequiredOptError):
        msg = "Missing option '{opt}'".format(opt=exc.opt_name)
        if exc.group:
            msg += " in group '{}'".format(exc.group)
        CONF.print_help()

    elif isinstance(exc, cfg.ConfigFilesNotFoundError):
        if CONF._args[0] == "init":
            return

        msg = (_("Configuration file specified ('%s') wasn't "
                 "found or was unreadable.") % ",".join(
            CONF.config_file))

    if msg:
        LOG.warning(msg)
        print(syntribos.SEP)
    else:
        LOG.exception(exc) 
开发者ID:openstack-archive,项目名称:syntribos,代码行数:27,代码来源:config.py

示例3: start

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def start():
    conf = service.prepare_service()

    if conf.statsd.resource_id is None:
        raise cfg.RequiredOptError("resource_id", cfg.OptGroup("statsd"))

    stats = Stats(conf)

    loop = asyncio.get_event_loop()
    # TODO(jd) Add TCP support
    listen = loop.create_datagram_endpoint(
        lambda: StatsdServer(stats),
        local_addr=(conf.statsd.host, conf.statsd.port))

    def _flush():
        loop.call_later(conf.statsd.flush_delay, _flush)
        stats.flush()

    loop.call_later(conf.statsd.flush_delay, _flush)
    transport, protocol = loop.run_until_complete(listen)

    LOG.info("Started on %s:%d", conf.statsd.host, conf.statsd.port)
    LOG.info("Flush delay: %d seconds", conf.statsd.flush_delay)

    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass

    transport.close()
    loop.close() 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:33,代码来源:statsd.py

示例4: get_project

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def get_project(self, pod):
        project_id = config.CONF.neutron_defaults.project

        if not project_id:
            # NOTE(ivc): this option is only required for
            # DefaultPodProjectDriver and its subclasses, but it may be
            # optional for other drivers (e.g. when each namespace has own
            # project)
            raise cfg.RequiredOptError('project',
                                       cfg.OptGroup('neutron_defaults'))

        return project_id 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:14,代码来源:default_project.py

示例5: get_subnets

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def get_subnets(self, pod, project_id):
        subnet_id = config.CONF.neutron_defaults.pod_subnet

        if not subnet_id:
            # NOTE(ivc): this option is only required for
            # DefaultPodSubnetDriver and its subclasses, but it may be
            # optional for other drivers (e.g. when each namespace has own
            # subnet)
            raise cfg.RequiredOptError('pod_subnet',
                                       cfg.OptGroup('neutron_defaults'))

        return {subnet_id: utils.get_subnet(subnet_id)} 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:14,代码来源:default_subnet.py

示例6: get_security_groups

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def get_security_groups(self, pod, project_id):
        sg_list = config.CONF.neutron_defaults.pod_security_groups

        if not sg_list:
            # NOTE(ivc): this option is only required for
            # Default{Pod,Service}SecurityGroupsDriver and its subclasses,
            # but it may be optional for other drivers (e.g. when each
            # namespace has own set of security groups)
            raise cfg.RequiredOptError('pod_security_groups',
                                       cfg.OptGroup('neutron_defaults'))

        return sg_list[:] 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:14,代码来源:default_security_groups.py

示例7: test_get_subnets_not_set

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def test_get_subnets_not_set(self, m_get_subnet):
        pod = mock.sentinel.pod
        project_id = mock.sentinel.project_id
        driver = default_subnet.DefaultPodSubnetDriver()

        self.assertRaises(cfg.RequiredOptError, driver.get_subnets,
                          pod, project_id)
        m_get_subnet.assert_not_called() 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:10,代码来源:test_default_subnet.py

示例8: test_get_project_not_set

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def test_get_project_not_set(self):
        pod = mock.sentinel.pod
        driver = default_project.DefaultPodProjectDriver()
        self.assertRaises(cfg.RequiredOptError, driver.get_project, pod) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:6,代码来源:test_default_project.py

示例9: test_get_security_groups_not_set

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def test_get_security_groups_not_set(self):
        project_id = mock.sentinel.project_id
        pod = mock.sentinel.pod
        driver = default_security_groups.DefaultPodSecurityGroupsDriver()

        self.assertRaises(cfg.RequiredOptError, driver.get_security_groups,
                          pod, project_id) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:9,代码来源:test_default_security_groups.py

示例10: test_acquire_service_pub_ip_info_pool_net_not_defined

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def test_acquire_service_pub_ip_info_pool_net_not_defined(self, m_cfg):
        driver = d_lb_public_ip.FloatingIpServicePubIPDriver()
        public_net = ''
        m_cfg.neutron_defaults.external_svc_net = public_net
        os_net = self.useFixture(k_fix.MockNetworkClient()).client
        os_net.ips.return_value = (ip for ip in [])
        project_id = mock.sentinel.project_id
        spec_type = 'LoadBalancer'
        spec_lb_ip = None

        self.assertRaises(cfg.RequiredOptError,
                          driver.acquire_service_pub_ip_info,
                          spec_type, spec_lb_ip, project_id) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:15,代码来源:test_lb_public_ip.py

示例11: test_get_sgs_no_crds

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def test_get_sgs_no_crds(self, m_get_crds):
        m_get_crds.return_value = {"items": []}
        cfg.CONF.set_override('pod_security_groups', [],
                              group='neutron_defaults')

        self.assertRaises(cfg.RequiredOptError,
                          self._driver.get_security_groups, self._pod,
                          self._project_id)
        m_get_crds.assert_called_with(namespace=self._namespace) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:11,代码来源:test_network_policy_security_groups.py

示例12: test_get_parent_port_by_host_ip_subnet_id_not_configured

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def test_get_parent_port_by_host_ip_subnet_id_not_configured(self):
        cls = nested_vif.NestedPodVIFDriver
        m_driver = mock.Mock(spec=cls)
        self.useFixture(k_fix.MockNetworkClient()).client
        oslo_cfg.CONF.set_override('worker_nodes_subnet',
                                   '',
                                   group='pod_vif_nested')
        node_fixed_ip = mock.sentinel.node_fixed_ip
        self.assertRaises(oslo_cfg.RequiredOptError,
                          cls._get_parent_port_by_host_ip,
                          m_driver, node_fixed_ip) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:13,代码来源:test_nested_vif.py

示例13: __init__

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def __init__(self):
        super(VIFVHostUserDriver, self).__init__()
        self.mount_path = config.CONF.vhostuser.mount_point
        self.ovs_vu_path = config.CONF.vhostuser.ovs_vhu_path
        if not self.mount_path:
            raise cfg.RequiredOptError('mount_point', 'vhostuser') 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:8,代码来源:vhostuser.py

示例14: _test_missing_config

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def _test_missing_config(self, **kwargs):
        self._set_config(**kwargs)
        self.assertRaisesRegex(cfg.RequiredOptError,
                               r'value required for option \w+ in group '
                               r'\[ml2_odl\]',
                               plugin.Ml2Plugin) 
开发者ID:openstack,项目名称:networking-odl,代码行数:8,代码来源:test_l3_odl_v2.py

示例15: _test_missing_config

# 需要导入模块: from oslo_config import cfg [as 别名]
# 或者: from oslo_config.cfg import RequiredOptError [as 别名]
def _test_missing_config(self, **kwargs):
        self._set_config(**kwargs)
        self.assertRaisesRegex(cfg.RequiredOptError,
                               r'value required for option \w+ in group '
                               r'\[ml2_odl\]',
                               client.OpenDaylightRestClient._check_opt,
                               cfg.CONF.ml2_odl.url) 
开发者ID:openstack,项目名称:networking-odl,代码行数:9,代码来源:test_client.py


注:本文中的oslo_config.cfg.RequiredOptError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。