• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python context.get_admin_context_without_session函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neutron_lib.context.get_admin_context_without_session函数的典型用法代码示例。如果您正苦于以下问题:Python get_admin_context_without_session函数的具体用法?Python get_admin_context_without_session怎么用?Python get_admin_context_without_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: context

 def context(self):
     # TODO(kevinbenton): the context should really be passed in to each of
     # these methods so a call can be tracked all of the way through the
     # system but that will require a larger refactor to pass the context
     # everywhere. We just generate a new one here on each call so requests
     # can be independently tracked server side.
     return context.get_admin_context_without_session()
开发者ID:openstack,项目名称:neutron,代码行数:7,代码来源:agent.py


示例2: __init__

 def __init__(self, host, conf=None):
     try:
         sock_dir, sock_mode = utils.get_socket_settings()
     except Exception:
         sock_dir = constants.VHOSTUSER_SOCKET_DIR
         sock_mode = constants.VHOSTUSER_SOCKET_MODE
         LOG.warning("Cannot get vhostuser socket info from fp-vdev, use "
                     "default path '%s' and mode '%s'" % (sock_dir,
                                                          sock_mode))
     self.fp_info = {
         'timestamp': '',
         'product': 'virtual-accelerator',
         'active': False,
         'vhostuser_socket_dir': sock_dir,
         'vhostuser_socket_prefix': constants.VHOSTUSER_SOCKET_PREFIX,
         'vhostuser_socket_mode': sock_mode,
         'supported_plugs': ['ovs', 'bridge', 'tap'],
     }
     self.agent_state = {
         'binary': 'neutron-fastpath-agent',
         'host': cfg.CONF.host,
         'topic': n_constants.L2_AGENT_TOPIC,
         'configurations': self.fp_info,
         'start_flag': True,
         'agent_type': constants.FP_AGENT_TYPE,
     }
     self.ctx = context.get_admin_context_without_session()
     self._setup_rpc()
开发者ID:openstack,项目名称:networking-6wind,代码行数:28,代码来源:server.py


示例3: __init__

 def __init__(self, data):
     self._n_context = n_context.get_admin_context_without_session()
     self._data = data
     self._topic = data.pop('plugin_topic', None)
     self._interval = data.pop('report_interval', 0)
     self._state_rpc = n_agent_rpc.PluginReportStateAPI(
         self._topic)
开发者ID:openstack,项目名称:group-based-policy,代码行数:7,代码来源:rpc.py


示例4: _report_state

 def _report_state(self):
     try:
         self.agent_state.get('configurations').update(
             self.cache.get_state())
         ctx = context.get_admin_context_without_session()
         agent_status = self.state_rpc.report_state(
             ctx, self.agent_state, True)
         if agent_status == agent_consts.AGENT_REVIVED:
             LOG.info("Agent has just been revived. "
                      "Scheduling full sync")
             self.schedule_resync("Agent has just been revived")
     except AttributeError:
         # This means the server does not support report_state
         LOG.warning("Neutron server does not support state report. "
                     "State report for this agent will be disabled.")
         self.heartbeat.stop()
         self.run()
         return
     except Exception:
         self.failed_report_state = True
         LOG.exception("Failed reporting state!")
         return
     if self.failed_report_state:
         self.failed_report_state = False
         LOG.info("Successfully reported state after a previous failure.")
     if self.agent_state.pop('start_flag', None):
         self.run()
开发者ID:openstack,项目名称:neutron,代码行数:27,代码来源:agent.py


示例5: __init__

    def __init__(self, conf):
        super(LbaasAgentManager, self).__init__(conf)
        self.conf = conf
        self.context = ncontext.get_admin_context_without_session()
        self.serializer = agent_driver_base.DataModelSerializer()
        self.plugin_rpc = agent_api.LbaasAgentApi(
            lb_const.LOADBALANCER_PLUGINV2,
            self.context,
            self.conf.host
        )
        self._process_monitor = external_process.ProcessMonitor(
            config=self.conf, resource_type='loadbalancer')
        self._load_drivers()

        self.agent_state = {
            'binary': 'neutron-lbaasv2-agent',
            'host': conf.host,
            'topic': lb_const.LOADBALANCER_AGENTV2,
            'configurations': {'device_drivers': self.device_drivers.keys()},
            'agent_type': lb_const.AGENT_TYPE_LOADBALANCERV2,
            'start_flag': True}
        self.admin_state_up = True

        self._setup_state_rpc()
        self.needs_resync = False
        # pool_id->device_driver_name mapping used to store known instances
        self.instance_mapping = {}
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:27,代码来源:agent_manager.py


示例6: _report_state

 def _report_state(self):
     LOG.debug("Report state task started")
     try:
         self.agent_state.get('configurations').update(
             self.cache.get_state())
         ctx = context.get_admin_context_without_session()
         agent_status = self.state_rpc.report_state(ctx, self.agent_state,
                                                    True)
         if agent_status == agent_consts.AGENT_REVIVED:
             LOG.info(_LI("Agent has just been revived. "
                          "Scheduling full sync"))
             self.schedule_full_resync(
                     reason=_("Agent has just been revived"))
     except AttributeError:
         # This means the server does not support report_state
         LOG.warning(_LW("Neutron server does not support state report. "
                         "State report for this agent will be disabled."))
         self.heartbeat.stop()
         self.run()
         return
     except Exception:
         LOG.exception(_LE("Failed reporting state!"))
         return
     if self.agent_state.pop('start_flag', None):
         self.run()
开发者ID:openstack,项目名称:neutron-dynamic-routing,代码行数:25,代码来源:bgp_dragent.py


示例7: start

    def start(self):
        self.prevent_arp_spoofing = cfg.CONF.AGENT.prevent_arp_spoofing

        # stores all configured ports on agent
        self.network_ports = collections.defaultdict(list)
        # flag to do a sync after revival
        self.fullsync = False
        self.context = context.get_admin_context_without_session()
        self.setup_rpc()
        self.init_extension_manager(self.connection)

        configurations = {'extensions': self.ext_manager.names()}
        configurations.update(self.mgr.get_agent_configurations())

        #TODO(mangelajo): optimize resource_versions (see ovs agent)
        self.agent_state = {
            'binary': self.agent_binary,
            'host': cfg.CONF.host,
            'topic': constants.L2_AGENT_TOPIC,
            'configurations': configurations,
            'agent_type': self.agent_type,
            'resource_versions': resources.LOCAL_RESOURCE_VERSIONS,
            'start_flag': True}

        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)

        capabilities.notify_init_event(self.agent_type, self)
        # The initialization is complete; we can start receiving messages
        self.connection.consume_in_threads()

        self.daemon_loop()
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:35,代码来源:_common_agent.py


示例8: setUp

 def setUp(self):
     super(LoggingExtensionTestFramework, self).setUp()
     cfg.CONF.set_override('extensions', ['log'], group='agent')
     self.context = neutron_context.get_admin_context_without_session()
     self._set_resource_rpc_mock()
     if self.firewall_name != 'openvswitch':
         self.skipTest("Logging extension doesn't support firewall driver"
                       " %s at that time " % self.firewall_name)
     self.log_driver = self.initialize_ovs_fw_log()
开发者ID:cubeek,项目名称:neutron,代码行数:9,代码来源:test_logging.py


示例9: initialize

 def initialize(self):
     super(AristaHAScaleSimulationDriver, self).initialize()
     self.context = context.get_admin_context_without_session()
     # Subscribe to port updates to force ports to active after binding
     # since a fake virt driver is being used, so OVS will never see
     # the libvirt interfaces come up, triggering the OVS provisioning
     self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
     registry.subscribe(self._port_update_callback,
                        resources.PORT, events.AFTER_UPDATE)
开发者ID:openstack,项目名称:networking-arista,代码行数:9,代码来源:mechanism_ha_simulator.py


示例10: _report_state

 def _report_state(self):
     try:
         ctx = context.get_admin_context_without_session()
         self.state_rpc.report_state(ctx, self.agent_state,
                                     True)
         self.agent_state['start_flag'] = False
     except Exception:
         LOG.exception("Failed reporting state!")
         self.handle_report_state_failure()
