quota.py (openstack-cyborg-8.0.0) | : | quota.py (openstack-cyborg-9.0.0) | ||
---|---|---|---|---|
skipping to change at line 99 | skipping to change at line 99 | |||
seconds and added to the current time; if it is | seconds and added to the current time; if it is | |||
a datetime.timedelta object, it will also be | a datetime.timedelta object, it will also be | |||
added to the current time. A datetime.datetime | added to the current time. A datetime.datetime | |||
object will be interpreted as the absolute | object will be interpreted as the absolute | |||
expiration time. If None is specified, the | expiration time. If None is specified, the | |||
default expiration time set by | default expiration time set by | |||
--default-reservation-expire will be used (this | --default-reservation-expire will be used (this | |||
value will be treated as a number of seconds). | value will be treated as a number of seconds). | |||
:param project_id: Specify the project_id if current context | :param project_id: Specify the project_id if current context | |||
is admin and admin wants to impact on | is admin and admin wants to impact on | |||
common user's tenant. | common user's project. | |||
""" | """ | |||
if not project_id: | if not project_id: | |||
project_id = context.project_id | project_id = context.project_id | |||
reservations = self._driver.reserve(context, self._resources, deltas, | reservations = self._driver.reserve(context, self._resources, deltas, | |||
expire=expire, | expire=expire, | |||
project_id=project_id) | project_id=project_id) | |||
LOG.debug("Created reservations %s", reservations) | LOG.debug("Created reservations %s", reservations) | |||
return reservations | return reservations | |||
def commit(self, context, reservations, project_id=None): | def commit(self, context, reservations, project_id=None): | |||
"""Commit reservations. | """Commit reservations. | |||
:param context: The request context, for access checks. | :param context: The request context, for access checks. | |||
:param reservations: A list of the reservation UUIDs, as | :param reservations: A list of the reservation UUIDs, as | |||
returned by the reserve() method. | returned by the reserve() method. | |||
:param project_id: Specify the project_id if current context | :param project_id: Specify the project_id if current context | |||
is admin and admin wants to impact on | is admin and admin wants to impact on | |||
common user's tenant. | common user's project. | |||
""" | """ | |||
project_id = context.project_id | project_id = context.project_id | |||
try: | try: | |||
self._driver.commit(context, reservations, project_id=project_id) | self._driver.commit(context, reservations, project_id=project_id) | |||
except Exception: | except Exception: | |||
# NOTE(Vek): Ignoring exceptions here is safe, because the | # NOTE(Vek): Ignoring exceptions here is safe, because the | |||
# usage resynchronization and the reservation expiration | # usage resynchronization and the reservation expiration | |||
# mechanisms will resolve the issue. The exception is | # mechanisms will resolve the issue. The exception is | |||
# logged, however, because this is less than optimal. | # logged, however, because this is less than optimal. | |||
LOG.exception("Failed to commit reservations %s", reservations) | LOG.exception("Failed to commit reservations %s", reservations) | |||
skipping to change at line 174 | skipping to change at line 174 | |||
project_id=project_id) | project_id=project_id) | |||
def commit(self, context, reservations, project_id=None): | def commit(self, context, reservations, project_id=None): | |||
"""Commit reservations. | """Commit reservations. | |||
:param context: The request context, for access checks. | :param context: The request context, for access checks. | |||
:param reservations: A list of the reservation UUIDs, as | :param reservations: A list of the reservation UUIDs, as | |||
returned by the reserve() method. | returned by the reserve() method. | |||
:param project_id: Specify the project_id if current context | :param project_id: Specify the project_id if current context | |||
is admin and admin wants to impact on | is admin and admin wants to impact on | |||
common user's tenant. | common user's project. | |||
""" | """ | |||
try: | try: | |||
self.dbapi.reservation_commit(context, reservations, | self.dbapi.reservation_commit(context, reservations, | |||
project_id=project_id) | project_id=project_id) | |||
except Exception: | except Exception: | |||
# NOTE(Vek): Ignoring exceptions here is safe, because the | # NOTE(Vek): Ignoring exceptions here is safe, because the | |||
# usage resynchronization and the reservation expiration | # usage resynchronization and the reservation expiration | |||
# mechanisms will resolve the issue. The exception is | # mechanisms will resolve the issue. The exception is | |||
# logged, however, because this is less than optimal. | # logged, however, because this is less than optimal. | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |