"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cyborg/api/controllers/v2/device_profiles.py" between
openstack-cyborg-6.0.0.tar.gz and openstack-cyborg-7.0.0.tar.gz

About: OpenStack Cyborg provides a general purpose management framework for acceleration resources.
The "Xena" series (latest release).

device_profiles.py  (openstack-cyborg-6.0.0):device_profiles.py  (openstack-cyborg-7.0.0)
skipping to change at line 142 skipping to change at line 142
status_code=HTTPStatus.CREATED) status_code=HTTPStatus.CREATED)
def post(self, req_devprof_list): def post(self, req_devprof_list):
"""Create one or more device_profiles. """Create one or more device_profiles.
NOTE: Only one device profile supported in Train. NOTE: Only one device profile supported in Train.
:param devprof: a list of device_profiles. :param devprof: a list of device_profiles.
[{ "name": <string>, [{ "name": <string>,
"groups": [ {"key1: "value1", "key2": "value2"} ] "groups": [ {"key1: "value1", "key2": "value2"} ]
"uuid": <uuid> # optional "uuid": <uuid> # optional
"description": <description> # optional
}] }]
:returns: The list of created device profiles :returns: The list of created device profiles
""" """
# TODO(Sundar) Support more than one devprof per request, if needed # TODO(Sundar) Support more than one devprof per request, if needed
LOG.info("[device_profiles] POST request = (%s)", req_devprof_list) LOG.info("[device_profiles] POST request = (%s)", req_devprof_list)
if len(req_devprof_list) != 1: if len(req_devprof_list) != 1:
raise exception.InvalidParameterValue( raise exception.InvalidParameterValue(
err="Only one device profile allowed " err="Only one device profile allowed "
"per POST request for now.") "per POST request for now.")
skipping to change at line 185 skipping to change at line 186
groups = req_devprof.get("groups") groups = req_devprof.get("groups")
if not groups: if not groups:
raise exception.DeviceProfileGroupsExpected() raise exception.DeviceProfileGroupsExpected()
for group in groups: for group in groups:
tmp_group = copy.deepcopy(group) tmp_group = copy.deepcopy(group)
for key, value in tmp_group.items(): for key, value in tmp_group.items():
# check resource and trait prefix format # check resource and trait prefix format
if not re.match(GROUP_KEYS, key): if not re.match(GROUP_KEYS, key):
raise exception.InvalidParameterValue( raise exception.InvalidParameterValue(
err="Device profile group keys must be of " err="Device profile group keys must be of"
" the form %s" % GROUP_KEYS) " the form %s" % GROUP_KEYS)
# check trait name and it's value # check trait name and it's value
if key.startswith("trait:"): if key.startswith("trait:"):
inner_origin_trait = ":".join(key.split(":")[1:]) inner_origin_trait = ":".join(key.split(":")[1:])
inner_trait = inner_origin_trait.strip(" ") inner_trait = inner_origin_trait.strip(" ")
if not inner_trait.startswith('CUSTOM_'): if not inner_trait.startswith('CUSTOM_'):
raise exception.InvalidParameterValue( raise exception.InvalidParameterValue(
err="Unsupported trait name format %s, should " err="Unsupported trait name format %s, should "
"start with CUSTOM_" % inner_trait) "start with CUSTOM_" % inner_trait)
if value not in TRAIT_VALUES: if value not in TRAIT_VALUES:
raise exception.InvalidParameterValue( raise exception.InvalidParameterValue(
err="Unsupported trait value %s, the value must" err="Unsupported trait value %s, the value must"
" be one among %s" % TRAIT_VALUES) " be one among %s" % (value, TRAIT_VALUES))
# strip " " and update old group key. # strip " " and update old group key.
if inner_origin_trait != inner_trait: if inner_origin_trait != inner_trait:
del group[key] del group[key]
standard_key = "trait:" + inner_trait standard_key = "trait:" + inner_trait
group[standard_key] = value group[standard_key] = value
# check rc name and it's value # check rc name and it's value
if key.startswith("resources:"): if key.startswith("resources:"):
inner_origin_rc = ":".join(key.split(":")[1:]) inner_origin_rc = ":".join(key.split(":")[1:])
inner_rc = inner_origin_rc.strip(" ") inner_rc = inner_origin_rc.strip(" ")
if inner_rc not in constants.SUPPORT_RESOURCES and \ if inner_rc not in constants.SUPPORT_RESOURCES and \
not inner_rc.startswith('CUSTOM_'): not inner_rc.startswith('CUSTOM_'):
raise exception.InvalidParameterValue( raise exception.InvalidParameterValue(
err="Unsupported resource class %s" % inner_rc) err="Unsupported resource class %s" % inner_rc)
try: try:
int(value) int(value)
except ValueError: except ValueError:
raise exception.InvalidParameterValue( raise exception.InvalidParameterValue(
err="Resources nummber %s is invalid" % value) err="Resources number %s is invalid" % value)
# strip " " and update old group key. # strip " " and update old group key.
if inner_origin_rc != inner_rc: if inner_origin_rc != inner_rc:
del group[key] del group[key]
standard_key = "resources:" + inner_rc standard_key = "resources:" + inner_rc
group[standard_key] = value group[standard_key] = value
def _get_device_profile_list(self, names=None, uuid=None): def _get_device_profile_list(self, names=None, uuid=None):
"""Get a list of API objects representing device profiles.""" """Get a list of API objects representing device profiles."""
context = pecan.request.context context = pecan.request.context
 End of changes. 4 change blocks. 
3 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)