def main():
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    agent_config.setup_privsep()
    try:
        interface_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
    except ValueError as e:
        LOG.error("Parsing physical_interface_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Interface mappings: %s", interface_mappings)

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s", bridge_mappings)

    manager = LinuxBridgeManager(bridge_mappings, interface_mappings)
    linuxbridge_capabilities.register()

    polling_interval = cfg.CONF.AGENT.polling_interval
    quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout
    agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout,
                               constants.AGENT_TYPE_LINUXBRIDGE,
                               LB_AGENT_BINARY)
    setup_profiler.setup("neutron-linuxbridge-agent", cfg.CONF.host)
    LOG.info("Agent initialized successfully, now running... ")
    launcher = service.launch(cfg.CONF, agent, restart_method='mutate')
    launcher.wait()
Esempio n. 2
0
def main():
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    try:
        config_parser = SriovNicAgentConfigParser()
        config_parser.parse()
        device_mappings = config_parser.device_mappings
        exclude_devices = config_parser.exclude_devices

    except ValueError:
        LOG.exception(
            _LE("Failed on Agent configuration parse. "
                "Agent terminated!"))
        raise SystemExit(1)
    LOG.info(_LI("Physical Devices mappings: %s"), device_mappings)
    LOG.info(_LI("Exclude Devices: %s"), exclude_devices)

    polling_interval = cfg.CONF.AGENT.polling_interval
    try:
        agent = SriovNicSwitchAgent(device_mappings, exclude_devices,
                                    polling_interval)
    except exc.SriovNicError:
        LOG.exception(_LE("Agent Initialization Failed"))
        raise SystemExit(1)
    # Start everything.
    setup_profiler.setup("neutron-sriov-nic-agent", cfg.CONF.host)
    LOG.info(_LI("Agent initialized successfully, now running... "))
    agent.daemon_loop()
Esempio n. 3
0
def main():
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    agent_config.setup_privsep()
    try:
        interface_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
    except ValueError as e:
        LOG.error(_LE("Parsing physical_interface_mappings failed: %s. "
                      "Agent terminated!"), e)
        sys.exit(1)
    LOG.info(_LI("Interface mappings: %s"), interface_mappings)

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error(_LE("Parsing bridge_mappings failed: %s. "
                      "Agent terminated!"), e)
        sys.exit(1)
    LOG.info(_LI("Bridge mappings: %s"), bridge_mappings)

    manager = LinuxBridgeManager(bridge_mappings, interface_mappings)
    linuxbridge_capabilities.register()

    polling_interval = cfg.CONF.AGENT.polling_interval
    quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout
    agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout,
                               constants.AGENT_TYPE_LINUXBRIDGE,
                               LB_AGENT_BINARY)
    setup_profiler.setup("neutron-linuxbridge-agent", cfg.CONF.host)
    LOG.info(_LI("Agent initialized successfully, now running... "))
    launcher = service.launch(cfg.CONF, agent)
    launcher.wait()
Esempio n. 4
0
def main():
    common_config.register_common_config_options()
    common_config.init(sys.argv[1:])
    of_main.init_config()
    common_config.setup_logging()
    profiler.setup("neutron-ovs-agent", cfg.CONF.host)
    of_main.main()
Esempio n. 5
0
def main():
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    try:
        config_parser = SriovNicAgentConfigParser()
        config_parser.parse()
        device_mappings = config_parser.device_mappings
        exclude_devices = config_parser.exclude_devices
        rp_bandwidths = config_parser.rp_bandwidths
        rp_inventory_defaults = config_parser.rp_inventory_defaults
        rp_hypervisors = config_parser.rp_hypervisors

    except ValueError:
        LOG.exception("Failed on Agent configuration parse. "
                      "Agent terminated!")
        raise SystemExit(1)
    LOG.info("Physical Devices mappings: %s", device_mappings)
    LOG.info("Exclude Devices: %s", exclude_devices)
    LOG.info("Resource provider bandwidths: %s", rp_bandwidths)
    LOG.info("Resource provider inventory defaults: %s", rp_inventory_defaults)
    LOG.info("Resource provider hypervisors: %s", rp_hypervisors)

    polling_interval = cfg.CONF.AGENT.polling_interval
    try:
        agent = SriovNicSwitchAgent(device_mappings, exclude_devices,
                                    polling_interval, rp_bandwidths,
                                    rp_inventory_defaults, rp_hypervisors)
    except exc.SriovNicError:
        LOG.exception("Agent Initialization Failed")
        raise SystemExit(1)
    # Start everything.
    setup_profiler.setup("neutron-sriov-nic-agent", cfg.CONF.host)
    LOG.info("Agent initialized successfully, now running... ")
    agent.daemon_loop()
