Skip to content

Commit 5677c43

Browse files
Merge pull request #1070 from allmightyspiff/1067
fixed price lookup bug
2 parents 3faaa7d + 634cb64 commit 5677c43

File tree

9 files changed

+37
-11
lines changed

9 files changed

+37
-11
lines changed

SoftLayer/CLI/virt/create_options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Virtual server order options."""
22
# :license: MIT, see LICENSE for more details.
3+
# pylint: disable=too-many-statements
34
import os
45
import os.path
56

SoftLayer/CLI/vpn/ipsec/translation/add.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
@click.command()
1313
@click.argument('context_id', type=int)
14-
# todo: Update to utilize custom IP address type
1514
@click.option('-s',
1615
'--static-ip',
1716
required=True,
1817
help='Static IP address value')
19-
# todo: Update to utilize custom IP address type
2018
@click.option('-r',
2119
'--remote-ip',
2220
required=True,

SoftLayer/CLI/vpn/ipsec/translation/update.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
required=True,
1616
type=int,
1717
help='Translation identifier to update')
18-
# todo: Update to utilize custom IP address type
1918
@click.option('-s',
2019
'--static-ip',
2120
default=None,
2221
help='Static IP address value')
23-
# todo: Update to utilize custom IP address type
2422
@click.option('-r',
2523
'--remote-ip',
2624
default=None,

SoftLayer/CLI/vpn/ipsec/update.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
@click.option('--friendly-name',
1414
default=None,
1515
help='Friendly name value')
16-
# todo: Update to utilize custom IP address type
1716
@click.option('--remote-peer',
1817
default=None,
1918
help='Remote peer IP address value')

SoftLayer/managers/hardware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def cancel_hardware(self, hardware_id, reason='unneeded', comment='', immediate=
9292
billing_id = hw_billing['billingItem']['id']
9393

9494
if immediate and not hw_billing['hourlyBillingFlag']:
95-
LOGGER.warning("Immediate cancelation of montly servers is not guaranteed. " +
95+
LOGGER.warning("Immediate cancelation of montly servers is not guaranteed."
9696
"Please check the cancelation ticket for updates.")
9797

9898
result = self.client.call('Billing_Item', 'cancelItem',

SoftLayer/managers/ipsec.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ def update_translation(self, context_id, translation_id, static_ip=None,
227227
translation.pop('customerIpAddressId', None)
228228
if notes is not None:
229229
translation['notes'] = notes
230-
# todo: Update this signature to return the updated translation
231-
# once internal and customer IP addresses can be fetched
232-
# and set on the translation object, i.e. that which is
233-
# currently being handled in get_translations
234230
self.context.editAddressTranslation(translation, id=context_id)
235231
return True
236232

SoftLayer/managers/ordering.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ def get_item_price_id(core, prices):
378378
if not price['locationGroupId']:
379379
capacity_min = int(price.get('capacityRestrictionMinimum', -1))
380380
capacity_max = int(price.get('capacityRestrictionMaximum', -1))
381-
if capacity_min == -1:
381+
# return first match if no restirction, or no core to check
382+
if capacity_min == -1 or core is None:
382383
price_id = price['id']
384+
# this check is mostly to work nicely with preset configs
383385
elif capacity_min <= int(core) <= capacity_max:
384386
price_id = price['id']
385387
return price_id

tests/managers/ordering_tests.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,3 +569,31 @@ def test_get_item_price_id_with_capacity_restriction(self):
569569
price_id = self.ordering.get_item_price_id("8", price1)
570570

571571
self.assertEqual(1234, price_id)
572+
573+
def test_issues1067(self):
574+
# https://github.com/softlayer/softlayer-python/issues/1067
575+
item_mock = self.set_mock('SoftLayer_Product_Package', 'getItems')
576+
item_mock_return = [
577+
{
578+
'id': 10453,
579+
'itemCategory': {'categoryCode': 'server'},
580+
'keyName': 'INTEL_INTEL_XEON_4110_2_10',
581+
'prices': [
582+
{
583+
'capacityRestrictionMaximum': '2',
584+
'capacityRestrictionMinimum': '2',
585+
'capacityRestrictionType': 'PROCESSOR',
586+
'categories': [{'categoryCode': 'os'}],
587+
'id': 201161,
588+
'locationGroupId': None,
589+
'recurringFee': '250',
590+
'setupFee': '0'
591+
}
592+
]
593+
}
594+
]
595+
item_mock.return_value = item_mock_return
596+
item_keynames = ['INTEL_INTEL_XEON_4110_2_10']
597+
package = 'DUAL_INTEL_XEON_PROCESSOR_SCALABLE_FAMILY_4_DRIVES'
598+
result = self.ordering.get_price_id_list(package, item_keynames, None)
599+
self.assertIn(201161, result)

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ commands =
3636
-d locally-disabled \
3737
-d no-else-return \
3838
-d len-as-condition \
39+
-d useless-object-inheritance \
40+
-d consider-using-in \
41+
-d consider-using-dict-comprehension \
42+
-d useless-import-alias \
3943
--max-args=25 \
4044
--max-branches=20 \
4145
--max-statements=65 \

0 commit comments

Comments
 (0)