예제 #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')
예제 #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)
예제 #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)
예제 #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))
예제 #5
0
파일: plugin.py 프로젝트: crobby/sahara
    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))
예제 #6
0
파일: test_api.py 프로젝트: Imperat/sahara
    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))
예제 #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')
예제 #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))
예제 #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)
예제 #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)
예제 #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)
예제 #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"))
예제 #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"))
예제 #14
0
파일: validation.py 프로젝트: madar010/mad
    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)
예제 #15
0
def get_by_id(lst, id, **kwargs):
    return general.get_by_id(lst, id)
예제 #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))
예제 #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))