Class: Berta::Utils::OpenNebula::Helper
- Inherits:
-
Object
- Object
- Berta::Utils::OpenNebula::Helper
- Defined in:
- lib/berta/utils/opennebula/helper.rb
Overview
Class designed to help with working with OpenNebula
Constant Summary collapse
- ERRORS =
Hash of errors that can be returned by opennebula
Hash.new(Berta::Errors::OpenNebula::ResourceRetrievalError) .update(::OpenNebula::Error::EAUTHENTICATION => Berta::Errors::OpenNebula::AuthenticationError, ::OpenNebula::Error::EAUTHORIZATION => Berta::Errors::OpenNebula::UserNotAuthorizedError, ::OpenNebula::Error::ENO_EXISTS => Berta::Errors::OpenNebula::ResourceNotFoundError, ::OpenNebula::Error::EACTION => Berta::Errors::OpenNebula::ResourceStateError) .freeze
Class Method Summary collapse
-
.decode_error(errno) ⇒ Berta::Errors::OpenNebula::AuthenticationError, ...
Decodes OpenNebula error codes into exceptions and returns them.
-
.handle_error ⇒ Object
Handles OpenNebula error codes and turns them into exceptions.
Class Method Details
.decode_error(errno) ⇒ Berta::Errors::OpenNebula::AuthenticationError, ...
Decodes OpenNebula error codes into exceptions and returns them
38 39 40 |
# File 'lib/berta/utils/opennebula/helper.rb', line 38 def decode_error(errno) ERRORS[errno] end |
.handle_error ⇒ Object
Handles OpenNebula error codes and turns them into exceptions
23 24 25 26 27 28 |
# File 'lib/berta/utils/opennebula/helper.rb', line 23 def handle_error raise Berta::Errors::OpenNebula::StubError, 'OpenNebula service-wrapper was called without a block!' unless block_given? return_value = yield return return_value unless ::OpenNebula.is_error?(return_value) raise decode_error(return_value.errno), return_value. end |