Example #1
0
    def test_update_node_group_by_id(self):
        ctx, cluster = self._make_sample()
        ng_id = cluster.node_groups[0].id
        self.api.node_group_update(ctx, ng_id, {'name': 'changed_ng'})
        cluster = self.api.cluster_get(ctx, cluster.id)

        ng = gu.get_by_id(cluster.node_groups, ng_id)
        self.assertEqual(ng.name, 'changed_ng')
Example #2
0
    def test_update_node_group_by_id(self):
        ctx, cluster = self._make_sample()
        ng_id = cluster.node_groups[0].id
        self.api.node_group_update(ctx, ng_id, {"name": "changed_ng"})
        cluster = self.api.cluster_get(ctx, cluster.id)

        ng = gu.get_by_id(cluster.node_groups, ng_id)
        self.assertEqual("changed_ng", ng.name)
Example #3
0
    def test_update_instance_by_id(self):
        ctx, cluster = self._make_sample()
        ng_id = cluster.node_groups[0].id
        inst_id = self.api.instance_add(ctx, ng_id, SAMPLE_INSTANCE)

        self.api.instance_update(ctx, inst_id, {"instance_name": "tst123"})
        cluster = self.api.cluster_get(ctx, cluster.id)

        ng = gu.get_by_id(cluster.node_groups, ng_id)
        self.assertEqual("tst123", ng.instances[0].instance_name)
Example #4
0
    def test_instance_volume_ops(self):
        ctx, cluster = self._make_sample()
        ng_id = cluster.node_groups[0].id
        inst_id = self.api.instance_add(ctx, ng_id, SAMPLE_INSTANCE)

        self.api.append_volume(ctx, inst_id, 0)
        self.api.append_volume(ctx, inst_id, 1)

        cluster = self.api.cluster_get(ctx, cluster.id)
        ng = gu.get_by_id(cluster.node_groups, ng_id)

        self.assertEqual(2, len(gu.get_by_id(ng.instances, inst_id).volumes))

        self.api.remove_volume(ctx, inst_id, 0)

        cluster = self.api.cluster_get(ctx, cluster.id)
        ng = gu.get_by_id(cluster.node_groups, ng_id)

        self.assertEqual(1, len(gu.get_by_id(ng.instances, inst_id).volumes))
Example #5
0
    def _validate_additional_ng_scaling(self, cluster, additional):
        scalable_processes = self._get_scalable_processes()

        for ng_id in additional:
            ng = ug.get_by_id(cluster.node_groups, ng_id)
            if not set(ng.node_processes).issubset(scalable_processes):
                raise ex.NodeGroupCannotBeScaled(
                    ng.name, _("Spark plugin cannot scale nodegroup"
                               " with processes: %s") %
                    ' '.join(ng.node_processes))
Example #6
0
    def test_instance_volume_ops(self):
        ctx, cluster = self._make_sample()
        ng_id = cluster.node_groups[0].id
        inst_id = self.api.instance_add(ctx, ng_id, SAMPLE_INSTANCE)

        self.api.append_volume(ctx, inst_id, 0)
        self.api.append_volume(ctx, inst_id, 1)

        cluster = self.api.cluster_get(ctx, cluster.id)
        ng = gu.get_by_id(cluster.node_groups, ng_id)

        self.assertEqual(2, len(gu.get_by_id(ng.instances, inst_id).volumes))

        self.api.remove_volume(ctx, inst_id, 0)

        cluster = self.api.cluster_get(ctx, cluster.id)
        ng = gu.get_by_id(cluster.node_groups, ng_id)

        self.assertEqual(1, len(gu.get_by_id(ng.instances, inst_id).volumes))
Example #7
0
    def test_update_instance_by_id(self):
        ctx, cluster = self._make_sample()
        ng_id = cluster.node_groups[0].id
        inst_id = self.api.instance_add(ctx, ng_id, SAMPLE_INSTANCE)

        self.api.instance_update(ctx, inst_id, {'instance_name': 'tst123'})
        cluster = self.api.cluster_get(ctx, cluster.id)

        ng = gu.get_by_id(cluster.node_groups, ng_id)
        self.assertEqual(ng.instances[0].instance_name, 'tst123')
Example #8
0
    def _validate_additional_ng_scaling(self, cluster, additional):
        scalable_processes = self._get_scalable_processes()

        for ng_id in additional:
            ng = ug.get_by_id(cluster.node_groups, ng_id)
            if not set(ng.node_processes).issubset(scalable_processes):
                raise ex.NodeGroupCannotBeScaled(
                    ng.name,
                    _("Spark plugin cannot scale nodegroup"
                      " with processes: %s") % ' '.join(ng.node_processes))
Example #9
0
def validate_additional_ng_scaling(cluster, additional):
    rm = PU.get_resourcemanager(cluster)
    scalable_processes = _get_scalable_processes()

    for ng_id in additional:
        ng = gu.get_by_id(cluster.node_groups, ng_id)
        if not set(ng.node_processes).issubset(scalable_processes):
            msg = _("CDH plugin cannot scale nodegroup with processes: " "%(processes)s")
            raise ex.NodeGroupCannotBeScaled(ng.name, msg % {"processes": " ".join(ng.node_processes)})

        if not rm and "YARN_NODEMANAGER" in ng.node_processes:
            msg = _(
                "CDH plugin cannot scale node group with processes " "which have no master-processes run in cluster"
            )
            raise ex.NodeGroupCannotBeScaled(ng.name, msg)
