Ejemplo n.º 1
0
    def put():
        """
        Handles PUT /caps/mba_ctrl request.
        Raises BadRequest, InternalError

        Returns:
            response, status code
        """
        json_data = request.get_json()

        # validate request
        try:
            schema, resolver = ConfigStore.load_json_schema(
                'modify_mba_ctrl.json')
            jsonschema.validate(json_data, schema, resolver=resolver)
        except jsonschema.ValidationError as error:
            raise BadRequest("Request validation failed - %s" % (str(error)))

        if not caps.mba_bw_supported():
            return {'message': "MBA CTRL not supported!"}, 409

        if common.CONFIG_STORE.is_any_pool_defined():
            return {'message': "Please remove all Pools first!"}, 409

        data = deepcopy(common.CONFIG_STORE.get_config())

        CapsMbaCtrl.set_mba_ctrl_enabled(data, json_data['enabled'])

        common.CONFIG_STORE.set_config(data)

        return {'message': "MBA CTRL status changed."}, 200
Ejemplo n.º 2
0
    def _validate_rdt(data):
        """
        Validate RDT configuration (including MBA CTRL) configuration

        Parameters
            data: configuration (dict)
        """

        # if data to be validated does not contain RDT iface and/or MBA CTRL info
        # get missing info from current configuration
        rdt_iface = data['rdt_iface']['interface'] if 'rdt_iface' in data\
            else common.CONFIG_STORE.get_rdt_iface()
        mba_ctrl_enabled = data['mba_ctrl']['enabled'] if 'mba_ctrl' in data\
            else common.CONFIG_STORE.get_mba_ctrl_enabled()

        if mba_ctrl_enabled and rdt_iface != "os":
            raise ValueError(
                "RDT Configuration. MBA CTRL requires RDT OS interface!")

        if mba_ctrl_enabled and not caps.mba_bw_supported():
            raise ValueError(
                "RDT Configuration. MBA CTRL requested but not supported!")

        if not 'pools' in data:
            return

        mba_pool_ids = []
        mba_bw_pool_ids = []

        for pool in data['pools']:

            if 'cbm' in pool:
                result = re.search('1{1,32}0{1,32}1{1,32}', bin(pool['cbm']))
                if result or pool['cbm'] == 0:
                    raise ValueError("Pool {}, CBM {}/{} is not contiguous."\
                    .format(pool['id'], hex(pool['cbm']), bin(pool['cbm'])))
                if not caps.cat_supported():
                    raise ValueError("Pool {}, CBM {}/{}, CAT is not supported."\
                    .format(pool['id'], hex(pool['cbm']), bin(pool['cbm'])))

            if 'mba' in pool:
                mba_pool_ids.append(pool['id'])

            if 'mba_bw' in pool:
                mba_bw_pool_ids.append(pool['id'])

        if (mba_pool_ids or mba_bw_pool_ids) and not caps.mba_supported():
            raise ValueError("Pools {}, MBA is not supported."\
                .format(mba_pool_ids + mba_bw_pool_ids))

        if mba_bw_pool_ids and not mba_ctrl_enabled:
            raise ValueError("Pools {}, MBA BW is not enabled/supported."\
                .format(mba_bw_pool_ids))

        if mba_pool_ids and mba_ctrl_enabled:
            raise ValueError("Pools {}, MBA % is not enabled. Disable MBA BW and try again."\
                .format(mba_pool_ids))

        return
Ejemplo n.º 3
0
    def get():
        """
        Handles HTTP /caps/mba_ctrl request.
        Retrieve MBA CTRL capability and current state details

        Returns:
            response, status code
        """
        res = {
            'supported': caps.mba_bw_supported(),
            'enabled': caps.mba_bw_enabled()
        }
        return res, 200
Ejemplo n.º 4
0
        def check_alloc_tech(pool_id, json_data):
            if 'cbm' in json_data:
                if not caps.cat_l3_supported():
                    raise BadRequest("System does not support CAT!")
                if pool_id > common.PQOS_API.get_max_cos_id([common.CAT_L3_CAP]):
                    raise BadRequest("Pool {} does not support CAT".format(pool_id))

            if 'mba' in json_data or 'mba_bw' in json_data:
                if not caps.mba_supported():
                    raise BadRequest("System does not support MBA!")
                if pool_id > common.PQOS_API.get_max_cos_id([common.MBA_CAP]):
                    raise BadRequest("Pool {} does not support MBA".format(pool_id))

            if 'mba_bw' in json_data and not caps.mba_bw_enabled():
                    raise BadRequest("MBA CTRL is not {}!"\
                        .format("enabled" if caps.mba_bw_supported() else "supported"))

            if 'mba' in json_data and caps.mba_bw_enabled():
                    raise BadRequest("MBA RATE is disabled! Disable MBA CTRL and try again.")