开发者ID:openstack,项目名称:networking-l2gw,代码行数:9,代码来源:base_agent_manager.py


示例11: __init__

    def __init__(self, host, conf=None):
        super(BgpDrAgent, self).__init__()
        self.initialize_driver(conf)
        self.needs_resync_reasons = collections.defaultdict(list)
        self.needs_full_sync_reason = None

        self.cache = BgpSpeakerCache()
        self.context = context.get_admin_context_without_session()
        self.plugin_rpc = BgpDrPluginApi(bgp_consts.BGP_PLUGIN,
                                         self.context, host)
开发者ID:openstack,项目名称:neutron-dynamic-routing,代码行数:10,代码来源:bgp_dragent.py


示例12: __init__

 def __init__(self):
     self.vif_type = dvs_const.DVS
     sg_enabled = securitygroups_rpc.is_firewall_enabled()
     self.vif_details = {portbindings.CAP_PORT_FILTER: sg_enabled,
                         portbindings.OVS_HYBRID_PLUG: sg_enabled}
     self.context = context.get_admin_context_without_session()
     self.dvs_notifier = dvs_agent_rpc_api.DVSClientAPI(self.context)
     LOG.info(_LI('DVS_notifier'))
     super(VMwareDVSMechanismDriver, self).__init__(
         dvs_const.AGENT_TYPE_DVS,
         self.vif_type,
         self.vif_details)
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:12,代码来源:dvs_mechanism_driver.py


示例13: __init__

    def __init__(self, vsphere_hostname, vsphere_login, vsphere_password,
                 bridge_mappings, polling_interval):
        super(DVSAgent, self).__init__()

        self.agent_state = {
            'binary': 'neutron-dvs-agent',
            'host': cfg.CONF.host,
            'topic': n_const.L2_AGENT_TOPIC,
            'configurations': {'bridge_mappings': bridge_mappings,
                               'vsphere_hostname': vsphere_hostname},
            'agent_type': 'DVS agent',
            'start_flag': True}

        report_interval = cfg.CONF.DVS_AGENT.report_interval

        self.polling_interval = polling_interval
        # Security group agent support
        self.context = context.get_admin_context_without_session()
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.sg_agent = dvs_rpc.DVSSecurityGroupRpc(
            self.context, self.sg_plugin_rpc, defer_refresh_firewall=True)

        self.setup_rpc()
        self.run_daemon_loop = True
        self.iter_num = 0

        self.network_map = dvs_util.create_network_map_from_config(
            cfg.CONF.ML2_VMWARE, pg_cache=True)
        uplink_map = dvs_util.create_uplink_map_from_config(
            cfg.CONF.ML2_VMWARE, self.network_map)
        for phys, dvs in six.iteritems(self.network_map):
            if phys in uplink_map:
                dvs.load_uplinks(phys, uplink_map[phys])
        self.updated_ports = set()
        self.deleted_ports = set()
        self.known_ports = set()
        self.added_ports = set()
        self.booked_ports = set()
        LOG.info(_LI("Agent out of sync with plugin!"))
        connected_ports = self._get_dvs_ports()
        self.added_ports = connected_ports
        if cfg.CONF.DVS.clean_on_restart:
            self._clean_up_vsphere_extra_resources(connected_ports)
        self.fullsync = False

        # The initialization is complete; we can start receiving messages
        self.connection.consume_in_threads()
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
开发者ID:Zlei1115,项目名称:networking-vsphere,代码行数:51,代码来源:dvs_neutron_agent.py


示例14: __init__

    def __init__(self, host, conf=None):
        self.conf = conf or cfg.CONF
        self._load_drivers()
        self.context = context.get_admin_context_without_session()
        self.metering_loop = loopingcall.FixedIntervalLoopingCall(
            self._metering_loop
        )
        measure_interval = self.conf.measure_interval
        self.last_report = 0
        self.metering_loop.start(interval=measure_interval)
        self.host = host

        self.label_tenant_id = {}
        self.routers = {}
        self.metering_infos = {}
        super(MeteringAgent, self).__init__(host=host)
