Exemplo n.º 1
0
        def handler():
            node = models.Node(mac='60:a4:4c:35:28:95',
                               timestamp=datetime.datetime.now())

            node.attributes = models.IPAddr()
            db.add(node)
            db.flush()
Exemplo n.º 2
0
 def test_does_not_fail_if_there_is_deleted_task(self):
     task = models.Task(name=consts.TASK_NAMES.deployment,
                        deleted_at=datetime.datetime.now(),
                        cluster_id=self.cluster.id)
     db.add(task)
     db.flush()
     self.assertNotRaises(errors.TaskAlreadyRunning,
                          self.task_manager.check_running_task)
 def handler():
     node = models.Node(
         mac='60:a4:4c:35:28:95',
         timestamp=datetime.datetime.now(),
         status='batman'
     )
     db.add(node)
     db.flush()
 def handler():
     node = models.Node(
         mac='60:a4:4c:35:28:95',
         timestamp=datetime.datetime.now(),
         status='batman'
     )
     db.add(node)
     db.flush()
Exemplo n.º 5
0
def _update_nodes(transaction, nodes_instances, nodes_params):
    allow_update = {
        'name',
        'status',
        'hostname',
        'kernel_params',
        'pending_addition',
        'pending_deletion',
        'error_msg',
        'online',
        'progress',
    }

    # dry-run transactions must not update nodes except progress column
    if transaction.dry_run:
        allow_update = {'progress'}

    for node in nodes_instances:
        node_params = nodes_params.pop(node.uid)

        for param in allow_update.intersection(node_params):
            if param == 'status':
                new_status = node_params['status']
                if new_status == 'deleted':
                    # the deleted is special status which causes
                    # to delete node from cluster
                    objects.Node.remove_from_cluster(node)
                elif new_status == 'error':
                    # TODO(bgaifullin) do not persist status in DB
                    node.status = new_status
                    node.error_type = node_params.get(
                        'error_type', consts.NODE_ERRORS.deploy)
                    node.progress = 100
                    # Notification on particular node failure
                    notifier.notify(consts.NOTIFICATION_TOPICS.error,
                                    u"Node '{0}' failed: {1}".format(
                                        node.name,
                                        node_params.get(
                                            'error_msg', "Unknown error")),
                                    cluster_id=transaction.cluster_id,
                                    node_id=node.uid,
                                    task_uuid=transaction.uuid)
                elif new_status == 'ready':
                    # TODO(bgaifullin) need to remove pengind roles concept
                    node.roles = list(set(node.roles + node.pending_roles))
                    node.pending_roles = []
                    node.progress = 100
                    node.status = new_status
                else:
                    node.status = new_status
            else:
                setattr(node, param, node_params[param])
    db.flush()

    if nodes_params:
        logger.warning("The following nodes are not found: %s",
                       ",".join(sorted(nodes_params.keys())))
Exemplo n.º 6
0
 def test_does_not_fail_if_there_is_deleted_task(self):
     task = models.Task(name=consts.TASK_NAMES.deployment,
                        deleted_at=datetime.datetime.now(),
                        cluster_id=self.cluster.id)
     db.add(task)
     db.flush()
     self.assertNotRaises(
         errors.TaskAlreadyRunning, self.task_manager.check_running_task
     )
Exemplo n.º 7
0
        def handler():
            node = models.Node(
                mac='60:a4:4c:35:28:95',
                timestamp=datetime.datetime.now()
            )

            node.attributes = models.IPAddr()
            db.add(node)
            db.flush()
Exemplo n.º 8
0
    def test_fails_if_there_is_task(self):
        task = models.Task(name=consts.TASK_NAMES.deployment,
                           cluster_id=self.cluster.id,
                           status=consts.TASK_STATUSES.pending)
        db.add(task)
        db.flush()

        self.assertRaises(errors.TaskAlreadyRunning,
                          self.task_manager.check_running_task)
        def handler():
            mac = '60:a4:4c:35:28:95'

            node1 = models.Node(mac=mac, timestamp=datetime.datetime.now())
            db.add(node1)
            db.flush()

            node2 = models.Node(mac=mac, timestamp=datetime.datetime.now())
            db.add(node2)
            db.flush()
Exemplo n.º 10
0
        def handler():
            mac = '60:a4:4c:35:28:95'

            node1 = models.Node(mac=mac, timestamp=datetime.datetime.now())
            db.add(node1)
            db.flush()

            node2 = models.Node(mac=mac, timestamp=datetime.datetime.now())
            db.add(node2)
            db.flush()
Exemplo n.º 11
0
    def test_fails_if_there_is_task(self):
        task = models.Task(
            name=consts.TASK_NAMES.deployment, cluster_id=self.cluster.id,
            status=consts.TASK_STATUSES.pending
        )
        db.add(task)
        db.flush()

        self.assertRaises(
            errors.TaskAlreadyRunning, self.task_manager.check_running_task
        )
