def _place_order(quote_id, order_container): order_service = get_service('SoftLayer_Billing_Order_Quote', quote_id) log.debug("placing order for quote %d", quote_id) placed_order_container = SoftLayerContainerProductOrder( order_service.placeOrder(order_container._data)) log.debug("placed order for quote %d", quote_id) return placed_order_container
def _verify_order(quote_id, order_container): order_service = get_service('SoftLayer_Billing_Order_Quote', quote_id) log.debug("verifying order for quote %d", quote_id) verified_order_container = SoftLayerContainerProductOrder( order_service.verifyOrder(order_container._data)) log.debug("verified order for quote %d", quote_id) return verified_order_container
def osreload(args): """Execute OS reload Usage: slapi hardware osreload [options] [<hardware_spec>] Options: -c, --confirm TOKEN -h, --help """ # Parse Arguments hardware_spec = parse_hardware_spec(args) # Get Hardware hardware = list(_get_hardware(hardware_spec, None)) if not hardware: print warning("No objects found matching spec: %s." % (args['<hardware_spec>'])) return # Refuse hardware_specs that match more then one host if len(hardware) > 1: print error("More then one object matching spec: %s. " "Refusing to continue." % (args['<hardware_spec>'])) sys.exit(1) # Get server object server = hardware[0] # Get hardware service service = get_service('SoftLayer_Hardware_Server', server.id) confirmation_token = args['--confirm'] # Check for confirmation_token option if confirmation_token is None: # Prompt for confirmation print critical("You are about to issue an OS reload on %s." % (server.fqdn), label="WARNING: ") print critical("This will destroy all data on the device.", label="WARNING: ") if confirm(colored("Are you sure you want to continue?", fg='red', style='bright')): token = service.reloadCurrentOperatingSystemConfiguration() print "OS reload issued, confirm with token: %s" % (token) return else: # Prompt for confirmation print critical("You are about to confirm an OS reload on %s." % (server.fqdn), label="WARNING: ") print critical("This will destroy all data on the device.", label="WARNING: ") print critical("This is your last chance to abort.", label="WARNING: ") if confirm(colored("Are you sure you want to continue?", fg='red', style='bright')): service.reloadCurrentOperatingSystemConfiguration( token=confirmation_token) print "OS Reload Started on %s" % (server.fqdn) return
def _get_quote_product_orders(quote_id, mask): # pylint: disable-msg=C0103 """Generator returning all product order containers for the given quote""" quote_service = get_service('SoftLayer_Billing_Order_Quote', quote_id) quote_service.set_object_mask(mask) log.debug("fetching order container for quote id %d", quote_id) quote_container = quote_service.getRecalculatedOrderContainer() for product_order_container in quote_container['orderContainers']: yield SoftLayerContainerProductOrder(product_order_container)