Example #1
0
 def test_neutroncc_context_sriov(self, _import, plugin, nm):
     plugin.return_value = None
     self.test_config.set('enable-sriov', True)
     ctxt_data = {
         'debug': True,
         'verbose': True,
         'dns_domain': 'example.com.',
         'enable_dvr': False,
         'l3_ha': False,
         'dhcp_agents_per_network': 3,
         'enable_sriov': True,
         'external_network': 'bob',
         'neutron_bind_port': self.api_port,
         'l2_population': True,
         'overlay_network_type': 'gre',
         'tenant_network_types': 'gre,vlan,flat,local',
         'quota_floatingip': 50,
         'quota_health_monitors': -1,
         'quota_member': -1,
         'quota_network': 10,
         'quota_pool': 10,
         'quota_port': 50,
         'quota_router': 10,
         'quota_security_group': 10,
         'quota_security_group_rule': 100,
         'quota_subnet': 10,
         'quota_vip': 10,
         'vlan_ranges': 'physnet1:1000:2000',
         'vni_ranges': '1001:2000',
         'enable_ml2_port_security': True,
         'enable_hyperv': False
     }
     napi_ctxt = context.NeutronCCContext()
     with patch.object(napi_ctxt, '_ensure_packages'):
         self.assertEquals(ctxt_data, napi_ctxt())
 def test_neutroncc_context_l3ha(self, _import, plugin, nm):
     plugin.return_value = None
     self.test_config.set('enable-l3ha', True)
     self.test_config.set('overlay-network-type', 'gre')
     self.test_config.set('neutron-plugin', 'ovs')
     self.test_config.set('l2-population', False)
     self.os_release.return_value = 'juno'
     ctxt_data = {
         'debug': True,
         'enable_dvr': False,
         'l3_ha': True,
         'external_network': 'bob',
         'neutron_bind_port': self.api_port,
         'verbose': True,
         'l2_population': False,
         'overlay_network_type': 'gre',
         'max_l3_agents_per_router': 2,
         'min_l3_agents_per_router': 2,
         'quota_floatingip': 50,
         'quota_health_monitors': -1,
         'quota_member': -1,
         'quota_network': 10,
         'quota_pool': 10,
         'quota_port': 50,
         'quota_router': 10,
         'quota_security_group': 10,
         'quota_security_group_rule': 100,
         'quota_subnet': 10,
         'quota_vip': 10,
         'vlan_ranges': 'physnet1:1000:2000',
     }
     napi_ctxt = context.NeutronCCContext()
     with patch.object(napi_ctxt, '_ensure_packages'):
         self.assertEquals(ctxt_data, napi_ctxt())
 def test_neutroncc_context_vxlan(self, _import, plugin, nm):
     plugin.return_value = None
     self.test_config.set('flat-network-providers', 'physnet2 physnet3')
     self.test_config.set('overlay-network-type', 'vxlan')
     ctxt_data = {
         'debug': True,
         'enable_dvr': False,
         'l3_ha': False,
         'external_network': 'bob',
         'neutron_bind_port': self.api_port,
         'verbose': True,
         'l2_population': True,
         'overlay_network_type': 'vxlan',
         'quota_floatingip': 50,
         'quota_health_monitors': -1,
         'quota_member': -1,
         'quota_network': 10,
         'quota_pool': 10,
         'quota_port': 50,
         'quota_router': 10,
         'quota_security_group': 10,
         'quota_security_group_rule': 100,
         'quota_subnet': 10,
         'quota_vip': 10,
         'vlan_ranges': 'physnet1:1000:2000',
         'network_providers': 'physnet2,physnet3',
     }
     napi_ctxt = context.NeutronCCContext()
     with patch.object(napi_ctxt, '_ensure_packages'):
         self.assertEquals(ctxt_data, napi_ctxt())
Example #4
0
def resource_map():
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    resource_map = deepcopy(BASE_RESOURCE_MAP)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    # add neutron plugin requirements. nova-c-c only needs the neutron-server
    # associated with configs, not the plugin agent.
    plugin = config('neutron-plugin')
    conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
    ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or [])
    services = neutron_plugin_attribute(plugin, 'server_services', 'neutron')
    resource_map[conf] = {}
    resource_map[conf]['services'] = services
    resource_map[conf]['contexts'] = ctxts
    resource_map[conf]['contexts'].append(
        neutron_api_context.NeutronCCContext())

    # update for postgres
    resource_map[conf]['contexts'].append(
        context.PostgresqlDBContext(database=config('database')))

    return resource_map
