'Checks that the physical resource is in its expected state.
Gets the current status of the physical resource and updates the
database accordingly. If check is not supported by the resource,
default action is to fail and revert the resource\'s status to its
original state with the added message that check was not performed.'

def check(self):

    action = self.CHECK
    LOG.info('Checking    %s', self)
    if hasattr(self, ('handle_%s' % action.lower())):
        if (self.state == (self.INIT, self.COMPLETE)):
            reason = (_('Can    not    check    %s,    resource    not    created    yet.') % self.name)
            self.state_set(action, self.FAILED, reason)
            exc = Exception((_('Resource    %s    not    created    yet.') % self.name))
            failure = exception.ResourceFailure(exc, self, action)
            raise failure
        return self._do_action(action)
    else:
        reason = ('%s    not    supported    for    %s' % (action, self.type()))
        self.state_set(action, self.COMPLETE, reason)
