Skip to content

Commit 0ad4846

Browse files
author
Fernando
committed
Fix unit test and tox analysis.
1 parent 03583ee commit 0ad4846

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

SoftLayer/CLI/hardware/upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def get_place_order_information(response):
112112
def get_hardware_detail(response):
113113
"""Get the hardware server detail."""
114114
table_hardware = formatting.Table(['Account Id', 'Hostname', 'Domain'])
115-
for hardware in response['Hardware']:
115+
for hardware in response['hardware']:
116116
table_hardware.add_row([hardware.get('accountId'),
117117
hardware.get('hostname'),
118118
hardware.get('domain')])

SoftLayer/managers/hardware.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ def upgrade(self, instance_id, memory=None,
835835
:returns: bool
836836
"""
837837
result = None
838+
maintenance_window_id = None
838839
upgrade_prices = self._get_upgrade_prices(instance_id)
839840
prices = []
840841
data = {}
@@ -853,7 +854,9 @@ def upgrade(self, instance_id, memory=None,
853854
location_id = server_response['datacenter']['id']
854855

855856
maintenance_window = datetime.datetime.now(utils.UTC())
856-
maintenance_window_id = self.get_maintenance_windows_id(location_id)
857+
maintenance_window_detail = self.get_maintenance_windows_detail(location_id)
858+
if maintenance_window_detail:
859+
maintenance_window_id = maintenance_window_detail.get('id')
857860

858861
order = {
859862
'complexType': 'SoftLayer_Container_Product_Order_Hardware_Server_Upgrade',
@@ -894,12 +897,13 @@ def upgrade(self, instance_id, memory=None,
894897
result = self.client['Product_Order'].placeOrder(order)
895898
return result
896899

897-
def get_maintenance_windows_id(self, location_id):
900+
def get_maintenance_windows_detail(self, location_id):
898901
"""Get the disks prices to be added or upgraded.
899902
900903
:param int location_id: Hardware Server location id.
901904
:return int.
902905
"""
906+
result = None
903907
begin_date_object = datetime.datetime.now()
904908
begin_date = begin_date_object.strftime("%Y-%m-%dT00:00:00.0000-06:00")
905909
end_date_object = datetime.date.today() + datetime.timedelta(days=30)
@@ -909,7 +913,9 @@ def get_maintenance_windows_id(self, location_id):
909913
end_date,
910914
location_id)
911915
if len(result_windows) > 0:
912-
return result_windows[0].get('id')
916+
result = result_windows[0]
917+
918+
return result
913919

914920
@retry(logger=LOGGER)
915921
def get_instance(self, instance_id):

0 commit comments

Comments
 (0)