Skip to content

Commit 6c93b96

Browse files
Merge pull request softlayer#390 from Neetuj/issue389again
handle the case of missing billingitem in subnet cancel
2 parents 69c615d + 936f306 commit 6c93b96

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

SoftLayer/managers/network.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:license: MIT, see LICENSE for more details.
77
"""
88

9+
from SoftLayer import exceptions
910
from SoftLayer import utils
1011

1112
DEFAULT_SUBNET_MASK = ','.join(['hardware',
@@ -132,8 +133,10 @@ def cancel_subnet(self, subnet_id):
132133
:param int subnet_id: The ID of the subnet to be cancelled.
133134
"""
134135
subnet = self.get_subnet(subnet_id, mask='id, billingItem.id')
136+
if "billingItem" not in subnet:
137+
raise exceptions.SoftLayerError("subnet %s can not be cancelled"
138+
" " % subnet_id)
135139
billing_id = subnet['billingItem']['id']
136-
137140
return self.client['Billing_Item'].cancelService(id=billing_id)
138141

139142
def edit_rwhois(self, abuse_email=None, address1=None, address2=None,

0 commit comments

Comments
 (0)