def test_init_from_config_list(self, mock_fetch): self.cfg.config(odl_features_json=None, group='ml2_odl') self.cfg.config(odl_features=self.feature_list, group='ml2_odl') odl_features.init() self.assertTrue(odl_features.has('thing1')) self.assertTrue(odl_features.has('thing2')) mock_fetch.assert_not_called()
def test_init_from_json_overrides_list(self, mock_fetch): self.cfg.config(odl_features=self.feature_list, group='ml2_odl') self.cfg.config(odl_features_json=self.feature_json, group='ml2_odl') odl_features.init() self.assertFalse(odl_features.has('thing1')) self.assertTrue(odl_features.has('operational-port-status')) mock_fetch.assert_not_called()
def _hconfig_bind_port(self, port_context, hconfig): """bind port after validating odl host configuration.""" valid_segment = None for segment in port_context.segments_to_bind: if self._is_valid_segment(segment, hconfig['configurations']): valid_segment = segment break else: LOG.debug("No valid segments found!") return False confs = hconfig['configurations']['supported_vnic_types'] # nova provides vnic_type in port_context to neutron. # neutron provides supported vif_type for binding based on vnic_type # in this case ODL hostconfigs has the vif_type to bind for vnic_type vnic_type = port_context.current.get(portbindings.VNIC_TYPE) if vnic_type != portbindings.VNIC_NORMAL: LOG.error("Binding failed: unsupported VNIC %s", vnic_type) return False vif_details = None for conf in confs: if conf["vnic_type"] == vnic_type: vif_type = conf.get('vif_type', portbindings.VIF_TYPE_OVS) LOG.debug("Binding vnic:'%s' to vif:'%s'", vnic_type, vif_type) vif_details = conf.get('vif_details', {}) break else: vif_type = portbindings.VIF_TYPE_OVS # default: OVS LOG.warning( "No supported vif type found for host %s!, " "defaulting to OVS", port_context.host) if not vif_details: # empty vif_details could be trouble, warn. LOG.warning("hostconfig:vif_details was empty!") LOG.debug( "Bind port %(port)s on network %(network)s with valid " "segment %(segment)s and VIF type %(vif_type)r " "VIF details %(vif_details)r.", { 'port': port_context.current['id'], 'network': port_context.network.current['id'], 'segment': valid_segment, 'vif_type': vif_type, 'vif_details': vif_details }) port_status = nl_const.PORT_STATUS_ACTIVE if odl_features.has(odl_features.OPERATIONAL_PORT_STATUS): port_status = nl_const.PORT_STATUS_DOWN port_context.set_binding(valid_segment[api.ID], vif_type, vif_details, status=port_status) return True
def _prepare_initial_port_status(self, port_context): port_status = nl_const.PORT_STATUS_ACTIVE if odl_features.has(odl_features.OPERATIONAL_PORT_STATUS): port_status = nl_const.PORT_STATUS_DOWN provisioning_blocks.add_provisioning_component( port_context._plugin_context, port_context.current['id'], resources.PORT, provisioning_blocks.L2_AGENT_ENTITY) return port_status
def __init__(self, service_plugin): LOG.info("Initializing OpenDaylight BGPVPN v2 driver") super(OpenDaylightBgpvpnDriver, self).__init__(service_plugin) self.journal = journal.OpenDaylightJournalThread() full_sync.register(bgpvpn_const.ALIAS, BGPVPN_RESOURCES, self.get_resources) if odl_features.has(BGPVPN_VNI): self.more_supported_extension_aliases = [bgpvpn_vni_def.ALIAS]
def test_init(self, mocked_client): response = mock.MagicMock() response.status_code = 200 response.json = mock.MagicMock( return_value=jsonutils.loads(self.feature_json)) mocked_client.return_value = response odl_features.init() self.assertTrue(odl_features.has(odl_features.OPERATIONAL_PORT_STATUS))
def start(self): super(OdlPortStatusUpdate, self).start() LOG.debug('OdlPortStatusUpdate worker running') if odl_features.has(odl_features.OPERATIONAL_PORT_STATUS): self.run_websocket()
def test_init_from_config(self): self.cfg.config(odl_features='thing1,thing2', group='ml2_odl') odl_features.init() self.assertTrue(odl_features.has('thing1')) self.assertTrue(odl_features.has('thing2'))
def _assert_odl_feature_config(self, features): odl_features.init() for k, v in features.items(): self.assertTrue(odl_features.has(k)) self.assertEqual(odl_features.get_config(k), v)
def test_init_from_config(self): cfg.CONF.set_override('odl_features', 'thing1,thing2', 'ml2_odl') odl_features.init() self.assertTrue(odl_features.has('thing1')) self.assertTrue(odl_features.has('thing2'))