Exemplo n.º 12
0
def _update_nodes(transaction, nodes_instances, nodes_params):
    allow_update = {
        "name",
        "status",
        "hostname",
        "kernel_params",
        "pending_addition",
        "pending_deletion",
        "error_msg",
        "online",
        "progress",
    }

    # dry-run transactions must not update nodes except progress column
    if transaction.dry_run:
        allow_update = {"progress"}

    for node in nodes_instances:
        node_params = nodes_params.pop(node.uid)

        for param in allow_update.intersection(node_params):
            if param == "status":
                new_status = node_params["status"]
                if new_status == "deleted":
                    # the deleted is special status which causes
                    # to delete node from cluster
                    objects.Node.remove_from_cluster(node)
                elif new_status == "error":
                    # TODO(bgaifullin) do not persist status in DB
                    node.status = new_status
                    node.error_type = node_params.get("error_type", consts.NODE_ERRORS.deploy)
                    node.progress = 100
                    # Notification on particular node failure
                    notifier.notify(
                        consts.NOTIFICATION_TOPICS.error,
                        u"Node '{0}' failed: {1}".format(node.name, node_params.get("error_msg", "Unknown error")),
                        cluster_id=transaction.cluster_id,
                        node_id=node.uid,
                        task_uuid=transaction.uuid,
                    )
                elif new_status == "ready":
                    # TODO(bgaifullin) need to remove pengind roles concept
                    node.roles = list(set(node.roles + node.pending_roles))
                    node.pending_roles = []
                    node.progress = 100
                    node.status = new_status
                else:
                    node.status = new_status
            else:
                setattr(node, param, node_params[param])
    db.flush()

    if nodes_params:
        logger.warning("The following nodes are not found: %s", ",".join(sorted(nodes_params.keys())))
Exemplo n.º 13
0
    def test_does_not_fail_if_there_is_deleted_task(self):
        for task_name in DeploymentCheckMixin.deployment_tasks:
            task = models.Task(name=task_name,
                               deleted_at=datetime.datetime.now(),
                               cluster_id=self.cluster.id)
            db.add(task)
            db.flush()
            self.addCleanup(db.query(models.Task).delete)

            self.assertNotRaises(
                errors.DeploymentAlreadyStarted,
                DeploymentCheckMixin.check_no_running_deployment, self.cluster)
Exemplo n.º 14
0
def _update_history(transaction, nodes):
    for node in nodes:
        if {'deployment_graph_task_name', 'task_status'}.issubset(node.keys()):
            objects.DeploymentHistory.update_if_exist(
                transaction.id,
                node['uid'],
                node['deployment_graph_task_name'],
                node['task_status'],
                node.get('summary'),
                node.get('custom'),
            )
    db.flush()
Exemplo n.º 15
0
def _update_history(transaction, nodes):
    for node in nodes:
        if {'deployment_graph_task_name', 'task_status'}.issubset(node.keys()):
            objects.DeploymentHistory.update_if_exist(
                transaction.id,
                node['uid'],
                node['deployment_graph_task_name'],
                node['task_status'],
                node.get('summary'),
                node.get('custom'),
            )
    db.flush()
Exemplo n.º 16
0
    def test_fails_if_there_is_task(self):
        for task_name in DeploymentCheckMixin.deployment_tasks:
            task = models.Task(name=task_name, cluster_id=self.cluster.id)
            db.add(task)
            db.flush()
            self.assertRaisesWithMessage(
                errors.DeploymentAlreadyStarted,
                'Cannot perform the actions because there are '
                'running tasks {0}'.format([task]),
                DeploymentCheckMixin.check_no_running_deployment, self.cluster)

            db.query(models.Task).delete()
    def test_fails_if_there_is_task(self):
        for task_name in DeploymentCheckMixin.deployment_tasks:
            task = models.Task(name=task_name, cluster_id=self.cluster.id)
            db.add(task)
            db.flush()
            self.assertRaisesWithMessage(
                errors.DeploymentAlreadyStarted,
                'Cannot perform the actions because there are '
                'running tasks {0}'.format([task]),
                DeploymentCheckMixin.check_no_running_deployment,
                self.cluster)

            db.query(models.Task).delete()
Exemplo n.º 18
0
    def test_does_not_fail_if_there_is_deleted_task(self):
        for task_name in DeploymentCheckMixin.deployment_tasks:
            task = models.Task(name=task_name,
                               deleted_at=datetime.datetime.now(),
                               cluster_id=self.cluster.id)
            db.add(task)
            db.flush()
            self.addCleanup(db.query(models.Task).delete)

            self.assertNotRaises(
                errors.DeploymentAlreadyStarted,
                DeploymentCheckMixin.check_no_running_deployment,
                self.cluster)
 def handler():
     node = models.Node(mac=None)
     db.add(node)
     db.flush()
Exemplo n.º 20
0
 def handler():
     node = models.Node(mac=None)
     db.add(node)
     db.flush()
        def handler():
            ip_addr = models.IPAddr()

            ip_addr.network_data = models.IPAddr()
            db.add(ip_addr)
            db.flush()
Exemplo n.º 22
0
 def _update_release_state(cls, release_id, state):
     release = db().query(Release).get(release_id)
     release.state = state
     db.add(release)
     db.flush()
Exemplo n.º 23
0
 def _update_release_state(cls, release_id, state):
     release = db().query(Release).get(release_id)
     release.state = state
     db.add(release)
     db.flush()
Exemplo n.º 24
0
 def create_relation(cls, orig_cluster_id, seed_cluster_id):
     relation = models.UpgradeRelation(orig_cluster_id=orig_cluster_id,
                                       seed_cluster_id=seed_cluster_id)
     db.add(relation)
     db.flush()
Exemplo n.º 25
0
 def create_relation(cls, orig_cluster_id, seed_cluster_id):
     relation = models.UpgradeRelation(
         orig_cluster_id=orig_cluster_id,
         seed_cluster_id=seed_cluster_id)
     db.add(relation)
     db.flush()
        def handler():
            ip_addr = models.IPAddr()

            ip_addr.network_data = models.IPAddr()
            db.add(ip_addr)
            db.flush()