-
Notifications
You must be signed in to change notification settings - Fork 194
Feature/fblock 58 - Added volume-modify feature for File/Block. #893
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
SoftLayer/CLI/block/modify.py
Outdated
'500, 1000, 2000, 4000, 8000, 12000] ' | ||
'Minimum: [the size of the origin volume] ' | ||
'Maximum: [the minimum of 12000 GB or ' | ||
'10*(origin volume size)]') |
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.
This 10x limit will only apply to volumes created before volume modification is released, so this comment may need to be adjusted to mention that. On the other hand, we don't want the help output to grow too large, so I wonder if it would be better to leave out the max here and rely on an error message if the size is too large.
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.
For the 10x size limit I would recommend removing it from the help message and relying on a well worded exception. Does the SLAPI give a good exception there or do we need to make our own?
SoftLayer/CLI/file/modify.py
Outdated
'500, 1000, 2000, 4000, 8000, 12000] ' | ||
'Minimum: [the size of the origin volume] ' | ||
'Maximum: [the minimum of 12000 GB or ' | ||
'10*(origin volume size)]') |
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.
The "10x limit" part isn't applicable for File volumes.
the CI build is still complaining about the following.
Also, please try to improve the test coverage as well. Thanks. |
Hi Chris,
I fixed those errors, and a couple of test cases.
Regards,Surya Ghatty"This too shall pass"________________________________________________________________________________________________________Surya Ghatty | Software Engineer | IBM Cloud Infrastructure Services Development | tel: (507) 316-0559 | ghatty@us.ibm.com
----- Original message -----From: Christopher Gallo <notifications@github.com>To: softlayer/softlayer-python <softlayer-python@noreply.github.com>Cc: sghatty <ghatty@us.ibm.com>, Author <author@noreply.github.com>Subject: Re: [softlayer/softlayer-python] Feature/fblock 58 - Added volume-modify feature for File/Block. (#893)Date: Fri, Nov 17, 2017 2:56 PM
the CI build is still complaining about the following.
SoftLayer/managers/storage_utils.py:1083:9: E265 block comment should start with '# 'SoftLayer/managers/storage_utils.py:1183:1: E302 expected 2 blank lines, found 1
Also, please try to improve the test coverage as well.
Thanks.
—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.
|
SoftLayer/CLI/file/modify.py
Outdated
help='Endurance Storage Tier (IOPS per GB) [only used for ' | ||
'endurance volumes] ***If no tier is specified, the original tier ' | ||
'of the volume will be used.***\n' | ||
'Requirements: [IOPS/GB for the volume is 0.25, ' |
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.
This is minor, but for consistency, I think it would be helpful to insert "If original" before "IOPS/GB" here.
SoftLayer/CLI/routes.py
Outdated
('block:volume-count', 'SoftLayer.CLI.block.count:cli'), | ||
('block:volume-detail', 'SoftLayer.CLI.block.detail:cli'), | ||
('block:volume-duplicate', 'SoftLayer.CLI.block.duplicate:cli'), | ||
('block:volume-modify', 'SoftLayer.CLI.block.modify:cli'), |
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.
This is minor, but it would be ideal if this line was moved just below the line for 'volume-list', so that the commands remain in alphabetical order.
SoftLayer/CLI/routes.py
Outdated
('file:volume-count', 'SoftLayer.CLI.file.count:cli'), | ||
('file:volume-detail', 'SoftLayer.CLI.file.detail:cli'), | ||
('file:volume-duplicate', 'SoftLayer.CLI.file.duplicate:cli'), | ||
('file:volume-modify', 'SoftLayer.CLI.file.modify:cli'), |
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.
This is minor, but it would be ideal if this line was moved just below the line for 'volume-list', so that the commands remain in alphabetical order.
SoftLayer/managers/file.py
Outdated
|
||
file_mask = 'id,billingItem[location,hourlyFlag],snapshotCapacityGb,'\ | ||
'storageType[keyName],capacityGb,originalVolumeSize,'\ | ||
'provisionedIops,storageTierLevel,osType[keyName],'\ |
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.
osType is not relevant for File volumes, so this is not needed.
SoftLayer/managers/storage_utils.py
Outdated
|
||
def prepare_modify_order_object(manager, origin_volume, new_iops, new_tier, | ||
new_size, volume_type): | ||
"""Prepare the duplicate order to submit to SoftLayer_Product::placeOrder() |
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.
This should be something like "modification order" instead of "duplicate order".
SoftLayer/managers/storage_utils.py
Outdated
'packageId': package['id'], | ||
'prices': prices, | ||
'volume': origin_volume, | ||
#'useHourlyPricing' : 'true', |
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.
I don't think this line is needed anymore, since the hourly vs. monthly billing will be handled automatically by the API now.
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.
Only passing an ID should likely throw an error and print the help message
./slcli block volume-modify 26140889
SoftLayerAPIError(SoftLayer_Exception_Public): Price does not have an id.
Lets figure out a way to rewrite this error to indicate a proper size wasn't selected. IDEALLY the api would tell us that, but if thats not possible maybe something in the manager would be helpful.
Is there a good way to get a list of acceptable sizes from the API so that they don't have to be hard coded?
./slcli block volume-modify 34034881 -c 200
SoftLayerAPIError(SoftLayer_Exception_Public): Price does not have an id.
This should work.
./slcli block volume-modify 34034881 -c 250
SoftLayerAPIError(SoftLayer_Exception_Public): Price does not have an id.
This should also work.... am I doing something wrong?
./slcli block volume-modify 34034881 -c 250 -t 2
(this took a long time, maybe add a message before we place an api call)
SoftLayerAPIError(SoftLayer_Exception_Public): Price does not have an id.
Changes needed
- Please make sure the commands do work with the given list of arguments I tried.
- Please use a line width of 120. I know most of the codebase uses 80, but I'm trying to get that updated as we add new code
- the _validate functions you added seem to be duplicate of code that already exists, which I don't really like in the first place. So unless you have a good reason for adding new functions please remove them and use the ones that already exist.
if 'ENDURANCE' in volume_storage_type:
is a much better way of testing storage types than the 4 explicit key names. unless there is a good reason for testing the 4 explicitly.- There is a LOT of copy/pasted code it seems coming from the order duplicate methods into this modify method. I'd really like to see these condensed as much as possible.
SoftLayer/CLI/block/modify.py
Outdated
'500, 1000, 2000, 4000, 8000, 12000] ' | ||
'Minimum: [the size of the origin volume] ' | ||
'Maximum: [the minimum of 12000 GB or ' | ||
'10*(origin volume size)]') |
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.
For the 10x size limit I would recommend removing it from the help message and relying on a well worded exception. Does the SLAPI give a good exception there or do we need to make our own?
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.
For the size/performance validation helper functions in storage_utils.py, sort of along the same lines with what Chris mentioned, I think we can mostly get rid of these. I'm about to make an update to the similar helper functions for volume duplication as well. For both, I think we can get rid of most of this validation logic and just rely on the API to return an error when sizes/performance values are invalid (the API is validating all of these things anyway). This will likely reduce the chance that we need to update things as often any time the something changes with the API.
@allmightyspiff regarding the commands you were trying to run above, were you pointing to a current production API endpoint? The API changes are still in development/QE, so you would need to use a custom endpoint for these commands to work properly. |
@dpickle2 yeah removing those validation functions would solve a lot of my complaints about the pull request. Once that is done I'll test again against the the testing url. |
0acc6e2
to
5eaa9a2
Compare
5eaa9a2
to
20f2644
Compare
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.
looks good.
SoftLayer/CLI/block/modify.py
Outdated
for item in order['placedOrder']['items']: | ||
click.echo(" > %s" % item['description']) | ||
else: | ||
click.echo("Order could not be placed! Please verify your options " + |
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.
The line width for this project is 120, feel free to use it so you don't have to split strings needlessly.
SoftLayer/managers/block.py
Outdated
:return: Returns a SoftLayer_Container_Product_Order_Receipt | ||
""" | ||
|
||
block_mask = 'id,billingItem[location,hourlyFlag],snapshotCapacityGb,'\ |
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.
I prefer masks to be broken out a bit so they are more readable at a glance. Like in block/get_block_volume_details
SoftLayer/managers/file.py
Outdated
:return: Returns a SoftLayer_Container_Product_Order_Receipt | ||
""" | ||
|
||
file_mask = 'id,billingItem[location,hourlyFlag],snapshotCapacityGb,'\ |
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.
break out this object mask too
SoftLayer/managers/storage_utils.py
Outdated
'packageId': package['id'], | ||
'prices': prices, | ||
'volume': origin_volume, | ||
#'useHourlyPricing' : 'true', |
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.
why is this commented out?
SoftLayer/managers/storage_utils.py
Outdated
"IOPS/GB. %s IOPS/GB requested." % duplicate_tier) | ||
return duplicate_tier | ||
|
||
def _validate_new_size(origin_volume, new_volume_size, |
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.
does the API not give a decent error if you give it a bad size? Same with the other 2 _validate fuctions.
I'd prefer this sort of validation be done by the API
SoftLayer/managers/storage_utils.py
Outdated
"IOPS/GB. %s IOPS/GB requested." % duplicate_tier) | ||
return duplicate_tier | ||
|
||
def _validate_new_size(origin_volume, new_volume_size, |
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.
How are these 3 functions different than the _validate_dupl functions?
Some certain types of transactions which are currently returned in a volume's activeTransactions contain transactionStatus sub-properties of inconsistent types. There is a plan to fix the core issue in the backend, but until that fix is added, the changes in this commit should prevent the volume-detail commands from resulting in an error if any invalid transactionStatus objects are returned.
$ ./slcli block volume-modify 34034881 -c 250
Order #21207661 placed successfully!
> Storage as a Service
> 250 GBs
> 2 IOPS per GB |
No description provided.