當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。