Skip to content
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

fixed an issue when placing an order doesn't find the correct datacenter #2214

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SoftLayer/CLI/order/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def cli(env, package_keyname, location, preset, verify, billing, complex_type,
pods = network.get_closed_pods()
location_dc = network.get_datacenter_by_keyname(location)
for pod in pods:
if location_dc.get('name') in pod.get('name'):
if location_dc and location_dc.get('name') in pod.get('name'):
click.secho(f"Warning: Closed soon: {pod.get('name')}", fg='yellow')

if extras:
Expand Down
10 changes: 10 additions & 0 deletions tests/CLI/modules/order_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from unittest import mock as mock

from SoftLayer.CLI import exceptions
from SoftLayer.exceptions import SoftLayerError as SoftLayerError
from SoftLayer import testing


Expand Down Expand Up @@ -452,6 +453,15 @@ def test_quote_delete(self):
self.assert_no_fail(result)
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'deleteQuote', identifier='12345')

def test_empty_get_datacenter(self):
"""https://github.com/softlayer/softlayer-python/issues/2114 """
dc_mock = self.set_mock('SoftLayer_Location', 'getDatacenters')
dc_mock.side_effect = [[], [{'name': 'dal13', 'id': 123}]]
result = self.run_command(['--really', 'order', 'place', 'SOFTWARE_LICENSE_PACKAGE', 'dal13', 'SOMETHING'])
self.assertEqual(result.exit_code, 1)
self.assertIsInstance(result.exception, SoftLayerError)
self.assertEqual(str(result.exception), "A complex type must be specified with the order")


def _get_all_packages():
package_type = {'keyName': 'BARE_METAL_CPU'}
Expand Down