def createServerAndWait():
    """
    Creates a server with entered name, then uses the wait() method to poll 
    for it to be created.
    """
    print "Server Name to Create: "
    name = stdin.readline().strip()
    s = Server(name=name, imageId=3, flavorId=1)
    # Create doesn't return anything, but fills in the server with info
    # (including) admin p/w
    serverManager.create(s)
    pprint(s)
    print "Server is now: ", s # show the server with all values filled in
    serverManager.wait(s)

    print "Built!"
def resizeServer():
    """
    Resizes a server and asks you to confirm the resize.
    """
    id = getServerId()

    # Find is guaranteed not to throw a not-found exception
    server = serverManager.find(id)
    if server:
        print "Server: ", server
    else:
        print "Server not found"
        
    flavorId = 2    
    if server.flavorId == 2:
        flavorId = 1
    
    print "Resizing to Flavor ID ", flavorId
    serverManager.resize(server, flavorId)
    serverManager.wait(server)
    
    print "Done!  Ready to confirm or revert?\
           Type confirm or revert or press enter to do nothing:"
    action = stdin.readline().strip()
    
    if action == 'confirm':
        serverManager.confirmResize(server)
        serverManager.wait(server)
    elif action == 'revert':
        serverManager.revertResize(server)
        serverManager.wait(server)
        
    print "Done!"
    print "Server: ", server