コード例 #1
0
ファイル: test_redhat.py プロジェクト: enchantner/fuel-web
    def test_redhat_setup_task_manager(self, mocked_rpc):
        test_release_data = {
            'release_id': self.release.id,
            'redhat': {
                'license_type': 'rhsm',
                'username': '******',
                'password': '******'
            }
        }
        rhm = RedHatSetupTaskManager(test_release_data)
        rhm.execute()

        args, kwargs = nailgun.task.manager.rpc.cast.call_args
        rpc_message = args[1]

        for i, name in enumerate((
            'check_redhat_credentials',
            'check_redhat_licenses',
            'download_release'
        )):
            self.assertEquals(rpc_message[i]['method'], name)
            self.assertEquals(
                rpc_message[i]['args']['release_info'],
                test_release_data
            )
コード例 #2
0
ファイル: test_redhat.py プロジェクト: tleontovich/fuel-web
    def test_redhat_setup_task_manager(self, mocked_rpc):
        test_release_data = {
            'release_id': self.release.id,
            'redhat': {
                'license_type': 'rhsm',
                'username': '******',
                'password': '******'
            }
        }
        rhm = RedHatSetupTaskManager(test_release_data)
        rhm.execute()

        args, kwargs = nailgun.task.manager.rpc.cast.call_args
        rpc_message = args[1]

        for i, name in enumerate((
            'check_redhat_credentials',
            'check_redhat_licenses',
            'download_release'
        )):
            self.assertEquals(rpc_message[i]['method'], name)
            self.assertEquals(
                rpc_message[i]['args']['release_info'],
                test_release_data
            )
コード例 #3
0
ファイル: redhat.py プロジェクト: mydaisy2/fuelweb
    def POST(self):
        """
        Starts Red Hat setup and download process

        :returns: JSONized Task object.
        :http: * 202 (setup task created and started)
               * 400 (invalid account data specified)
               * 404 (release not found in db)
        """
        data = self.checked_data()

        license_type = data.get("license_type")
        if license_type == 'rhsm':
            data["satellite"] = ""
            data["activation_key"] = ""

        release_data = {'release_id': data['release_id']}
        release_id = data.pop('release_id')
        release_db = db().query(Release).get(release_id)
        if not release_db:
            raise web.notfound(
                "No release with ID={0} found".format(release_id)
            )
        release_data['redhat'] = data
        release_data['release_name'] = release_db.name

        account = db().query(RedHatAccount).first()
        if account:
            db().query(RedHatAccount).update(data)
        else:
            account = RedHatAccount(**data)
            db().add(account)
        db().commit()

        task_manager = RedHatSetupTaskManager(release_data)
        try:
            task = task_manager.execute()
        except Exception as exc:
            logger.error(u'RedHatAccountHandler: error while execution'
                         ' Red Hat validation task: {0}'.format(str(exc)))
            logger.error(traceback.format_exc())
            raise web.badrequest(str(exc))

        data = build_json_response(TaskHandler.render(task))
        raise web.accepted(data=data)
コード例 #4
0
ファイル: redhat.py プロジェクト: e0ne/fuel-web
    def POST(self):
        """Starts Red Hat setup and download process

        :returns: JSONized Task object.
        :http: * 202 (setup task created and started)
               * 400 (invalid account data specified)
               * 404 (release not found in db)
        """
        data = self.checked_data()

        license_type = data.get("license_type")
        if license_type == 'rhsm':
            data["satellite"] = ""
            data["activation_key"] = ""

        release_data = {'release_id': data['release_id']}
        release_id = data.pop('release_id')
        release_db = db().query(Release).get(release_id)
        if not release_db:
            raise web.notfound(
                "No release with ID={0} found".format(release_id)
            )
        release_data['redhat'] = data
        release_data['release_name'] = release_db.name

        account = db().query(RedHatAccount).first()
        if account:
            db().query(RedHatAccount).update(data)
        else:
            account = RedHatAccount(**data)
            db().add(account)
        db().commit()

        task_manager = RedHatSetupTaskManager(release_data)
        try:
            task = task_manager.execute()
        except Exception as exc:
            logger.error(u'RedHatAccountHandler: error while execution'
                         ' Red Hat validation task: {0}'.format(str(exc)))
            logger.error(traceback.format_exc())
            raise web.badrequest(str(exc))

        data = build_json_response(TaskHandler.render(task))
        raise web.accepted(data=data)