开发者ID:openstack,项目名称:neutron,代码行数:16,代码来源:metering_agent.py


示例15: __init__

    def __init__(self, physical_devices_mappings, exclude_devices,
                 polling_interval, rp_bandwidths, rp_inventory_defaults):

        self.polling_interval = polling_interval
        self.network_ports = collections.defaultdict(list)
        self.conf = cfg.CONF
        self.device_mappings = physical_devices_mappings
        self.exclude_devices = exclude_devices
        self.setup_eswitch_mgr(physical_devices_mappings,
                               exclude_devices)

        # Stores port update notifications for processing in the main loop
        self.updated_devices = set()
        # Stores <mac, pci_slot> pairs for ports whose binding has been
        # activated.
        self.activated_bindings = set()

        self.context = context.get_admin_context_without_session()
        self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.sg_agent = agent_sg_rpc.SecurityGroupAgentRpc(
            self.context, self.sg_plugin_rpc)
        self._setup_rpc()
        self.ext_manager = self._create_agent_extension_manager(
            self.connection)

        configurations = {'device_mappings': physical_devices_mappings,
                          n_constants.RP_BANDWIDTHS: rp_bandwidths,
                          n_constants.RP_INVENTORY_DEFAULTS:
                              rp_inventory_defaults,
                          'extensions': self.ext_manager.names()}

        # TODO(mangelajo): optimize resource_versions (see ovs agent)
        self.agent_state = {
            'binary': 'neutron-sriov-nic-agent',
            'host': self.conf.host,
            'topic': n_constants.L2_AGENT_TOPIC,
            'configurations': configurations,
            'agent_type': n_constants.AGENT_TYPE_NIC_SWITCH,
            'resource_versions': resources.LOCAL_RESOURCE_VERSIONS,
            'start_flag': True}

        # The initialization is complete; we can start receiving messages
        self.connection.consume_in_threads()
        # Initialize iteration counter
        self.iter_num = 0
开发者ID:openstack,项目名称:neutron,代码行数:46,代码来源:sriov_nic_agent.py


示例16: _setup_rpc

 def _setup_rpc(self):
     self.topic = topics.AGENT
     self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
     self.sg_plugin_rpc = api_sg_rpc.SecurityGroupServerRpcApi(
         topics.PLUGIN)
     self.context = q_context.get_admin_context_without_session()
     self.endpoints = [self]
     consumers = [[topics.PORT, topics.UPDATE],
                  [topics.SECURITY_GROUP, topics.UPDATE]]
     self.connection = agent_rpc.create_consumers(self.endpoints,
                                                  self.topic,
                                                  consumers)
     self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
     report_interval = cfg.CONF.AGENT.report_interval
     if report_interval:
         heartbeat = loopingcall.FixedIntervalLoopingCall(
             self._report_state)
         heartbeat.start(interval=report_interval)
开发者ID:sarath-kumar,项目名称:networking-bigswitch,代码行数:18,代码来源:restproxy_agent.py


示例17: _setup_server_rpc

    def _setup_server_rpc(self):
        self.agent_id = 'zvm_agent_%s' % self._host
        self.topic = topics.AGENT
        self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)

        self.context = context.get_admin_context_without_session()

        self.endpoints = [self]
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers)

        report_interval = CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
开发者ID:openstack,项目名称:networking-zvm,代码行数:20,代码来源:zvm_neutron_agent.py


示例18: _init_state_reporting

 def _init_state_reporting(self):
     self.context = context.get_admin_context_without_session()
     self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
     self.agent_state = {
         'binary': 'neutron-metadata-agent',
         'host': cfg.CONF.host,
         'topic': 'N/A',
         'configurations': {
             'metadata_proxy_socket': cfg.CONF.metadata_proxy_socket,
             'nova_metadata_host': cfg.CONF.nova_metadata_host,
             'nova_metadata_port': cfg.CONF.nova_metadata_port,
             'log_agent_heartbeats': cfg.CONF.AGENT.log_agent_heartbeats,
         },
         'start_flag': True,
         'agent_type': constants.AGENT_TYPE_METADATA}
     report_interval = cfg.CONF.AGENT.report_interval
     if report_interval:
         self.heartbeat = loopingcall.FixedIntervalLoopingCall(
             self._report_state)
         self.heartbeat.start(interval=report_interval)
