def action(): """ Performs a sync from the pool's list of images to the appliance. Cron: Every 15 minutes. """ # get the appliance for api token (not required, but sent if we have it) appliance = db.session.query(Appliance).first() # sync up all the images images = Images() response = images.sync(appliance) # now loop through and download non dynamic images if we don't have the files images = db.session.query(Images).filter_by(cache=1).all() download_images(appliance, images) # clear out old dynamic images images = db.session.query(Images).filter_by(cache=0).all() for image in images: image.housekeeping()
def action(ip=('i', default_ip)): """ Restores the appliance to factory default settings. """ try: if ip == default_ip: print "Please enter the appliance's IP address." print "Usage: ./manage.py reset -i x.x.x.x" return action # double check they want to do this if query_yes_no("Are you sure you want to reset the appliance?"): # initialize database path = os.path.dirname(os.path.abspath(__file__)) os.system('sqlite3 "%s/utterio.db" < "%s/schema.sql"' % (path, path)) # initialize the appliance object appliance = Appliance() appliance.initialize(ip) # sync with pool database images = Images() iresponse = images.sync(appliance) flavors = Flavors() fresponse = flavors.sync(appliance) if iresponse['response'] != "success": print iresponse['result'] elif fresponse['response'] != "success": print iresponse['result'] else: print "The database has been cleared and a new API token has been generated." configure_blurb() except ValueError as ex: print ex
def action(ip=('i', default_ip)): """ Installs a new database configuration for the appliance. """ # run database reset script - use current path to run file path = os.path.dirname(os.path.abspath(__file__)) # initialize database os.system('sqlite3 "%s/utterio.db" < "%s/schema.sql"' % (path, path)) # initialize the appliance object appliance = Appliance() appliance.initialize(ip) # sync to remote database images = Images() response = images.sync(appliance) flavors = Flavors() response = flavors.sync(appliance) # configure output configure_blurb()