def _update_app_scale_config(self, app, data):

        scale_config = dict()
        target = data.get('scale_target', '1')
        try:
            target = int(target)
        except __HOLE__:
            msg = "Must provide integer value for scale target."
            raise exception.BadRequest(reason=msg)

        if target <= 0:
            msg = "Scale target must be greater than zero."
            raise exception.BadRequest(reason=msg)

        if target > cfg.CONF.api.max_instances_per_app:
            msg = "Target scale '%s' exceeds maximum scale limit '%s'." % (
                target, cfg.CONF.api.max_instances_per_app)
            raise exception.ResourceLimitExceeded(reason=msg)

        current_config = app.scale_config

        if current_config:
            current_config[app.name]['target'] = str(target)
            scale_config['scale_config'] = current_config
        else:
            config_data = dict()
            config_data['target'] = str(target)
            app_scale_config = dict()
            app_scale_config[app.name] = config_data
            scale_config = dict()
            scale_config['scale_config'] = app_scale_config

        objects.registry.App.update_and_save(self.context, app.id,
                                             scale_config)
dataset/ETHPy150Open openstack/solum/solum/api/handlers/workflow_handler.py/WorkflowHandler._update_app_scale_config