Beispiel #1
0
 def check_create_complete(self, data):
     attributes = self._show_resource()
     status = attributes['status']
     if status == 'PENDING_CREATE':
         return False
     elif status == 'ACTIVE':
         vip_attributes = self.client().show_vip(
             self.metadata_get()['vip'])['vip']
         vip_status = vip_attributes['status']
         if vip_status == 'PENDING_CREATE':
             return False
         if vip_status == 'ACTIVE':
             return True
         if vip_status == 'ERROR':
             raise exception.ResourceInError(
                 resource_status=vip_status,
                 status_reason=_('error in vip'))
         raise exception.ResourceUnknownStatus(
             resource_status=vip_status,
             result=_('Pool creation failed due to vip'))
     elif status == 'ERROR':
         raise exception.ResourceInError(
             resource_status=status,
             status_reason=_('error in pool'))
     else:
         raise exception.ResourceUnknownStatus(
             resource_status=status,
             result=_('Pool creation failed'))
Beispiel #2
0
    def check_delete_server_complete(self, server_id):
        """Wait for server to disappear from Nova."""
        try:
            server = self.fetch_server(server_id)
        except Exception as exc:
            self.ignore_not_found(exc)
            return True
        if not server:
            return False
        task_state_in_nova = getattr(server, 'OS-EXT-STS:task_state', None)
        # the status of server won't change until the delete task has done
        if task_state_in_nova == 'deleting':
            return False

        status = self.get_status(server)
        if status in ("DELETED", "SOFT_DELETED"):
            return True
        if status == 'ERROR':
            fault = getattr(server, 'fault', {})
            message = fault.get('message', 'Unknown')
            code = fault.get('code')
            errmsg = _("Server %(name)s delete failed: (%(code)s) "
                       "%(message)s") % dict(
                           name=server.name, code=code, message=message)
            raise exception.ResourceInError(resource_status=status,
                                            status_reason=errmsg)
        return False
Beispiel #3
0
    def check_delete_complete(self, prg):
        if not prg.backup['called']:
            prg.backup_id = self._create_backup()
            prg.backup['called'] = True
            return False

        if not prg.backup['complete']:
            prg.backup['complete'] = self._check_create_backup_complete(prg)
            return False

        if not prg.delete['called']:
            prg.delete['complete'] = self._delete_volume()
            prg.delete['called'] = True
            return False

        if not prg.delete['complete']:
            try:
                vol = self.client().volumes.get(self.resource_id)
            except Exception as ex:
                self.client_plugin().ignore_not_found(ex)
                prg.delete['complete'] = True
                return True
            if vol.status.lower() == 'error_deleting':
                raise exception.ResourceInError(status_reason='delete',
                                                resource_status=vol.status)
            else:
                return False
        return True
Beispiel #4
0
 def is_built(attributes):
     status = attributes['status']
     if status == 'BUILD':
         return False
     if status in ('ACTIVE', 'DOWN'):
         return True
     elif status == 'ERROR':
         raise exception.ResourceInError(resource_status=status)
     else:
         raise exception.ResourceUnknownStatus(
             resource_status=status, result=_('Resource is not built'))
Beispiel #5
0
    def check_create_complete(self, vol_id):
        vol = self.client().volumes.get(vol_id)

        if vol.status == 'available':
            return True
        if vol.status in self._volume_creating_status:
            return False
        if vol.status == 'error':
            raise exception.ResourceInError(resource_status=vol.status)
        else:
            raise exception.ResourceUnknownStatus(
                resource_status=vol.status, result=_('Volume create failed'))
Beispiel #6
0
    def _check_action_complete(self, action):
        stack = self.heat().stacks.get(stack_id=self.resource_id)
        if stack.action != action:
            return False

        if stack.status == self.IN_PROGRESS:
            return False
        elif stack.status == self.COMPLETE:
            return True
        elif stack.status == self.FAILED:
            raise exception.ResourceInError(
                resource_status=stack.stack_status,
                status_reason=stack.stack_status_reason)
        else:
            # Note: this should never happen, so it really means that
            # the resource/engine is in serious problem if it happens.
            raise exception.ResourceUnknownStatus(
                resource_status=stack.stack_status,
                status_reason=stack.stack_status_reason)
Beispiel #7
0
    def _check_active(self, server, res_name='Server'):
        """Check server status.

        Accepts both server IDs and server objects.
        Returns True if server is ACTIVE,
        raises errors when server has an ERROR or unknown to Heat status,
        returns False otherwise.

        :param res_name: name of the resource to use in the exception message

        """
        # not checking with is_uuid_like as most tests use strings e.g. '1234'
        if isinstance(server, six.string_types):
            server = self.fetch_server(server)
            if server is None:
                return False
            else:
                status = self.get_status(server)
        else:
            status = self.get_status(server)
            if status != 'ACTIVE':
                self.refresh_server(server)
                status = self.get_status(server)

        if status in self.deferred_server_statuses:
            return False
        elif status == 'ACTIVE':
            return True
        elif status == 'ERROR':
            fault = getattr(server, 'fault', {})
            raise exception.ResourceInError(
                resource_status=status,
                status_reason=_("Message: %(message)s, Code: %(code)s") % {
                    'message': fault.get('message', _('Unknown')),
                    'code': fault.get('code', _('Unknown'))
                })
        else:
            raise exception.ResourceUnknownStatus(
                resource_status=server.status,
                result=_('%s is not active') % res_name)
Beispiel #8
0
 def _check_active(self, elb_status):
     if elb_status == utils.ACTIVE:
         return True
     if elb_status == utils.ERROR:
         raise exception.ResourceInError(resource_status=elb_status)
Beispiel #9
0
 def check_lb_status(self, lb_id):
     lb = self.client().show_loadbalancer(lb_id)['loadbalancer']
     status = lb['provisioning_status']
     if status == 'ERROR':
         raise exception.ResourceInError(resource_status=status)
     return status == 'ACTIVE'