コード例 #1
0
 def execute(self, instance, backend_pull_method, success_state, erred_state):
     backend = self.get_backend(instance)
     getattr(backend, backend_pull_method)(instance)
     instance.refresh_from_db()
     if instance.runtime_state not in (success_state, erred_state):
         self.retry()
     elif instance.runtime_state == erred_state:
         raise RuntimeStateException(
             '%s (PK: %s) runtime state become erred: %s' % (
                 instance.__class__.__name__, instance.pk, erred_state))
     return instance
コード例 #2
0
    def execute(self, node):
        pull_cluster_nodes(node.cluster_id)
        node.refresh_from_db()

        if node.runtime_state == models.Node.RuntimeStates.ACTIVE:
            # We don't need to change the node state here as it will be done
            # in an executor.
            return
        elif (node.runtime_state in [
                models.Node.RuntimeStates.REGISTERING,
                models.Node.RuntimeStates.UNAVAILABLE,
        ] or not node.runtime_state):
            self.retry()
        elif node.runtime_state:
            raise RuntimeStateException(
                '%s (PK: %s) runtime state become erred: %s' %
                (node.__class__.__name__, node.pk, node.runtime_state))

        return node
コード例 #3
0
    def execute(self, node):
        update_nodes(node.cluster_id)
        node.refresh_from_db()

        if node.runtime_state == models.Node.RuntimeStates.ACTIVE:
            # If node runtime state is ACTIVE,
            # then it is necessary to update node state and to call signal for usages updating.
            utils.update_cluster_nodes_states(node.cluster.id)
            return
        elif (node.runtime_state in [
                models.Node.RuntimeStates.REGISTERING,
                models.Node.RuntimeStates.UNAVAILABLE,
        ] or not node.runtime_state):
            self.retry()
        elif node.runtime_state:
            raise RuntimeStateException(
                '%s (PK: %s) runtime state become erred: %s' %
                (node.__class__.__name__, node.pk, node.runtime_state))

        return node
コード例 #4
0
ファイル: tasks.py プロジェクト: yyri/waldur-mastermind
    def execute(self, cluster):
        app = models.Application.objects.get(
            cluster=cluster,
            name=LONGHORN_NAME,
            namespace__name=LONGHORN_NAMESPACE)
        backend = app.get_backend()
        backend.check_application_state(app)
        if app.runtime_state == 'active':
            app.state = models.Application.States.OK
            app.save()
        elif app.runtime_state == 'error':
            app.state = models.Application.States.ERRED
            app.save()

        if app.runtime_state not in ('active', 'error'):
            self.retry()
        elif app.runtime_state == 'error':
            raise RuntimeStateException(
                '%s (PK: %s) runtime state become erred: %s' %
                (app.__class__.__name__, app.pk, app.runtime_state))

        return app