-
Notifications
You must be signed in to change notification settings - Fork 194
Fix the block and file storage detail. #1232
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
Fix the block and file storage detail. #1232
Conversation
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.
- Move the id resolver to the managers
- make sure to pass in just the id for the list volumes method
- Make sure to pass in a username to the list volumes methods
- Only need to test for a few strings, not the whole output
- Test to make sure the appropriate API calls were called.
| from SoftLayer import utils | ||
|
|
||
|
|
||
| def get_block_volume_id(volume_id, block_manager): |
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.
lets move this to the block and file managers as _get_ids_from_username(username)
Then add it as a resolver to the manager itself.
class BlockStorageManager(utils.IdentifierMixin, object):
def __init__(self, client):
self.configuration = {}
self.client = client
self.resolvers = [self._get_ids_from_username]| :param block_manager: Block Storage Manager. | ||
| :return: Returns the volume id. | ||
| """ | ||
| storage_list = block_manager.list_block_volumes() |
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.
list_block_volumes() takes in a username parameter to filter by that, which will let you only get the volume back that matches the username. Also pass in a mask of just id help reduce API call returned data.
| """Display details for a specified volume.""" | ||
| block_manager = SoftLayer.BlockStorageManager(env.client) | ||
| block_volume = block_manager.get_block_volume_details(volume_id) | ||
| volume_id = get_block_volume_id(volume_id, block_manager) |
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.
since were moving get_block_volume_id to the block manager's resolvers feature, we can just remove this line and the rest should work.
| result = self.run_command(['file', 'volume-detail', 'user']) | ||
|
|
||
| self.assert_no_fail(result) | ||
| self.assertEqual({ |
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.
We don't really need to test the WHOLE output is equal, that will make this test break anytime we change the fixture.
Instead you can do something like this to test a few fields of the output
self.assert_called_with('SoftLayer_Network_Storage', 'getObject')
self.assertIn('username', result.output)
self.assertIn('READHEAVY_TIER', result.output)or whatever other strings you want to look for to make sure it called the correct data.
…nandoOjeda/softlayer-python into issues1233-fbRefactor softlayer#1232
|
I've added your changes to #1235 |
Fix block and file storage detail #1229.
This works for block and file storage with id and name identifier.
Valid name:
slcli -v file volume-detail SL01SEV30_1
Valid id
slcli -v file volume-detail 11111
Bad name
slcli -v file volume-detail test
Error: Unable to find File Storage 'test'