Fuel plugin that enables to configure multiple Cinder backend support for Kaminario K2 All-Flash Array
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exception.py 36KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. # Copyright 2010 United States Government as represented by the
  2. # Administrator of the National Aeronautics and Space Administration.
  3. # All Rights Reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. # not use this file except in compliance with the License. You may obtain
  7. # a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. # License for the specific language governing permissions and limitations
  15. # under the License.
  16. """Cinder base exception handling.
  17. Includes decorator for re-raising Cinder-type exceptions.
  18. SHOULD include dedicated exception logging.
  19. """
  20. import sys
  21. from oslo_config import cfg
  22. from oslo_log import log as logging
  23. from oslo_versionedobjects import exception as obj_exc
  24. import six
  25. import webob.exc
  26. from webob.util import status_generic_reasons
  27. from webob.util import status_reasons
  28. from cinder.i18n import _, _LE
  29. LOG = logging.getLogger(__name__)
  30. exc_log_opts = [
  31. cfg.BoolOpt('fatal_exception_format_errors',
  32. default=False,
  33. help='Make exception message format errors fatal.'),
  34. ]
  35. CONF = cfg.CONF
  36. CONF.register_opts(exc_log_opts)
  37. class ConvertedException(webob.exc.WSGIHTTPException):
  38. def __init__(self, code=500, title="", explanation=""):
  39. self.code = code
  40. # There is a strict rule about constructing status line for HTTP:
  41. # '...Status-Line, consisting of the protocol version followed by a
  42. # numeric status code and its associated textual phrase, with each
  43. # element separated by SP characters'
  44. # (http://www.faqs.org/rfcs/rfc2616.html)
  45. # 'code' and 'title' can not be empty because they correspond
  46. # to numeric status code and its associated text
  47. if title:
  48. self.title = title
  49. else:
  50. try:
  51. self.title = status_reasons[self.code]
  52. except KeyError:
  53. generic_code = self.code // 100
  54. self.title = status_generic_reasons[generic_code]
  55. self.explanation = explanation
  56. super(ConvertedException, self).__init__()
  57. class Error(Exception):
  58. pass
  59. class CinderException(Exception):
  60. """Base Cinder Exception
  61. To correctly use this class, inherit from it and define
  62. a 'message' property. That message will get printf'd
  63. with the keyword arguments provided to the constructor.
  64. """
  65. message = _("An unknown exception occurred.")
  66. code = 500
  67. headers = {}
  68. safe = False
  69. def __init__(self, message=None, **kwargs):
  70. self.kwargs = kwargs
  71. self.kwargs['message'] = message
  72. if 'code' not in self.kwargs:
  73. try:
  74. self.kwargs['code'] = self.code
  75. except AttributeError:
  76. pass
  77. for k, v in self.kwargs.items():
  78. if isinstance(v, Exception):
  79. self.kwargs[k] = six.text_type(v)
  80. if self._should_format():
  81. try:
  82. message = self.message % kwargs
  83. except Exception:
  84. exc_info = sys.exc_info()
  85. # kwargs doesn't match a variable in the message
  86. # log the issue and the kwargs
  87. LOG.exception(_LE('Exception in string format operation'))
  88. for name, value in kwargs.items():
  89. LOG.error(_LE("%(name)s: %(value)s"),
  90. {'name': name, 'value': value})
  91. if CONF.fatal_exception_format_errors:
  92. six.reraise(*exc_info)
  93. # at least get the core message out if something happened
  94. message = self.message
  95. elif isinstance(message, Exception):
  96. message = six.text_type(message)
  97. # NOTE(luisg): We put the actual message in 'msg' so that we can access
  98. # it, because if we try to access the message via 'message' it will be
  99. # overshadowed by the class' message attribute
  100. self.msg = message
  101. super(CinderException, self).__init__(message)
  102. def _should_format(self):
  103. return self.kwargs['message'] is None or '%(message)' in self.message
  104. def __unicode__(self):
  105. return six.text_type(self.msg)
  106. class VolumeBackendAPIException(CinderException):
  107. message = _("Bad or unexpected response from the storage volume "
  108. "backend API: %(data)s")
  109. class VolumeDriverException(CinderException):
  110. message = _("Volume driver reported an error: %(message)s")
  111. class BackupDriverException(CinderException):
  112. message = _("Backup driver reported an error: %(message)s")
  113. class GlanceConnectionFailed(CinderException):
  114. message = _("Connection to glance failed: %(reason)s")
  115. class ProgrammingError(CinderException):
  116. message = _('Programming error in Cinder: %(reason)s')
  117. class NotAuthorized(CinderException):
  118. message = _("Not authorized.")
  119. code = 403
  120. class AdminRequired(NotAuthorized):
  121. message = _("User does not have admin privileges")
  122. class PolicyNotAuthorized(NotAuthorized):
  123. message = _("Policy doesn't allow %(action)s to be performed.")
  124. class ImageNotAuthorized(CinderException):
  125. message = _("Not authorized for image %(image_id)s.")
  126. class DriverNotInitialized(CinderException):
  127. message = _("Volume driver not ready.")
  128. class Invalid(CinderException):
  129. message = _("Unacceptable parameters.")
  130. code = 400
  131. class InvalidSnapshot(Invalid):
  132. message = _("Invalid snapshot: %(reason)s")
  133. class InvalidVolumeAttachMode(Invalid):
  134. message = _("Invalid attaching mode '%(mode)s' for "
  135. "volume %(volume_id)s.")
  136. class VolumeAttached(Invalid):
  137. message = _("Volume %(volume_id)s is still attached, detach volume first.")
  138. class InvalidResults(Invalid):
  139. message = _("The results are invalid.")
  140. class InvalidInput(Invalid):
  141. message = _("Invalid input received: %(reason)s")
  142. class InvalidVolumeType(Invalid):
  143. message = _("Invalid volume type: %(reason)s")
  144. class InvalidGroupType(Invalid):
  145. message = _("Invalid group type: %(reason)s")
  146. class InvalidVolume(Invalid):
  147. message = _("Invalid volume: %(reason)s")
  148. class InvalidContentType(Invalid):
  149. message = _("Invalid content type %(content_type)s.")
  150. class InvalidHost(Invalid):
  151. message = _("Invalid host: %(reason)s")
  152. # Cannot be templated as the error syntax varies.
  153. # msg needs to be constructed when raised.
  154. class InvalidParameterValue(Invalid):
  155. message = _("%(err)s")
  156. class InvalidAuthKey(Invalid):
  157. message = _("Invalid auth key: %(reason)s")
  158. class InvalidConfigurationValue(Invalid):
  159. message = _('Value "%(value)s" is not valid for '
  160. 'configuration option "%(option)s"')
  161. class ServiceUnavailable(Invalid):
  162. message = _("Service is unavailable at this time.")
  163. class ImageUnacceptable(Invalid):
  164. message = _("Image %(image_id)s is unacceptable: %(reason)s")
  165. class DeviceUnavailable(Invalid):
  166. message = _("The device in the path %(path)s is unavailable: %(reason)s")
  167. class SnapshotUnavailable(VolumeBackendAPIException):
  168. message = _("The snapshot is unavailable: %(data)s")
  169. class InvalidUUID(Invalid):
  170. message = _("Expected a uuid but received %(uuid)s.")
  171. class InvalidAPIVersionString(Invalid):
  172. message = _("API Version String %(version)s is of invalid format. Must "
  173. "be of format MajorNum.MinorNum.")
  174. class VersionNotFoundForAPIMethod(Invalid):
  175. message = _("API version %(version)s is not supported on this method.")
  176. class InvalidGlobalAPIVersion(Invalid):
  177. message = _("Version %(req_ver)s is not supported by the API. Minimum "
  178. "is %(min_ver)s and maximum is %(max_ver)s.")
  179. class MissingRequired(Invalid):
  180. message = _("Missing required element '%(element)s' in request body.")
  181. class APIException(CinderException):
  182. message = _("Error while requesting %(service)s API.")
  183. def __init__(self, message=None, **kwargs):
  184. if 'service' not in kwargs:
  185. kwargs['service'] = 'unknown'
  186. super(APIException, self).__init__(message, **kwargs)
  187. class APITimeout(APIException):
  188. message = _("Timeout while requesting %(service)s API.")
  189. class RPCTimeout(CinderException):
  190. message = _("Timeout while requesting capabilities from backend "
  191. "%(service)s.")
  192. code = 502
  193. class Duplicate(CinderException):
  194. pass
  195. class NotFound(CinderException):
  196. message = _("Resource could not be found.")
  197. code = 404
  198. safe = True
  199. class VolumeNotFound(NotFound):
  200. message = _("Volume %(volume_id)s could not be found.")
  201. class MessageNotFound(NotFound):
  202. message = _("Message %(message_id)s could not be found.")
  203. class VolumeAttachmentNotFound(NotFound):
  204. message = _("Volume attachment could not be found with "
  205. "filter: %(filter)s .")
  206. class VolumeMetadataNotFound(NotFound):
  207. message = _("Volume %(volume_id)s has no metadata with "
  208. "key %(metadata_key)s.")
  209. class VolumeAdminMetadataNotFound(NotFound):
  210. message = _("Volume %(volume_id)s has no administration metadata with "
  211. "key %(metadata_key)s.")
  212. class InvalidVolumeMetadata(Invalid):
  213. message = _("Invalid metadata: %(reason)s")
  214. class InvalidVolumeMetadataSize(Invalid):
  215. message = _("Invalid metadata size: %(reason)s")
  216. class SnapshotMetadataNotFound(NotFound):
  217. message = _("Snapshot %(snapshot_id)s has no metadata with "
  218. "key %(metadata_key)s.")
  219. class VolumeTypeNotFound(NotFound):
  220. message = _("Volume type %(volume_type_id)s could not be found.")
  221. class VolumeTypeNotFoundByName(VolumeTypeNotFound):
  222. message = _("Volume type with name %(volume_type_name)s "
  223. "could not be found.")
  224. class VolumeTypeAccessNotFound(NotFound):
  225. message = _("Volume type access not found for %(volume_type_id)s / "
  226. "%(project_id)s combination.")
  227. class VolumeTypeExtraSpecsNotFound(NotFound):
  228. message = _("Volume Type %(volume_type_id)s has no extra specs with "
  229. "key %(extra_specs_key)s.")
  230. class VolumeTypeInUse(CinderException):
  231. message = _("Volume Type %(volume_type_id)s deletion is not allowed with "
  232. "volumes present with the type.")
  233. class GroupTypeNotFound(NotFound):
  234. message = _("Group type %(group_type_id)s could not be found.")
  235. class GroupTypeNotFoundByName(GroupTypeNotFound):
  236. message = _("Group type with name %(group_type_name)s "
  237. "could not be found.")
  238. class GroupTypeAccessNotFound(NotFound):
  239. message = _("Group type access not found for %(group_type_id)s / "
  240. "%(project_id)s combination.")
  241. class GroupTypeSpecsNotFound(NotFound):
  242. message = _("Group Type %(group_type_id)s has no specs with "
  243. "key %(group_specs_key)s.")
  244. class GroupTypeInUse(CinderException):
  245. message = _("Group Type %(group_type_id)s deletion is not allowed with "
  246. "groups present with the type.")
  247. class SnapshotNotFound(NotFound):
  248. message = _("Snapshot %(snapshot_id)s could not be found.")
  249. class ServerNotFound(NotFound):
  250. message = _("Instance %(uuid)s could not be found.")
  251. class VolumeIsBusy(CinderException):
  252. message = _("deleting volume %(volume_name)s that has snapshot")
  253. class SnapshotIsBusy(CinderException):
  254. message = _("deleting snapshot %(snapshot_name)s that has "
  255. "dependent volumes")
  256. class ISCSITargetNotFoundForVolume(NotFound):
  257. message = _("No target id found for volume %(volume_id)s.")
  258. class InvalidImageRef(Invalid):
  259. message = _("Invalid image href %(image_href)s.")
  260. class ImageNotFound(NotFound):
  261. message = _("Image %(image_id)s could not be found.")
  262. class ServiceNotFound(NotFound):
  263. def __init__(self, message=None, **kwargs):
  264. if kwargs.get('host', None):
  265. self.message = _("Service %(service_id)s could not be "
  266. "found on host %(host)s.")
  267. else:
  268. self.message = _("Service %(service_id)s could not be found.")
  269. super(ServiceNotFound, self).__init__(None, **kwargs)
  270. class ServiceTooOld(Invalid):
  271. message = _("Service is too old to fulfil this request.")
  272. class WorkerNotFound(NotFound):
  273. message = _("Worker with %s could not be found.")
  274. def __init__(self, message=None, **kwargs):
  275. keys_list = ('{0}=%({0})s'.format(key) for key in kwargs)
  276. placeholder = ', '.join(keys_list)
  277. self.message = self.message % placeholder
  278. super(WorkerNotFound, self).__init__(message, **kwargs)
  279. class WorkerExists(Duplicate):
  280. message = _("Worker for %(type)s %(id)s already exists.")
  281. class ClusterNotFound(NotFound):
  282. message = _('Cluster %(id)s could not be found.')
  283. class ClusterHasHosts(Invalid):
  284. message = _("Cluster %(id)s still has hosts.")
  285. class ClusterExists(Duplicate):
  286. message = _("Cluster %(name)s already exists.")
  287. class HostNotFound(NotFound):
  288. message = _("Host %(host)s could not be found.")
  289. class SchedulerHostFilterNotFound(NotFound):
  290. message = _("Scheduler Host Filter %(filter_name)s could not be found.")
  291. class SchedulerHostWeigherNotFound(NotFound):
  292. message = _("Scheduler Host Weigher %(weigher_name)s could not be found.")
  293. class InvalidReservationExpiration(Invalid):
  294. message = _("Invalid reservation expiration %(expire)s.")
  295. class InvalidQuotaValue(Invalid):
  296. message = _("Change would make usage less than 0 for the following "
  297. "resources: %(unders)s")
  298. class InvalidNestedQuotaSetup(CinderException):
  299. message = _("Project quotas are not properly setup for nested quotas: "
  300. "%(reason)s.")
  301. class QuotaNotFound(NotFound):
  302. message = _("Quota could not be found")
  303. class QuotaResourceUnknown(QuotaNotFound):
  304. message = _("Unknown quota resources %(unknown)s.")
  305. class ProjectQuotaNotFound(QuotaNotFound):
  306. message = _("Quota for project %(project_id)s could not be found.")
  307. class QuotaClassNotFound(QuotaNotFound):
  308. message = _("Quota class %(class_name)s could not be found.")
  309. class QuotaUsageNotFound(QuotaNotFound):
  310. message = _("Quota usage for project %(project_id)s could not be found.")
  311. class ReservationNotFound(QuotaNotFound):
  312. message = _("Quota reservation %(uuid)s could not be found.")
  313. class OverQuota(CinderException):
  314. message = _("Quota exceeded for resources: %(overs)s")
  315. class FileNotFound(NotFound):
  316. message = _("File %(file_path)s could not be found.")
  317. class VolumeTypeExists(Duplicate):
  318. message = _("Volume Type %(id)s already exists.")
  319. class VolumeTypeAccessExists(Duplicate):
  320. message = _("Volume type access for %(volume_type_id)s / "
  321. "%(project_id)s combination already exists.")
  322. class VolumeTypeEncryptionExists(Invalid):
  323. message = _("Volume type encryption for type %(type_id)s already exists.")
  324. class VolumeTypeEncryptionNotFound(NotFound):
  325. message = _("Volume type encryption for type %(type_id)s does not exist.")
  326. class GroupTypeExists(Duplicate):
  327. message = _("Group Type %(id)s already exists.")
  328. class GroupTypeAccessExists(Duplicate):
  329. message = _("Group type access for %(group_type_id)s / "
  330. "%(project_id)s combination already exists.")
  331. class GroupTypeEncryptionExists(Invalid):
  332. message = _("Group type encryption for type %(type_id)s already exists.")
  333. class GroupTypeEncryptionNotFound(NotFound):
  334. message = _("Group type encryption for type %(type_id)s does not exist.")
  335. class MalformedRequestBody(CinderException):
  336. message = _("Malformed message body: %(reason)s")
  337. class ConfigNotFound(NotFound):
  338. message = _("Could not find config at %(path)s")
  339. class ParameterNotFound(NotFound):
  340. message = _("Could not find parameter %(param)s")
  341. class PasteAppNotFound(NotFound):
  342. message = _("Could not load paste app '%(name)s' from %(path)s")
  343. class NoValidHost(CinderException):
  344. message = _("No valid host was found. %(reason)s")
  345. class NoMoreTargets(CinderException):
  346. """No more available targets."""
  347. pass
  348. class QuotaError(CinderException):
  349. message = _("Quota exceeded: code=%(code)s")
  350. code = 413
  351. headers = {'Retry-After': '0'}
  352. safe = True
  353. class VolumeSizeExceedsAvailableQuota(QuotaError):
  354. message = _("Requested volume or snapshot exceeds allowed %(name)s "
  355. "quota. Requested %(requested)sG, quota is %(quota)sG and "
  356. "%(consumed)sG has been consumed.")
  357. def __init__(self, message=None, **kwargs):
  358. kwargs.setdefault('name', 'gigabytes')
  359. super(VolumeSizeExceedsAvailableQuota, self).__init__(
  360. message, **kwargs)
  361. class VolumeSizeExceedsLimit(QuotaError):
  362. message = _("Requested volume size %(size)d is larger than "
  363. "maximum allowed limit %(limit)d.")
  364. class VolumeBackupSizeExceedsAvailableQuota(QuotaError):
  365. message = _("Requested backup exceeds allowed Backup gigabytes "
  366. "quota. Requested %(requested)sG, quota is %(quota)sG and "
  367. "%(consumed)sG has been consumed.")
  368. class VolumeLimitExceeded(QuotaError):
  369. message = _("Maximum number of volumes allowed (%(allowed)d) exceeded for "
  370. "quota '%(name)s'.")
  371. def __init__(self, message=None, **kwargs):
  372. kwargs.setdefault('name', 'volumes')
  373. super(VolumeLimitExceeded, self).__init__(message, **kwargs)
  374. class SnapshotLimitExceeded(QuotaError):
  375. message = _("Maximum number of snapshots allowed (%(allowed)d) exceeded")
  376. class UnexpectedOverQuota(QuotaError):
  377. message = _("Unexpected over quota on %(name)s.")
  378. class BackupLimitExceeded(QuotaError):
  379. message = _("Maximum number of backups allowed (%(allowed)d) exceeded")
  380. class ImageLimitExceeded(QuotaError):
  381. message = _("Image quota exceeded")
  382. class DuplicateSfVolumeNames(Duplicate):
  383. message = _("Detected more than one volume with name %(vol_name)s")
  384. class VolumeTypeCreateFailed(CinderException):
  385. message = _("Cannot create volume_type with "
  386. "name %(name)s and specs %(extra_specs)s")
  387. class VolumeTypeUpdateFailed(CinderException):
  388. message = _("Cannot update volume_type %(id)s")
  389. class GroupTypeCreateFailed(CinderException):
  390. message = _("Cannot create group_type with "
  391. "name %(name)s and specs %(group_specs)s")
  392. class GroupTypeUpdateFailed(CinderException):
  393. message = _("Cannot update group_type %(id)s")
  394. class UnknownCmd(VolumeDriverException):
  395. message = _("Unknown or unsupported command %(cmd)s")
  396. class MalformedResponse(VolumeDriverException):
  397. message = _("Malformed response to command %(cmd)s: %(reason)s")
  398. class FailedCmdWithDump(VolumeDriverException):
  399. message = _("Operation failed with status=%(status)s. Full dump: %(data)s")
  400. class InvalidConnectorException(VolumeDriverException):
  401. message = _("Connector doesn't have required information: %(missing)s")
  402. class GlanceMetadataExists(Invalid):
  403. message = _("Glance metadata cannot be updated, key %(key)s"
  404. " exists for volume id %(volume_id)s")
  405. class GlanceMetadataNotFound(NotFound):
  406. message = _("Glance metadata for volume/snapshot %(id)s cannot be found.")
  407. class ExportFailure(Invalid):
  408. message = _("Failed to export for volume: %(reason)s")
  409. class RemoveExportException(VolumeDriverException):
  410. message = _("Failed to remove export for volume %(volume)s: %(reason)s")
  411. class MetadataCreateFailure(Invalid):
  412. message = _("Failed to create metadata for volume: %(reason)s")
  413. class MetadataUpdateFailure(Invalid):
  414. message = _("Failed to update metadata for volume: %(reason)s")
  415. class MetadataCopyFailure(Invalid):
  416. message = _("Failed to copy metadata to volume: %(reason)s")
  417. class InvalidMetadataType(Invalid):
  418. message = _("The type of metadata: %(metadata_type)s for volume/snapshot "
  419. "%(id)s is invalid.")
  420. class ImageCopyFailure(Invalid):
  421. message = _("Failed to copy image to volume: %(reason)s")
  422. class BackupInvalidCephArgs(BackupDriverException):
  423. message = _("Invalid Ceph args provided for backup rbd operation")
  424. class BackupOperationError(Invalid):
  425. message = _("An error has occurred during backup operation")
  426. class BackupMetadataUnsupportedVersion(BackupDriverException):
  427. message = _("Unsupported backup metadata version requested")
  428. class BackupVerifyUnsupportedDriver(BackupDriverException):
  429. message = _("Unsupported backup verify driver")
  430. class VolumeMetadataBackupExists(BackupDriverException):
  431. message = _("Metadata backup already exists for this volume")
  432. class BackupRBDOperationFailed(BackupDriverException):
  433. message = _("Backup RBD operation failed")
  434. class EncryptedBackupOperationFailed(BackupDriverException):
  435. message = _("Backup operation of an encrypted volume failed.")
  436. class BackupNotFound(NotFound):
  437. message = _("Backup %(backup_id)s could not be found.")
  438. class BackupFailedToGetVolumeBackend(NotFound):
  439. message = _("Failed to identify volume backend.")
  440. class InvalidBackup(Invalid):
  441. message = _("Invalid backup: %(reason)s")
  442. class SwiftConnectionFailed(BackupDriverException):
  443. message = _("Connection to swift failed: %(reason)s")
  444. class TransferNotFound(NotFound):
  445. message = _("Transfer %(transfer_id)s could not be found.")
  446. class VolumeMigrationFailed(CinderException):
  447. message = _("Volume migration failed: %(reason)s")
  448. class SSHInjectionThreat(CinderException):
  449. message = _("SSH command injection detected: %(command)s")
  450. class QoSSpecsExists(Duplicate):
  451. message = _("QoS Specs %(specs_id)s already exists.")
  452. class QoSSpecsCreateFailed(CinderException):
  453. message = _("Failed to create qos_specs: "
  454. "%(name)s with specs %(qos_specs)s.")
  455. class QoSSpecsUpdateFailed(CinderException):
  456. message = _("Failed to update qos_specs: "
  457. "%(specs_id)s with specs %(qos_specs)s.")
  458. class QoSSpecsNotFound(NotFound):
  459. message = _("No such QoS spec %(specs_id)s.")
  460. class QoSSpecsAssociateFailed(CinderException):
  461. message = _("Failed to associate qos_specs: "
  462. "%(specs_id)s with type %(type_id)s.")
  463. class QoSSpecsDisassociateFailed(CinderException):
  464. message = _("Failed to disassociate qos_specs: "
  465. "%(specs_id)s with type %(type_id)s.")
  466. class QoSSpecsKeyNotFound(NotFound):
  467. message = _("QoS spec %(specs_id)s has no spec with "
  468. "key %(specs_key)s.")
  469. class InvalidQoSSpecs(Invalid):
  470. message = _("Invalid qos specs: %(reason)s")
  471. class QoSSpecsInUse(CinderException):
  472. message = _("QoS Specs %(specs_id)s is still associated with entities.")
  473. class KeyManagerError(CinderException):
  474. message = _("key manager error: %(reason)s")
  475. class ManageExistingInvalidReference(CinderException):
  476. message = _("Manage existing volume failed due to invalid backend "
  477. "reference %(existing_ref)s: %(reason)s")
  478. class ManageExistingAlreadyManaged(CinderException):
  479. message = _("Unable to manage existing volume. "
  480. "Volume %(volume_ref)s already managed.")
  481. class InvalidReplicationTarget(Invalid):
  482. message = _("Invalid Replication Target: %(reason)s")
  483. class UnableToFailOver(CinderException):
  484. message = _("Unable to failover to replication target:"
  485. "%(reason)s).")
  486. class ReplicationError(CinderException):
  487. message = _("Volume %(volume_id)s replication "
  488. "error: %(reason)s")
  489. class ReplicationNotFound(NotFound):
  490. message = _("Volume replication for %(volume_id)s "
  491. "could not be found.")
  492. class ManageExistingVolumeTypeMismatch(CinderException):
  493. message = _("Manage existing volume failed due to volume type mismatch: "
  494. "%(reason)s")
  495. class ExtendVolumeError(CinderException):
  496. message = _("Error extending volume: %(reason)s")
  497. class EvaluatorParseException(Exception):
  498. message = _("Error during evaluator parsing: %(reason)s")
  499. class LockCreationFailed(CinderException):
  500. message = _('Unable to create lock. Coordination backend not started.')
  501. class LockingFailed(CinderException):
  502. message = _('Lock acquisition failed.')
  503. UnsupportedObjectError = obj_exc.UnsupportedObjectError
  504. OrphanedObjectError = obj_exc.OrphanedObjectError
  505. IncompatibleObjectVersion = obj_exc.IncompatibleObjectVersion
  506. ReadOnlyFieldError = obj_exc.ReadOnlyFieldError
  507. ObjectActionError = obj_exc.ObjectActionError
  508. ObjectFieldInvalid = obj_exc.ObjectFieldInvalid
  509. class CappedVersionUnknown(CinderException):
  510. message = _('Unrecoverable Error: Versioned Objects in DB are capped to '
  511. 'unknown version %(version)s.')
  512. class VolumeGroupNotFound(CinderException):
  513. message = _('Unable to find Volume Group: %(vg_name)s')
  514. class VolumeGroupCreationFailed(CinderException):
  515. message = _('Failed to create Volume Group: %(vg_name)s')
  516. class VolumeNotDeactivated(CinderException):
  517. message = _('Volume %(name)s was not deactivated in time.')
  518. class VolumeDeviceNotFound(CinderException):
  519. message = _('Volume device not found at %(device)s.')
  520. # Driver specific exceptions
  521. # Dell
  522. class DellDriverRetryableException(VolumeBackendAPIException):
  523. message = _("Retryable Dell Exception encountered")
  524. # Pure Storage
  525. class PureDriverException(VolumeDriverException):
  526. message = _("Pure Storage Cinder driver failure: %(reason)s")
  527. class PureRetryableException(VolumeBackendAPIException):
  528. message = _("Retryable Pure Storage Exception encountered")
  529. # SolidFire
  530. class SolidFireAPIException(VolumeBackendAPIException):
  531. message = _("Bad response from SolidFire API")
  532. class SolidFireDriverException(VolumeDriverException):
  533. message = _("SolidFire Cinder Driver exception")
  534. class SolidFireAPIDataException(SolidFireAPIException):
  535. message = _("Error in SolidFire API response: data=%(data)s")
  536. class SolidFireAccountNotFound(SolidFireDriverException):
  537. message = _("Unable to locate account %(account_name)s on "
  538. "Solidfire device")
  539. class SolidFireRetryableException(VolumeBackendAPIException):
  540. message = _("Retryable SolidFire Exception encountered")
  541. # HP 3Par
  542. class Invalid3PARDomain(VolumeDriverException):
  543. message = _("Invalid 3PAR Domain: %(err)s")
  544. # RemoteFS drivers
  545. class RemoteFSException(VolumeDriverException):
  546. message = _("Unknown RemoteFS exception")
  547. class RemoteFSConcurrentRequest(RemoteFSException):
  548. message = _("A concurrent, possibly contradictory, request "
  549. "has been made.")
  550. class RemoteFSNoSharesMounted(RemoteFSException):
  551. message = _("No mounted shares found")
  552. class RemoteFSNoSuitableShareFound(RemoteFSException):
  553. message = _("There is no share which can host %(volume_size)sG")
  554. # NFS driver
  555. class NfsException(RemoteFSException):
  556. message = _("Unknown NFS exception")
  557. class NfsNoSharesMounted(RemoteFSNoSharesMounted):
  558. message = _("No mounted NFS shares found")
  559. class NfsNoSuitableShareFound(RemoteFSNoSuitableShareFound):
  560. message = _("There is no share which can host %(volume_size)sG")
  561. # Smbfs driver
  562. class SmbfsException(RemoteFSException):
  563. message = _("Unknown SMBFS exception.")
  564. class SmbfsNoSharesMounted(RemoteFSNoSharesMounted):
  565. message = _("No mounted SMBFS shares found.")
  566. class SmbfsNoSuitableShareFound(RemoteFSNoSuitableShareFound):
  567. message = _("There is no share which can host %(volume_size)sG.")
  568. # Gluster driver
  569. class GlusterfsException(RemoteFSException):
  570. message = _("Unknown Gluster exception")
  571. class GlusterfsNoSharesMounted(RemoteFSNoSharesMounted):
  572. message = _("No mounted Gluster shares found")
  573. class GlusterfsNoSuitableShareFound(RemoteFSNoSuitableShareFound):
  574. message = _("There is no share which can host %(volume_size)sG")
  575. # Virtuozzo Storage Driver
  576. class VzStorageException(RemoteFSException):
  577. message = _("Unknown Virtuozzo Storage exception")
  578. class VzStorageNoSharesMounted(RemoteFSNoSharesMounted):
  579. message = _("No mounted Virtuozzo Storage shares found")
  580. class VzStorageNoSuitableShareFound(RemoteFSNoSuitableShareFound):
  581. message = _("There is no share which can host %(volume_size)sG")
  582. # Fibre Channel Zone Manager
  583. class ZoneManagerException(CinderException):
  584. message = _("Fibre Channel connection control failure: %(reason)s")
  585. class FCZoneDriverException(CinderException):
  586. message = _("Fibre Channel Zone operation failed: %(reason)s")
  587. class FCSanLookupServiceException(CinderException):
  588. message = _("Fibre Channel SAN Lookup failure: %(reason)s")
  589. class BrocadeZoningCliException(CinderException):
  590. message = _("Brocade Fibre Channel Zoning CLI error: %(reason)s")
  591. class BrocadeZoningHttpException(CinderException):
  592. message = _("Brocade Fibre Channel Zoning HTTP error: %(reason)s")
  593. class CiscoZoningCliException(CinderException):
  594. message = _("Cisco Fibre Channel Zoning CLI error: %(reason)s")
  595. class NetAppDriverException(VolumeDriverException):
  596. message = _("NetApp Cinder Driver exception.")
  597. class EMCVnxCLICmdError(VolumeBackendAPIException):
  598. message = _("EMC VNX Cinder Driver CLI exception: %(cmd)s "
  599. "(Return Code: %(rc)s) (Output: %(out)s).")
  600. class EMCSPUnavailableException(EMCVnxCLICmdError):
  601. message = _("EMC VNX Cinder Driver SPUnavailableException: %(cmd)s "
  602. "(Return Code: %(rc)s) (Output: %(out)s).")
  603. # ConsistencyGroup
  604. class ConsistencyGroupNotFound(NotFound):
  605. message = _("ConsistencyGroup %(consistencygroup_id)s could not be found.")
  606. class InvalidConsistencyGroup(Invalid):
  607. message = _("Invalid ConsistencyGroup: %(reason)s")
  608. # CgSnapshot
  609. class CgSnapshotNotFound(NotFound):
  610. message = _("CgSnapshot %(cgsnapshot_id)s could not be found.")
  611. class InvalidCgSnapshot(Invalid):
  612. message = _("Invalid CgSnapshot: %(reason)s")
  613. # Hitachi Block Storage Driver
  614. class HBSDError(CinderException):
  615. message = _("HBSD error occurs.")
  616. class HBSDCmdError(HBSDError):
  617. def __init__(self, message=None, ret=None, err=None):
  618. self.ret = ret
  619. self.stderr = err
  620. super(HBSDCmdError, self).__init__(message=message)
  621. class HBSDBusy(HBSDError):
  622. message = "Device or resource is busy."
  623. class HBSDNotFound(NotFound):
  624. message = _("Storage resource could not be found.")
  625. class HBSDVolumeIsBusy(VolumeIsBusy):
  626. message = _("Volume %(volume_name)s is busy.")
  627. # Datera driver
  628. class DateraAPIException(VolumeBackendAPIException):
  629. message = _("Bad response from Datera API")
  630. # Target drivers
  631. class ISCSITargetCreateFailed(CinderException):
  632. message = _("Failed to create iscsi target for volume %(volume_id)s.")
  633. class ISCSITargetRemoveFailed(CinderException):
  634. message = _("Failed to remove iscsi target for volume %(volume_id)s.")
  635. class ISCSITargetAttachFailed(CinderException):
  636. message = _("Failed to attach iSCSI target for volume %(volume_id)s.")
  637. class ISCSITargetDetachFailed(CinderException):
  638. message = _("Failed to detach iSCSI target for volume %(volume_id)s.")
  639. class ISCSITargetHelperCommandFailed(CinderException):
  640. message = _("%(error_message)s")
  641. # X-IO driver exception.
  642. class XIODriverException(VolumeDriverException):
  643. message = _("X-IO Volume Driver exception!")
  644. # Violin Memory drivers
  645. class ViolinInvalidBackendConfig(VolumeDriverException):
  646. message = _("Volume backend config is invalid: %(reason)s")
  647. class ViolinRequestRetryTimeout(VolumeDriverException):
  648. message = _("Backend service retry timeout hit: %(timeout)s sec")
  649. class ViolinBackendErr(VolumeBackendAPIException):
  650. message = _("Backend reports: %(message)s")
  651. class ViolinBackendErrExists(VolumeBackendAPIException):
  652. message = _("Backend reports: item already exists")
  653. class ViolinBackendErrNotFound(NotFound):
  654. message = _("Backend reports: item not found")
  655. class ViolinResourceNotFound(NotFound):
  656. message = _("Backend reports: %(message)s")
  657. class BadHTTPResponseStatus(VolumeDriverException):
  658. message = _("Bad HTTP response status %(status)s")
  659. # ZADARA STORAGE VPSA driver exception
  660. class ZadaraServerCreateFailure(VolumeDriverException):
  661. message = _("Unable to create server object for initiator %(name)s")
  662. class ZadaraServerNotFound(NotFound):
  663. message = _("Unable to find server object for initiator %(name)s")
  664. class ZadaraVPSANoActiveController(VolumeDriverException):
  665. message = _("Unable to find any active VPSA controller")
  666. class ZadaraAttachmentsNotFound(NotFound):
  667. message = _("Failed to retrieve attachments for volume %(name)s")
  668. class ZadaraInvalidAttachmentInfo(Invalid):
  669. message = _("Invalid attachment info for volume %(name)s: %(reason)s")
  670. class ZadaraVolumeNotFound(VolumeDriverException):
  671. message = _("%(reason)s")
  672. # ZFSSA NFS driver exception.
  673. class WebDAVClientError(CinderException):
  674. message = _("The WebDAV request failed. Reason: %(msg)s, "
  675. "Return code/reason: %(code)s, Source Volume: %(src)s, "
  676. "Destination Volume: %(dst)s, Method: %(method)s.")
  677. # XtremIO Drivers
  678. class XtremIOAlreadyMappedError(CinderException):
  679. message = _("Volume to Initiator Group mapping already exists")
  680. class XtremIOArrayBusy(CinderException):
  681. message = _("System is busy, retry operation.")
  682. class XtremIOSnapshotsLimitExceeded(CinderException):
  683. message = _("Exceeded the limit of snapshots per volume")
  684. # Infortrend EonStor DS Driver
  685. class InfortrendCliException(CinderException):
  686. message = _("Infortrend CLI exception: %(err)s Param: %(param)s "
  687. "(Return Code: %(rc)s) (Output: %(out)s)")
  688. # DOTHILL drivers
  689. class DotHillInvalidBackend(CinderException):
  690. message = _("Backend doesn't exist (%(backend)s)")
  691. class DotHillConnectionError(CinderException):
  692. message = _("%(message)s")
  693. class DotHillAuthenticationError(CinderException):
  694. message = _("%(message)s")
  695. class DotHillNotEnoughSpace(CinderException):
  696. message = _("Not enough space on backend (%(backend)s)")
  697. class DotHillRequestError(CinderException):
  698. message = _("%(message)s")
  699. class DotHillNotTargetPortal(CinderException):
  700. message = _("No active iSCSI portals with supplied iSCSI IPs")
  701. # Sheepdog
  702. class SheepdogError(VolumeBackendAPIException):
  703. message = _("An error has occurred in SheepdogDriver. "
  704. "(Reason: %(reason)s)")
  705. class SheepdogCmdError(SheepdogError):
  706. message = _("(Command: %(cmd)s) "
  707. "(Return Code: %(exit_code)s) "
  708. "(Stdout: %(stdout)s) "
  709. "(Stderr: %(stderr)s)")
  710. class MetadataAbsent(CinderException):
  711. message = _("There is no metadata in DB object.")
  712. class NotSupportedOperation(Invalid):
  713. message = _("Operation not supported: %(operation)s.")
  714. code = 405
  715. # Hitachi HNAS drivers
  716. class HNASConnError(CinderException):
  717. message = _("%(message)s")
  718. # Coho drivers
  719. class CohoException(VolumeDriverException):
  720. message = _("Coho Data Cinder driver failure: %(message)s")
  721. # Tegile Storage drivers
  722. class TegileAPIException(VolumeBackendAPIException):
  723. message = _("Unexpected response from Tegile IntelliFlash API")
  724. # NexentaStor driver exception
  725. class NexentaException(VolumeDriverException):
  726. message = _("%(message)s")
  727. # Google Cloud Storage(GCS) backup driver
  728. class GCSConnectionFailure(BackupDriverException):
  729. message = _("Google Cloud Storage connection failure: %(reason)s")
  730. class GCSApiFailure(BackupDriverException):
  731. message = _("Google Cloud Storage api failure: %(reason)s")
  732. class GCSOAuth2Failure(BackupDriverException):
  733. message = _("Google Cloud Storage oauth2 failure: %(reason)s")
  734. # Kaminario K2
  735. class KaminarioCinderDriverException(VolumeDriverException):
  736. message = _("KaminarioCinderDriver failure: %(reason)s")
  737. class KaminarioRetryableException(VolumeDriverException):
  738. message = _("Kaminario retryable exception: %(reason)s")
  739. # Synology driver
  740. class SynoAPIHTTPError(CinderException):
  741. message = _("HTTP exit code: [%(code)s]")
  742. class SynoAuthError(CinderException):
  743. message = _("Synology driver authentication failed: %(reason)s.")
  744. class SynoLUNNotExist(CinderException):
  745. message = _("LUN not found by UUID: %(uuid)s.")