@@ -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