Esempio n. 6
0
def main():
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    try:
        config_parser = SriovNicAgentConfigParser()
        config_parser.parse()
        device_mappings = config_parser.device_mappings
        exclude_devices = config_parser.exclude_devices

    except ValueError:
        LOG.exception(_LE("Failed on Agent configuration parse. " "Agent terminated!"))
        raise SystemExit(1)
    LOG.info(_LI("Physical Devices mappings: %s"), device_mappings)
    LOG.info(_LI("Exclude Devices: %s"), exclude_devices)

    polling_interval = cfg.CONF.AGENT.polling_interval
    try:
        agent = SriovNicSwitchAgent(device_mappings, exclude_devices, polling_interval)
    except exc.SriovNicError:
        LOG.exception(_LE("Agent Initialization Failed"))
        raise SystemExit(1)
    # Start everything.
    setup_profiler.setup("neutron-sriov-nic-agent", cfg.CONF.host)
    LOG.info(_LI("Agent initialized successfully, now running... "))
    agent.daemon_loop()
Esempio n. 7
0
def main():
    eventlet.monkey_patch()
    common_config.init(sys.argv[1:])
    kaloom_config.register_kaloomkvs_opts()
    common_config.setup_logging()
    agent_config.setup_privsep()

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.kaloom_kvs.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s", bridge_mappings)

    try:
        vhostuser_socket_dir = cfg.CONF.kaloom_kvs.vhostuser_socket_dir
    except ValueError as e:
        LOG.error(
            "Parsing vhostuser_socket_dir failed: %s. "
            "Agent terminated!", e)
        sys.exit(1)
    LOG.info("vhostuser_socket_dir: %s", vhostuser_socket_dir)

    dir_exists = os.path.exists(vhostuser_socket_dir)
    if dir_exists is False:
        #creating the dir with right selinux context is not preferred.
        #the dir should be pre-configured.
        LOG.error(
            "vhostuser_socket_dir %s does not exists."
            "Agent terminated!", vhostuser_socket_dir)
        sys.exit(1)

    # is it compliance with permission
    status, msg = kvs_utils.check_permission(vhostuser_socket_dir)
    if status is not True:
        LOG.error("%s. Agent terminated!", msg)
        sys.exit(1)

    host = cfg.CONF.host
    kvs_id = 'kvs-agent-%s' % host

    manager = KaloomKVSManager(bridge_mappings, kvs_id, vhostuser_socket_dir)
    kaloomkvs_capabilities.register()

    polling_interval = cfg.CONF.AGENT.polling_interval
    quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout

    LOG.info("polling_interval: %s", polling_interval)
    LOG.info("quitting_rpc_timeout: %s", quitting_rpc_timeout)

    agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout,
                               a_const.AGENT_TYPE_KALOOM_KVS,
                               a_const.KVS_AGENT_BINARY)
    setup_profiler.setup("neutron-kaloom-agent", cfg.CONF.host)
    LOG.info("Agent initialized successfully, now running... ")
    launcher = service.launch(cfg.CONF, agent)
    launcher.wait()
Esempio n. 8
0
    def _init_(self, args):
        neutron_config = []
        for file in args.config_file:
            neutron_config.extend(["--config-file", file])

        common_config.init(neutron_config)
        common_config.setup_logging()
        profiler.setup(nsxv3_constants.NSXV3_BIN, cfg.CONF.host)
Esempio n. 9
0
def main():
    common_config.init(sys.argv[1:])
    driver_name = cfg.CONF.OVS.of_interface
    mod_name = _main_modules[driver_name]
    mod = importutils.import_module(mod_name)
    mod.init_config()
    common_config.setup_logging()
    profiler.setup("neutron-ovs-agent", cfg.CONF.host)
    mod.main()
Esempio n. 10
0
def main():
    common_config.init(sys.argv[1:])
    driver_name = cfg.CONF.OVS.of_interface
    mod_name = _main_modules[driver_name]
    mod = importutils.import_module(mod_name)
    mod.init_config()
    common_config.setup_logging()
    profiler.setup("neutron-ovs-agent", cfg.CONF.host)
    mod.main()
