Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import SoftLayer
  2. import json
  3. import sys
  4. parm=sys.argv
  5. itemId=parm[1]
  6.  
  7. # menu
  8. print (30 * '-')
  9. print (" M A I N - M E N U")
  10. print (30 * '-')
  11. print ("1. Immediate Cancel")
  12. print ("2. ABD Cancel")
  13. print (30 * '-')
  14.  
  15. # account info
  16. client = SoftLayer.create_client_from_env()
  17. Billing = client['SoftLayer_Billing_Item']
  18.  
  19. # define option
  20. is_valid=0
  21.  
  22. while not is_valid :
  23. try :
  24. choice = int ( raw_input('Enter your choice [1-2] : ') )
  25. is_valid = 1 ## set it to 1 to validate input and to terminate the while..not loop
  26. except ValueError, e :
  27. print ("'%s' is not a valid integer." % e.args[0].split(": ")[1])
  28.  
  29. ### Take action as per selected menu-option ###
  30. if choice == 1:
  31. print ("Cancelling Immediately...")
  32. cancel = Billing.cancelItem(True,False,"No longer needed",id=itemId)
  33. print('Completed!')
  34. elif choice == 2:
  35. print ("Configuring ABD Cancellation...")
  36. cancel = Billing.cancelItem(False,False,"No longer needed",id=itemId)
  37. print('Completed!')
  38. else:
  39. print ("Invalid number. Try again...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement