Fix Python 3 issue in opendaylight client
* Replace "resp.status_code / 100" with "resp.status_code // 100" to use integer division, not float division, on Python 3 * Replace also "int(status / 100)" with "status // 100" in other files Change-Id: I609065529ffbfc718a7b382b191e588bd5ed3933
This commit is contained in:
parent
e8cb08fdba
commit
b7cd3a99b1
@ -109,7 +109,7 @@ class GnocchiThresholdEvaluator(evaluator.Evaluator):
|
||||
except Exception:
|
||||
LOG.exception(_('alarm stats retrieval failed'))
|
||||
return []
|
||||
if int(r.status_code / 100) != 2:
|
||||
if r.status_code // 100 != 2:
|
||||
LOG.exception(_('alarm stats retrieval failed: %s') % r.text)
|
||||
return []
|
||||
else:
|
||||
|
@ -419,7 +419,7 @@ class GnocchiDispatcher(dispatcher.Base):
|
||||
'resource_id': resource_id,
|
||||
'status_code': r.status_code})
|
||||
raise NoSuchMetric
|
||||
elif int(r.status_code / 100) != 2:
|
||||
elif r.status_code // 100 != 2:
|
||||
raise UnexpectedWorkflowError(
|
||||
_("Fail to post measure on metric %(metric_name)s of "
|
||||
"resource %(resource_id)s with status: "
|
||||
@ -442,7 +442,7 @@ class GnocchiDispatcher(dispatcher.Base):
|
||||
LOG.debug("Resource %s already exists", resource_id)
|
||||
raise ResourceAlreadyExists
|
||||
|
||||
elif int(r.status_code / 100) != 2:
|
||||
elif r.status_code // 100 != 2:
|
||||
raise UnexpectedWorkflowError(
|
||||
_("Resource %(resource_id)s creation failed with "
|
||||
"status: %(status_code)d: %(msg)s") %
|
||||
@ -460,7 +460,7 @@ class GnocchiDispatcher(dispatcher.Base):
|
||||
headers=self._get_headers(),
|
||||
data=json.dumps(resource_attributes))
|
||||
|
||||
if int(r.status_code / 100) != 2:
|
||||
if r.status_code // 100 != 2:
|
||||
raise UnexpectedWorkflowError(
|
||||
_("Resource %(resource_id)s update failed with "
|
||||
"status: %(status_code)d: %(msg)s") %
|
||||
@ -483,7 +483,7 @@ class GnocchiDispatcher(dispatcher.Base):
|
||||
metric_name, resource_id)
|
||||
raise MetricAlreadyExists
|
||||
|
||||
elif int(r.status_code / 100) != 2:
|
||||
elif r.status_code // 100 != 2:
|
||||
raise UnexpectedWorkflowError(
|
||||
_("Fail to create metric %(metric_name)s of "
|
||||
"resource %(resource_id)s with status: "
|
||||
|
@ -227,7 +227,7 @@ class Client(object):
|
||||
resp = requests.get(url, **self._req_params)
|
||||
if CONF.debug:
|
||||
self._log_res(resp)
|
||||
if resp.status_code / 100 != 2:
|
||||
if resp.status_code // 100 != 2:
|
||||
raise OpenDaylightRESTAPIFailed(
|
||||
_('OpenDaylitght API returned %(status)s %(reason)s') %
|
||||
{'status': resp.status_code, 'reason': resp.reason})
|
||||
|
Loading…
Reference in New Issue
Block a user