Esempio n. 11
0
def main():
    common_config.init(sys.argv[1:])
    # driver_name = ovs-ofctl
    driver_name = cfg.CONF.OVS.of_interface
    mod_name = _main_modules[driver_name]
    mod = importutils.import_module(mod_name)
    mod.init_config()
    common_config.setup_logging()
    n_utils.log_opt_values(LOG)
    profiler.setup("neutron-ovs-agent", cfg.CONF.host)
    # 调用ovs-ofctl对应的main方法
    mod.main()
Esempio n. 12
0
    def __init__(self, host, binary, topic, manager, report_interval=None,
                 periodic_interval=None, periodic_fuzzy_delay=None,
                 *args, **kwargs):

        self.binary = binary
        self.manager_class_name = manager
        manager_class = importutils.import_class(self.manager_class_name)
        self.manager = manager_class(host=host, *args, **kwargs)
        self.report_interval = report_interval
        self.periodic_interval = periodic_interval
        self.periodic_fuzzy_delay = periodic_fuzzy_delay
        self.saved_args, self.saved_kwargs = args, kwargs
        self.timers = []
        profiler.setup(binary, host)
        super(Service, self).__init__(host, topic, manager=self.manager)
Esempio n. 13
0
    def __init__(self, host, binary, topic, manager, report_interval=None,
                 periodic_interval=None, periodic_fuzzy_delay=None,
                 *args, **kwargs):

        self.binary = binary
        self.manager_class_name = manager
        manager_class = importutils.import_class(self.manager_class_name)
        self.manager = manager_class(host=host, *args, **kwargs)
        self.report_interval = report_interval
        self.periodic_interval = periodic_interval
        self.periodic_fuzzy_delay = periodic_fuzzy_delay
        self.saved_args, self.saved_kwargs = args, kwargs
        self.timers = []
        profiler.setup(binary, host)
        super(Service, self).__init__(host, topic, manager=self.manager)
Esempio n. 14
0
def main():
    common_config.init(sys.argv[1:])
    common_config.setup_logging()

    manager = SrManager()

    polling_interval = cfg.CONF.AGENT.polling_interval
    quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout
    agent = sr_agent_loop.SrAgentLoop(manager, polling_interval,
                                      quitting_rpc_timeout, AGENT_TYPE_SR,
                                      SR_AGENT_BINARY)
    setup_profiler.setup(SR_AGENT_BINARY, cfg.CONF.host)
    LOG.info("Agent initialized successfully, now running... ")
    launcher = service.launch(cfg.CONF, agent, restart_method='mutate')
    launcher.wait()
Esempio n. 15
0
def main():
    common_config.init(sys.argv[1:])
    common_config.setup_logging()
    profiler.setup('neutron-dvs-agent', cfg.CONF.host)
    try:
        resolution = float(os.getenv('DEBUG_BLOCKING'))
        import eventlet.debug
        eventlet.debug.hub_blocking_detection(state=True,
                                              resolution=resolution)
    except (ValueError, TypeError):
        pass

    try:
        agent = DvsNeutronAgent()
        dvs_inst = agent
        # Start everything.
        LOG.info(_LI("Agent initialized successfully, now running... "))
        agent.daemon_loop()
    except KeyboardInterrupt:
        pass
def main():
    common_config.register_common_config_options()
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    agent_config.setup_privsep()
    service_conf.register_service_opts(service_conf.RPC_EXTRA_OPTS, cfg.CONF)

    try:
        interface_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
    except ValueError as e:
        LOG.error(
            "Parsing physical_interface_mappings failed: %s. "
            "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Interface mappings: %s", interface_mappings)

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s", bridge_mappings)

    manager = LinuxBridgeManager(bridge_mappings, interface_mappings)
    linuxbridge_capabilities.register()

    polling_interval = cfg.CONF.AGENT.polling_interval
    quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout
    agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout,
                               constants.AGENT_TYPE_LINUXBRIDGE,
                               constants.AGENT_PROCESS_LINUXBRIDGE)
    setup_profiler.setup(constants.AGENT_PROCESS_LINUXBRIDGE, cfg.CONF.host)
    LOG.info("Agent initialized successfully, now running... ")
    launcher = service.launch(cfg.CONF, agent, restart_method='mutate')
    launcher.wait()
Esempio n. 17
0
 def __init__(self, app_name):
     profiler.setup('neutron-server', cfg.CONF.host)
     super(NeutronApiService, self).__init__(app_name)
Esempio n. 18
0
def neutron_dvs_cli():
    """
        CLI command for retrieving a port from Neutron by id;
        Comparing the retrieved port to a port in the linked portgroup from vSphere;
        The port from vSphere is fetched by the Neutron port MAC address and the portgroup key;
        If --correct opt is set a reconfigure task on the port will be started which will apply the rules from the Neutron port to the DVS port
    :return: 
    """
    common_config.init(sys.argv[1:])
    port_id = CONF.port_id
    correct = CONF.correct

    profiler.setup('neutron-dvs-agent-cli', cfg.CONF.host)
    agent = DvsNeutronAgent()
    neutron_ports = agent.plugin_rpc.get_devices_details_list(
        agent.context,
        devices=[port_id],
        agent_id=agent.agent_id,
        host=agent.conf.host)

    if neutron_ports[0].has_key('mac_address'):
        mac_addr = neutron_ports[0]['mac_address']
    else:
        raise Exception('Neutron port not found!')

    sg_api = securitygroups_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
    sg_info = sg_api.security_group_info_for_devices(
        agent.context, [neutron_ports[0]['port_id']])

    rules = sg_api.security_group_rules_for_devices(agent.context, [port_id])
    patched_sg_rules = sg_util._patch_sg_rules(
        rules[port_id]['security_group_rules'])

    sg_set = sg_util.security_group_set(sg_info)

    dvs = agent.api.network_dvs_map.get(neutron_ports[0]['physical_network'],
                                        None)
    sg_aggr_obj = defaultdict(lambda: defaultdict(sg_util.SgAggr))
    sg_aggr = sg_aggr_obj[dvs.uuid][sg_set]
    sg_util.apply_rules(patched_sg_rules, sg_aggr)

    sg_set_rules = sg_util.get_rules(sg_aggr)
    port_config = sg_util.port_configuration(None, sg_set_rules, {}, None,
                                             None).setting

    neutron_vlan_id = neutron_ports[0]['segmentation_id']
    dvpg_name = dvs_util.dvportgroup_name(dvs.uuid, sg_set)
    """
        Retrieving the DVS portgroup and properties
    """
    port_group = dvs.get_port_group_for_security_group_set(sg_set)
    portgroup_key = port_group['ref']['value']

    dvs_vlan_id = port_group['defaultPortConfig'].vlan.vlanId

    dvs_port = agent.api.fetch_ports_by_mac(portgroup_key, mac_addr)
    neutron_port_rules = port_config.filterPolicy.filterConfig[
        0].trafficRuleset.rules
    dvs_port_rules = dvs_port.config.setting.filterPolicy.filterConfig[
        0].trafficRuleset.rules

    match = False

    for i in range(len(dvs_port_rules)):
        config_match = dvs_util._config_differs(dvs_port_rules[i],
                                                neutron_port_rules[i])
        if config_match:
            match = True
            print("Neutron Port configuration rule not matched for : ",
                  neutron_port_rules[i])
            print("DVS Port configuraiton rule: ", dvs_port_rules[i])

    if match == False:
        print("Neutron port config matches DVS port config")
    else:
        if correct == 'True':
            print("Updating port configuration")
            if neutron_vlan_id != dvs_vlan_id:
                port_config.vlan = builder.vlan(neutron_vlan_id)

            dv_port_config_spec = builder.port_config_spec(
                key=dvs_port.key,
                version=dvs_port.config.configVersion,
                setting=port_config)
            dvs.update_ports([dv_port_config_spec])
Esempio n. 19
0
 def __init__(self, app_name):
     profiler.setup('neutron-server', cfg.CONF.host)
     super(NeutronApiService, self).__init__(app_name)
Esempio n. 20
0
def get_application():
    _init_configuration()
    profiler.setup('neutron-server', cfg.CONF.host)
    return config.load_paste_app('neutron')
Esempio n. 21
0
def eventlet_api_server():
    profiler.setup('neutron-server', cfg.CONF.host)
    return config.load_paste_app('neutron')
Esempio n. 22
0
def get_application():
    _init_configuration()
    profiler.setup('neutron-server', cfg.CONF.host)
    return config.load_paste_app('neutron')