示例#1
0
 def test_node_group_template_delete_bad_id(self):
     self.logger.clear_log()
     option_values = {"tenant_id": 1, "id": "badid"}
     template_api.set_conf(Config(option_values))
     template_api.do_node_group_template_delete_by_id()
     msg = ("Deletion of node group template {id} failed, "
            "no such template".format(id=option_values["id"]))
     self.assertIn(msg, self.logger.warnings)
示例#2
0
 def test_node_group_template_delete_bad_id(self):
     self.logger.clear_log()
     option_values = {"tenant_id": 1,
                      "id": "badid"}
     template_api.set_conf(Config(option_values))
     template_api.do_node_group_template_delete_by_id()
     msg = ("Deletion of node group template {id} failed, "
            "no such template".format(id=option_values["id"]))
     self.assertIn(msg, self.logger.warnings)
示例#3
0
    def test_node_group_template_delete_in_use(self):
        self.logger.clear_log()
        ctx = context.ctx()
        t = self.api.node_group_template_create(ctx, c.SAMPLE_NGT)

        # Make a cluster that references the node group template
        cluster_values = copy.deepcopy(c.SAMPLE_CLUSTER)
        cluster_values["node_groups"][0]["node_group_template_id"] = t["id"]
        cl = self.api.cluster_create(ctx, cluster_values)

        # Make a cluster template that references the node group template
        cluster_temp_values = copy.deepcopy(c.SAMPLE_CLT)
        cluster_temp_values["node_groups"] = cluster_values["node_groups"]
        clt = self.api.cluster_template_create(ctx, cluster_temp_values)

        # Set up the expected messages
        msgs = [
            "Node group template {info} in use "
            "by clusters {clusters}".format(info=u.name_and_id(t),
                                            clusters=[cl["name"]])
        ]

        msgs += [
            "Node group template {info} in use "
            "by cluster templates {cluster_temps}".format(
                info=u.name_and_id(t), cluster_temps=[clt["name"]])
        ]

        msgs += [
            "Deletion of node group template {info} failed".format(
                info=u.name_and_id(t))
        ]

        # Check delete by name
        option_values = {
            "tenant_id": t["tenant_id"],
            "template_name": t["name"]
        }
        template_api.set_conf(Config(option_values))
        template_api.do_node_group_template_delete()
        for msg in msgs:
            self.assertIn(msg, self.logger.warnings)
        self.logger.clear_log()

        # Check again with delete by id
        option_values = {"tenant_id": t["tenant_id"], "id": t["id"]}
        template_api.set_conf(Config(option_values))
        template_api.do_node_group_template_delete_by_id()
        for msg in msgs:
            self.assertIn(msg, self.logger.warnings)
        self.logger.clear_log()
示例#4
0
    def test_node_group_template_delete_by_id(self):
        self.logger.clear_log()
        ctx = context.ctx()
        t = self.api.node_group_template_create(ctx, c.SAMPLE_NGT)

        option_values = {"tenant_id": t["tenant_id"], "id": t["id"]}
        template_api.set_conf(Config(option_values))

        template_api.do_node_group_template_delete_by_id()
        msg = 'Deleted node group template {info}'.format(
            info=u.name_and_id(t))
        self.assertIn(msg, self.logger.infos)

        t = self.api.node_group_template_get(ctx, t["id"])
        self.assertIsNone(t)
示例#5
0
    def test_node_group_template_delete_by_id(self):
        self.logger.clear_log()
        ctx = context.ctx()
        t = self.api.node_group_template_create(ctx, c.SAMPLE_NGT)

        option_values = {"tenant_id": t["tenant_id"],
                         "id": t["id"]}
        template_api.set_conf(Config(option_values))

        template_api.do_node_group_template_delete_by_id()
        msg = 'Deleted node group template {info}'.format(
            info=u.name_and_id(t))
        self.assertIn(msg, self.logger.infos)

        t = self.api.node_group_template_get(ctx, t["id"])
        self.assertIsNone(t)
示例#6
0
    def test_node_group_template_delete_by_id_skipped(self):
        self.logger.clear_log()
        ctx = context.ctx()
        template_values = copy.copy(c.SAMPLE_NGT)
        template_values["is_default"] = False
        t = self.api.node_group_template_create(ctx, template_values)

        option_values = {"tenant_id": t["tenant_id"], "id": t["id"]}
        template_api.set_conf(Config(option_values))

        template_api.do_node_group_template_delete_by_id()
        msg = ("Deletion of node group template {info} skipped, "
               "not a default template".format(info=u.name_and_id(t)))
        self.assertIn(msg, self.logger.warnings)

        t = self.api.node_group_template_get(ctx, t["id"])
        self.assertIsNotNone(t)
示例#7
0
    def test_node_group_template_delete_by_id_skipped(self):
        self.logger.clear_log()
        ctx = context.ctx()
        template_values = copy.copy(c.SAMPLE_NGT)
        template_values["is_default"] = False
        t = self.api.node_group_template_create(ctx, template_values)

        option_values = {"tenant_id": t["tenant_id"],
                         "id": t["id"]}
        template_api.set_conf(Config(option_values))

        template_api.do_node_group_template_delete_by_id()
        msg = ("Deletion of node group template {info} skipped, "
               "not a default template".format(info=u.name_and_id(t)))
        self.assertIn(msg, self.logger.warnings)

        t = self.api.node_group_template_get(ctx, t["id"])
        self.assertIsNotNone(t)
示例#8
0
    def test_node_group_template_delete_in_use(self):
        self.logger.clear_log()
        ctx = context.ctx()
        t = self.api.node_group_template_create(ctx, c.SAMPLE_NGT)

        # Make a cluster that references the node group template
        cluster_values = copy.deepcopy(c.SAMPLE_CLUSTER)
        cluster_values["node_groups"][0]["node_group_template_id"] = t["id"]
        cl = self.api.cluster_create(ctx, cluster_values)

        # Make a cluster template that references the node group template
        cluster_temp_values = copy.deepcopy(c.SAMPLE_CLT)
        cluster_temp_values["node_groups"] = cluster_values["node_groups"]
        clt = self.api.cluster_template_create(ctx, cluster_temp_values)

        # Set up the expected messages
        msgs = ["Node group template {info} in use "
                "by clusters {clusters}".format(
                    info=u.name_and_id(t), clusters=[cl["name"]])]

        msgs += ["Node group template {info} in use "
                 "by cluster templates {cluster_temps}".format(
                     info=u.name_and_id(t), cluster_temps=[clt["name"]])]

        msgs += ["Deletion of node group template {info} failed".format(
            info=u.name_and_id(t))]

        # Check delete by name
        option_values = {"tenant_id": t["tenant_id"],
                         "template_name": t["name"]}
        template_api.set_conf(Config(option_values))
        template_api.do_node_group_template_delete()
        for msg in msgs:
            self.assertIn(msg, self.logger.warnings)
        self.logger.clear_log()

        # Check again with delete by id
        option_values = {"tenant_id": t["tenant_id"],
                         "id": t["id"]}
        template_api.set_conf(Config(option_values))
        template_api.do_node_group_template_delete_by_id()
        for msg in msgs:
            self.assertIn(msg, self.logger.warnings)
        self.logger.clear_log()