开发者ID:eayunstack,项目名称:neutron,代码行数:20,代码来源:agent.py


示例19: __init__

    def __init__(self, vpn_service, host):
        # TODO(pc_m) Replace vpn_service with config arg, once all driver
        # implementations no longer need vpn_service.
        self.conf = vpn_service.conf
        self.host = host
        self.conn = n_rpc.Connection()
        self.context = context.get_admin_context_without_session()
        self.topic = topics.IPSEC_AGENT_TOPIC
        node_topic = '%s.%s' % (self.topic, self.host)

        self.processes = {}
        self.routers = {}
        self.process_status_cache = {}

        self.endpoints = [self]
        self.conn.create_consumer(node_topic, self.endpoints, fanout=False)
        self.conn.consume_in_threads()
        self.agent_rpc = IPsecVpnDriverApi(topics.IPSEC_DRIVER_TOPIC)
        self.process_status_cache_check = loopingcall.FixedIntervalLoopingCall(
            self.report_status, self.context)
        self.process_status_cache_check.start(
            interval=self.conf.ipsec.ipsec_status_check_interval)
开发者ID:openstack,项目名称:neutron-vpnaas,代码行数:22,代码来源:ipsec.py


示例20: __init__

    def __init__(self, host, conf=None):
        if conf:
            self.conf = conf
        else:
            self.conf = cfg.CONF
        self.router_info = {}

        self._check_config_params()

        self.process_monitor = external_process.ProcessMonitor(
            config=self.conf,
            resource_type='router')

        self.driver = common_utils.load_interface_driver(self.conf)

        self._context = n_context.get_admin_context_without_session()
        self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host)
        self.fullsync = True
        self.sync_routers_chunk_size = SYNC_ROUTERS_MAX_CHUNK_SIZE

        # Get the list of service plugins from Neutron Server
        # This is the first place where we contact neutron-server on startup
        # so retry in case its not ready to respond.
        while True:
            try:
                self.neutron_service_plugins = (
                    self.plugin_rpc.get_service_plugin_list(self.context))
            except oslo_messaging.RemoteError as e:
                LOG.warning(_LW('l3-agent cannot check service plugins '
                                'enabled at the neutron server when '
                                'startup due to RPC error. It happens '
                                'when the server does not support this '
                                'RPC API. If the error is '
                                'UnsupportedVersion you can ignore this '
                                'warning. Detail message: %s'), e)
                self.neutron_service_plugins = None
            except oslo_messaging.MessagingTimeout as e:
                LOG.warning(_LW('l3-agent cannot contact neutron server '
                                'to retrieve service plugins enabled. '
                                'Check connectivity to neutron server. '
                                'Retrying... '
                                'Detailed message: %(msg)s.'), {'msg': e})
                continue
            break

        self.init_extension_manager(self.plugin_rpc)

        self.metadata_driver = None
        if self.conf.enable_metadata_proxy:
            self.metadata_driver = metadata_driver.MetadataDriver(self)

        self.namespaces_manager = namespace_manager.NamespaceManager(
            self.conf,
            self.driver,
            self.metadata_driver)

        self._queue = queue.RouterProcessingQueue()
        super(L3NATAgent, self).__init__(host=self.conf.host)

        self.target_ex_net_id = None
        self.use_ipv6 = ipv6_utils.is_enabled_and_bind_by_default()

        self.pd = pd.PrefixDelegation(self.context, self.process_monitor,
                                      self.driver,
                                      self.plugin_rpc.process_prefix_update,
                                      self.create_pd_router_update,
                                      self.conf)
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:67,代码来源:agent.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.resource_fields函数代码示例发布时间:2022-05-27
下一篇:
Python context.get_admin_context函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap