コード例 #1
0
ファイル: test_update.py プロジェクト: AlexanderYAPPO/sahara
    def test_do_update_add_clts_fails(self,
                                      add_config,
                                      get_configs,
                                      add_clts,
                                      reverse_ng_creates,
                                      reverse_ng_updates):
        self.logger.clear_log()
        ctx = context.ctx()

        tempdir = tempfile.mkdtemp()

        self._write_files(tempdir, [cluster_json, master_json, worker_json])

        get_configs.return_value = {"flavor_id": 2,
                                    "neutron_management_network": uuid.uuid4()}
        option_values = {"tenant_id": ctx.tenant_id,
                         "directory": tempdir,
                         "norecurse": None,
                         "plugin_name": None,
                         "plugin_version": None}
        template_api.set_conf(Config(option_values))

        add_clts.return_value = True

        template_api.do_update()
        reverse_ng_creates.assert_called_once()
        reverse_ng_updates.assert_called_once()

        clts = self.api.cluster_template_get_all(ctx)
        self.assertEqual([], clts)

        msg = ("Skipping processing for {dir}, "
               "error processing cluster templates".format(dir=tempdir))
        self.assertIn(msg, self.logger.warnings)
コード例 #2
0
ファイル: test_update.py プロジェクト: AlexanderYAPPO/sahara
    def test_do_update(self, add_config, get_configs):
        self.logger.clear_log()
        ctx = context.ctx()

        tempdir = tempfile.mkdtemp()

        self._write_files(tempdir, [cluster_json, master_json, worker_json])

        get_configs.return_value = {"flavor_id": 2,
                                    "neutron_management_network": uuid.uuid4()}
        option_values = {"tenant_id": ctx.tenant_id,
                         "directory": tempdir,
                         "norecurse": None,
                         "plugin_name": None,
                         "plugin_version": None}
        template_api.set_conf(Config(option_values))

        template_api.do_update()

        ngs = self.api.node_group_template_get_all(ctx)
        ng_names = sorted([ng["name"] for ng in ngs])
        self.assertEqual(sorted([master_json["name"], worker_json["name"]]),
                         ng_names)

        clts = self.api.cluster_template_get_all(ctx)
        clt_names = sorted([clt["name"] for clt in clts])
        clts = self.api.cluster_template_get_all(ctx)
        self.assertEqual([cluster_json["name"]], clt_names)
コード例 #3
0
ファイル: test_update.py プロジェクト: egafford/sahara
    def test_do_update_existing_fails(self, add_config,
                                      get_configs, check_existing):
        self.logger.clear_log()
        ctx = context.ctx()

        tempdir = tempfile.mkdtemp()

        self._write_files(tempdir, [cluster_json, master_json, worker_json])

        get_configs.return_value = {
            "flavor_id": '2',
            "neutron_management_network": str(uuid.uuid4())
        }
        option_values = {"tenant_id": ctx.tenant_id,
                         "directory": tempdir,
                         "norecurse": None,
                         "plugin_name": None,
                         "plugin_version": None}
        template_api.set_conf(Config(option_values))

        check_existing.return_value = True

        template_api.do_update()

        ngs = self.api.node_group_template_get_all(ctx)
        self.assertEqual([], ngs)

        clts = self.api.cluster_template_get_all(ctx)
        self.assertEqual([], clts)

        msg = ("Skipping processing for {dir}, "
               "templates in use".format(dir=tempdir))
        self.assertIn(msg, self.logger.warnings)
コード例 #4
0
    def test_do_update_add_clts_fails(self, add_config, get_configs, add_clts,
                                      reverse_ng_updates, reverse_ng_creates):
        self.logger.clear_log()
        ctx = context.ctx()

        tempdir = tempfile.mkdtemp()

        self._write_files(tempdir, [cluster_json, master_json, worker_json])

        get_configs.return_value = {
            "flavor_id": '2',
            "neutron_management_network": str(uuid.uuid4())
        }

        option_values = {
            "tenant_id": ctx.tenant_id,
            "directory": tempdir,
            "norecurse": None,
            "plugin_name": None,
            "plugin_version": None
        }
        template_api.set_conf(Config(option_values))

        add_clts.return_value = True

        template_api.do_update()
        self.assertEqual(1, reverse_ng_creates.call_count)
        self.assertEqual(1, reverse_ng_updates.call_count)

        clts = self.api.cluster_template_get_all(ctx)
        self.assertEqual([], clts)

        msg = ("Skipping processing for {dir}, "
               "error processing cluster templates".format(dir=tempdir))
        self.assertIn(msg, self.logger.warnings)
コード例 #5
0
    def test_do_update_trash(self, add_config, get_configs):
        self.logger.clear_log()
        ctx = context.ctx()

        tempdir = tempfile.mkdtemp()

        self._write_files(tempdir, [cluster_json, master_json, worker_json])

        get_configs.return_value = {
            "flavor_id": '2',
            "neutron_management_network": str(uuid.uuid4()),
            'auto_security_group': True,
            'security_groups': [],
        }

        option_values = {
            "tenant_id": ctx.tenant_id,
            "directory": tempdir,
            "norecurse": None,
            "plugin_name": None,
            "plugin_version": None
        }
        template_api.set_conf(Config(option_values))
        template_api.do_update()

        ngs = self.api.node_group_template_get_all(ctx)
        ng_names = sorted([ng["name"] for ng in ngs])
        self.assertEqual(sorted([master_json["name"], worker_json["name"]]),
                         ng_names)

        clts = self.api.cluster_template_get_all(ctx)
        clt_names = sorted([clt["name"] for clt in clts])
        clts = self.api.cluster_template_get_all(ctx)
        self.assertEqual([cluster_json["name"]], clt_names)
コード例 #6
0
ファイル: test_update.py プロジェクト: lhcxx/sahara
    def test_do_update_existing_fails(self, add_config, get_configs,
                                      check_existing):
        self.logger.clear_log()
        ctx = context.ctx()

        tempdir = tempfile.mkdtemp()

        self._write_files(tempdir, [cluster_json, master_json, worker_json])

        get_configs.return_value = {
            "flavor_id": 2,
            "neutron_management_network": uuid.uuid4()
        }
        option_values = {
            "tenant_id": ctx.tenant_id,
            "directory": tempdir,
            "norecurse": None,
            "plugin_name": None,
            "plugin_version": None
        }
        template_api.set_conf(Config(option_values))

        check_existing.return_value = True

        template_api.do_update()

        ngs = self.api.node_group_template_get_all(ctx)
        self.assertEqual([], ngs)

        clts = self.api.cluster_template_get_all(ctx)
        self.assertEqual([], clts)

        msg = ("Skipping processing for {dir}, "
               "templates in use".format(dir=tempdir))
        self.assertIn(msg, self.logger.warnings)