Example #10
0
def validate_additional_ng_scaling(cluster, additional):
    rm = vu.get_resourcemanager(cluster)
    scalable_processes = _get_scalable_processes()

    for ng_id in additional:
        ng = gu.get_by_id(cluster.node_groups, ng_id)
        if not set(ng.node_processes).issubset(scalable_processes):
            msg = "Vanilla plugin cannot scale nodegroup with processes: %s"
            raise ex.NodeGroupCannotBeScaled(ng.name,
                                             msg % ' '.join(ng.node_processes))

        if not rm and 'nodemanager' in ng.node_processes:
            msg = ("Vanilla plugin cannot scale node group with processes "
                   "which have no master-processes run in cluster")
            raise ex.NodeGroupCannotBeScaled(ng.name, msg)
Example #11
0
def validate_additional_ng_scaling(cluster, additional):
    rm = u.get_resourcemanager(cluster)
    scalable_processes = _get_scalable_processes()

    for ng_id in additional:
        ng = gu.get_by_id(cluster.node_groups, ng_id)
        if not set(ng.node_processes).issubset(scalable_processes):
            msg = "Vanilla plugin cannot scale nodegroup with processes: %s"
            raise ex.NodeGroupCannotBeScaled(ng.name,
                                             msg % ' '.join(ng.node_processes))

        if not rm and 'nodemanager' in ng.node_processes:
            msg = ("Vanilla plugin cannot scale node group with processes "
                   "which have no master-processes run in cluster")
            raise ex.NodeGroupCannotBeScaled(ng.name, msg)
Example #12
0
    def _validate_additional_ng_scaling(self, cluster, additional):
        jt = vu.get_jobtracker(cluster)
        scalable_processes = self._get_scalable_processes()

        for ng_id in additional:
            ng = g.get_by_id(cluster.node_groups, ng_id)
            if not set(ng.node_processes).issubset(scalable_processes):
                raise ex.NodeGroupCannotBeScaled(
                    ng.name, _("Vanilla plugin cannot scale nodegroup"
                               " with processes: %s") %
                    ' '.join(ng.node_processes))
            if not jt and 'tasktracker' in ng.node_processes:
                raise ex.NodeGroupCannotBeScaled(
                    ng.name, _("Vanilla plugin cannot scale node group with "
                               "processes which have no master-processes run "
                               "in cluster"))
Example #13
0
    def _validate_additional_ng_scaling(self, cluster, additional):
        jt = vu.get_jobtracker(cluster)
        scalable_processes = self._get_scalable_processes()

        for ng_id in additional:
            ng = g.get_by_id(cluster.node_groups, ng_id)
            if not set(ng.node_processes).issubset(scalable_processes):
                raise ex.NodeGroupCannotBeScaled(
                    ng.name, _("Vanilla plugin cannot scale nodegroup"
                               " with processes: %s") %
                    ' '.join(ng.node_processes))
            if not jt and 'tasktracker' in ng.node_processes:
                raise ex.NodeGroupCannotBeScaled(
                    ng.name, _("Vanilla plugin cannot scale node group with "
                               "processes which have no master-processes run "
                               "in cluster"))
Example #14
0
    def validate_additional_ng_scaling(cls, cluster, additional):
        rm = cls.PU.get_resourcemanager(cluster)
        scalable_processes = cls._get_scalable_processes()

        for ng_id in additional:
            ng = gu.get_by_id(cluster.node_groups, ng_id)
            if not set(ng.node_processes).issubset(scalable_processes):
                msg = _("CDH plugin cannot scale nodegroup with processes: "
                        "%(processes)s")
                raise ex.NodeGroupCannotBeScaled(
                    ng.name, msg % {'processes': ' '.join(ng.node_processes)})

            if not rm and 'YARN_NODEMANAGER' in ng.node_processes:
                msg = _("CDH plugin cannot scale node group with processes "
                        "which have no master-processes run in cluster")
                raise ex.NodeGroupCannotBeScaled(ng.name, msg)
Example #15
0
def get_by_id(lst, id, **kwargs):
    return general.get_by_id(lst, id)
Example #16
0
 def test_get_by_id(self):
     lst = [mock.Mock(id=5), mock.Mock(id=7)]
     self.assertIsNone(general.get_by_id(lst, 9))
     self.assertEqual(lst[0], general.get_by_id(lst, 5))
     self.assertEqual(lst[1], general.get_by_id(lst, 7))
Example #17
0
 def test_get_by_id(self):
     lst = [mock.Mock(id=5), mock.Mock(id=7)]
     self.assertIsNone(general.get_by_id(lst, 9))
     self.assertEqual(lst[0], general.get_by_id(lst, 5))
     self.assertEqual(lst[1], general.get_by_id(lst, 7))