ctx.reraise = False
key = collection_name[:-1] if len(to_be_synced) == 1 else (
collection_name)
-
- # 400 errors are returned if an object exists, which we ignore.
- self.sendjson('post', collection_name, {key: to_be_synced},
- [requests.codes.bad_request])
+ self.sendjson('post', collection_name, {key: to_be_synced})
@utils.synchronized('odl-sync-full')
def sync_full(self, context):
attr_filter = self.update_object_map[object_type]
resource = context.current.copy()
attr_filter(resource, context)
- # 400 errors are returned if an object exists, which we ignore.
- self.sendjson(method, urlpath, {object_type[:-1]: resource},
- [requests.codes.bad_request])
+ self.sendjson(method, urlpath, {object_type[:-1]: resource})
except Exception:
with excutils.save_and_reraise_exception():
self.out_of_sync = True
for sg in port['security_groups']]
port['security_groups'] = groups
- def sendjson(self, method, urlpath, obj, ignorecodes=[]):
+ def sendjson(self, method, urlpath, obj):
"""Send json to the OpenDaylight controller."""
headers = {'Content-Type': 'application/json'}
data = jsonutils.dumps(obj, indent=2) if obj else None
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):
'delete', **kwargs)
def test_create_network_postcommit(self):
- for status_code in (requests.codes.created,
- requests.codes.bad_request):
- self._test_create_resource_postcommit('network', status_code)
- self._test_create_resource_postcommit(
- 'network', requests.codes.unauthorized,
- requests.exceptions.HTTPError)
+ self._test_create_resource_postcommit('network',
+ requests.codes.created)
+ for status_code in (requests.codes.bad_request,
+ requests.codes.unauthorized):
+ self._test_create_resource_postcommit(
+ 'network', status_code, requests.exceptions.HTTPError)
def test_create_subnet_postcommit(self):
- for status_code in (requests.codes.created,
- requests.codes.bad_request):
- self._test_create_resource_postcommit('subnet', status_code)
- for status_code in (requests.codes.unauthorized,
+ self._test_create_resource_postcommit('subnet', requests.codes.created)
+ for status_code in (requests.codes.bad_request,
+ requests.codes.unauthorized,
requests.codes.forbidden,
requests.codes.not_found,
requests.codes.conflict,
'subnet', status_code, requests.exceptions.HTTPError)
def test_create_port_postcommit(self):
- for status_code in (requests.codes.created,
- requests.codes.bad_request):
- self._test_create_resource_postcommit('port', status_code)
- for status_code in (requests.codes.unauthorized,
+ self._test_create_resource_postcommit('port', requests.codes.created)
+ for status_code in (requests.codes.bad_request,
+ requests.codes.unauthorized,
requests.codes.forbidden,
requests.codes.not_found,
requests.codes.conflict,
'port', status_code, requests.exceptions.HTTPError)
def test_update_network_postcommit(self):
- for status_code in (requests.codes.ok,
- requests.codes.bad_request):
- self._test_update_resource_postcommit('network', status_code)
- for status_code in (requests.codes.forbidden,
+ self._test_update_resource_postcommit('network', requests.codes.ok)
+ for status_code in (requests.codes.bad_request,
+ requests.codes.forbidden,
requests.codes.not_found):
self._test_update_resource_postcommit(
'network', status_code, requests.exceptions.HTTPError)
def test_update_subnet_postcommit(self):
- for status_code in (requests.codes.ok,
- requests.codes.bad_request):
- self._test_update_resource_postcommit('subnet', status_code)
- for status_code in (requests.codes.unauthorized,
+ self._test_update_resource_postcommit('subnet', requests.codes.ok)
+ for status_code in (requests.codes.bad_request,
+ requests.codes.unauthorized,
requests.codes.forbidden,
requests.codes.not_found,
requests.codes.not_implemented):
'subnet', status_code, requests.exceptions.HTTPError)
def test_update_port_postcommit(self):
- for status_code in (requests.codes.ok,
- requests.codes.bad_request):
- self._test_update_resource_postcommit('port', status_code)
- for status_code in (requests.codes.unauthorized,
+ self._test_update_resource_postcommit('port', requests.codes.ok)
+ for status_code in (requests.codes.bad_request,
+ requests.codes.unauthorized,
requests.codes.forbidden,
requests.codes.not_found,
requests.codes.conflict,