Example #5
0
 def test_neutroncc_context_l3ha_l3_agents(self, _import, plugin, nm):
     plugin.return_value = None
     self.os_release.return_value = 'juno'
     self.test_config.set('enable-l3ha', True)
     self.test_config.set('l2-population', False)
     self.test_config.set('max-l3-agents-per-router', 2)
     self.test_config.set('min-l3-agents-per-router', 3)
     napi_ctxt = context.NeutronCCContext()
     with patch.object(napi_ctxt, '_ensure_packages'):
         self.assertRaises(ValueError, napi_ctxt)
 def test_neutroncc_context_api_rel(self, _import, plugin, nm):
     nova_url = 'http://127.0.0.10'
     plugin.return_value = None
     self.related_units.return_value = ['unit1']
     self.relation_ids.return_value = ['rid2']
     self.test_relation.set({'nova_url': nova_url,
                             'restart_trigger': 'bob'})
     napi_ctxt = context.NeutronCCContext()
     self.assertEquals(nova_url, napi_ctxt()['nova_url'])
     self.assertEquals('bob', napi_ctxt()['restart_trigger'])
     self.assertEquals(self.api_port, napi_ctxt()['neutron_bind_port'])
Example #7
0
 def test_neutroncc_context_no_setting(self, _import, plugin, nm):
     plugin.return_value = None
     ctxt_data = {
         'debug': True,
         'external_network': 'bob',
         'neutron_bind_port': self.api_port,
         'verbose': True,
         'l2_population': True,
         'overlay_network_type': 'gre',
     }
     napi_ctxt = context.NeutronCCContext()
     with patch.object(napi_ctxt, '_ensure_packages'):
         self.assertEquals(ctxt_data, napi_ctxt())
Example #8
0
def resource_map(release=None):
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    release = release or os_release('neutron-common')

    resource_map = deepcopy(BASE_RESOURCE_MAP)
    if CompareOpenStackReleases(release) >= 'liberty':
        resource_map.update(LIBERTY_RESOURCE_MAP)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    if manage_plugin():
        # add neutron plugin requirements. nova-c-c only needs the
        # neutron-server associated with configs, not the plugin agent.
        plugin = config('neutron-plugin')
        conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
        ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or [])
        services = neutron_plugin_attribute(plugin, 'server_services',
                                            'neutron')
        resource_map[conf] = {}
        resource_map[conf]['services'] = services
        resource_map[conf]['contexts'] = ctxts
        resource_map[conf]['contexts'].append(
            neutron_api_context.NeutronCCContext())

        if ('kilo' <= CompareOpenStackReleases(release) <= 'mitaka'
                and config('enable-sriov')):
            resource_map[ML2_SRIOV_INI] = {}
            resource_map[ML2_SRIOV_INI]['services'] = services
            resource_map[ML2_SRIOV_INI]['contexts'] = []
        if (config('enable-arista')):
            resource_map[NEUTRON_DEFAULT]['contexts'] = \
                [neutron_api_context.NeutronApiSDNConfigFileContext()]
    else:
        resource_map[NEUTRON_CONF]['contexts'].append(
            neutron_api_context.NeutronApiSDNContext())
        resource_map[NEUTRON_DEFAULT]['contexts'] = \
            [neutron_api_context.NeutronApiSDNConfigFileContext()]
    if enable_memcache(release=release):
        resource_map[MEMCACHED_CONF] = {
            'contexts': [context.MemcacheContext()],
            'services': ['memcached']
        }

    return resource_map
Example #9
0
 def test_neutroncc_context_nsx(self, _import, plugin, nm):
     plugin.return_value = 'nsx'
     self.related_units.return_value = []
     self.test_config.set('neutron-plugin', 'nsx')
     napi_ctxt = context.NeutronCCContext()()
     expect = {
         'nsx_controllers': 'ctrl1,ctrl2',
         'nsx_controllers_list': ['ctrl1', 'ctrl2'],
         'nsx_l3_uuid': 'l3uuid',
         'nsx_password': '******',
         'nsx_tz_uuid': 'tzuuid',
         'nsx_username': '******',
     }
     for key in expect.iterkeys():
         self.assertEquals(napi_ctxt[key], expect[key])
Example #10
0
 def test_neutroncc_context_nuage(self, _import, plugin, nm):
     plugin.return_value = 'vsp'
     self.related_units.return_value = ['vsdunit1']
     self.relation_ids.return_value = ['vsdrid2']
     self.test_config.set('neutron-plugin', 'vsp')
     napi_ctxt = context.NeutronCCContext()()
     expect = {
         'vsd_server': '192.168.2.202',
         'vsd_auth': 'fooadmin:password',
         'vsd_organization': 'foo',
         'vsd_base_uri': '/nuage/api/v1_0',
         'vsd_netpart_name': 'foo-enterprise',
     }
     for key in expect.iterkeys():
         self.assertEquals(napi_ctxt[key], expect[key])
Example #11
0
def resource_map(release=None):
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    release = release or os_release('neutron-common')

    resource_map = deepcopy(BASE_RESOURCE_MAP)
    if release >= 'liberty':
        resource_map.update(LIBERTY_RESOURCE_MAP)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    if manage_plugin():
        # add neutron plugin requirements. nova-c-c only needs the
        # neutron-server associated with configs, not the plugin agent.
        plugin = config('neutron-plugin')
        conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
        ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or
                 [])
        services = neutron_plugin_attribute(plugin, 'server_services',
                                            'neutron')
        resource_map[conf] = {}
        resource_map[conf]['services'] = services
        resource_map[conf]['contexts'] = ctxts
        resource_map[conf]['contexts'].append(
            neutron_api_context.NeutronCCContext())

        # update for postgres
        resource_map[conf]['contexts'].append(
            context.PostgresqlDBContext(database=config('database')))

    else:
        resource_map[NEUTRON_CONF]['contexts'].append(
            neutron_api_context.NeutronApiSDNContext()
        )
        resource_map[NEUTRON_DEFAULT]['contexts'] = \
            [neutron_api_context.NeutronApiSDNConfigFileContext()]
    return resource_map
