forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Cciupgrade #2
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
Open
amol
wants to merge
7
commits into
amol:master
Choose a base branch
from
swapnil90:cciupgrade
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Cciupgrade #2
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a28821c
cpu upgrade feature added
ddd2c8c
Added Exception Handling and Made pep8 compatible
2e10441
Slight Code Modification
b390d41
adding test cases
2d8bc54
made the code more structered
ebd63a4
slight modification
e4da339
Test cases implementation, pep8 compatible and slight code modifications
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
Test cases implementation, pep8 compatible and slight code modifications
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1072,19 +1072,41 @@ def execute(self, args): | |
| "This action will incur charges on your account. " | ||
| "Continue?"): | ||
| item_id = [] | ||
| import pdb;pdb.set_trace() | ||
| try: | ||
| package_items = cci.get_package_items_for_virtual_guest() | ||
| if data['cpus']: | ||
| item_id.append({'id': cci.get_item_id_for_upgrade( | ||
| item_id.append({'id': self.get_item_id_for_upgrade( | ||
| package_items, 'cpus', data['cpus'])}) | ||
| if data['memory']: | ||
| item_id.append({'id': cci.get_item_id_for_upgrade( | ||
| item_id.append({'id': self.get_item_id_for_upgrade( | ||
| package_items, 'memory', data['memory'])}) | ||
| if data['nic_speed']: | ||
| item_id.append({'id': cci.get_item_id_for_upgrade( | ||
| item_id.append({'id': self.get_item_id_for_upgrade( | ||
| package_items, 'nic_speed', | ||
| data['nic_speed'])}) | ||
| cci.upgrade(instance_id, item_id) | ||
| except: | ||
| raise CLIAbort('CCI Upgrade Failed') | ||
|
|
||
| def get_item_id_for_upgrade(self, package_items, option, value): | ||
| """ | ||
| Find the item ids for the parameters you want to upgrade to. | ||
| :param list package_items: Contains all the items related to an CCI | ||
| :param string option: Describes type of paramter to be upgraded | ||
| :param int value: The value of the parameter to be upgraded | ||
| """ | ||
| id = {'memory': 3, 'cpus': 80, 'nic_speed': 26, | ||
| 'First Disk': 81, 'Second Disk': 82, 'Third Disk': 92, | ||
| 'Fourth Disk': 93, 'Fifth Disk': 116} | ||
| f = 0 | ||
| for item in package_items: | ||
| if len(filter(lambda x: x.get('id') == id[option], \ | ||
| item['categories'])) \ | ||
| and item.get('capacity') == str(value): | ||
| if option == 'cpus' or option =='nic_speed': | ||
| if f == 1: | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this |
||
| return item['prices'][0]['id'] | ||
| else: | ||
| f = f + 1 | ||
| else: | ||
| return item['prices'][0]['id'] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -532,35 +532,42 @@ def test_captures(self): | |
| archive.called_once_with('a', [{"device": 0, "uuid": 1}, | ||
| {"device": 2, "uuid": 2}], "", id=1) | ||
|
|
||
|
|
||
| def test_upgrade_(self): | ||
| def test_upgrade(self): | ||
| # Testing Upgrade | ||
| orderClient = self.client['Product_Order'] | ||
|
|
||
| # test memory/RAM upgrade | ||
| self.cci.upgrade(1, memory = 2048) | ||
|
|
||
| # test single upgrade | ||
| item_ids = [{'id': 1024}] | ||
| self.cci.upgrade(1, item_ids) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are we testing here? Nothing seems to be getting asserted after this. |
||
|
|
||
| # test single upgrade with rebot | ||
| item_ids = [{'id': 1024}] | ||
| self.cci.upgrade(1, item_ids, reboot = True) | ||
|
|
||
| # Now test a blank upgrade | ||
| self.assertTrue(self.cci.upgrade, 1) | ||
|
|
||
| # Finally, test a full Upgrade | ||
| args = { | ||
| 'cpus': 2, | ||
| 'memory': 2048, | ||
| 'disk': [25,50], | ||
| 'nic_speed': 100 } | ||
| self.cci.upgrade(1, **args) | ||
| item_ids = [{'id': 1}, {'id': 2}, {'id': 3}] | ||
| self.cci.upgrade(1, item_ids) | ||
| order = self.test_ordercontainer_options() | ||
| orderClient.verifyOrder.called_once_with(order) | ||
| orderClient.placeOrder.called_once_with(order) | ||
|
|
||
| def test_package_ids_for_virtual_guest(self): | ||
| result = self.cci.get_package_items_for_virtual_guest()[0] | ||
| self.assertEqual(4444, result['prices'][0]['id']) | ||
|
|
||
| def test_ordercontainer_options(self): | ||
| orderContainer = {} | ||
| orderContainer['complexType'] = \ | ||
| 'SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade' | ||
| orderContainer['virtualGuests'] = [{'id': 1}] | ||
| orderContainer['prices'] = [{'id': 1645}] | ||
| orderContainer['properties'] = [{'name': 'MAINTENANCE_WINDOW', | ||
| 'value':'2014-03-21 03:12:47.942307'}] | ||
| orderClient.verifyOrder.assert_called_once_with(orderContainer) | ||
| orderClient.placeOrder.assert_called_once_with(orderContainer) | ||
|
|
||
| 'value': '2014-03-21 03:12:47.942307'}] | ||
| return orderContainer | ||
|
|
||
|
|
||
| class CCIWaitReadyGoTests(unittest.TestCase): | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do not use
idas object or function name. It's might confuse with built-in pythonidfunction. Can you use pluralids?