self.timeout = cfg.CONF.ml2_odl.timeout
self.username = cfg.CONF.ml2_odl.username
self.password = cfg.CONF.ml2_odl.password
+ required_opts = ('url', 'username', 'password')
+ for opt in required_opts:
+ if not getattr(self, opt):
+ raise cfg.RequiredOptError(opt, 'ml2_odl')
self.auth = JsessionId(self.url, self.username, self.password)
self.vif_type = portbindings.VIF_TYPE_OVS
self.vif_details = {portbindings.CAP_PORT_FILTER: True}
headers = {'Content-Type': 'application/json'}
data = jsonutils.dumps(obj, indent=2) if obj else None
- if self.url:
- url = '/'.join([self.url, urlpath])
- LOG.debug(_('ODL-----> sending URL (%s) <-----ODL') % url)
- LOG.debug(_('ODL-----> sending JSON (%s) <-----ODL') % obj)
- r = requests.request(method, url=url,
- headers=headers, data=data,
- auth=self.auth, timeout=self.timeout)
-
- # ignorecodes contains a list of HTTP error codes to ignore.
- if r.status_code in ignorecodes:
- return
- r.raise_for_status()
+ url = '/'.join([self.url, urlpath])
+ LOG.debug(_('ODL-----> sending URL (%s) <-----ODL') % url)
+ LOG.debug(_('ODL-----> sending JSON (%s) <-----ODL') % obj)
+ r = requests.request(method, url=url,
+ headers=headers, data=data,
+ auth=self.auth, timeout=self.timeout)
+
+ # ignorecodes contains a list of HTTP error codes to ignore.
+ if r.status_code in ignorecodes:
+ return
+ r.raise_for_status()
def bind_port(self, context):
LOG.debug(_("Attempting to bind port %(port)s on "
config.cfg.CONF.set_override('mechanism_drivers',
['logger', 'opendaylight'],
'ml2')
+ # Set URL/user/pass so init doesn't throw a cfg required error.
+ # They are not used in these tests since sendjson is overwritten.
+ config.cfg.CONF.set_override('url', 'http://127.0.0.1:9999', 'ml2_odl')
+ config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl')
+ config.cfg.CONF.set_override('password', 'somepass', 'ml2_odl')
+
super(OpenDaylightTestCase, self).setUp(PLUGIN_NAME)
self.port_create_status = 'DOWN'
self.segment = {'api.NETWORK_TYPE': ""}
self.assertFalse(self.mech.check_segment(self.segment))
+class OpenDayLightMechanismConfigTests(test_plugin.NeutronDbPluginV2TestCase):
+
+ def _setUp(self):
+ config.cfg.CONF.set_override('mechanism_drivers',
+ ['logger', 'opendaylight'],
+ 'ml2')
+ config.cfg.CONF.set_override('url', 'http://127.0.0.1:9999', 'ml2_odl')
+ config.cfg.CONF.set_override('username', 'someuser', 'ml2_odl')
+ config.cfg.CONF.set_override('password', 'somepass', 'ml2_odl')
+
+ def test_url_required(self):
+ self._setUp()
+ config.cfg.CONF.set_override('url', None, 'ml2_odl')
+ self.assertRaises(config.cfg.RequiredOptError, self.setUp, PLUGIN_NAME)
+
+ def test_username_required(self):
+ self._setUp()
+ config.cfg.CONF.set_override('username', None, 'ml2_odl')
+ self.assertRaises(config.cfg.RequiredOptError, self.setUp, PLUGIN_NAME)
+
+ def test_password_required(self):
+ self._setUp()
+ config.cfg.CONF.set_override('password', None, 'ml2_odl')
+ self.assertRaises(config.cfg.RequiredOptError, self.setUp, PLUGIN_NAME)
+
+
class OpenDaylightMechanismTestBasicGet(test_plugin.TestBasicGet,
OpenDaylightTestCase):
pass