def setup_conf(): ovs_conf.register_ovs_agent_opts(cfg.CONF) lb_conf.register_linuxbridge_opts(cfg.CONF) ml2_conf.register_ml2_plugin_opts(cfg.CONF) securitygroups_rpc.register_securitygroups_opts(cfg.CONF) dhcp_agent.register_options(cfg.CONF) l3_hamode_db.register_db_l3_hamode_opts(cfg.CONF)
def setUp(self): super(DHCPAgentOVSTestFramework, self).setUp() config.setup_logging() self.conf_fixture = self.useFixture(fixture_config.Config()) self.conf = self.conf_fixture.conf dhcp_agent.register_options(self.conf) # NOTE(cbrandily): TempDir fixture creates a folder with 0o700 # permissions but agent dir must be readable by dnsmasq user (nobody) agent_config_dir = self.useFixture(fixtures.TempDir()).path self.useFixture( helpers.RecursivePermDirFixture(agent_config_dir, 0o555)) self.conf.set_override("dhcp_confs", agent_config_dir) self.conf.set_override( 'interface_driver', 'neutron.agent.linux.interface.OVSInterfaceDriver') self.conf.set_override('report_interval', 0, 'AGENT') br_int = self.useFixture(net_helpers.OVSBridgeFixture()).bridge self.conf.set_override('ovs_integration_bridge', br_int.br_name) self.mock_plugin_api = mock.patch( 'neutron.agent.dhcp.agent.DhcpPluginApi').start().return_value mock.patch('neutron.agent.rpc.PluginReportStateAPI').start() self.agent = agent.DhcpAgentWithStateReport('localhost') self.ovs_driver = interface.OVSInterfaceDriver(self.conf)
def main(): register_options(cfg.CONF) calico_config.register_options(cfg.CONF) common_config.init(sys.argv[1:]) setup_logging() agent = CalicoDhcpAgent() agent.run()
def setUp(self): super(DHCPAgentOVSTestFramework, self).setUp() config.setup_logging() self.conf_fixture = self.useFixture(fixture_config.Config()) self.conf = self.conf_fixture.conf dhcp_agent.register_options(self.conf) # NOTE(cbrandily): TempDir fixture creates a folder with 0o700 # permissions but agent dir must be readable by dnsmasq user (nobody) agent_config_dir = self.useFixture(fixtures.TempDir()).path self.useFixture( helpers.RecursivePermDirFixture(agent_config_dir, 0o555)) self.conf.set_override("dhcp_confs", agent_config_dir) self.conf.set_override( 'interface_driver', 'neutron.agent.linux.interface.OVSInterfaceDriver') self.conf.set_override('report_interval', 0, 'AGENT') br_int = self.useFixture(net_helpers.OVSBridgeFixture()).bridge self.conf.set_override('ovs_integration_bridge', br_int.br_name) self.mock_plugin_api = mock.patch( 'neutron.agent.dhcp.agent.DhcpPluginApi').start().return_value mock.patch('neutron.agent.rpc.PluginReportStateAPI').start() self.agent = agent.DhcpAgentWithStateReport('localhost') self.ovs_driver = interface.OVSInterfaceDriver(self.conf) self.conf.set_override('check_child_processes_interval', 1, 'AGENT')
def setUp(self): super(TestDhcpAgent, self).setUp() register_options(cfg.CONF) calico_config.register_options(cfg.CONF) self.mock_makedirs_p = mock.patch("os.makedirs") self.mock_makedirs = self.mock_makedirs_p.start() self.hostname = socket.gethostname() cfg.CONF.host = self.hostname
def setUp(self): super(TestDnsmasqRouted, self).setUp() register_options(cfg.CONF) cfg.CONF.set_override('dhcp_confs', '/run') cfg.CONF.set_override( 'interface_driver', 'networking_calico.agent.linux.interface.RoutedInterfaceDriver' )
def setUp(self): super(TestDnsmasqRouted, self).setUp() register_options(cfg.CONF) cfg.CONF.set_override('dhcp_confs', '/run') cfg.CONF.set_override( 'interface_driver', 'networking_calico.agent.linux.interface.RoutedInterfaceDriver') self.mock_makedirs_p = mock.patch("os.makedirs") self.mock_makedirs = self.mock_makedirs_p.start()
def setUp(self): super(TestDnsmasqRouted, self).setUp() register_options(cfg.CONF) cfg.CONF.set_override('dhcp_confs', '/run') cfg.CONF.set_override( 'interface_driver', 'networking_calico.agent.linux.interface.RoutedInterfaceDriver' ) self.mock_makedirs_p = mock.patch("os.makedirs") self.mock_makedirs = self.mock_makedirs_p.start()
def setup_conf(): config.register_common_config_options() ovs_conf.register_ovs_agent_opts(cfg.CONF) lb_conf.register_linuxbridge_opts(cfg.CONF) sriov_conf.register_agent_sriov_nic_opts(cfg.CONF) ml2_conf.register_ml2_plugin_opts(cfg.CONF) securitygroups_rpc.register_securitygroups_opts(cfg.CONF) dhcp_agent.register_options(cfg.CONF) l3_hamode_db.register_db_l3_hamode_opts(cfg.CONF) common_config.register_core_common_config_opts(cfg.CONF)
def setup_conf(): cfg.CONF.import_group('AGENT', 'neutron.plugins.ml2.drivers.openvswitch.' 'agent.common.config') cfg.CONF.import_group('OVS', 'neutron.plugins.ml2.drivers.openvswitch.' 'agent.common.config') cfg.CONF.import_group('VXLAN', 'neutron.plugins.ml2.drivers.linuxbridge.' 'agent.common.config') cfg.CONF.import_group('ml2', 'neutron.conf.plugins.ml2.config') cfg.CONF.import_group('SECURITYGROUP', 'neutron.agent.securitygroups_rpc') dhcp_agent.register_options(cfg.CONF) cfg.CONF.register_opts(l3_hamode_db.L3_HA_OPTS)
def setup_conf(): cfg.CONF.import_group('AGENT', 'neutron.plugins.ml2.drivers.openvswitch.' 'agent.common.config') cfg.CONF.import_group('OVS', 'neutron.plugins.ml2.drivers.openvswitch.' 'agent.common.config') cfg.CONF.import_group('VXLAN', 'neutron.plugins.ml2.drivers.linuxbridge.' 'agent.common.config') cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config') cfg.CONF.import_group('ml2_sriov', 'neutron.plugins.ml2.drivers.mech_sriov.mech_driver.' 'mech_driver') dhcp_agent.register_options(cfg.CONF) cfg.CONF.register_opts(l3_hamode_db.L3_HA_OPTS)
def main(): register_options(cfg.CONF) calico_config.register_options(cfg.CONF) common_config.init(sys.argv[1:]) setup_logging() try: # Neutron agent code has been migrating from rootwrap to privsep. # Initialize the privsep system if it is available. config.setup_privsep() except Exception as e: # But don't worry if it isn't; that means we are running with older # Neutron code. LOG.info("Couldn't setup_privsep(): %r", e) agent = CalicoDhcpAgent() agent.run()
def setup_conf(): cfg.CONF.import_group( 'AGENT', 'neutron.plugins.ml2.drivers.openvswitch.' 'agent.common.config') cfg.CONF.import_group( 'OVS', 'neutron.plugins.ml2.drivers.openvswitch.' 'agent.common.config') cfg.CONF.import_group( 'VXLAN', 'neutron.plugins.ml2.drivers.linuxbridge.' 'agent.common.config') cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config') cfg.CONF.import_group( 'ml2_sriov', 'neutron.plugins.ml2.drivers.mech_sriov.mech_driver.' 'mech_driver') dhcp_agent.register_options(cfg.CONF) cfg.CONF.register_opts(l3_hamode_db.L3_HA_OPTS)
def t_create_testns(testns_name, network): try: neutron_credentials = get_neutron_credentials() neutron = neutron_client.Client(**neutron_credentials) dhcp_agent.register_options() dhcp_agent.cfg.CONF(project='neutron') conf = dhcp_agent.cfg.CONF root_helper = config.get_root_helper(conf) ctx = context.get_admin_context_without_session() plugin = dhcp_agent.DhcpPluginApi(topics.PLUGIN, ctx, conf.use_namespaces) conf.interface_driver = "neutron.agent.linux.interface.OVSInterfaceDriver" a = os.system("ip netns add " + testns_name) if a != 0: return time.sleep(2) test_device = dhcp.DeviceManager(conf, root_helper, plugin) test_device.test = True pnetwork = plugin.get_network_info(network['id']) test_tap_interface = test_device.setup( pnetwork, reuse_existing=False, test_tap=True, test_tap_mac="ee:ff:ff:ff:ff:ef", test_ns=testns_name) subnet_id = network['subnets'][0] while True: try: subnet = neutron.list_subnets(id=subnet_id)['subnets'][0] break except: continue gateway_ip = subnet['gateway_ip'] os.system("sudo ip netns exec " + testns_name + " ifconfig " + test_tap_interface + " " + gateway_ip + " netmask 255.255.255.0 up") os.system("sudo ip netns exec " + testns_name + " ifconfig " + test_tap_interface + " up") print "\nAdded test tap interface {0} ({1}) in namespace {2}".format( test_tap_interface, gateway_ip, testns_name) time.sleep(2) try: f = os.popen("sudo ip netns exec qdhcp-" + str(network['id']) + " ip a | grep inet | grep -v 'inet6\|127\|169'") output = f.read().splitlines()[0] ping_ip = output.split()[1].split('/')[0] except Exception as e: print "\n ERROR : Error when running command in namespace {0}".format( "qdhcp-" + str(network['id'])) print e return f = os.popen("sudo ip netns exec " + testns_name + " ping -c 5 " + ping_ip) output = f.read() ping_output = output.splitlines() ping_output = ping_output[len(ping_output) - 2] # if " 0% packet loss" not in ping_output: # print "\n ERROR: Cannot ping {0} from test namespace {1}\n".format(ping_ip, testns_name) f = os.popen("sudo ip netns exec " + testns_name + " ping -c 5 " + ping_ip) output = f.read() ping_output = output.splitlines() ping_output = ping_output[len(ping_output) - 2] # if " 0% packet loss" not in ping_output: # print "\n ERROR: Cannot ping {0} from test namespace {1}\n".format(ping_ip, testns_name) f = os.popen("sudo ip netns exec " + testns_name + " ping -c 5 " + ping_ip) output = f.read() ping_output = output.splitlines() ping_output = ping_output[len(ping_output) - 2] # if " 0% packet loss" not in ping_output: # print "\n ERROR: Cannot ping {0} from test namespace {1}\n".format(ping_ip, testns_name) except Exception as e: print "\n ERROR : An exception occurred when creating test namespace {0} for {1}".format( testns_name, network['name']) print e os.system("ip netns delete " + testns_name) time.sleep(0.5)
def setUp(self): super(TestDhcpAgent, self).setUp() register_options(cfg.CONF) calico_config.register_options(cfg.CONF)
def setUp(self): super(TestDhcpAgent, self).setUp() register_options(cfg.CONF)
# License for the specific language governing permissions and limitations # under the License. import mock from neutron.agent import dhcp_agent from neutron.tests import base from oslo_config import cfg from networking_cisco.plugins.cisco.cpnr.dhcp_driver import OPTS from networking_cisco.plugins.cisco.cpnr import dhcpopts from networking_cisco.plugins.cisco.cpnr import model from networking_cisco.tests.unit.cisco.cpnr import fake_networks dhcp_agent.register_options(cfg.CONF) cfg.CONF.register_opts(OPTS, "cisco_pnr") class TestModel(base.BaseTestCase): @mock.patch.object(model, "_get_client", autospec=True) def test_network_init(self, mock_client): net = model.Network.from_neutron(fake_networks.fake_net1) self.assertIsInstance(net, model.Network) self.assertFalse(mock_client.called) @mock.patch.object(model, "_get_client", autospec=True) def test_network_create(self, mock_client): net = model.Network.from_neutron(fake_networks.fake_net1) net.create()
from neutron.agent import dhcp_agent from neutron.cmd.sanity import checks from neutron.common import config from neutron.i18n import _LE, _LW from neutron.openstack.common import log as logging from oslo_config import cfg LOG = logging.getLogger(__name__) cfg.CONF.import_group('AGENT', 'neutron.plugins.openvswitch.common.config') cfg.CONF.import_group('OVS', 'neutron.plugins.openvswitch.common.config') cfg.CONF.import_group('VXLAN', 'neutron.plugins.linuxbridge.common.config') cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config') cfg.CONF.import_group('ml2_sriov', 'neutron.plugins.ml2.drivers.mech_sriov.mech_driver') dhcp_agent.register_options() class BoolOptCallback(cfg.BoolOpt): def __init__(self, name, callback, **kwargs): if 'default' not in kwargs: kwargs['default'] = False self.callback = callback super(BoolOptCallback, self).__init__(name, **kwargs) def check_ovs_vxlan(): result = checks.ovs_vxlan_supported() if not result: LOG.error( _LE('Check for Open vSwitch VXLAN support failed. '
from oslo_log import log as logging from neutron.agent import dhcp_agent from neutron.cmd.sanity import checks from neutron.common import config from neutron.i18n import _LE, _LW LOG = logging.getLogger(__name__) cfg.CONF.import_group('AGENT', 'neutron.plugins.openvswitch.common.config') cfg.CONF.import_group('OVS', 'neutron.plugins.openvswitch.common.config') cfg.CONF.import_group('VXLAN', 'neutron.plugins.linuxbridge.common.config') cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config') cfg.CONF.import_group('ml2_sriov', 'neutron.plugins.ml2.drivers.mech_sriov.mech_driver') dhcp_agent.register_options() class BoolOptCallback(cfg.BoolOpt): def __init__(self, name, callback, **kwargs): if 'default' not in kwargs: kwargs['default'] = False self.callback = callback super(BoolOptCallback, self).__init__(name, **kwargs) def check_ovs_vxlan(): result = checks.ovs_vxlan_supported() if not result: LOG.error(_LE('Check for Open vSwitch VXLAN support failed. ' 'Please ensure that the version of openvswitch '
def setUp(self): super(TestDhcpAgent, self).setUp() register_options(cfg.CONF) calico_config.register_options(cfg.CONF) self.mock_makedirs_p = mock.patch("os.makedirs") self.mock_makedirs = self.mock_makedirs_p.start()
def setUp(self): super(TestDnsmasqRouted, self).setUp() register_options(cfg.CONF) cfg.CONF.set_override('dhcp_confs', '/run')
# License for the specific language governing permissions and limitations # under the License. import mock from neutron.agent import dhcp_agent from neutron.tests import base from oslo_config import cfg from networking_cisco.plugins.cisco.cpnr.dhcp_driver import OPTS from networking_cisco.plugins.cisco.cpnr import dhcpopts from networking_cisco.plugins.cisco.cpnr import model from networking_cisco.tests.unit.cisco.cpnr import fake_networks dhcp_agent.register_options(cfg.CONF) cfg.CONF.register_opts(OPTS, 'cisco_pnr') class TestModel(base.BaseTestCase): @mock.patch.object(model, "_get_client", autospec=True) def test_network_init(self, mock_client): net = model.Network.from_neutron(fake_networks.fake_net1) self.assertIsInstance(net, model.Network) self.assertFalse(mock_client.called) @mock.patch.object(model, "_get_client", autospec=True) def test_network_create(self, mock_client): net = model.Network.from_neutron(fake_networks.fake_net1) net.create()