def __init__(self, ): self.conf = cfg.CONF self.root_helper = cconfig.get_root_helper(self.conf) self.external_br = ovs_lib.OVSBridge(EXTERNAL_BRIDGE, self.root_helper) self.sync = True self.ovs_restarted = False self.ip_wrapper = ip_lib.IPWrapper(self.root_helper)
def __init__(self, conf): self.conf = conf try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: msg = _('Error importing interface driver: %s') raise SystemExit(msg % conf.interface_driver) try: self.driver = importutils.import_object( conf.device_driver, config.get_root_helper(self.conf), conf.loadbalancer_state_path, vif_driver, self._vip_plug_callback ) except ImportError: msg = _('Error importing loadbalancer device driver: %s') raise SystemExit(msg % conf.device_driver) self.agent_state = { 'binary': 'neutron-loadbalancer-agent', 'host': conf.host, 'topic': plugin_driver.TOPIC_LOADBALANCER_AGENT, 'configurations': {'device_driver': conf.device_driver, 'interface_driver': conf.interface_driver}, 'agent_type': constants.AGENT_TYPE_LOADBALANCER, 'start_flag': True} self.admin_state_up = True self.context = context.get_admin_context_without_session() self._setup_rpc() self.needs_resync = False self.cache = LogicalDeviceCache()
def main(): """Main method for cleaning up network namespaces. This method will make two passes checking for namespaces to delete. The process will identify candidates, sleep, and call garbage collect. The garbage collection will re-verify that the namespace meets the criteria for deletion (ie it is empty). The period of sleep and the 2nd pass allow time for the namespace state to settle, so that the check prior deletion will re-confirm the namespace is empty. The utility is designed to clean-up after the forced or unexpected termination of Neutron agents. The --force flag should only be used as part of the cleanup of a devstack installation as it will blindly purge namespaces and their devices. This option also kills any lingering DHCP instances. """ conf = setup_conf() conf() config.setup_logging() root_helper = agent_config.get_root_helper(conf) # Identify namespaces that are candidates for deletion. candidates = [ns for ns in ip_lib.IPWrapper.get_namespaces(root_helper) if eligible_for_deletion(conf, ns, conf.force)] if candidates: eventlet.sleep(2) for namespace in candidates: destroy_namespace(conf, namespace, conf.force)
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} self._check_config_params() try: self.driver = importutils.import_object(self.conf.interface_driver, self.conf) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver LOG.error(msg) raise SystemExit(msg) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host) self.fullsync = True self.updated_routers = set() self.removed_routers = set() self.sync_progress = False self._delete_stale_namespaces = (self.conf.use_namespaces and self.conf.router_delete_namespaces) self.rpc_loop = loopingcall.FixedIntervalLoopingCall(self._rpc_loop) self.rpc_loop.start(interval=RPC_LOOP_INTERVAL) super(L3NATAgent, self).__init__(conf=self.conf)
def __init__(self, host, conf=None): self.conf = conf or cfg.CONF self.context = context.get_admin_context_without_session() self.host = host self.qos_info = {'qos': {}, 'queue': {}, 'filter': {}} self.root_helper = config.get_root_helper(self.conf) super(QosAgent, self).__init__(host=host)
def __init__(self, host=None): super(DhcpAgent, self).__init__(host=host) self.needs_resync = False self.conf = cfg.CONF self.cache = NetworkCache() self.root_helper = config.get_root_helper(self.conf) self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver) # Work out if DHCP serving for bridged or routed VM interfaces. try: interface_driver = importutils.import_object( self.conf.interface_driver, self.conf) self.bridged = interface_driver.bridged() except Exception as e: msg = (_("Error importing interface driver '%(driver)s': " "%(inner)s") % { 'driver': self.conf.interface_driver, 'inner': e }) LOG.error(msg) raise SystemExit(msg) ctx = context.get_admin_context_without_session() self.plugin_rpc = DhcpPluginApi( topics.PLUGIN, ctx, self.bridged and self.conf.use_namespaces) # create dhcp dir to store dhcp info dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path) if not os.path.isdir(dhcp_dir): os.makedirs(dhcp_dir, 0o755) self.dhcp_version = self.dhcp_driver_cls.check_version() self._populate_networks_cache()
def __init__(self, conf): LOG.debug(_("Initializing firewall agent")) self.conf = conf fwaas_driver_class_path = cfg.CONF.fwaas.driver self.fwaas_enabled = cfg.CONF.fwaas.enabled # None means l3-agent has no information on the server # configuration due to the lack of RPC support. if self.neutron_service_plugins is not None: fwaas_plugin_configured = (constants.FIREWALL in self.neutron_service_plugins) if fwaas_plugin_configured and not self.fwaas_enabled: msg = _("FWaaS plugin is configured in the server side, but " "FWaaS is disabled in L3-agent.") LOG.error(msg) raise SystemExit(1) self.fwaas_enabled = self.fwaas_enabled and fwaas_plugin_configured if self.fwaas_enabled: try: self.fwaas_driver = importutils.import_object( fwaas_driver_class_path) LOG.debug(_("FWaaS Driver Loaded: '%s'"), fwaas_driver_class_path) except ImportError: msg = _('Error importing FWaaS device driver: %s') raise ImportError(msg % fwaas_driver_class_path) self.services_sync = False self.root_helper = config.get_root_helper(conf) # setup RPC to msg fwaas plugin self.fwplugin_rpc = FWaaSL3PluginApi(topics.FIREWALL_PLUGIN, conf.host) super(FWaaSL3AgentRpcCallback, self).__init__(host=conf.host)
def main(): """Main method for cleaning up network namespaces. This method will make two passes checking for namespaces to delete. The process will identify candidates, sleep, and call garbage collect. The garbage collection will re-verify that the namespace meets the criteria for deletion (ie it is empty). The period of sleep and the 2nd pass allow time for the namespace state to settle, so that the check prior deletion will re-confirm the namespace is empty. The utility is designed to clean-up after the forced or unexpected termination of Neutron agents. The --force flag should only be used as part of the cleanup of a devstack installation as it will blindly purge namespaces and their devices. This option also kills any lingering DHCP instances. """ eventlet.monkey_patch() conf = setup_conf() conf() config.setup_logging(conf) root_helper = agent_config.get_root_helper(conf) # Identify namespaces that are candidates for deletion. candidates = [ ns for ns in ip_lib.IPWrapper.get_namespaces(root_helper) if eligible_for_deletion(conf, ns, conf.force) ] if candidates: eventlet.sleep(2) for namespace in candidates: destroy_namespace(conf, namespace, conf.force)
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} self._check_config_params() try: self.driver = importutils.import_object( self.conf.interface_driver, self.conf ) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver LOG.error(msg) raise SystemExit(msg) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host) self.fullsync = True self.updated_routers = set() self.removed_routers = set() self.sync_progress = False if self.conf.use_namespaces: self._destroy_router_namespaces(self.conf.router_id) self.rpc_loop = loopingcall.FixedIntervalLoopingCall( self._rpc_loop) self.rpc_loop.start(interval=RPC_LOOP_INTERVAL) super(L3NATAgent, self).__init__(conf=self.conf)
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} self._check_config_params() try: self.driver = importutils.import_object( self.conf.interface_driver, self.conf ) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver LOG.error(msg) raise SystemExit(1) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host) self.fullsync = True self.updated_routers = set() self.removed_routers = set() self.sync_progress = False self._clean_stale_namespaces = self.conf.use_namespaces self._queue = RouterProcessingQueue() super(L3NATAgent, self).__init__(conf=self.conf) self.target_ex_net_id = None
def __init__(self, conf): self.conf = conf try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: # the driver is optional msg = _('Error importing interface driver: %s') raise SystemExit(msg % conf.interface_driver) vif_driver = None try: self.driver = importutils.import_object( conf.device_driver, config.get_root_helper(self.conf), conf.loadbalancer_state_path, vif_driver, self._vip_plug_callback ) except ImportError: msg = _('Error importing loadbalancer device driver: %s') raise SystemExit(msg % conf.device_driver) ctx = context.get_admin_context_without_session() self.plugin_rpc = agent_api.LbaasAgentApi( plugin_driver.TOPIC_PROCESS_ON_HOST, ctx, conf.host ) self.needs_resync = False self.cache = LogicalDeviceCache()
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} if not self.conf.interface_driver: raise SystemExit(_('An interface driver must be specified')) try: self.driver = importutils.import_object(self.conf.interface_driver, self.conf) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver raise SystemExit(msg) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.PLUGIN, host) self.fullsync = True self.updated_routers = set() self.removed_routers = set() self.sync_progress = False if self.conf.use_namespaces: self._destroy_router_namespaces(self.conf.router_id) self.rpc_loop = loopingcall.FixedIntervalLoopingCall(self._rpc_loop) self.rpc_loop.start(interval=RPC_LOOP_INTERVAL) super(L3NATAgent, self).__init__(conf=self.conf)
def __init__(self, host=None): super(DhcpAgent, self).__init__(host=host) self.needs_resync = False self.conf = cfg.CONF self.cache = NetworkCache() self.root_helper = config.get_root_helper(self.conf) self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver) # Work out if DHCP serving for bridged or routed VM interfaces. try: interface_driver = importutils.import_object( self.conf.interface_driver, self.conf) self.bridged = interface_driver.bridged() except Exception as e: msg = (_("Error importing interface driver '%(driver)s': " "%(inner)s") % {'driver': self.conf.interface_driver, 'inner': e}) LOG.error(msg) raise SystemExit(msg) ctx = context.get_admin_context_without_session() self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, ctx, self.bridged and self.conf.use_namespaces) # create dhcp dir to store dhcp info dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path) if not os.path.isdir(dhcp_dir): os.makedirs(dhcp_dir, 0o755) self.dhcp_version = self.dhcp_driver_cls.check_version() self._populate_networks_cache()
def __init__(self, conf, plugin_rpc): self.conf = conf self.root_helper = config.get_root_helper(conf) self.state_path = conf.zorp.loadbalancer_state_path try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: with excutils.save_and_reraise_exception(): msg = (_('Error importing interface driver: %s') % conf.zorp.interface_driver) LOG.error(msg) self.vif_driver = vif_driver self.plugin_rpc = plugin_rpc self.pool_to_port_id = {} # generators for zorp config # xml generator generates policy.xml for easy tracking of changes # policy.py generator policy.py and instances.conf for Zorp configuration self.xml_generator = XMLGenerator() # TODO: maybe loadbalancer_state_path should be used self.policy_py_generator = PolicyPyFromXMLGenerator( policy_xml='/tmp/policy.xml', policy_py='/tmp/policy.py', instances_conf='/tmp/instances.conf' )
def __init__(self, conf): LOG.debug("Initializing firewall agent") self.conf = conf fwaas_driver_class_path = cfg.CONF.fwaas.driver self.fwaas_enabled = cfg.CONF.fwaas.enabled # None means l3-agent has no information on the server # configuration due to the lack of RPC support. if self.neutron_service_plugins is not None: fwaas_plugin_configured = (constants.FIREWALL in self.neutron_service_plugins) if fwaas_plugin_configured and not self.fwaas_enabled: msg = _("FWaaS plugin is configured in the server side, but " "FWaaS is disabled in L3-agent.") LOG.error(msg) raise SystemExit(1) self.fwaas_enabled = self.fwaas_enabled and fwaas_plugin_configured if self.fwaas_enabled: try: self.fwaas_driver = importutils.import_object( fwaas_driver_class_path) LOG.debug("FWaaS Driver Loaded: '%s'", fwaas_driver_class_path) except ImportError: msg = _('Error importing FWaaS device driver: %s') raise ImportError(msg % fwaas_driver_class_path) self.services_sync = False self.root_helper = config.get_root_helper(conf) # setup RPC to msg fwaas plugin self.fwplugin_rpc = FWaaSL3PluginApi(topics.FIREWALL_PLUGIN, conf.host) super(FWaaSL3AgentRpcCallback, self).__init__(host=conf.host)
def __init__(self, host, conf=None): super(VPNAgent, self).__init__(host=host, conf=conf) self.root_helper = config.get_root_helper(cfg.CONF) cfg.CONF.register_opts(vpn_agent_opts, 'ngfw') self.setup_device_drivers(host) for device in self.devices: device.sync(self.context, [])
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} if not self.conf.interface_driver: raise SystemExit(_('An interface driver must be specified')) try: self.driver = importutils.import_object( self.conf.interface_driver, self.conf ) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver raise SystemExit(msg) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.PLUGIN, host) self.fullsync = True self.sync_sem = semaphore.Semaphore(1) if self.conf.use_namespaces: self._destroy_router_namespaces(self.conf.router_id) super(L3NATAgent, self).__init__(host=self.conf.host)
def __init__(self, host, conf=None): super(QosAgent, self).__init__(host=host) self.conf = conf or cfg.CONF self.context = context.get_admin_context_without_session() self.host = host self.root_helper = config.get_root_helper(self.conf) self.plugin_rpc = QosPluginRpc(qos_topics.QOS_PLUGIN, self.host) self.known_namespaces = netns.get_related_ns()
def __init__(self, conf, router): self.conf = conf self.id = router["id"] self.router = router self.root_helper = config.get_root_helper(self.conf) self.iptables_manager = iptables_manager.IptablesManager( root_helper=self.conf.root_helper, namespace=self.ns_name(), binary_name=WRAP_NAME ) self.metering_labels = {}
def __init__(self, conf, router): self.conf = conf self.id = router['id'] self.router = router self.root_helper = config.get_root_helper(self.conf) self.iptables_manager = iptables_manager.IptablesManager( root_helper=self.root_helper, namespace=self.ns_name(), binary_name=WRAP_NAME) self.metering_labels = {}
def kill_dhcp(conf, namespace): """Disable DHCP for a network if DHCP is still active.""" root_helper = agent_config.get_root_helper(conf) network_id = namespace.replace(dhcp.NS_PREFIX, '') dhcp_driver = importutils.import_object(conf.dhcp_driver, conf, FakeNetwork(network_id), root_helper) if dhcp_driver.active: dhcp_driver.disable()
def __init__(self, conf, router): self.conf = conf self.id = router['id'] self.router = router self.root_helper = config.get_root_helper(self.conf) self.ns_name = NS_PREFIX + self.id if conf.use_namespaces else None self.iptables_manager = iptables_manager.IptablesManager( root_helper=self.root_helper, namespace=self.ns_name, binary_name=WRAP_NAME) self.metering_labels = {}
def __init__(self, conf, plugin): self.conf = conf self.root_helper = config.get_root_helper(conf) self.plugin = plugin if not conf.interface_driver: raise SystemExit(_("You must specify an interface driver")) try: self.driver = importutils.import_object(conf.interface_driver, conf) except Exception: msg = _("Error importing interface driver " "'%s'") % conf.interface_driver raise SystemExit(msg)
def unplug_device(conf, device): try: device.link.delete() except RuntimeError: root_helper = agent_config.get_root_helper(conf) # Maybe the device is OVS port, so try to delete bridge_name = ovs_lib.get_bridge_for_iface(root_helper, device.name) if bridge_name: bridge = ovs_lib.OVSBridge(bridge_name, root_helper) bridge.delete_port(device.name) else: LOG.debug(_('Unable to find bridge for device: %s'), device.name)
def __init__(self, conf): LOG.debug(_("Initializing firewall agent")) fwaas_driver_class_path = cfg.CONF.fw_app.fw_app_driver self.fwaas_enabled = cfg.CONF.fw_app.fw_enabled self.fwaas_driver_class = fwaas_driver_class_path self.fwaas_driver = {} self.services_sync = False self.root_helper = config.get_root_helper(conf) # setup RPC to msg fwaas plugin self.fwplugin_rpc = FWaaSNetconfPluginApi(topics.FIREWALL_PLUGIN, conf.host) super(FWaaSNetconfAgentRpcCallback, self).__init__(host=conf.host)
def __init__(self, cmd, *args, **kwargs): for arg in ('stdin', 'stdout', 'stderr'): kwargs.setdefault(arg, subprocess.PIPE) self.namespace = kwargs.pop('namespace', None) self.cmd = cmd if self.namespace is not None: cmd = ['ip', 'netns', 'exec', self.namespace] + cmd root_helper = config.get_root_helper(utils.cfg.CONF) cmd = shlex.split(root_helper) + cmd self.child_pid = None super(RootHelperProcess, self).__init__(cmd, *args, **kwargs) self._wait_for_child_process()
def __init__(self, conf, router): self.conf = conf self.id = router['id'] self.router = router self.root_helper = config.get_root_helper(self.conf) self.ns_name = NS_PREFIX + self.id if conf.use_namespaces else None self.iptables_manager = iptables_manager.IptablesManager( root_helper=self.root_helper, namespace=self.ns_name, binary_name=WRAP_NAME, use_ipv6=ipv6_utils.is_enabled()) self.metering_labels = {}
def __init__(self, conf): LOG.debug(_("Initializing firewall agent")) fwaas_driver_class_path = cfg.CONF.fw_app.fw_app_driver self.fwaas_enabled = cfg.CONF.fw_app.fw_enabled self.fwaas_driver_class = fwaas_driver_class_path self.fwaas_driver = {} self.services_sync = False self.root_helper = config.get_root_helper(conf) # setup RPC to msg fwaas plugin self.fwplugin_rpc = FWaaSNetconfPluginApi(topics.FIREWALL_PLUGIN, conf.host) super(FWaaSNetconfAgentRpcCallback, self).__init__(host = conf.host)
def __init__(self, cmd, *args, **kwargs): for arg in ("stdin", "stdout", "stderr"): kwargs.setdefault(arg, subprocess.PIPE) self.namespace = kwargs.pop("namespace", None) self.cmd = cmd if self.namespace is not None: cmd = ["ip", "netns", "exec", self.namespace] + cmd root_helper = config.get_root_helper(utils.cfg.CONF) cmd = shlex.split(root_helper) + cmd self.child_pid = None super(RootHelperProcess, self).__init__(cmd, *args, **kwargs) self._wait_for_child_process()
def __init__(self, conf, plugin): self.conf = conf self.root_helper = config.get_root_helper(conf) self.plugin = plugin if not conf.interface_driver: raise SystemExit(_('You must specify an interface driver')) try: self.driver = importutils.import_object(conf.interface_driver, conf) except Exception: msg = _("Error importing interface driver " "'%s'") % conf.interface_driver raise SystemExit(msg)
def kill_dhcp(conf, namespace): """Disable DHCP for a network if DHCP is still active.""" root_helper = agent_config.get_root_helper(conf) network_id = namespace.replace(dhcp.NS_PREFIX, '') dhcp_driver = importutils.import_object( conf.dhcp_driver, conf, FakeNetwork(network_id), root_helper) if dhcp_driver.active: dhcp_driver.disable()
def eligible_for_deletion(conf, namespace, force=False): """Determine whether a namespace is eligible for deletion. Eligibility is determined by having only the lo device or if force is passed as a parameter. """ # filter out namespaces without UUID as the name if not re.match(NS_MANGLING_PATTERN, namespace): return False root_helper = agent_config.get_root_helper(conf) ip = ip_lib.IPWrapper(root_helper, namespace) return force or ip.namespace_is_empty()
def __init__(self, host=None): super(DhcpAgent, self).__init__(host=host) self.needs_resync = False self.conf = cfg.CONF self.cache = NetworkCache() self.root_helper = config.get_root_helper(self.conf) self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver) ctx = context.get_admin_context_without_session() self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, ctx) self.device_manager = DeviceManager(self.conf, self.plugin_rpc) self.lease_relay = DhcpLeaseRelay(self.update_lease) self.dhcp_version = self.dhcp_driver_cls.check_version() self._populate_networks_cache()
def __init__(self, conf, plugin_rpc): self.conf = conf self.root_helper = config.get_root_helper(conf) self.state_path = conf.haproxy.loadbalancer_state_path try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: with excutils.save_and_reraise_exception(): msg = _("Error importing interface driver: %s") % conf.haproxy.interface_driver LOG.error(msg) self.vif_driver = vif_driver self.plugin_rpc = plugin_rpc self.pool_to_port_id = {}
def kill_dhcp(conf, namespace): """Disable DHCP for a network if DHCP is still active.""" root_helper = agent_config.get_root_helper(conf) network_id = namespace.replace(dhcp.NS_PREFIX, '') dhcp_driver = importutils.import_object( conf.dhcp_driver, conf=conf, network=dhcp.NetModel(conf.use_namespaces, {'id': network_id}), root_helper=root_helper, plugin=FakeDhcpPlugin()) if dhcp_driver.active: dhcp_driver.disable()
def __init__(self, host, conf=None): super(TunnelAgent, self).__init__(host=host) if conf: self.conf = conf else: self.conf = cfg.CONF config.register_root_helper(self.conf) self.context = context.get_admin_context_without_session() self.root_helper = config.get_root_helper(self.conf) self.setup_device_drivers(host) self.sync_tunnels(self.context) self.rpc_loop = loopingcall.FixedIntervalLoopingCall( self._rpc_loop_nosync) self.rpc_loop.start(interval=cfg.CONF.tunnel_agent.rpc_loop_interval)
def __init__(self, host, conf=None): super(TunnelAgent, self).__init__(host=host) if conf: self.conf = conf else: self.conf = cfg.CONF config.register_root_helper(self.conf) self.context = context.get_admin_context_without_session() self.root_helper = config.get_root_helper(self.conf) self.setup_device_drivers(host) self.sync_tunnels(self.context) self.rpc_loop = loopingcall.FixedIntervalLoopingCall( self._rpc_loop_nosync) self.rpc_loop.start(interval= cfg.CONF.tunnel_agent.rpc_loop_interval)
def __init__(self, conf, plugin_rpc): self.conf = conf self.root_helper = config.get_root_helper(conf) self.state_path = conf.haproxy.loadbalancer_state_path try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: msg = (_('Error importing interface driver: %s') % conf.haproxy.interface_driver) LOG.error(msg) raise self.vif_driver = vif_driver self.plugin_rpc = plugin_rpc self.pool_to_port_id = {}
def __init__(self, host=None): super(DhcpAgent, self).__init__(host=host) self.needs_resync = False self.conf = cfg.CONF self.cache = NetworkCache() self.root_helper = config.get_root_helper(self.conf) self.dhcp_driver_cls = importutils.import_class(self.conf.dhcp_driver) ctx = context.get_admin_context_without_session() self.plugin_rpc = DhcpPluginApi(topics.PLUGIN, ctx, self.conf.use_namespaces) # create dhcp dir to store dhcp info dhcp_dir = os.path.dirname("/%s/dhcp/" % self.conf.state_path) if not os.path.isdir(dhcp_dir): os.makedirs(dhcp_dir, 0o755) self.dhcp_version = self.dhcp_driver_cls.check_version() self._populate_networks_cache()
def __init__(self, conf, plugin_rpc): self.conf = conf self.root_helper = config.get_root_helper(conf) self.state_path = conf.haproxy.loadbalancer_state_path try: vif_driver = importutils.import_object(conf.interface_driver, conf) except ImportError: with excutils.save_and_reraise_exception(): msg = (_('Error importing interface driver: %s') % conf.interface_driver) LOG.error(msg) self.vif_driver = vif_driver self.plugin_rpc = plugin_rpc self.pool_to_port_id = {}
def create_process(cmd, run_as_root=False, addl_env=None): """Create a process object for the given command. The return value will be a tuple of the process object and the list of command arguments used to create it. """ cmd = map(str, addl_env_args(addl_env) + cmd) if run_as_root: cmd = shlex.split(config.get_root_helper(cfg.CONF)) + cmd LOG.debug("Running command: %s", cmd) obj = utils.subprocess_popen( cmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) return obj, cmd
def create_process(cmd, run_as_root=False, addl_env=None): """Create a process object for the given command. The return value will be a tuple of the process object and the list of command arguments used to create it. """ cmd = list(map(str, addl_env_args(addl_env) + cmd)) if run_as_root: cmd = shlex.split(config.get_root_helper(cfg.CONF)) + cmd LOG.debug("Running command: %s", cmd) obj = utils.subprocess_popen(cmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return obj, cmd
def __init__(self, host, conf=None): self.conf = conf or cfg.CONF self._load_drivers() self.root_helper = config.get_root_helper(self.conf) self.context = context.get_admin_context_without_session() self.metering_info = {} 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)
def __init__(self, conf, plugin_rpc): self.conf = conf self.root_helper = config.get_root_helper(conf) self.state_path = conf.haproxy_int.loadbalancer_state_path self.external_networks = self.conf.haproxy_int.external_networks self.ngfw_client = NGFWClient() self.plugin_rpc = plugin_rpc self.pools_stats = {} self.cfg_data = {} self.proxy_ips = {} self._set_proxy_info() self.last_process_time = 0 self.last_rpc_time = 0 self.last_collect_time = 0 self.context = context.get_admin_context_without_session() self._setup_proxy_rpc()
def __init__(self, host, conf=None): self.conf = conf or cfg.CONF self._load_drivers() self.root_helper = config.get_root_helper(self.conf) self.context = context.get_admin_context_without_session() self.metering_info = {} 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)
def __init__(self, conf): LOG.debug(_("Initializing firewall agent")) self.conf = conf fwaas_driver_class_path = cfg.CONF.fwaas.driver self.fwaas_enabled = cfg.CONF.fwaas.enabled try: self.fwaas_driver = importutils.import_object( fwaas_driver_class_path) LOG.debug(_("FWaaS Driver Loaded: '%s'"), fwaas_driver_class_path) except ImportError: msg = _('Error importing FWaaS device driver: %s') raise ImportError(msg % fwaas_driver_class_path) self.services_sync = False self.root_helper = config.get_root_helper(conf) # setup RPC to msg fwaas plugin self.fwplugin_rpc = FWaaSL3PluginApi(topics.FIREWALL_PLUGIN, conf.host) super(FWaaSL3AgentRpcCallback, self).__init__(host=conf.host)
def __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host) self.fullsync = True self.updated_routers = set() self.removed_routers = set() self.sync_progress = False self.servers = None self.fail_update_rest_router_id = set() self.fail_delete_rest_router_id = set() conf_proxy = get_rest_proxy_conf() self.whole_syncing_not_succ_yet = False self.sync_protect_tick = 0 self.agent_id = 'zenic-agent-%s' % self.conf.host self.zenic_rpc = ZenicPluginApi(topics.PLUGIN) self.up_gw_status = conf_proxy.RESTPROXY.up_gw_status self.sync_router = conf_proxy.RESTPROXY.sync_router if conf_proxy.RESTPROXY.servers is not '': self.servers = ZenicL3RestServerPool( conf_proxy.RESTPROXY.servers, conf_proxy.RESTPROXY.server_auth, conf_proxy.RESTPROXY.zenic_version, conf_proxy.RESTPROXY.server_ssl, conf_proxy.RESTPROXY.no_ssl_validation, conf_proxy.RESTPROXY.ssl_sticky, conf_proxy.RESTPROXY.ssl_cert_directory, conf_proxy.RESTPROXY.consistency_interval, conf_proxy.RESTPROXY.server_timeout, conf_proxy.RESTPROXY.cache_connections, conf_proxy.RESTPROXY.base_url, conf_proxy.RESTPROXY.op_version) # self.rpc_loop = loopingcall.FixedIntervalLoopingCall( # self._rpc_loop) # self.rpc_loop.start(interval=RPC_LOOP_INTERVAL) super(ZenicAgent, self).__init__(host=host) self.target_ex_net_id = None self.sync_routers_chunk_size = SYNC_ROUTERS_MAX_CHUNK_SIZE
def __init__(self, conf): super(LbaasProxyManager, self).__init__() self.conf = conf self.root_helper = config.get_root_helper(conf) self.context = context.get_admin_context_without_session() self.agent_rpc = LbassProxyApi( '%s-%s' % (topics.LOADBALANCER_INTEGRATION_PROXY, self.conf.cluster_name), self.context, self.conf.host ) self.state_path = self.conf.loadbalancer_state_path self.pools_config = '' self.needs_resync = False self.sync_state() report_interval = self.conf.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def destroy_namespace(conf, namespace, force=False): """Destroy a given namespace. If force is True, then dhcp (if it exists) will be disabled and all devices will be forcibly removed. """ try: root_helper = agent_config.get_root_helper(conf) ip = ip_lib.IPWrapper(root_helper, namespace) if force: kill_dhcp(conf, namespace) # NOTE: The dhcp driver will remove the namespace if is it empty, # so a second check is required here. if ip.netns.exists(namespace): for device in ip.get_devices(exclude_loopback=True): unplug_device(conf, device) ip.garbage_collect_namespace() except Exception: LOG.exception(_('Error unable to destroy namespace: %s'), namespace)
def __init__(self, conf): LOG.debug("TaaS OVS Agent initialize called") self.conf = conf taas_driver_class_path = cfg.CONF.taas.driver self.taas_enabled = cfg.CONF.taas.enabled self.root_helper = config.get_root_helper(conf) try: self.taas_driver = importutils.import_object( taas_driver_class_path, self.root_helper) LOG.debug("TaaS Driver Loaded: '%s'", taas_driver_class_path) except ImportError: msg = _('Error importing TaaS device driver: %s') raise ImportError(msg % taas_driver_class_path) # setup RPC to msg taas plugin self.taas_plugin_rpc = TaasOvsPluginApi(topics.TAAS_PLUGIN, conf.host) super(TaasOvsAgentRpcCallback, self).__init__() return