Example #12
0
 def test_neutroncc_context_manager_pkgs(self):
     napi_ctxt = context.NeutronCCContext()
     with patch.object(napi_ctxt, '_ensure_packages') as ep:
         napi_ctxt._ensure_packages()
         ep.assert_has_calls([])
Example #13
0
 def test_neutroncc_context_manager(self):
     napi_ctxt = context.NeutronCCContext()
     self.assertEquals(napi_ctxt.network_manager, 'neutron')
     self.assertEquals(napi_ctxt.plugin, 'ovs')
     self.assertEquals(napi_ctxt.neutron_security_groups, True)
Example #14
0
 def test_neutroncc_context_unsupported_overlay(self, _import, plugin, nm):
     plugin.return_value = None
     self.test_config.set('overlay-network-type', 'bobswitch')
     with self.assertRaises(Exception) as context:
         context.NeutronCCContext()
API_PASTE_INI = '%s/api-paste.ini' % NEUTRON_CONF_DIR

BASE_RESOURCE_MAP = OrderedDict([
    (NEUTRON_CONF, {
        'services': ['neutron-server'],
        'contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR),
                     context.SharedDBContext(
                         user=config('database-user'),
                         database=config('database'),
                         ssl_dir=NEUTRON_CONF_DIR),
                     context.PostgresqlDBContext(database=config('database')),
                     neutron_api_context.IdentityServiceContext(
                         service='neutron',
                         service_user='******'),
                     context.OSConfigFlagContext(),
                     neutron_api_context.NeutronCCContext(),
                     context.SyslogContext(),
                     context.ZeroMQContext(),
                     context.NotificationDriverContext(),
                     context.BindHostContext(),
                     context.WorkerConfigContext(),
                     context.InternalEndpointContext(),
                     context.MemcacheContext()],
    }),
    (NEUTRON_DEFAULT, {
        'services': ['neutron-server'],
        'contexts': [neutron_api_context.NeutronCCContext()],
    }),
    (API_PASTE_INI, {
        'services': ['neutron-server'],
        'contexts': [neutron_api_context.NeutronApiApiPasteContext()],
def resource_map(release=None):
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    release = release or os_release('neutron-common')

    resource_map = deepcopy(BASE_RESOURCE_MAP)
    if CompareOpenStackReleases(release) >= 'liberty':
        resource_map.update(LIBERTY_RESOURCE_MAP)

    if CompareOpenStackReleases(release) >= 'train':
        resource_map.pop(NEUTRON_LBAAS_CONF)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    if manage_plugin():
        # add neutron plugin requirements. nova-c-c only needs the
        # neutron-server associated with configs, not the plugin agent.
        plugin = config('neutron-plugin')
        conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
        ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or
                 [])
        services = neutron_plugin_attribute(plugin, 'server_services',
                                            'neutron')
        resource_map[conf] = {}
        resource_map[conf]['services'] = services
        resource_map[conf]['contexts'] = ctxts
        resource_map[conf]['contexts'].append(
            neutron_api_context.NeutronCCContext())

        if ('kilo' <= CompareOpenStackReleases(release) <= 'mitaka' and
                config('enable-sriov')):
            resource_map[ML2_SRIOV_INI] = {}
            resource_map[ML2_SRIOV_INI]['services'] = services
            resource_map[ML2_SRIOV_INI]['contexts'] = []
    else:
        plugin_ctxt_instance = neutron_api_context.NeutronApiSDNContext()
        if (plugin_ctxt_instance.is_default('core_plugin') and
                plugin_ctxt_instance.is_default('neutron_plugin_config')):
            # The default core plugin is ML2.  If the driver provided by plugin
            # subordinate is built on top of ML2, the subordinate will have use
            # for influencing existing template variables as well as injecting
            # sections into the ML2 configuration file.
            conf = neutron_plugin_attribute('ovs', 'config', 'neutron')
            services = neutron_plugin_attribute('ovs', 'server_services',
                                                'neutron')
            if conf not in resource_map:
                resource_map[conf] = {}
                resource_map[conf]['services'] = services
                resource_map[conf]['contexts'] = [
                    neutron_api_context.NeutronCCContext(),
                ]
            resource_map[conf]['contexts'].append(
                neutron_api_context.NeutronApiSDNContext(
                    config_file=conf)
            )

        resource_map[NEUTRON_CONF]['contexts'].append(
            plugin_ctxt_instance,
        )
        resource_map[NEUTRON_DEFAULT]['contexts'] = \
            [neutron_api_context.NeutronApiSDNConfigFileContext()]
    if enable_memcache(release=release):
        resource_map[MEMCACHED_CONF] = {
            'contexts': [context.MemcacheContext()],
            'services': ['memcached']}

    return resource_map