-
Notifications
You must be signed in to change notification settings - Fork 194
Add functionality to order a hw for capacityRestrictionType PROCCESOR. #1290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I did not find any relationship between the os (capacityRestrictionType PROCCESOR) and the other items such as cpu. e.g. |
|
So, I don't think users have the option to change the number of Processors in a package, so just skipping Here is what I'm thinking. @staticmethod
def get_item_price_id(core, prices):
"""get item price id"""
price_id = None
for price in prices:
# This is the default location group then
if not price['locationGroupId']:
restriction = price.get('capacityRestrictionType', False)
# There is a price restriction. Make sure the price is within the restriction
if restriction:
capacity_min = int(price.get('capacityRestrictionMinimum', -1))
capacity_max = int(price.get('capacityRestrictionMaximum', -1))
if restriction == "STORAGE":
if capacity_min <= int(core) <= capacity_max:
price_id = price['id']
if restriction == "CORE":
if capacity_min <= int(core) <= capacity_max:
price_id = price['id']
if restriction == "PROCESSOR":
price_id = price['id']
# No price restrictions
else:
price_id = price['id']
return price_idThis way we can handle each restriction a little different if needed. Still not great looking, but what can you do. I thought about just looking up the processor capacity but that seems like a bit more work than just assuming the package will only have 1 type of processor, which so far seems to be the case. |
allmightyspiff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the change itself is fine, I'd like to take this time to refactor this method a bit to be more readable.
Having 3 different if branches on one line isn't great in my opinion. This way if there are ever any other restrictions added, should be easier to work around.
|
yep, I am agree refactoring this method using different I changing the It is ok the implementation below or I change the rest of |
Yeah that should be fine. |
|
Done. |
allmightyspiff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add functionality to order a hw for capacityRestrictionType PROCCESOR #1289.